Docker安装Oracle_11g的方法

1. 拉取oracle_11g镜像

docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

Docker安装Oracle_11g的方法_第1张图片

2. 创建oracle11g容器 

docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

3. 查看oracle11g容器是否创建成功

docker ps -a

在这里插入图片描述

 4. 启动oracle11g容器

docker start oracle11g

5. 进入oracle11g容器进行配置

docker exec -it oracle11g bash

6. 切换到root用户下进行配置

su root

密码为:helowin

7. 编辑profile文件配置ORACLE环境变量

vi /etc/profile

8. 最后添加以下3行配置

export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH

Docker安装Oracle_11g的方法_第2张图片

 保存 ::wq
让配置生效:source /etc/profile

9. 创建软连接

ln -s $ORACLE_HOME/bin/sqlplus /usr/bin

10. 切换到oracle 用户

su - oracle

Docker安装Oracle_11g的方法_第3张图片

11. 登录sqlplus并修改sys、system用户密码

sqlplus /nolog
conn /as sysdba

 Docker安装Oracle_11g的方法_第4张图片

12. 修改sys、system用户密码并刷新权限 

alter user system identified by oracle;
alter user sys identified by oracle;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;

Docker安装Oracle_11g的方法_第5张图片

 退出:exit;

13. 查看一下oracle实例状态

lsnrctl status

Docker安装Oracle_11g的方法_第6张图片

 

14. 创建用户并分配表空间和分配权限

create user tmy identified by 123456;

create tablespace tablespace_tmy datafile '/home/oracle/app/tmydata' size 500m  
autoextend on  
next 50m maxsize 20480m  
extent management local;  

alter user tmy default tablespace tablespace_tmy;




GRANT ALTER ANY PROCEDURE TO tmy;
GRANT ALTER ANY TABLE TO tmy;
GRANT ALTER ANY TRIGGER TO tmy;
GRANT ALTER ANY TYPE TO tmy;
GRANT CREATE ANY TABLE TO tmy;
GRANT DELETE ANY TABLE TO tmy;
GRANT DROP ANY PROCEDURE TO tmy;
GRANT DROP ANY SEQUENCE TO tmy;
GRANT DROP ANY TABLE TO tmy;
GRANT DROP ANY TRIGGER TO tmy;
GRANT DROP ANY TYPE TO tmy;
GRANT DROP ANY VIEW TO tmy;
GRANT SELECT ANY DICTIONARY TO tmy;
GRANT SELECT ANY SEQUENCE TO tmy;
GRANT SELECT ANY TABLE TO tmy;
GRANT UNDER ANY TABLE TO tmy;
GRANT UNDER ANY TYPE TO tmy;
GRANT UNDER ANY VIEW TO tmy;
GRANT UNLIMITED TABLESPACE TO tmy;
GRANT UPDATE ANY TABLE TO tmy;
GRANT CONNECT TO tmy;
GRANT DBA TO tmy;
GRANT RESOURCE TO tmy;
GRANT insert ANY TABLE TO tmy;
GRANT execute ANY PROCEDURE TO tmy;

二. 修改SID

原镜像中,SID为helowin,本案例中修改为ORCL

1.查看原镜像中设置的SID

sqlplus / as sysdba
> select instance from v$thread;

INSTANCE
--------------------------------------------------------------------------------
helowin

2.关闭数据库

> shutdown immediate;
> exit;

3.修改oracle用户的ORACLE_SID环境变量

vi /home/oracle/.bash_profile
export ORACLE_SID=ORCL
source /home/oracle/.bash_profile

4.修改/etc/oratab文件

$ vi /etc/oratab
将
helowin:/home/oracle/app/oracle/product/11.2.0/dbhome_2:Y
改为
ORCL:/home/oracle/app/oracle/product/11.2.0/dbhome_2:Y

5.进入到$ORACLE_HOME/dbs目录,修改文件名

cd $ORACLE_HOME/dbs
mv hc_helowin.dat hc_ORCL.dat
mv lkHELOWIN lkORCL
mv orapwhelowin orapwORCL
mv spfilehelowin.ora spfileORCL.ora
mv inithelowin.ora initORCL.ora

6.重建口令文件(orapwORCL文件)

因为口令文件改名后不能在新实例中使用,所以重建

orapwd file=$ORACLE_HOME/dbs/orapwORCL password=123456 entries=5 force=y

7.启动数据库,检查SID名称

sqlplus / as sysdba
> startup
> select instance from v$thread;

INSTANCE
--------------------------------------------------------------------------------
ORCL

你可能感兴趣的:(docker,java,容器)