CentOS Linux release 7.6.1810 (Core) 靜默安裝oracle18c
淌過的河偿乖,濕了鞋
經(jīng)歷的煩,能渡人
參考
https://www.linuxidc.com/Linux/2017-03/141830.htm
https://www.linuxidc.com/Linux/2016-12/138678.htm
https://docs.oracle.com/cd/E11882_01/em.112/e12255/oui3_response_files.htm#OUICG183
http://www.ha97.com/4788.html
下載鏈接(需要登陸,使用wget下載時影兽,rpm包需要認證,而zip包不需要,直接可下載)
http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_1of2.zip
https://download.oracle.com/otn/linux/oracle18c/180000/oracle-database-ee-18c-1.0-1.x86_64.rpm?AuthParam=1564123203_97207c60053b2834fecbd8a7786ccc44
https://download.oracle.com/otn/linux/oracle18c/180000/oracle-database-ee-18c-1.0-1.x86_64.rpm
https://download.oracle.com/otn/linux/oracle18c/180000/oracle-database-ee-18c-1.0-1.x86_64.rpm
https://download.oracle.com/otn/linux/oracle18c/180000/LINUX.X64_180000_db_home.zip?AuthParam=1564126689_3e44379dc67f5b129e0af3962eaab5db
開始安裝
環(huán)境
硬件環(huán)境
物理內(nèi)存不小于1.5G
硬盤可用空間不小于5G(安裝包3-4G)
swap分區(qū)空間不小于2G
軟件環(huán)境
所需依賴(oracle官網(wǎng)顯示)
binutils-2.23.52.0.1-12.el7.x86_64
compat-libcap1-1.10-3.el7.x86_64
compat-libstdc++-33-3.2.3-71.el7.i686
compat-libstdc++-33-3.2.3-71.el7.x86_64
gcc-4.8.2-3.el7.x86_64
gcc-c++-4.8.2-3.el7.x86_64
glibc-2.17-36.el7.i686
glibc-2.17-36.el7.x86_64
glibc-devel-2.17-36.el7.i686
glibc-devel-2.17-36.el7.x86_64
ksh
libaio-0.3.109-9.el7.i686
libaio-0.3.109-9.el7.x86_64
libaio-devel-0.3.109-9.el7.i686
libaio-devel-0.3.109-9.el7.x86_64
libgcc-4.8.2-3.el7.i686
libgcc-4.8.2-3.el7.x86_64
libstdc++-4.8.2-3.el7.i686
libstdc++-4.8.2-3.el7.x86_64
libstdc++-devel-4.8.2-3.el7.i686
libstdc++-devel-4.8.2-3.el7.x86_64
libXi-1.7.2-1.el7.i686
libXi-1.7.2-1.el7.x86_64
libXtst-1.2.2-1.el7.i686
libXtst-1.2.2-1.el7.x86_64
make-3.82-19.el7.x86_64
sysstat-10.1.5-1.el7.x86_64
查詢?nèi)笔б蕾嚥惭b
rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXext libXtst libX11 libXau libxcb libXi make sysstat
binutils-2.27-34.base.el7.x86_64
package compat-libcap1 is not installed
package compat-libstdc++-33 is not installed
gcc-4.8.5-36.el7_6.2.x86_64
package gcc-c++ is not installed
glibc-2.17-260.el7_6.6.x86_64
glibc-devel-2.17-260.el7_6.6.x86_64
package ksh is not installed
package libaio is not installed
package libaio-devel is not installed
libgcc-4.8.5-36.el7_6.2.x86_64
libstdc++-4.8.5-36.el7_6.2.x86_64
package libstdc++-devel is not installed
libXext-1.3.3-3.el7.x86_64
libXtst-1.2.3-1.el7.x86_64
libX11-1.6.5-2.el7.x86_64
libXau-1.0.8-2.1.el7.x86_64
libxcb-1.13-1.el7.x86_64
libXi-1.7.9-1.el7.x86_64
make-3.82-23.el7.x86_64
sysstat-10.1.5-17.el7.x86_64
#####安裝
yum -y install compat-libcap1 compat-libstdc++-33 gcc-c++ ksh libaio libaio-devel libstdc++-devel
創(chuàng)建用戶組設(shè)置賬戶密碼
groupadd oracle #添加oracle組
groupadd dba #添加dba組
useradd -g oracle -Gdba oracle #添加oracle用戶
passwd oracle #設(shè)置oracle用戶密碼
修改內(nèi)核參數(shù)(oracle建議)
vim /etc/sysctl.conf
cat >> /etc/sysctl.conf<<EOF
#ORACLE SETTING
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4181979136
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
EOF
sysctl -p
修改用戶內(nèi)核限制參數(shù)(oracle建議)
vim /etc/security/limits.conf
cat >> /etc/security/limits.conf<<EOF
#ORACLE SETTING
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
EOF
關(guān)閉防火墻關(guān)閉selinux(---)
創(chuàng)建安裝目錄并設(shè)置權(quán)限
cd /usr/local
mkdir -p oracle/database
mkdir -p oracle/oraInventory #安裝目錄--》ORACLE_HOME=/usr/local/oracle/databas ORACLE_BASE=/usr/local/oracle
移動安裝包到安裝目錄
unzip /opt/soft/oracle_18c/LINUX.X64_180000_db_home.zip -d /usr/local/oracle/database
chmod -R 775 oracle
chown -R oracle:oracle oracle #設(shè)置oracle文件夾為oracle用戶
設(shè)置環(huán)境變量
su - oracle
vim /home/oracle/.bash_profile
export PATH
export ORACLE_BASE=/usr/local/oracle #oracle數(shù)據(jù)庫安裝目錄
export ORACLE_HOME=$ORACLE_BASE/database #數(shù)據(jù)庫路徑
export ORACLE_SID=myorcl #啟動數(shù)據(jù)庫實例名
export ORACLE_TERM=xterm #xterm窗口模式安裝
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH #添加系統(tǒng)環(huán)境變量
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export LANG=en_US
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
或者執(zhí)行腳本setEnv.sh
腳本如下:
cat > /home/oracle/scripts/setEnv.sh <<EOF
#Oracle Settings
export TMP=/tmp
export TMPDIR=\$TMP
export ORACLE_UNQNAME=myorcl
export ORACLE_BASE=/usr/local/oracle
export ORACLE_HOME=/usr/local/oracle/database
export ORA_INVENTORY=/usr/local/oracle/oraInventory
export ORACLE_SID=myorcl
export PDB_NAME=myorclpdb
export DATA_DIR=/usr/local/oracle/oradata/
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
EOF
echo ". /home/oracle/scripts/setEnv.sh" >> /home/oracle/.bash_profile
source /home/oracle/.bash_profile
安裝oracle18c(靜默安裝钥屈,非圖形化安裝)
配置oracle安裝響應(yīng)文件
vim /usr/local/oracle/database/install/response/db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v18.0.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oracle
INVENTORY_LOCATION=/usr/local/oracle/oraInventory
ORACLE_HOME=/usr/local/oracle/database
ORACLE_BASE=/usr/local/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_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.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=myorcl
oracle.install.db.config.starterdb.SID=myorcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
修改所需必要配置即可
cd /usr/local/oracle/database
./runInstaller -force -silent -responseFile /usr/local/oracle/database/install/response/db_install.rsp
執(zhí)行這條命令就開始安裝過程
安裝過程中如報錯,請檢查環(huán)境配置以及安裝響應(yīng)配置文件
安裝完成后 提示執(zhí)行兩條腳本(切換到root用戶執(zhí)行),按提示執(zhí)行即可
sh /usr/local/oracle/oraInventory/orainstRoot.sh
sh /usr/local/oracle/root.sh
安裝后設(shè)置
靜默監(jiān)聽配置(自行配置)
/usr/local/oracle/database/assistants/netca
vim /usr/local/oracle/database/assistants/netca/netca.rsp
netca -silent -responsefile /usr/local/oracle/database/assistants/netca/netca.rsp
更改監(jiān)聽配置(自行配置)
/usr/local/oracle/database/network/admin/listener.ora
lsnrctl stop
lsnrctl start
lsnrctl status
dbca靜默創(chuàng)建數(shù)據(jù)庫實例
vim /usr/local/oracle/database/assistants/dbca/dbca.rsp
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v18.0.0
gdbName=myorcl
sid=myorcl
databaseConfigType=SI
policyManaged=false
createServerPool=false
force=false
numberOfPDBs=1
templateName=/usr/local/oracle/database/assistants/dbca/templates/General_Purpose.dbc
emExpressPort=5500
runCVUChecks=false
omsPort=0
dvConfiguration=false
olsConfiguration=false
datafileJarLocation={ORACLE_HOME}/assistants/dbca/templates/
datafileDestination={ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/
recoveryAreaDestination={ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME}
storageType=fs
characterSet=AL32UTF8
nationalCharacterSet=AL16UTF16
registerWithDirService=FALSE
listeners=LISTENER
variables=DB_UNIQUE_NAME=myorcl,ORACLE_BASE=/usr/local/oracle,PDB_NAME=,DB_NAME=myorcl,ORACLE_HOME=/usr/local/oracle/database,SID=myorcl
initParams=undo_tablespace=UNDOTBS1,memory_target=2048MB,processes=300,db_recovery_file_dest_size=10834MB,nls_language=AMERICAN,dispatchers=(PROTOCOL=TCP) (SERVICE=myorcl),db_recovery_file_dest={ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME},db_block_size=8192BYTES,diagnostic_dest={ORACLE_BASE},audit_file_dest={ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/adump,nls_territory=AMERICA,local_listener=LISTENER_MYORCL,compatible=18.0.0,control_files=("{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control01.ctl", "{ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME}/control02.ctl"),db_name=myorcl,audit_trail=db,remote_login_passwordfile=EXCLUSIVE,open_cursors=300
sampleSchema=false
memoryPercentage=40
databaseType=MULTIPURPOSE
automaticMemoryManagement=false
totalMemory=0
dbca -silent -createDatabase -responseFile /usr/local/oracle/database/assistants/dbca/dbca.rsp
接下來會自動創(chuàng)建數(shù)據(jù)庫實例并啟動
安裝過程如下所示坝辫,實例會自動配置并啟動
[oracle@iZ2zeb281zcjztofgty6tnZ response]$ dbca -silent -createDatabase -responseFile /usr/local/oracle/response/test_dbca.rsp
輸入 SYS 用戶口令:
輸入 SYSTEM 用戶口令:
準(zhǔn)備執(zhí)行數(shù)據(jù)庫操作
已完成 10%
復(fù)制數(shù)據(jù)庫文件
已完成 40%
正在創(chuàng)建并啟動 Oracle 實例
已完成 42%
已完成 46%
已完成 50%
已完成 54%
已完成 60%
正在進行數(shù)據(jù)庫創(chuàng)建
已完成 66%
已完成 69%
已完成 70%
執(zhí)行配置后操作
已完成 100%
數(shù)據(jù)庫創(chuàng)建完成篷就。有關(guān)詳細信息, 請查看以下位置的日志文件:
/usr/local/oracle/cfgtoollogs/dbca/test。
數(shù)據(jù)庫信息:
全局數(shù)據(jù)庫名:test
系統(tǒng)標(biāo)識符 (SID):test
有關(guān)詳細信息, 請參閱日志文件 "/usr/local/oracle/cfgtoollogs/dbca/test/test.log"近忙。
數(shù)據(jù)庫基本操作
sqlplus / as sysdba // 登錄數(shù)據(jù)庫
select open_mode from vinstance; //查看數(shù)據(jù)庫狀態(tài)
alter user sys identified by oracle; //改sys超級管理員密碼
alter user system identified by oracle竭业; //改system管理員密碼
create user identified by oracle; //創(chuàng)建用戶
exit // 退出數(shù)據(jù)庫
sqlplus sys/oracle as sysdba //使用sys超級管理員登錄數(shù)據(jù)庫
startup // 啟動數(shù)據(jù)庫
select name from v$database; //查看數(shù)據(jù)庫
shutdown abort //關(guān)閉數(shù)據(jù)庫
conn system/oracle //切換用戶conn后面直接跟用戶名和密碼就可以
設(shè)置開機自啟動oracle和監(jiān)聽器
su - oracle
vim /usr/local/oracle/database/bin/dbstart
#將ORACLE_HOME_LISTNER=$1,修改為ORACLE_HOME_LISTNER=$ORACLE_HOME
vim /usr/local/oracle/database/bin/dbshut
#將ORACLE_HOME_LISTNER=$1,修改為ORACLE_HOME_LISTNER=$ORACLE_HOME
vim /etc/oratab
myorcl:/usr/local/oracle/database:Y
vim /etc/rc.local
su - oracle -c 'dbstart'
su - oracle -c 'lsnrctl start'
chmod+x /etc/rc.local
Linux下重啟Oracle數(shù)據(jù)庫步驟
1、Linux下以O(shè)racle帳戶進入Linux系統(tǒng)银锻。
2永品、執(zhí)行以下命令查看數(shù)據(jù)庫監(jiān)聽器的狀況:
lsnrctl status
3做鹰、執(zhí)行以下命令停止數(shù)據(jù)庫監(jiān)聽器運行:
lsnrctl stop
4击纬、執(zhí)行以下命令進入SQLPlus:
sqlplus /nolog
conn /as sysdba
shutdown immediate
5、執(zhí)行以下命令退出SQLPlus:
Exit
6钾麸、啟動,查看數(shù)據(jù)庫監(jiān)聽器:
lsnrctl start
lsnrctl status
7更振、啟動Oracle數(shù)據(jù)庫:
sqlplus /nolog
conn /as sysdba
startup
window下進入sqlplus 命令:sqlplus / as sysdba
Linux下進入sqlplus 命令:sqlplus "/as sysdba"