資源
下載自己操作系統(tǒng)對應(yīng)的軟件包:官網(wǎng)下載地址
配置內(nèi)核參數(shù)
編輯? /etc/sysctl.conf 添加如下內(nèi)容
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
更改當(dāng)前內(nèi)核參數(shù)
[root@localhost heweiwei]# sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key
error: "net.bridge.bridge-nf-call-iptables" is an unknown key
error: "net.bridge.bridge-nf-call-arptables" is an unknown key
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
限制oracle用戶資源使用
編輯 /etc/security/limits.conf 添加如下內(nèi)容
oracle? soft? nofile? ? 1024
oracle? hard? nofile? ? 65536
oracle? soft? nproc? ? 16384
oracle? hard? nproc? ? 16384
oracle? soft? stack? ? 10240
oracle? hard? stack? ? 32768
oracle? hard? memlock? ? 134217728
oracle? soft? memlock? ? 134217728
安裝所有依賴
可以寫個(gè)安裝腳本
#!/bin/bash
yum install binutils -y
yum install compat-libcap1 -y
yum install compat-libstdc++-33 -y
yum install compat-libstdc++-33.i686 -y
yum install glibc -y
yum install glibc.i686 -y
yum install glibc-devel -y
yum install glibc-devel.i686 -y
yum install ksh -y
yum install libaio -y
yum install libaio.i686 -y
yum install libaio-devel -y
yum install libaio-devel.i686 -y
yum install libX11 -y
yum install libX11.i686 -y
yum install libXau -y
yum install libXau.i686 -y
yum install libXi -y
yum install libXi.i686 -y
yum install libXtst -y
yum install libXtst.i686 -y
yum install libgcc -y
yum install libgcc.i686 -y
yum install libstdc++ -y
yum install libstdc++.i686 -y
yum install libstdc++-devel -y
yum install libstdc++-devel.i686 -y
yum install libxcb -y
yum install libxcb.i686 -y
yum install make -y
yum install nfs-utils -y
yum install net-tools -y
yum install smartmontools -y
yum install sysstat -y
yum install unixODBC -y
yum install unixODBC-devel -y
創(chuàng)建oracle用戶組
[root@localhost heweiwei]# groupadd -g 54321 oinstall
[root@localhost heweiwei]# groupadd -g 54322 dba
[root@localhost heweiwei]# groupadd -g 54323 oper
[root@localhost heweiwei]# useradd -u 54321 -g oinstall -G dba,oper oracle
修改設(shè)置SELINUX
將/etc/selinux/config 中 `SELINUX` 修改為permissive
[root@localhost oracle]# vim /etc/selinux/config
[root@localhost oracle]# setenforce Permissive
setenforce: SELinux is disabled
關(guān)閉防火墻
[root@localhost oracle]# service iptables stop
創(chuàng)建Oracle安裝目錄
[root@localhost oracle]# mkdir -p /usr/local/products/oracle12c
[root@localhost oracle]# chown -R oracle:oinstall /usr/local/products/
[root@localhost oracle]# chmod -R 775 /usr/local/products/
配置Oracle環(huán)境變量并驗(yàn)證
oracle用戶名下,配置oracle用戶下環(huán)境變量
[oracle@localhost ~]$ vim .bash_profile
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_HOSTNAME=localhost? // 注意要換成 /etc/hosts 中的用戶
export ORACLE_UNQNAME=cdb1
export ORACLE_BASE=/usr/local/products
export ORACLE_HOME=$ORACLE_BASE/oracle12c
export ORACLE_SID=cdb1
export PATH=/usr/sbin:/usr/local/bin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
[oracle@localhost ~]$ source .bash_profile
[oracle@localhost ~]$ echo $ORACLE_HOME
/usr/local/products/oracle12c
安裝
我的目錄/home下空間不夠 所以我創(chuàng)建了/oracle目錄(實(shí)際應(yīng)該為/home/oracle目錄),將官網(wǎng)下載的文件包解壓
unzip linuxx64_12201_database.zip 我這里采用靜態(tài)安裝
./runInstaller -ignoreSysPrereqs -ignorePrereq -waitforcompletion \
-showProgress -silent -responseFile/oracle/database/response/db_install.rsp\
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/usr/local/products/oracle12c/oraInventory \
ORACLE_HOME=/usr/local/products/oracle12c \
ORACLE_BASE=/usr/local/products \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSBACKUPDBA_GROUP=dba \
oracle.install.db.OSDGDBA_GROUP=dba \
oracle.install.db.OSKMDBA_GROUP=dba \
oracle.install.db.OSRACDBA_GROUP=dba
[oracle@localhost database]$ ./runInstaller -ignoreSysPrereqs -ignorePrereq -waitforcompletion -showProgress -silent -responseFile /oracle/database/response/db_install.rsp oracle.install.option=INSTALL_DB_SWONLY UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/usr/local/products/oracle12c/oraInventory ORACLE_HOME=/usr/local/products/oracle12c ORACLE_BASE=/usr/local/products oracle.install.db.InstallEdition=EE oracle.install.db.OSDBA_GROUP=dba oracle.install.db.OSBACKUPDBA_GROUP=dba oracle.install.db.OSDGDBA_GROUP=dba oracle.install.db.OSKMDBA_GROUP=dba oracle.install.db.OSRACDBA_GROUP=dba
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 500 MB.? Actual 36281 MB? ? Passed
Checking swap space: must be greater than 150 MB.? Actual 7107 MB? ? Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-10-22_10-58-44AM. Please wait ...[WARNING] [INS-32016] The selected Oracle home contains directories or files.
? ACTION: To start with an empty Oracle home, either remove its contents or choose another location.
[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
? ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
You can find the log of this install session at:
/usr/local/products/oracle12c/oraInventory/logs/installActions2018-10-22_10-58-44AM.log
Prepare in progress.
..................................................? 8% Done.
Prepare successful.
Copy files in progress.
..................................................? 17% Done.
..................................................? 22% Done.
..................................................? 27% Done.
..................................................? 32% Done.
..................................................? 40% Done.
..................................................? 45% Done.
..................................................? 50% Done.
..................................................? 55% Done.
..................................................? 60% Done.
..................................................? 65% Done.
..................................................? 70% Done.
..................................................? 75% Done.
..................................................? 80% Done.
....................
Copy files successful.
Link binaries in progress.
..........
Link binaries successful.
Setup files in progress.
..............................
Setup files successful.
Setup Inventory in progress.
Setup Inventory successful.
Finish Setup successful.
The installation of Oracle Database 12c was successful.
Please check '/usr/local/products/oracle12c/oraInventory/logs/silentInstall2018-10-22_10-58-44AM.log' for more details.
Setup Oracle Base in progress.
Setup Oracle Base successful.
..................................................? 95% Done.
As a root user, execute the following script(s):
1. /usr/local/products/oracle12c/oraInventory/orainstRoot.sh
2. /usr/local/products/oracle12c/root.sh
..................................................? 100% Done.
Successfully Setup Software.
根據(jù)提示運(yùn)行腳本
[root@localhost database]# /usr/local/products/oracle12c/oraInventory/orainstRoot.sh
Changing permissions of /usr/local/products/oracle12c/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /usr/local/products/oracle12c/oraInventory to oinstall.
The execution of the script is complete.
[root@localhost database]# /usr/local/products/oracle12c/root.sh
Check /usr/local/products/oracle12c/install/root_localhost.localdomain_2018-10-22_11-05-52-854397878.log for the output of root script
[root@localhost database]#
[root@localhost oracle]# su oracle
[oracle@localhost ~]$
安裝成功
測試如下:
[oracle@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Mon Oct 22 11:11:14 2018
Copyright (c) 1982, 2016, Oracle.? All rights reserved.
Connected to an idle instance.
SQL>
數(shù)據(jù)庫創(chuàng)建
執(zhí)行下列命令:OraPasswd1 是自己的密碼,包含大小寫及數(shù)字
dbca -silent -createDatabase \
-templateName /usr/local/products/oracle12c/assistants/dbca/templates/General_Purpose.dbc \
-gdbname cdb1 -sid cdb1 -responseFile /home/oracle/database/response/dbca.rsp \
-characterSet AL32UTF8 \
-sysPassword OraPasswd1 \
-systemPassword OraPasswd1 \
-createAsContainerDatabase true \
-numberOfPDBs 1 \
-pdbName pdb1 \
-pdbAdminPassword OraPasswd1 \
-automaticMemoryManagement false \
-ignorePreReqs
[oracle@localhost ~]$ dbca -silent -createDatabase -templateName /usr/local/products/oracle12c/assistants/dbca/templates/General_Purpose.dbc -gdbname cdb1 -sid cdb1 -responseFile /oracle/database/response/dbca.rsp -characterSet AL32UTF8 -sysPassword OraPasswd1 -systemPassword OraPasswd1 -createAsContainerDatabase true -numberOfPDBs 1 -pdbName pdb1 -pdbAdminPassword OraPasswd1 -automaticMemoryManagement false -ignorePreReqs
Copying database files
1% complete
13% complete
25% complete
Creating and starting Oracle instance
26% complete
30% complete
31% complete
35% complete
38% complete
39% complete
41% complete
Completing Database Creation
42% complete
43% complete
44% complete
46% complete
49% complete
50% complete
Creating Pluggable Databases
55% complete
75% complete
Executing Post Configuration Actions
100% complete
Look at the log file "/usr/local/products/cfgtoollogs/dbca/cdb1/cdb1.log" for further details.
[oracle@localhost ~]$
dbca -silent -createDatabase \
-templateName /usr/local/products/oracle12c/assistants/dbca/templates/General_Purpose.dbc \
-gdbname cdb1 -sid cdb1 -responseFile /home/oracle/database/response/dbca.rsp \
-characterSet AL32UTF8 \
-sysPassword OraPasswd1 \
-systemPassword OraPasswd1 \
-createAsContainerDatabase true \
-numberOfPDBs 1 \
-pdbName pdb1 \
-pdbAdminPassword OraPasswd1 \
-automaticMemoryManagement false \
-ignorePreReqs
數(shù)據(jù)庫監(jiān)聽配置
使用默認(rèn)的netca.rsp文件? 執(zhí)行netca -silent -responseFile /home/oracle/database/response/netca.rsp
netca -silent -responseFile /oracle/database/response/netca.rsp? // 因?yàn)?home空間不足 所以安裝時(shí)創(chuàng)建了/oracle 來安裝
啟動
[oracle@localhost ~]$ lsnrctl start
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 22-OCT-2018 17:16:26
Copyright (c) 1991, 2016, Oracle.? All rights reserved.
Starting /usr/local/products/oracle12c/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /usr/local/products/oracle12c/network/admin/listener.ora
Log messages written to /usr/local/products/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1539)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1539)))
STATUS of the LISTENER
------------------------
Alias? ? ? ? ? ? ? ? ? ? LISTENER
Version? ? ? ? ? ? ? ? ? TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date? ? ? ? ? ? ? ? 22-OCT-2018 17:16:26
Uptime? ? ? ? ? ? ? ? ? ? 0 days 0 hr. 0 min. 0 sec
Trace Level? ? ? ? ? ? ? off
Security? ? ? ? ? ? ? ? ? ON: Local OS Authentication
SNMP? ? ? ? ? ? ? ? ? ? ? OFF
Listener Parameter File? /usr/local/products/oracle12c/network/admin/listener.ora
Listener Log File? ? ? ? /usr/local/products/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
? (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1539)))
? (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
查看狀態(tài)
[oracle@localhost ~]$ lsnrctl status
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 22-OCT-2018 17:18:59
Copyright (c) 1991, 2016, Oracle.? All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1539)))
STATUS of the LISTENER
------------------------
Alias? ? ? ? ? ? ? ? ? ? LISTENER
Version? ? ? ? ? ? ? ? ? TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date? ? ? ? ? ? ? ? 22-OCT-2018 17:16:26
Uptime? ? ? ? ? ? ? ? ? ? 0 days 0 hr. 2 min. 33 sec
Trace Level? ? ? ? ? ? ? off
Security? ? ? ? ? ? ? ? ? ON: Local OS Authentication
SNMP? ? ? ? ? ? ? ? ? ? ? OFF
Listener Parameter File? /usr/local/products/oracle12c/network/admin/listener.ora
Listener Log File? ? ? ? /usr/local/products/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
? (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1539)))
? (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully