最近公司項目需要用到oracle數(shù)據(jù)庫,為方面同事開發(fā)敷燎,于是在公司阿里云服務(wù)器上用docker安裝了一個oracle11g谣殊,給同事開發(fā)測試使用。
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岸啡、創(chuàng)建運(yùn)行oracle容器
[root@iZbp13sno1lc2yxlhjc4b3Z ~]#docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
3、配置oracle
進(jìn)入oracle容器赫编,配置環(huán)境變量巡蘸。
分別在在/etc/profile和/home/oracle/.bashrc文件末尾添加環(huán)境變量。
在/etc/profile設(shè)置oracle環(huán)境變量:
[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設(shè)置oracle環(huán)境變量:
[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
測試數(shù)據(jù)庫連接:
[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數(shù)據(jù)庫狀態(tài)、實(shí)例名等信息:
[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
根據(jù)狀態(tài)信息可知嘹吨,實(shí)例名為:helowin搬味。
5、PLSQL客戶端連接
用戶:sys躺苦,密碼:sys身腻,數(shù)據(jù)庫:你的IP地址/helowin,以sysdba角色登錄即可匹厘。