CentOS7下使用RPM包安裝Oracle 19c
一、概述
Oracle Database 19c ,也就是12.2.0.3,最初在livesql.oracle.com上發(fā)布,是Oracle Database 12c和18c系列產(chǎn)品的最終版本,因此也是“長期支持”版本(以前稱為“終端版本”)。 “長期支持”意味著Oracle Database 19c提供4年的高級支持(截止到2023年1月底)和至少3年的延長支持(截至2026年1月底)。 這個(gè)擴(kuò)展的支持窗口對我們的很多客戶至關(guān)重要,因?yàn)楹芏嗫蛻糁贫讼嚓P(guān)的升級策略。有關(guān)最新的Oracle支持計(jì)劃,請參閱My Oracle Support上的文檔ID 742060.1。截止目前,Oracle Database 19c已經(jīng)可以在Oracle數(shù)據(jù)庫一體機(jī)上使用了。
19c的安裝,除了支持圖形、命令行、靜默安裝外,最大的改進(jìn)是支持RPM安裝。Linux上安裝Oracle 19c,需要OL7、RHEL7、SLES12及以上的更高版本。Oracle Enterprise Linux6和RedHat Linux6并沒有出現(xiàn)在官方給的列表中。
19c相關(guān)技術(shù)文檔:
https://docs.oracle.com/en/database/oracle/oracle-database/19/index.html
https://docs.oracle.com/en/database/oracle/oracle-database/19/ladbi/operating-system-checklist-for-oracle-database-installation-on-linux.html
19c的RPM包下載鏈接:
https://www.oracle.com/database/technologies/oracle-database-software-downloads.html
Linux:https://www.oracle.com/database/technologies/oracle19c-linux-downloads.html
19c開始支持企業(yè)版本的RPM,如下圖所示,RPM包有2.5G。
二、環(huán)境準(zhǔn)備
測試服務(wù)器配置(VM虛擬機(jī)):2vCPU/ Mem 4G /Disk 20G
OS:CentOS 7.8 x64 (最小化安裝)
oracle版本:19c(19.3)
三、基礎(chǔ)設(shè)置
## 關(guān)閉SELINUX
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
sed -i 's/SELINUXTYPE=targeted/#SELINUXTYPE=targeted/' /etc/selinux/config
setenforce 0
## 關(guān)閉防火墻(若不關(guān)閉防火墻,后續(xù)需放開相應(yīng)端口)
systemctl disable firewalld.service
systemctl stop firewalld.service
或
systemctl disable iptables.service
systemctl stop iptables.service
## 修改用戶進(jìn)程限制
vi /etc/security/limits.d/20-nproc.conf
不同于編譯安裝時(shí)需要手動(dòng)修改oracle用戶的句柄數(shù)和內(nèi)核參數(shù),RPM安裝時(shí)會(huì)自動(dòng)設(shè)置這些參數(shù),所以一般不用再做設(shè)置。
安裝完成后可以通過/etc/security/limits.d/oracle-database-preinstall-19c.conf文件查看oracle句柄數(shù)相關(guān)設(shè)置,通過cat /etc/sysctl.d/99-oracle-database-preinstall-19c-sysctl.conf查看oracle內(nèi)核相關(guān)參數(shù)設(shè)置。這些默認(rèn)設(shè)置一般可以根據(jù)機(jī)器性能情況再改大一些,但是不能小于默認(rèn)設(shè)置。
四、安裝preinstall
下載地址:https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/index.html
安裝oracle-database-preinstall需要很多依賴包,如果有yum源可以自動(dòng)解決依賴關(guān)系,如果沒有只能提前準(zhǔn)備好安裝包。
cd /data/tools
wget https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-2.el7.x86_64.rpm
yum -y localinstall oracle-database-preinstall-19c-1.0-2.el7.x86_64.rpm
五、安裝及配置oracle 19c
1.安裝oracle-database-ee-19c
RPM包下載鏈接:https://www.oracle.com/database/technologies/oracle19c-linux-downloads.html
本文中先在本地下載RPM安裝包,再使用rz命令上傳至服務(wù)器內(nèi)。
cd /data/tools
yum -y localinstall oracle-database-ee-19c-1.0-1.x86_64.rpm
2.配置文件
## 可以通過如下文件配置實(shí)例端口和路徑
cat /etc/sysconfig/oracledb_ORCLCDB-19c.conf
## 另可以通過 /etc/init.d/oracledb_ORCLCDB-19c 此文件修改實(shí)例名稱SID名稱等更詳細(xì)的信息,更改之前最好備份。
3.創(chuàng)建數(shù)據(jù)庫實(shí)例
建立數(shù)據(jù)庫實(shí)例(大概十幾分鐘的過程,和服務(wù)器性能有關(guān)。本文中測試服務(wù)器配置初始化花了四十分鐘>_<)
/etc/init.d/oracledb_ORCLCDB-19c configure
4.配置環(huán)境變量
和11g相同,19c的oracle用戶的profile,需要增加環(huán)境變量。
vi /home/oracle/.bash_profile //文件末尾添加如下內(nèi)容
source /home/oracle/.bash_profile
5.重啟服務(wù)器及Oracle數(shù)據(jù)庫
## 切換至oracle用戶
su - oracle
## 啟動(dòng)監(jiān)聽
lsnrctl start
## 啟動(dòng)數(shù)據(jù)庫
sqlplus / as sysdba
startup
六、使用數(shù)據(jù)庫
1.修改oracle用戶密碼(本文中密碼為:OrAclE123#)
passwd oracle
2.登陸數(shù)據(jù)庫
su - oracle
sqlplus / as sysdba
3.輸入數(shù)據(jù)庫語句確認(rèn)數(shù)據(jù)庫語句可以正常執(zhí)行
show pdbs;
4.修改用戶密碼
## 查看已啟用的用戶
select username from dba_users where account_status='OPEN';
## 修改sys、system密碼
password system
password sys
或
alter user system identified by PassWr0d;
alter user sys identified by PassWr0d;
注意:
在root用戶權(quán)限下,需要輸入賬號(hào)和密碼才能進(jìn)入數(shù)據(jù)庫;
在oracle用戶權(quán)限下,不需要輸入賬號(hào)和密碼就能進(jìn)入數(shù)據(jù)庫。
七、服務(wù)管理
需切換至oracle用戶操作(su - oracle)
啟動(dòng):lsnrctl start
關(guān)閉:lsnrctl stop
重啟:lsnrctl restart
查看狀態(tài):lsnrctl status
八、Navicat連接Oracle數(shù)據(jù)庫
1.開放端口
防火墻放開端口1521。本文測試服務(wù)器系統(tǒng)沒有啟動(dòng)防火墻,所以不需配置。
2.服務(wù)名查詢
在數(shù)據(jù)庫中輸入查詢語句,
select global_name from global_name;
記下“ORCLCDB”。
3.Navicat新建Oracle連接
## 服務(wù)名不要亂寫,不然就會(huì)出現(xiàn)如下錯(cuò)誤:ORA-12514
或者服務(wù)名寫錯(cuò),當(dāng)選擇SID時(shí),就會(huì)出現(xiàn)如下錯(cuò)誤:ORA-12505
服務(wù)名寫對了,選擇SID也可以連接成功。
九、Oracle的卸載
切換到oracle用戶權(quán)限下進(jìn)行下列操作(su - oracle)
1.切換到oracle的deinstall目錄
cd /opt/oracle/product/19c/dbhome_1/deinstall
2.運(yùn)行deinstall文件
http://www.toutiao.com/a6946459456678937096/deinstall
3.在刪除的過程中有以下幾點(diǎn)需要確認(rèn)的:(其它沒有提到的都回車)
Specify the list of database names that are configured in this Oracle home [ORCLCDB]:
指定需要?jiǎng)h除的數(shù)據(jù)庫名稱,默認(rèn)即可,直接回車。
The details of database(s) orcl have been discovered automatically. Do you still want to modify the details of orcl database(s)? [n]:
是否需要修改數(shù)據(jù)庫的詳細(xì)信息,默認(rèn)n,直接回車。
Do you want to continue (y - yes, n - no)? [n]: y
是否繼續(xù),填寫y,回車
腳本結(jié)尾,提示需要使用root用戶刪除如下四個(gè)目錄。
rm -rf /etc/oraInst.loc
rm -rf /opt/ORCLfmap
rm -rf /etc/oratab
rm -rf /opt/oracle
下一篇:Centos7下設(shè)置Oracle數(shù)據(jù)庫開機(jī)自啟