Oracle Docker安装及连接
Posted 肤浅
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle Docker安装及连接相关的知识,希望对你有一定的参考价值。
Oracle Docker安装及连接
拉取镜像
运行镜像
进入容器
修改oracle配置
修改root密码
passwd
切换oracle用户
su oracle
匿名登录oracle
sqlplus /nolog
dba身份登录
conn /as sysdba
修改用户system、sys用户的密码
alter user system identified by system;
alter user sys identified by sys;
测试连接oracle11g
Docker安装Oracle,Navicate连接Oracle
1.安装Docker
2.Docker安装Hadoop
3.安装Oracle
3.1 拉取Oracle
[root@hadoop_zxy docker]# docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
Using default tag: latest
latest: Pulling from helowin/oracle_11g
ed5542b8e0e1: Pull complete
a3ed95caeb02: Pull complete
1e8f80d0799e: Pull complete
Digest: sha256:4c12b98372dfcbaafcd9564a37c8d91456090a5c6fb07a4ec18270c9d9ef9726
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g:latest
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g:latest
3.2 查看镜像
[root@hadoop_zxy docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
6053537/portainer-ce latest 9cb527671ac0 3 weeks ago 265MB
portainer/portainer latest 580c0e4e98b0 9 months ago 79.1MB
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g latest 3fa112fd3642 6 years ago 6.85GB
3.3 创建容器
[root@hadoop_zxy docker]# docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
26778a7f73a3708a8a351ea56aaa1a8507df9b3ab58cbad9c64433a19d608bee
3.4 进入容器
[root@hadoop_zxy docker]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
26778a7f73a3 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g "/bin/sh -c '/home/o…" About a minute ago Up About a minute 0.0.0.0:1521->1521/tcp, :::1521->1521/tcp oracle11g
[root@hadoop_zxy docker]# docker exec -it 26778a7f73a3 bash
[oracle@26778a7f73a3 /]$
3.5 进行软连接
[oracle@26778a7f73a3 /]$ sqlplus /nolog
bash: sqlplus: command not found
[oracle@26778a7f73a3 /]$ su root
Password:
[root@26778a7f73a3 /]#
在Oracle用户下没有找到sqlplus,切换到root用户下,密码一律为helowin
3.6 配置环境变量
[root@26778a7f73a3 dbhome_2]# vi /etc/profile
[root@26778a7f73a3 dbhome_2]# source /etc/profile
[root@26778a7f73a3 dbhome_2]#
## 在profile末尾添加以下环境变量
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH
3.7 创建软连接
## 在/usr/bin目录下创建sqlplus的软连接
[root@26778a7f73a3 dbhome_2]# ln -s /home/oracle/app/oracle/product/11.2.0/dbhome_2/bin/sqlplus /usr/bin
[root@26778a7f73a3 dbhome_2]#
3.8 再次切换到Oracle用户
## 加 - 的目的是为了上一步创建的软连接能够生效
[root@26778a7f73a3 dbhome_2]# su - oracle
[oracle@26778a7f73a3 ~]$
3.9 操作Oracle
3.9.1 登录
[oracle@26778a7f73a3 ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Sun Jan 9 13:00:11 2022
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL>
3.9.2 连接
SQL> conn /as sysdba
Connected.
SQL>
3.9.3 修改账号密码
-- 修改system用户账号密码
SQL> alter user system identified by system;
User altered.
-- 修改sys用户账号密码
SQL> alter user sys identified by system;
User altered.
3.9.4 创建用户
-- 创建内部管理员账号密码
SQL> create user zxy identified by zxy;
User created.
3.9.5 授权
-- 为内部管理元分配dba权限
SQL> grant connect,resource,dba to zxy;
Grant succeeded.
SQL>
3.9.6 修改密码规则
-- 设置密码永不过期
SQL> alter profile default limit password_life_time unlimited;
Profile altered.
SQL>
3.9.7 修改密码最大连接数
SQL> alter system set processes=1000 scope=spfile;
System altered.
SQL>
3.9.8 重启数据库
-- 关闭数据库
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
-- 启动数据库
SQL> startup;
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size 2213776 bytes
Variable Size 402655344 bytes
Database Buffers 1191182336 bytes
Redo Buffers 7360512 bytes
Database mounted.
Database opened.
SQL>
3.9.9 退出
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@26778a7f73a3 ~]$
4.0 Navicate连接
主要注意的是这里的服务名字需要写helowin,如果安装默认的ORCL会报错
4.1 退出容器
[oracle@26778a7f73a3 /]$ exit
exit
[root@hadoop_zxy docker]# ls或者 ctrl + d
以上是关于Oracle Docker安装及连接的主要内容,如果未能解决你的问题,请参考以下文章
在Ubuntu18.04的Docker中安装Oracle镜像及简单使用