最近需要安裝oracle,然后網(wǎng)上查了一下教程,在centos7.7上安裝成功,運(yùn)行正常。這里記錄一下。
環(huán)境:
硬件4核/8G RAM/100G 存儲
centos7.7(64bit)
oracle11g(官網(wǎng)下載的)
步驟(轉(zhuǎn)載):
第一個腳本preinstalloracle.sh,以root用戶運(yùn)行。執(zhí)行完后需要重啟電腦,需要注意看一下hostname是否修改好了
#!/bin/bash
#以root用戶運(yùn)行
#注意修改第三行的ip為自己的ip地址
echo "172.16.1.110 orcl orcl" >> /etc/hosts
cat >> /etc/sysconfig/network EOF
network=yes
hostname=orcl
EOF
第二個腳本secinstalloracle.sh,以root用戶運(yùn)行
#!/bin/bash
#以root用戶運(yùn)行
#內(nèi)核參數(shù)設(shè)置kernel.shmall=2097152其中16G物理內(nèi)存建議設(shè)為4194304類推8G應(yīng)為2097152
#kernel.shmmax=4294967296一般設(shè)置為物理內(nèi)存的一半,8G:4294967296也可以全部用完8*1024*1024*1024
yum install -y binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc gcc-c++ libaio-devel libaio libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel ksh numactl-devel zip unzip
cat >> /etc/sysctl.conf EOF
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 4294967296
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
EOF
sysctl -p #使配置文件生效
cat >> /etc/security/limits.conf EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
cat >> /etc/pam.d/login EOF
session required /lib/security/pam_limits.so
session required pam_limits.so
EOF
cat >> /etc/profile EOF
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
EOF
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
mkdir -p /u01/app/oracle/product/11.2.0/db_1
mkdir -p /u01/app/oracle/oradata
mkdir -p /u01/app/oraInventory
mkdir -p /u01/app/oracle/fast_recovery_area
chown -R oracle:oinstall /u01/app/oracle
chown -R oracle:oinstall /u01/app/oraInventory
chmod -R 755 /u01/app/oracle
chmod -R 755 /u01/app/oraInventory
systemctl disable firewalld
systemctl stop firewalld
setenforce 0
sed -i 's/=enforcing/=disabled/g' /etc/selinux/config
mv p13390677_112040_Linux-x86-64_1of7.zip /home/oracle
mv p13390677_112040_Linux-x86-64_2of7.zip /home/oracle
cp thiinstalloracle.sh /home/oracle/
cp fouinstalloracle.sh /home/oracle/
第三個腳本thiinstalloracle.sh,以oracle用戶運(yùn)行,su - oracle
#!/bin/bash
#以oracle用戶運(yùn)行,su - oracle
cat >> .bash_profile EOF
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/db_1
ORACLE_SID=orcl
export NLS_LANG=AMERICAN_AMERICA.UTF8
PATH=\$PATH:\$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
umask 022
EOF
source .bash_profile
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip
chown -R oracle:oinstall database
cd database/response
cp db_install.rsp db_install.rsp.bak
sed -i "s/^oracle.install.option=/oracle.install.option=INSTALL_DB_SWONLY/g" db_install.rsp
sed -i "s/^ORACLE_HOSTNAME=/ORACLE_HOSTNAME= orcl/g" db_install.rsp
sed -i "s/^UNIX_GROUP_NAME=/UNIX_GROUP_NAME=oinstall/g" db_install.rsp
sed -i "s/^INVENTORY_LOCATION=/INVENTORY_LOCATION=\/u01\/app\/oraInventory/g" db_install.rsp
sed -i "s/^SELECTED_LANGUAGES=en/SELECTED_LANGUAGES=en,zh_CN/g" db_install.rsp
sed -i "s/^ORACLE_HOME=/ORACLE_HOME=\/u01\/app\/oracle\/product\/11.2.0\/db_1/g" db_install.rsp
sed -i "s/^ORACLE_BASE=/ORACLE_BASE=\/u01\/app\/oracle/g" db_install.rsp
sed -i "s/^oracle.install.db.InstallEdition=/oracle.install.db.InstallEdition=EE/g" db_install.rsp
sed -i "s/^oracle.install.db.DBA_GROUP=/oracle.install.db.DBA_GROUP=dba/g" db_install.rsp
sed -i "s/^oracle.install.db.OPER_GROUP=/oracle.install.db.OPER_GROUP=dba/g" db_install.rsp
sed -i "s/^DECLINE_SECURITY_UPDATES=/DECLINE_SECURITY_UPDATES=true/g" db_install.rsp
cd ..
./runInstaller -silent -responseFile /home/oracle/database/response/db_install.rsp #可能會包INS-13014目標(biāo)不滿足一些可選要求,查看日志,如果是pdksh缺少的話,可以忽略直接進(jìn)行下一步。沒有異常,不報錯的話會在三兩分鐘后出現(xiàn)使用root用戶執(zhí)行orainstRoot.sh和root.sh的提示
第三腳本執(zhí)行結(jié)果截圖,需要等到最后那行提示success才可以回車,大概需要三四分鐘
查看/tmp/OraInstall2019-05-10_03-42-57PM/installActions2019-05-10_03-42-57PM.log,可以看到其中一部分內(nèi)容如下,如果只有這個報錯,可以忽略跳過
所以,我們接著另開一個端口,以root用戶身份執(zhí)行
sh /u01/app/oraInventory/orainstRoot.sh
sh /u01/app/oracle/product/11.2.0/db_1/root.sh
第四個腳本fouinstalloracle.sh,以oracle用戶運(yùn)行,執(zhí)行以下腳本之前需要先檢測以下oracle用戶環(huán)境變量是否設(shè)置正確,測試方法輸入netc然后tab補(bǔ)全,如果不能自動補(bǔ)全為netca,則需要再次執(zhí)行
source .bash_profile,直到可以自動補(bǔ)全netca和dbca等命令為止
#/bin/bash
#以oracle用戶運(yùn)行
netca /silent /responseFile /home/oracle/database/response/netca.rsp #靜默方式配置監(jiān)聽
ls $ORACLE_HOME/network/admin/ #正常情況下會自動生成listener.ora sqlnet.ora
cd /home/oracle/database/response
cp dbca.rsp db
sed -i '78s/.*/GDBNAME= "orcl"/' dbca.rsp
sed -i '170s/.*/SID = "orcl"/' dbca.rsp
sed -i '211s/.*/SYSPASSWORD = "123456"/' dbca.rsp
sed -i '221s/.*/SYSTEMPASSWORD = "123456"/' dbca.rsp
sed -i '252s/.*/SYSMANPASSWORD = "123456"/' dbca.rsp
sed -i '262s/.*/DBSNMPPASSWORD = "123456"/' dbca.rsp
sed -i '360s/.*/DATAFILEDESTINATION=\/u01\/app\/oracle\/oradata/' dbca.rsp
sed -i '370s/.*/RECOVERYAREADESTINATION=\/u01\/app\/oracle\/fast_recovery_area/' dbca.rsp
sed -i '418s/.*/CHARACTERSET= "ZHS16GBK"/' dbca.rsp
sed -i '553s/.*/TOTALMEMORY= "3276"/' dbca.rsp #值設(shè)置為物理內(nèi)存的60%
dbca -silent -responseFile /home/oracle/database/response/dbca.rsp #開始靜默安裝,安裝結(jié)束后會提示100%,數(shù)據(jù)庫也跟著起來了
ps -ef | grep ora_ | grep -v grep #檢測oracle進(jìn)程
lsnrctl status
最后,我們嘗試創(chuàng)建一個用戶,從外部進(jìn)行連接,如果可以正常連接,說明沒有問題了
sqlplus / as sysdba #進(jìn)入數(shù)據(jù)庫
select status from v$instance; #查看數(shù)據(jù)庫運(yùn)行狀態(tài)
create user test identified by test; #創(chuàng)建數(shù)據(jù)庫用戶,連接時數(shù)據(jù)庫實(shí)例名為orcl,用戶名test密碼test
grant connect to test;
grant resource to test;
總結(jié)
以上所述是小編給大家介紹的centos7.7安裝oracle11g腳本,希望對大家有所幫助!
您可能感興趣的文章:- centos7下安裝oracle11gR2的詳細(xì)步驟
- Centos7下oracle12c的安裝與配置圖文教程(詳細(xì))
- Oracle VM VirtualBox 安裝CentOS7操作系統(tǒng)的教程圖解
- VMWare 虛擬機(jī)Centos7安裝Oracle數(shù)據(jù)庫的教程圖解