docker安裝Oracle11g數據庫

最近公司項目需要用到oracle數據庫,爲方面同事開發,於是在公司阿里雲服務器上用docker安裝了一個oracle11g,給同事開發測試使用。
1、下載oracle11g的鏡像文件
這裏我使用的鏡像文件是:registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g,這個鏡像文件有6.85G這麼大,下載需要幾分鐘的時間。

[root@iZbp13sno1lc2yxlhjc4b3Z ~]# docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
[root@iZbp13sno1lc2yxlhjc4b3Z ~]# docker images
REPOSITORY                                             TAG                 IMAGE ID            CREATED             SIZE
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g   latest              3fa112fd3642        4 years ago         6.85GB

2、創建運行oracle容器

[root@iZbp13sno1lc2yxlhjc4b3Z ~]#docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

3、配置oracle
進入oracle容器,配置環境變量。
分別在在/etc/profile和/home/oracle/.bashrc文件末尾添加環境變量。
在/etc/profile設置oracle環境變量:

[root@iZbp13sno1lc2yxlhjc4b3Z ~]# docker exec -it oracle11g bash
[oracle@753d0436c2f1 /]$ vi /etc/profile
# /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

在/home/oracle/.bashrc設置oracle環境變量:

[oracle@753d0436c2f1 /]$ vi /home/oracle/.bashrc
# .bashrc
...
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH

測試數據庫連接:

[oracle@753d0436c2f1 /]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Thu May 14 20:57:07 2020

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL> conn / as sysdba
Connected.
SQL> 

4、修改oracle用戶密碼
修改sys、system等管理員賬戶密碼

SQL> alter user system identified by system;

User altered.

SQL> alter user sys identified by sys;

User altered.

SQL> 

查看oracle數據庫狀態、實例名等信息:

[oracle@753d0436c2f1 /]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAY-2020 21:00:56

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                12-MAY-2020 09:25:18
Uptime                    2 days 11 hr. 35 min. 38 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/diag/tnslsnr/753d0436c2f1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=753d0436c2f1)(PORT=1521)))
Services Summary...
Service "helowin" has 1 instance(s).
  Instance "helowin", status READY, has 1 handler(s) for this service...
Service "helowinXDB" has 1 instance(s).
  Instance "helowin", status READY, has 1 handler(s) for this service...
The command completed successfully

根據狀態信息可知,實例名爲:helowin。

5、PLSQL客戶端連接
用戶:sys,密碼:sys,數據庫:你的IP地址/helowin,以sysdba角色登錄即可。
image.png

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