您好,登錄后才能下訂單哦!
這篇文章主要介紹“Linux下怎么安裝Oracle 11g”的相關知識,小編通過實際案例向大家展示操作過程,操作方法簡單快捷,實用性強,希望這篇“Linux下怎么安裝Oracle 11g”文章能幫助大家解決問題。
oracle 11g客戶端是一款出自甲骨文公司之手的專業化關系數據庫管理系統,oracle 11g客戶端功能強勁,具有高效性、安全性、穩定性和延展性等特點,世界上的幾乎所有大型信息化系統都在應用Oracle數據庫技術。
1.1.配置本地yum源
#因公司內網環境,沒有互聯網,所以需要配置本地yum源,安裝所需依賴包等。#掛載ios鏡像centos7.5-1804[root@oracle ~]#mount /dev/cdrom /mnt#備份原配置文件[root@oracle ~]#cd /etc/yum.repos.d/[root@oracle ~]#mkdir bak[root@oracle ~]#mv * bak#創建yum配置文件[root@oracle ~]#vi /etc/yum.repos.d/local.repo#添加以下內容[local] name=localbaseurl=file:///mnt gpgcheck=0 enabled=1#清空yum所有源信息[root@oracle ~]#yum clean all#查看本地源的所有軟件[root@oracle ~]#yum list
1.2上傳解壓oracle 11g安裝包
#將下載的linux.x64_11gR2_database_1of2.zip和linux.x64_11gR2_database_2of2.zip解壓到/usr/local/apps/oracle目錄[root@oracle ~]# mkdir -p /usr/local/apps/oracle[root@oracle ~]# cd /usr/local/apps/oracle[root@oracle oracle]# unzip p13390677_112040_Linux-x86-64_1of7.zip && unzip p13390677_112040_Linux-x86-64_2of7.zip#沒有安裝unzip命令工具的安裝一下[root@oracle ~]# yum install unzip –y#解壓后會產生一個database目錄,即/usr/local/apps/oracle/database,目錄里面是oracle11g企業版的安裝文件
1.3.給本機服務IP地址作個映射
#添加本機IP地址和主機名[root@oracle oracle]# vim /etc/hosts10.0.0.10 oracle
1.4.關閉selinux
#修改SELINUX=disabled[root@oracle ~]#vi /etc/selinux/configSELINUX=disabled [root@oracle ~]#setenforce 0setenforce: SELinux is disabled
1.5.關閉防火墻
[root@oracle ~]#service iptables stop[root@oracle ~]#systemctl stop firewalld[root@oracle ~]#systemctl disable firewalld
1.6.安裝Oracle 11g依賴包
[root@oracle ~]#yum install gcc make ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel –y
1.7.添加安裝用戶和用戶組
#創建用戶組[root@oracle ~]#groupadd oinstall[root@oracle ~]#groupadd dba#創建oracle用戶并指定用戶組[root@oracle ~]#useradd -g oinstall -G dba oracle#為oracle用戶設置密碼[root@oracle ~]#passwd oracle#查看用戶信息[root@oracle ~]#id oracle uid=1001(oracle) gid=1001(oinstall) 組=1001(oinstall),1002(dba)#如顯示以上類似信息則表示添加用戶和用戶組成功
1.8.修改內核參數
[root@oracle ~]#vi /etc/sysctl.conf#添加以下內容fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 1073741824 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#其中shmmax是單個共享內存段的最大值,一般設置為本機物理內存的一半,單位為byte,可根據自己的實際情況做相應調整#使新內核參數生效[root@oracle ~]#sysctl –p
1.9.修改用戶的限制文件
[root@oracle ~]#vi /etc/security/limits.conf#添加以下內容oracle soft nproc 2047oracle hard nproc 16384oracle soft nofile 1024oracle hard nofile 65536oracle soft stack 10240
1.10.修改/etc/pam.d/login文件
[root@oracle ~]#vi /etc/pam.d/login#添加以下內容session required /lib64/security/pam_limits.sosession required pam_limits.so
1.11.修改/etc/profile文件
[root@oracle ~]#vi /etc/profile#添加以下內容if [ $USER = "oracle" ]; thenif [ $SHELL = "/bin/ksh" ]; thenulimit -p 16384ulimit -n 65536elseulimit -u 16384 -n 65536fifi#使之生效[root@oracle ~]#source /etc/profile
1.12.創建安裝目錄和設置文件權限
[root@oracle ~]#mkdir -p /usr/local/apps/oracle/product/11.2.0[root@oracle ~]#mkdir /usr/local/apps/oracle/oradata[root@oracle ~]#mkdir /usr/local/apps/oracle/inventory[root@oracle ~]#mkdir /usr/local/apps/oracle/fast_recovery_area[root@oracle ~]#chown -R oracle:oinstall /usr/local/apps/oracle[root@oracle ~]#chmod -R 775 /usr/local/apps/oracle
1.13.設置oracle用戶環境變量
[root@oracle ~]#su - oracle#此處注意,切換用戶時切記要加"-",加-會擁有目標用戶的環境變量,不加"-"則沒有,詳細的可自行網上搜索找解答[oracle@oracle ~]$vi .bash_profile#添加如下內容ORACLE_BASE=/usr/local/apps/oracleORACLE_HOME=$ORACLE_BASE/product/11.2.0ORACLE_SID=orclPATH=$PATH:$ORACLE_HOME/binexport ORACLE_BASEexport ORACLE_HOMEexport ORACLE_SIDexport PATH#使配置生效[oracle@oracle ~]$source .bash_profile
1.14.編輯靜默安裝響應文件
[oracle@oracle ~]$cp -R /usr/local/apps/oracle/database/response/ /home/oracle[oracle@oracle ~]$cd /home/oracle/response[oracle@oracle ~]$vi db_install.rsp#需要設置的選項如下,注意只修改以下設置,其他設置不變,否則會報錯。oracle.install.option=INSTALL_DB_SWONLYORACLE_HOSTNAME=oracleUNIX_GROUP_NAME=oinstallINVENTORY_LOCATION=/usr/local/apps/oracle/inventorySELECTED_LANGUAGES=en,zh_CNORACLE_HOME=/usr/local/apps/oracle/product/11.2.0ORACLE_BASE=/usr/local/apps/oracleoracle.install.db.InstallEdition=EEoracle.install.db.DBA_GROUP=dbaoracle.install.db.OPER_GROUP=dbaDECLINE_SECURITY_UPDATES=true
[oracle@oracle ~]$cd /usr/local/apps/oracle/database[oracle@oracle ~]$./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq#Oracle開始在后臺靜默安裝,如果提示Successfully則表示安裝成功#按照要求執行腳本,打開終端,以root用戶登錄,執行腳本[root@oracle ~]#/usr/local/apps/oracle/inventory/orainstRoot.sh[root@oracle ~]#/usr/local/apps/oracle/product/11.2.0/root.sh
#以oracle用戶登錄,執行[oracle@oracle ~]$netca /silent /responsefile /home/oracle/response/netca.rsp#通過netstat命令查看1521端口是否在監聽中[oracle@oracle ~]$ss -tnulp | grep 1521
4.1.修改dbca.rsp配置文件
[oracle@oracle ~]$vim /home/oracle/response/dbca.rsp#設置以下參數[CREATEDATABASE]GDBNAME = "orcl"SID = "orcl"SYSPASSWORD = "123456"SYSTEMPASSWORD = "123456"SYSMANPASSWORD = "123456"DBSNMPPASSWORD = "123456"DATAFILEDESTINATION =/usr/local/apps/oracle/oradataRECOVERYAREADESTINATION=/usr/local/apps/oracle/fast_recovery_areaCHARACTERSET = "AL32UTF8"TOTALMEMORY = "800"#其中TOTALMEMORY = "800"為800MB,一般設置為物理內存的80%
4.2.進行靜默配置創建實例
[oracle@oracle ~]$dbca -silent -responseFile /home/oracle/response/dbca.rsp#建庫后進行實例進程檢查[oracle@oracle ~]$ps -ef | grep ora_ | grep -v grep#查看監聽狀態[oracle@oracle ~]$lsnrctl status#登錄查看實例狀態[oracle@oracle ~]$sqlplus / as sysdbaSQL> select status from v$instance;#如顯示STATUS------------OPEN#則表示實例是啟動狀態#查看數據庫編碼SQL> select userenv('language') from dual;#查看數據庫版本SQL> select * from v$version;
5.1.修改啟動腳本文件
#修改/usr/local/apps/oracle/product/11.2.0/bin/dbstart[oracle@oracle ~]$vi /usr/local/apps/oracle/product/11.2.0/bin/dbstart#將ORACLE_HOME_LISTNER=$1修改為ORACLE_HOME_LISTNER=$ORACLE_HOME#修改/usr/local/apps/oracle/product/11.2.0/bin/dbshut[oracle@oracle ~]$vi /usr/local/apps/oracle/product/11.2.0/bin/dbshut#將ORACLE_HOME_LISTNER=$1修改為ORACLE_HOME_LISTNER=$ORACLE_HOME
5.2.修改/etc/oratab文件
[oracle@oracle ~]$vi /etc/oratab#將orcl:/usr/local/apps/oracle/product/11.2.0:N中最后的N改為Y,成為orcl:/usr/local/apps/oracle/product/11.2.0:Y#輸入dbshut和dbstart測試[oracle@oracle ~]$dbshut#Oracle監聽停止,進程消失[oracle@oracle ~]$dbstart#Oracle監聽啟動,進程啟動5.3.切換到root賬戶建立自啟動腳本 [oracle@oracle ~]$su - [root@oracle ~]#vim /etc/rc.d/init.d/oracle#添加以下內容(有些值如ORA_HOME和ORA_USER等根據實際情況可以修改):#!/bin/sh# chkconfig: 35 80 10# description: Oracle auto start-stop script.## Set ORA_HOME to be equivalent to the $ORACLE_HOME# from which you wish to execute dbstart and dbshut;## Set ORA_OWNER to the user id of the owner of the# Oracle database in ORA_HOME.ORA_HOME=/usr/local/apps/oracle/product/11.2.0 ORA_OWNER=oracleif [ ! -f $ORA_HOME/bin/dbstart ]then echo "Oracle startup: cannot start" exitficase "$1" in'start')# Start the Oracle databases:echo "Starting Oracle Databases ... "echo "-------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >>/var/log/oracleecho "Done"# Start the Listener:echo "Starting Oracle Listeners ... "echo "-------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracleecho "Done."echo "-------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Finished." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle touch /var/lock/subsys/oracle ;;'stop')# Stop the Oracle Listener:echo "Stoping Oracle Listeners ... "echo "-------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Stoping Oracle Listener as part of system down." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >>/var/log/oracleecho "Done."rm -f /var/lock/subsys/oracle# Stop the Oracle Database:echo "Stoping Oracle Databases ... "echo "-------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" >>/var/log/oracleecho "Done."echo ""echo "-------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Finished." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle ;;'restart')$0 stop$0 start ;;esac
5.4.修改/etc/init.d/oracle服務文件權限
[root@oracle ~]#chmod 755 /etc/init.d/oracle
5.5.添加開機自啟服務
[root@oracle ~]#chkconfig oracle on
5.6.需要在關機或重啟機器之前停止數據庫,做一下操作
#關機[root@oracle ~]ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle#重啟[root@oracle ~]ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle #進行測試[root@oracle ~]# service oracle start #啟動oracle[root@oracle ~]# service oracle stop #關閉oracle
5.7.重啟查看Oracle監聽和實例進程是否均能自動啟動
[root@oracle ~]#reboot
關于“Linux下怎么安裝Oracle 11g”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識,可以關注億速云行業資訊頻道,小編每天都會為大家更新不同的知識點。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。