【DB寶3】在Docker中使用rpm包的方式安裝Oracle 19c
【DB寶3】在Docker中使用rpm包的方式安裝Oracle 19c
一、安裝Docker軟體
CentOS 7安裝Docker: https://docs.docker.com/engine/install/centos/
1、解除安裝掉舊版本的 Docker:
yum remove -y docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine
2、執行以下安裝命令去安裝依賴包:
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum -y install docker-ce docker-ce-cli containerd.io
# 若執行報錯,則配置yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
或一鍵安裝:
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh
systemctl start docker
systemctl status docker
3、檢查版本
docker version
docker info
二、建立CentOS7.6的容器
https://hub.docker.com/_/centos?tab=tags
--拉取映象
docker pull centos:7.6.1810
--建立容器
docker run -d --name lhr2019ocp -h lhr2019ocp -p 5500-5510:5500-5510 -p 1521:1521 -p 222:22 --privileged=true centos:7.6.1810 /usr/sbin/init
--修改時區
docker cp /usr/share/zoneinfo/Asia/Shanghai lhr2019ocp:/etc/localtime
--進入容器
docker exec -it lhr2019ocp /bin/bash
--安裝一些必要的系統包
yum install -y openssh-clients openssh-server initscripts net-tools telnet which wget passwd e4fsprogs lrzsz sudo unzip lvm2 tree traceroute bridge-utils dos2unix rlwrap
yum -y install vim redhat-lsb
--解決agetty程式cpu佔用率100%,宿主機和容器都需要執行
systemctl stop getty@tty1.service
systemctl mask getty@tty1.service
--啟動ssh程式
systemctl restart sshd
--修改root使用者密碼
echo "root:lhr" | chpasswd
--遠端登入
ssh root@192.168.1.35 -p222
-- 配置容器內的yum源:阿里雲
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
rpm --rebuilddb
三、rpm方式安裝Oracle 19c
3.1 、安裝database-preinstall包
# https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/index.html
yum install -y https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
3.2、下載安裝db軟體,上傳到docker容器內
下載db 19c的地址:
https://www.oracle.com/database/technologies/oracle-database-software-downloads.html
安裝19c資料庫軟體:
yum install -y oracle-database-ee-19c-1.0-1.x86_64.rpm
3.3、建立資料庫例項
引數檔案:/etc/init.d/oracledb_ORCLCDB-19c、/etc/sysconfig/oracledb_ORCLCDB-19c.conf
/etc/init.d/oracledb_ORCLCDB-19c configure #也可以重啟資料庫
執行過程:
[root@lhr2019ocp ~]# /etc/init.d/oracledb_ORCLCDB-19c configure
Configuring Oracle Database ORCLCDB.
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
/opt/oracle/cfgtoollogs/dbca/ORCLCDB.
Database Information:
Global Database Name:ORCLCDB
System Identifier(SID):ORCLCDB
Look at the log file "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log" for further details.
Database configuration completed successfully. The passwords were auto generated, you must change them by connecting to the database using 'sqlplus / as sysdba' as the oracle user.
此過程即靜默建庫的過程,我們也可以使用DBCA命令來直接建立資料庫。
四、資料庫配置
4.1、修改密碼
alter user sys identified by lhr;
4.2、修改引數
alter system set sga_max_size=1g scope=spfile;
alter system set sga_max_size=1g;
alter system set pga_aggregate_target=100m;
startup force
4.3、修改EM的展現方式
可通過如下命令切換:
##切換為Flash-based的EM Express
SQL> @?/rdbms/admin/execemx emx
##切換為Java JET的EM Express
SQL> @?/rdbms/admin/execemx omx
訪問容器內的EM:
https://192.168.1.35:5500/em
4.3、配置使用者環境變數
cat >> /home/oracle/.bash_profile << "EOF"
export ORACLE_SID=ORCLCDB
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19c/dbhome_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export PATH=$ORACLE_HOME/bin:$PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias asmcmd='rlwrap asmcmd'
alias sas='sqlplus / as sysdba'
EOF
cat >> $ORACLE_HOME/sqlplus/admin/glogin.sql << "EOF"
set linesize 9999 pagesize 9999
set sqlprompt "_USER'@'_CONNECT_IDENTIFIER> "
EOF
注意:對於18c的安裝,和19c一樣。以上程式碼中,凡是有19c的地方都修改為18c。
五、重啟容器後的操作
若重啟容器後,則需要重新啟動db,如下:
[root@docker35 ~]# docker start lhr2019ocp
lhr2019ocp
You have new mail in /var/spool/mail/root
[root@docker35 ~]# docker exec -it lhr2019ocp bash
[root@lhr2019ocp /]# ps -ef|grep pmon
root 971 941 0 15:22 pts/1 00:00:00 grep --color=auto pmon
[root@lhr2019ocp /]# /etc/init.d/oracledb_ORCLCDB-19c start
Starting Oracle Net Listener.
Oracle Net Listener started.
Starting Oracle Database instance ORCLCDB.
Oracle Database instance ORCLCDB started.
[root@lhr2019ocp /]# su - oracle
Last login: Wed Jun 24 15:22:45 CST 2020 on pts/1
[oracle@lhr2019ocp ~]$ sas
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jun 24 15:23:19 2020
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SYS@ORCLCDB> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB1 READ WRITE NO
SYS@ORCLCDB> ! lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 24-JUN-2020 15:23:29
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=lhr2019ocp)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 24-JUN-2020 15:22:45
Uptime 0 days 0 hr. 0 min. 43 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/lhr2019ocp/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhr2019ocp)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=lhr2019ocp)(PORT=5500))(Security=(my_wallet_directory=/opt/oracle/product/19c/dbhome_1/admin/ORCLCDB/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "ORCLCDB" has 1 instance(s).
Instance "ORCLCDB", status READY, has 1 handler(s) for this service...
Service "ORCLCDBXDB" has 1 instance(s).
Instance "ORCLCDB", status READY, has 1 handler(s) for this service...
Service "a8be8cc09f902cd2e0530d0011ac912e" has 1 instance(s).
Instance "ORCLCDB", status READY, has 1 handler(s) for this service...
Service "orclpdb1" has 1 instance(s).
Instance "ORCLCDB", status READY, has 1 handler(s) for this service...
The command completed successfully
[root@docker35 ~]# docker container stop lhr2019ocp
lhr2019ocp
[root@docker35 ~]# docker commit lhr2019ocp lhrbest/oracle19clhr_rpm_db
sha256:96b0393fbc96f2ee2c9f5de17e4cd9ee82818b112b3491c0c64bbc48ddf306b8
You have new mail in /var/spool/mail/root
[root@docker35 ~]# docker images | grep oracle19clhr_rpm_db
lhrbest/oracle19clhr_rpm_db latest 96b0393fbc96 About a minute ago 12.5GB
oracle19clhr_rpm_db 1.0 6749a424a440 About a minute ago 12.5GB
[root@docker35 ~]#
[root@docker35 ~]# docker login
Authenticating with existing credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
--後臺執行
[root@docker35 ~]# nohup docker push lhrbest/oracle19clhr_rpm_db:latest &
[1] 27202
[root@docker35 ~]# ps -ef|grep push
root 27202 4743 0 16:39 pts/5 00:00:00 docker push lhrbest/oracle19clhr_rpm_db:latest
... ...
[root@docker35 ~]# ps -ef|grep push
root 16822 14646 0 08:41 pts/0 00:00:00 grep --color push
[root@docker35 ~]#
[root@docker35 ~]#
[root@docker35 ~]# docker push lhrbest/oracle19clhr_rpm_db:latest
The push refers to repository [docker.io/lhrbest/oracle19clhr_rpm_db]
b70a2f017499: Layer already exists
89169d87dbe2: Layer already exists
latest: digest: sha256:0d1bf18e4242610d16fc342b4d6c8ff6bdefcbe39c5484eeb8b83e2c2dd016dd size: 743
About Me
● 本文作者:小麥苗,部分內容整理自網路,若有侵權請聯絡小麥苗刪除
● 本文在個人微 信公眾號( DB寶)上有同步更新
● QQ群號: 230161599 、618766405,微信群私聊
● 個人QQ號(646634621),微 訊號(db_bao),註明新增緣由
● 於 2020年7月 在西安完成
● 最新修改時間:2020年7月
● 版權所有,歡迎分享本文,轉載請保留出處
●小麥苗的微店: https://weidian.com/s/793741433?wfr=c&ifr=shopdetail
●小麥苗出版的資料庫類叢書: http://blog.itpub.net/26736162/viewspace-2142121/
●小麥苗OCP、OCM、高可用、DBA學習班: http://blog.itpub.net/26736162/viewspace-2148098/
●資料庫筆試面試題庫及解答: http://blog.itpub.net/26736162/viewspace-2134706/
使用微信客戶端掃描下面的二維碼來關注小麥苗的微信公眾號( DB寶)及QQ群(DBA寶典)、新增小麥苗微信, 學習最實用的資料庫技術。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2703949/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 19c RPM安裝Oracle
- 【DB寶18】在Docker中安裝使用MySQL高可用之MGRDockerMySql
- Docker中安裝Oracle 19cDockerOracle
- 在 Fedora 中安裝替代版本的 RPM 包
- centos以RPM包方式安裝redis的方法CentOSRedis
- 『現學現忘』Docker基礎 — 12、通過RPM軟體包方式安裝DockerDocker
- 19c(19.3) RPM方式單機資料庫安裝資料庫
- CentOS下使用rpm包安裝MySQLCentOSMySql
- 【BUILD_ORACLE】Oracle 19c RAC搭建(五)DB軟體安裝UIOracle
- Docker安裝Oracle 19c 詳細教程DockerOracle
- 在Ubuntu中安裝Docker和docker的使用UbuntuDocker
- yum如何解除安裝已安裝的rpm並安裝本地rpm包
- MySQL 5.7.22 rpm 安裝方式MySql
- Oracle 19c TFA的安裝與使用Oracle
- Docker中安裝OracleDockerOracle
- Mysql 5.7在OL 6上以RPM包安裝MySql
- RPM包的安裝與升級
- Oracle 19c的安裝Oracle
- 在RockyLinux 9.3環境中採用RPM模式部署Oracle 19CLinux模式Oracle
- 使用Docker方式安裝JenkinsDockerJenkins
- clickhouse-backup(RPM方式安裝)
- rpm方式離線安裝ansible
- rpm方式安裝redis4.0Redis
- rpm包安裝升級與解除安裝
- RPM包安裝與介紹
- 在Linux(Redhat/CentOS)下安裝MySQL之yum(rpm)線上安裝方式LinuxRedhatCentOSMySql
- 在Linux(Redhat/CentOS)下安裝MySQL之yum(rpm)離線安裝方式LinuxRedhatCentOSMySql
- 使用RPM安裝ORACLE-21c資料庫Oracle資料庫
- 使用RPM安裝ORACLE-19c資料庫Oracle資料庫
- 使用CheckInstall從原始碼製作RPM安裝包原始碼
- centos(linux): rpm -V 驗證rpm包安裝程式的安全CentOSLinux
- oracle 19c 安裝、解除安裝Oracle
- mysql8.0.30的RPM包安裝方法MySql
- 【DB寶19】在Docker中使用MySQL高可用之MHADockerMySql
- yum/dnf/rpm 等 檢視rpm 包安裝路徑 (fedora 中 pygtk 包內容安裝到哪裡了)
- 在Oracle Linux 7.1上安裝DockerOracleLinuxDocker
- 使用docker安裝設定oracleDockerOracle
- 使用免費的Oracle雲服務-在雲主機上安裝Oracle Database 19cOracleDatabase