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;

 

三  驗證

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章