docker 安装 oracle11g

目录

 

一 前言

二 实现

1、下载oracle镜像

2、检查镜像

3、运行镜像

4、配置oracle服务

 5、修改oracle默认密码(可选)

三  验证


一 前言

1、需要docker环境,oracle镜像

2、本文使用windows-docker环境

操作系统 winodws10 64
docker Docker version 18.09.2, build 6247962
网络模式 桥接
oracle镜像 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

二 实现

1、下载oracle镜像

docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
#此镜像为阿里云基于centos7 打包的oracle11g镜像 约为6g

2、检查镜像

docker images

3、运行镜像

docker run --restart=always  -d -p 8080:8080 -p 1521:1521 --name oracle11g  registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
命令解析
docker run                    #运行容器
--restart=always              #启动策略 设置为保持重启
-d                            #后台运行
-p 8080:8080                  #端口映射
-p 1521:1521                  #端口映射
--name oracle11g              #服务命名
-v /data/oracle:/data/oracle  #如果需要挂载使用此参数
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
#注意
1、宿主机端口不可冲突 可以通过(window系统)netstat -a 查询宿主机已使用端口 否则

docker: Error response from daemon: driver failed programming external connectivity on endpoint oracle11g (0ab988bf0e46eab2786a6fe764bfc92281e5b3fa6129d408fe9b9dc4479502b1): Error starting userland proxy: Bind for 0.0.0.0:8080: unexpected error Permission denied.

2、若启动失败  需要先docker rm 服务名 否则
docker: Error response from daemon: Conflict. The container name "/oracle11g" is already in use by container "a5cb047193e7e9928b6502f1218bcecea98bafbf57927504014fe22908a56c09". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.

4、配置oracle服务

step1:进入容器


docker exec -it oracle11g  /bin/bash

step2:修改环境变量



su root
#密码 helowin
vi /etc/profile

#行末 unset -f pathmunge 下一行 按i 粘贴如下环境变量

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

#按esc  输入  :wq!   按enter

source /etc/profile
##注意
1、必须使用su root 否则 文件只读无法保存

E45: 'readonly' option is set (add ! to override)


2、必须source /etc/profile 否则 环境变量无效

[root@a757a7352392 /]# echo $ORACLE_HOME

[root@a757a7352392 /]#

step3:配置软连接


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

 5、修改oracle默认密码(可选)

账号 system
密码 helowin
sid helowin

 step1:切换用户

#容器切换oracle用户
su oracle

##注意
1、需要切换到oracle用户 否则
Enter user-name: system
Enter password:
ERROR:
ORA-12546: TNS:permission denied

step2:修改oracle用户 

#容器切换oracle用户
su oracle

#登录oracle dba
sqlplus /nolog;
conn /as sysdba;

#修改初始账号
alter user system identified by system;
alter user sys identified by system;

#添加自己的dba账号
create user my_account identified by my_password;
grant connect,resource,dba to my_account;

#设置密码永不过期
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;

#关闭
shutdown immediate;

#启动数据库
startup;

三  验证

猜你喜欢

转载自blog.csdn.net/qq_22211217/article/details/98952842
今日推荐