使用docker安装配置oracle 11g

1、安装docker环境。
2、开始拉取oracle镜像
 docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle\_11g
3、下载完成后,查看镜像
 docker images
4、启动容器
 docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle\_11g

可以写成shell脚本,下次打开oracle数据库就可以一条命令创建容器。

shell脚本如下:

\# BEGIN ANSIBLE MANAGED BLOCK  
#!/bin/bash  
docker rm -f oracle11;  
docker run -it -d -p 1521:1521 -v /data/oracle:/data/oracle --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle\_11g  
\# END ANSIBLE MANAGED BLOCK

但为了保存上一次容易的配置值,是不建议写这个shell脚本的,下次打开直接用docker start oracle11命令打开。

如果创建成功能会返回容器id

5、进入镜像进行配置
 docker exec -it oracle11g bash

6、进行软连接
  sqlplus /nolog

发现没有该命令,所以切换root用户。

su root 

输入密码:helowin
7、编辑profile文件配置ORACLE环境变量
   打开:vi /etc/profile ,在文件最后写上下面内容:
export ORACLE\_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome\_2

export ORACLE\_SID=helowin

export PATH=$ORACLE\_HOME/bin:$PATH

8、保存后执行source /etc/profile 加载环境变量;
9、创建软连接
 ln -s $ORACLE\_HOME/bin/sqlplus /usr/bin
10、切换到oracle 用户
          这里还要说一下,一定要写中间的内条 -   必须要,否则软连接无效

11、登录sqlplus并修改sys、system用户密码
  sqlplus /nolog   --登录  
 conn /as sysdba  --  
 alter user system identified by system;--修改system用户账号密码;  
alter user sys identified by system;--修改sys用户账号密码;  
create user test identified by test; -- 创建内部管理员账号密码;  
grant connect,resource,dba to test; --将dba权限授权给内部管理员账号和密码;  
ALTER PROFILE DEFAULT LIMIT PASSWORD\_LIFE\_TIME UNLIMITED; --修改密码规则策略为密码永不过期;(会出现坑,后面讲解)  
alter system set processes=1000 scope=spfile; --修改数据库最大连接数据;


其中一个坑说明:


当执行修改密码的时候出现 :    database not open
  提示数据库没有打开,不急按如下操作

  输入:alter database open;

注意了:这里也许还会提示  :   ORA-01507: database not mounted

解决办法:

输入:alter database mount;

 输入 :alter database open;

然后就可执行 修改数据库密码的命令了

  改完之后输入:ALTER PROFILE DEFAULT LIMIT PASSWORD\_LIFE\_TIME UNLIMITED;

  刷新下表  exit  是退出sql 软连接

12、修改以上信息后,需要重新启动数据库;
conn /as sysdba  
shutdown immediate; --关闭数据库  
startup; --启动数据库

exit 退出软链接


13.navicat连接成功图:

猜你喜欢

转载自blog.csdn.net/qq_41787812/article/details/133132711