說明:本文的所有步驟不適用于生產環境,僅用于個人測驗環境的快速部署和學習,下述操作程序在Oracle Linux 7.9上安裝Oracle 11.2.0.4單實體為例,
1 安裝環境檢查
安裝環境的檢查可以參考官方檔案Oracle Database Quick Installation Guide for Linux x86-64,由于是測驗環境,本文僅檢查:
- 物理記憶體大于1G,使用
free -m命令檢查 - /tmp目錄大于200MB,使用
df -h命令檢查,默認/tmp目錄在根磁區中,會大于200MB - hosts檔案有對應的IP和主機名決議,使用
cat /etc/hosts檢查 - 安裝和建庫需要約10GB的空間,本文安裝在
/u01,未使用獨立的磁區,也隸屬于根磁區中,有40GB的空間,
2 安裝環境準備
2.1 準備Oracle用戶和目錄
使用root用戶創建軟體安裝目錄/u01/app/oracle/product/11.2.0.4/db_1,創建oinstall、dba、oper用戶組,創建oracle用戶,并且為oracle用戶設定密碼,
groupadd -g 1300 oinstall
groupadd -g 1301 dba
groupadd -g 1302 oper
useradd -u 1300 -g oinstall -G dba,oper -s /bin/bash oracle
mkdir -p /u01/app/oracle/product/11.2.0.4/db_1
chown -R oracle.oinstall /u01
passwd oracle
2.2 檢查和安裝所需的RPM包
- 使用rpm檢查軟體包是否已安裝,如果未安裝,則會提示
is not installed,
rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n" binutils compat-db compat-libcap1 compat-libstdc++-33 control-center elfutils-libelf-devel gcc gcc-c++ glibc-common glibc glibc-devel glibc-headers ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel libgomp libXp make sysstat unzip
- 配置本地yum源,確保
/etc/yum.repos.d/目錄下僅有oracle-linux-ol7.repo組態檔
[root@oracle11g ~]# cat /etc/yum.repos.d/oracle-linux-ol7.repo
[ol7_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=file:///media/OEL79
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
[root@oracle11g ~]# df -h | grep OEL
/dev/sr0 4.6G 4.6G 0 100% /media/OEL79
[root@oracle11g ~]# yum makecache
Loaded plugins: ulninfo
ol7_latest | 3.6 kB 00:00:00
Metadata Cache Created
- 使用yum安裝軟體包
yum install binutils compat-db compat-libcap1 compat-libstdc++-33 control-center elfutils-libelf-devel gcc gcc-c++ glibc-common glibc glibc-devel glibc-headers ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel libgomp libXp make sysstat unzip -y
2.3 修改配置引數
- 修改pam認證機制,加載
pam_limits.so模塊來限制系統資源的使用
echo "session required pam_limits.so">>/etc/pam.d/login
- 配置oracle用戶的資源限制,限制打開行程數量和檔案數量
echo "oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
">>/etc/security/limits.conf
- 修改profile,Linux中初始化shell時會使用該組態檔,當用戶登錄系統時,系統會首先加載/etc/profile檔案,然后再加載用戶個人的shell初始化檔案,如~/.bash_profile等,
echo "if [ \$USER = "oracle" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
">>/etc/profile
- 修改內核引數,限制信號量、埠、檔案數量等
echo "fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 15461882265 #16GB
kernel.shmmax = 4294967295 #4GB
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
">>/etc/sysctl.conf
內核引數介紹:
- fs.aio-max-nr = 1048576:控制系統異步輸入輸出操作(Asynchronous I/O)并發數的最大值,影響系統的資料傳輸效率和壓力處理能力,
- fs.file-max = 6815744:表示系統最大檔案打開數量,默認是1024,可能會造成系統資源不足或行程無法打開檔案等問題,
- kernel.shmall = 15461882265:定義了系統使用的最大共享記憶體容量,以頁面(4K)為單位,這里設定的是16GB,
- kernel.shmmax = 4294967295:定義了用戶行程可使用的共享記憶體大小,以位元組為單位,這里設定的是4GB,
- kernel.shmmni = 4096:定義了系統最大的共享記憶體區數量,
- kernel.sem = 250 32000 100 128:設定內核信號量的值,后面的數字分別表示“信號量陣列的數量”、“每個信號量陣列中信號量的數目”、“系統所允許的信號量總數”和“一個信號量能帶有的最大值”,
- net.ipv4.ip_local_port_range = 9000 65500:設定本地埠范圍,這里設定了本地埠的最小和最大值,限制要使用該埠的行程數量,
- net.core.rmem_default = 262144:表示系統默認接收快取區大小,
- net.core.rmem_max = 4194304:表示系統中接收快取區的最大數量,用來調節系統接收性能,
- net.core.wmem_default = 262144:表示系統默認發送快取區大小,
- net.core.wmem_max = 1048576:表示系統中發送快取區的最大數量,用來調節系統發送性能,
- 配置oracle用戶的環境變數,設定實體名為
orcl、安裝路徑為/u01/app/oracle/product/11.2.0.4/db_1
export ORACLE_SID=orcl
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1
echo "export ORACLE_SID=$ORACLE_SID
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/usr/local/lib
export PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/OPatch
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
umask 022
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export SQLPATH=$ORACLE_HOME/sqlplus/admin
">>/home/oracle/.bash_profile
2.4 關閉selinux和防火墻
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
systemctl disable firewalld --now
完成上述操作后,需要重啟作業系統才生效
reboot
2.5 準備軟體安裝包
- 將安裝包放在/tmp目錄下
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip
- 更改安裝包的屬組和用戶為oinstall和oracle
chown -R oracle.oinstall /tmp/database
2.6 創建回應檔案
需要留意的是UNIX_GROUP_NAME、INVENTORY_LOCATION、ORACLE_HOME、ORACLE_BASE,保持和前文的創建的用戶名、安裝路徑一致,
echo "oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=DBProduce
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en,en_GB
ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=false
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.config.starterdb.characterSet=
oracle.install.db.config.starterdb.memoryOption=false
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=SKIP_UPDATES
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD="/tmp/11gR2.rsp
3 執行靜默安裝
- 使用oracle用戶,執行
./runInstaller,注意-responseFile要用絕對路徑
cd /tmp/database
./runInstaller -ignoreSysPrereqs -ignorePrereq -waitforcompletion -showProgress -silent -responseFile /tmp/11gR2.rsp
- 安裝程序輸出
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 28865 MB Passed
Checking swap space: must be greater than 150 MB. Actual 3967 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2023-05-06_03-53-30AM. Please wait ...You can find the log of this install session at:
/u01/app/oraInventory/logs/installActions2023-05-06_03-53-30AM.log
Prepare in progress.
.................................................. 9% Done.
Prepare successful.
Copy files in progress.
.................................................. 14% Done.
.................................................. 20% Done.
.................................................. 26% Done.
.................................................. 31% Done.
.................................................. 36% Done.
.................................................. 41% Done.
.................................................. 46% Done.
.................................................. 51% Done.
.................................................. 56% Done.
.................................................. 63% Done.
.................................................. 68% Done.
.................................................. 73% Done.
.................................................. 78% Done.
.................................................. 83% Done.
..............................
Copy files successful.
Link binaries in progress.
..........
Link binaries successful.
Setup files in progress.
.................................................. 88% Done.
.................................................. 94% Done.
Setup files successful.
The installation of Oracle Database 11g was successful.
Please check '/u01/app/oraInventory/logs/silentInstall2023-05-06_03-53-30AM.log' for more details.
Execute Root Scripts in progress.
As a root user, execute the following script(s):
1. /u01/app/oraInventory/orainstRoot.sh
2. /u01/app/oracle/product/11.2.0.4/db_1/root.sh
.................................................. 100% Done.
Execute Root Scripts successful.
Successfully Setup Software.
4 安裝后配置
使用root用戶來之執行配置腳本
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0.4/db_1/root.sh
5 執行靜默建庫
5.1 創建監聽
- 準備netca回應檔案
echo 'RESPONSEFILE_VERSION="11.2"
CREATE_TYPE="CUSTOM"
INSTALLED_COMPONENTS={"server","net8″,"javavm"}
INSTALL_TYPE=""typical""
LISTENER_NUMBER=1
LISTENER_NAMES={"LISTENER"}
LISTENER_PROTOCOLS={"TCP;1521"}
LISTENER_START=""LISTENER""
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
NSN_NUMBER=1
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}
NSN_SERVICE={"PLSExtProc"}
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"'>>/tmp/netca.rsp
- 執行靜默安裝,注意是
/responsefile,而且回應檔案要絕對路徑
netca /silent /responsefile /tmp/netca.rsp
- 配置成功后,輸出如下:
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /u01/install/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Services configuration successful. The exit code is 0
- 啟動監聽程式
[oracle@oracle11g admin]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 06-MAY-2023 04:28:25
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0.4/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Log messages written to /u01/app/oracle/diag/tnslsnr/oracle11g/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle11g)(PORT=1521)))
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 06-MAY-2023 04:28:26
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /u01/app/oracle/diag/tnslsnr/oracle11g/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle11g)(PORT=1521)))
5.2 執行靜默建庫
- 使用
oracle用戶執行dbca命令來完成靜默建庫,安裝程序中會自動創建/u01/app/oracle/oradata目錄,并拷貝資料檔案和生成控制檔案、日志檔案,將所有密碼設定為oracle11g,
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname orcl -sid orcl -responseFile NO_VALUE -characterSet ZHS16GBK -memoryPercentage 75 -emConfiguration LOCAL -datafiledestination /u01/app/oracle/oradata -sysPassword oracle11g -systemPassword oracle11g -dbsnmpPassword oracle11g -sysmanPassword oracle11g
- 建庫程序輸出
Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
6 安裝完成后檢查
- 資料庫實體的監聽注冊狀態,確定是READY
[oracle@oracle11g ~]$ lsnrctl stat
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 06-MAY-2023 04:35:48
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 06-MAY-2023 04:28:26
Uptime 0 days 0 hr. 7 min. 22 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /u01/app/oracle/diag/tnslsnr/oracle11g/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle11g)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
- 登錄資料庫,檢查資料庫狀態為OPEN
[oracle@oracle11g ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sat May 6 04:36:58 2023
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
ORCL READ WRITE
至此,Oracle11gR2單實體靜默安裝和建庫完成,
再次強調一遍,本文安裝的環境僅適用于測驗,生產環境的資料庫安裝,請遵循Oracle的最佳實踐,
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/551861.html
標籤:其他
下一篇:返回列表
