一、拉取镜像
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
时间可能有点久,下面是执行过程
[root@centos images]# docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
Using default tag: latest
latest: Pulling from helowin/oracle_11g
[DEPRECATION NOTICE] Docker Image Format v1, and Docker Image manifest version 2, schema 1 support will be removed in an upcoming release. Suggest the author of registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g:latest to upgrade the image to the OCI Format, or Docker Image manifest v2, schema 2. More information at https://docs.docker.com/go/deprecated-image-specs/
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
二、运行容器
docker run -d -p 1521:1521 --name oracle_11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
参数解析说明
参数解释:
-d:后台运行
p:容器端口映射到宿主机端口(前者为宿主机)
--name:容器别名
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g:镜像名称
三、进入容器
docker exec -it oracle_11g /bin/bash
(1)切换到root用户下
su root
root密码为:helowin
(2)配置Oracle环境变量
vi /etc/profile
进入到文件内之后,可以按快捷键shift+G 快速将光标移动到文件末尾。加入以下的代码。
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH
然后保存退出。
(3)重新加载配置文件,让其生效
source /etc/profile
(4)创建软连接
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
(5)切到oracle 用户下
su - oracle
(6)登录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 yan_test; --将dba权限授权给内部管理员账号和密码;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED; --修改密码规则策略为密码永不过期;(会出现坑,后面讲解)alter system set processes=1000 scope=spfile; --修改数据库最大连接数据;
(7)重启数据库
shutdown immediate; --关闭数据库
startup; --启动数据库
exit:--退出软链接