Use docker to install and configure oracle 11g

1. Install docker environment.
2. Start pulling the oracle image
 docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle\_11g
3. After the download is completed, view the image
 docker images
4. Start the container
 docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle\_11g

It can be written as a shell script. Next time you open the Oracle database, you can create a container with one command.

The shell script is as follows:

\# 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

But in order to save the last easy configuration value, it is not recommended to write this shell script. Next time you open it, just use the docker start oracle11 command to open it.

If the function is created successfully, it will return the container id.

5. Enter the image to configure
 docker exec -it oracle11g bash

6. Make soft connections
  sqlplus /nolog

I found that there is no such command, so I switched to the root user.

su root 

输入密码:helowin
7. Edit the profile file to configure the ORACLE environment variables
   打开: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. After saving, execute source /etc/profile to load environment variables;
9. Create soft connections
 ln -s $ORACLE\_HOME/bin/sqlplus /usr/bin
10. Switch to oracle user
          这里还要说一下,一定要写中间的内条 -   必须要,否则软连接无效

11. Log in to sqlplus and modify the sys and system user passwords
  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; --修改数据库最大连接数据;


One of the pit descriptions:


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

  输入:alter database open;

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

Solution:

输入:alter database mount;

 输入 :alter database open;

Then you can execute the command to change the database password.

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

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

12. After modifying the above information, the database needs to be restarted;
conn /as sysdba  
shutdown immediate; --关闭数据库  
startup; --启动数据库

exit 退出软链接


13.navicat connection success picture:

Guess you like

Origin blog.csdn.net/qq_41787812/article/details/133132711