centos 6.5下安裝oracle 11gR2與Oracle自動啟動的配置
注意:以下命令使用 root 用戶操作
安裝依賴包
主要思路為配置 oracle yum 倉庫,直接使用 yum 命令來安裝依賴包,避免手工逐個的安裝依賴包。
配置 yum 倉庫以下載 orcale 依賴包
注意:這里是CentOS 6.X 的 oracle 依賴倉庫,其他版本不同的。
導入 GPG Keys
wget https://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle --no-check-certificate
安裝 oracle 依賴
yum install oracle-rdbms-server-11gR2-preinstall
設置 hostname
打開文件 /etc/sysconfig/network,并修改 HOSTNAME。
vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=oracle.buzheng.org
打開 /etc/host, 添加服務器本機IP地址 指向到 HOSTNAME
vi /etc/hosts 192.168.1.15 oracle.buzheng.org oracle
oracle 用戶設置
當安裝好 oracle 依賴之后, oracle 用戶已經(jīng)創(chuàng)建好了,不需要手工創(chuàng)建 oracle 用戶和相關的用戶組。
修改 oracle 用戶密碼
[root@oracle ~]# passwd oracle 更改用戶 oracle 的密碼 。 新的 密碼: 重新輸入新的 密碼: passwd: 所有的身份驗證令牌已經(jīng)成功更新。
修改系統(tǒng)限制
在文件 /etc/security/limits.d/90-nproc.conf 中添加如下的最后一行
[root@oracle ~]# vi /etc/security/limits.d/90-nproc.conf # Default limit for number of user's processes to prevent # accidental fork bombs. # See rhbz #432903 for reasoning. * soft nproc 1024 root soft nproc unlimited * - nproc 16384
修改 SELinux 為 permissive 模式
修改文件 /etc/selinux/config 如下所示
[root@oracle ~]# vi /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=permissive # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
重啟機器
[root@oracle]# reboot
創(chuàng)建 oracle 安裝目錄,并授權
[root@oracle]# mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1 [root@oracle]# chown -R oracle:oinstall /u01 [root@oracle]# chmod -R 775 /u01
授權 oracle 用戶能夠訪問 X Server
[root@oracle]# xhost + # 要在主機上運行,不能是遠程 shell
注意:以下命令使用 oracle 用戶操作
配置 oracle 安裝環(huán)境變量
切換到 oracle 用戶, 編輯 .bash_profile 文件, 如下所示, 添加環(huán)境配置。
[root@oracle]# su oracle [oracle@oracle]# vi .bash_profile # Oracle Settings TMP=/tmp; export TMP TMPDIR=$TMP; export TMPDIR ORACLE_HOSTNAME=oracle.buzheng.org; export ORACLE_HOSTNAME ORACLE_UNQNAME=orcl; export ORACLE_UNQNAME ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME ORACLE_SID=orcl; export ORACLE_SID PATH=/usr/sbin:$PATH; export PATH PATH=$ORACLE_HOME/bin:$PATH; export PATH LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH export PATH
下載 oracle 安裝文件,解壓縮后安裝
下載 oracle
打開 oracle 下載頁面,http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html , 下載下面兩個文件到 /home/oracle
linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip
解壓縮文件并運行
unzip linux.x64_11gR2_database_1of2.zip unzip linux.x64_11gR2_database_2of2.zip cd database ./runInstaller
若為中文系統(tǒng),安裝界面會出現(xiàn)中文亂碼,需要先將環(huán)境變?yōu)橛⑽?,在安裝
export LANG=en_US ./runInstaller
沒有截圖, 安裝步驟大致包括以下幾步:
- Create and configure a database
- Server Class
- Single instance database installation
- Advanced install
- Language: English
- Enterprise Edition
- database type: General Purpose / Transaction Processing
- Memory: Enable Automatic Memory Management
- Character sets: Use Unicode(AL32UTF8)
圖性界面安裝最后會提示以ROOT 執(zhí)行下面兩個腳本
[root@oracle ~]# /u01/app/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oraInventory. Adding read,write permissions for group. Removing read,write,execute permissions for world. Changing groupname of /u01/app/oraInventory to oinstall. The execution of the script is complete.
[root@oracle ~]# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh Running Oracle 11g root.sh script... The following environment variables are set as: ORACLE_OWNER= oracle ORACLE_HOME= /u01/app/oracle/product/11.2.0/dbhome_1 Enter the full pathname of the local bin directory: [/usr/local/bin]: Copying dbhome to /usr/local/bin ... Copying oraenv to /usr/local/bin ... Copying coraenv to /usr/local/bin ... Creating /etc/oratab file... Entries will be added to the /etc/oratab file as needed by Database Configuration Assistant when a database is created Finished running generic part of root.sh script. Now product-specific root actions will be performed. Finished product-specific root actions.
出現(xiàn)的問題
1, 當環(huán)境變量中的 ORACLE_SID 與 安裝時實際配置不一致時,會導致 startup 出錯,出錯信息如下:
ORA-01078: failure in processing system parameters LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initDB11G.ora'
2, 如果遠程客戶端連接是報錯:ora-12514 tns 監(jiān)聽程序當前無法識別連接描述符中請求的服務,則需要配置 listener.ora,添加如下節(jié)點:
SID_LIST_LISTENER = (SID_LIST= (SID_DESC = (SID_NAME = orcl) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1) ) )
好了,到此已經(jīng)安裝完成,通過訪問 web 管理界面可驗證。下面步驟也很重要,請繼續(xù)。
注意:以下命令使用 root 用戶操作
配置防火墻規(guī)則,開放偵聽端口
將 1521(你配置的 oracle 偵聽端口) 端口添加到防火墻規(guī)則,以便遠程用戶能順利的訪問到 oracle 服務。
iptables -I INPUT 4 -m state --state NEW -p tcp --dport 1521 -j ACCEPT service iptables save service iptables reload
設置 oracle 自動啟動
完成 oracle 安裝后,我們可以通過命令啟動停止數(shù)據(jù)庫,但是當機器重啟時并不能隨機器啟動,這也給我們帶來了一些不便,下面記錄了,如何將 oralce 加入服務中,并隨機機器啟動。
修改配置文件 /etc/oratab
修改 /etc/oratab 的最后一行的最后一個字符,將 N 修改為 Y。此舉主要是為了使 oracle 的 dbstart 命令能在系統(tǒng)啟動時能運行。如下所示:
[root@oracle ~]# vi /etc/oratab # # This file is used by ORACLE utilities. It is created by root.sh # and updated by the Database Configuration Assistant when creating # a database. # A colon, ':', is used as the field terminator. A new line terminates # the entry. Lines beginning with a pound sign, '#', are comments. # # Entries are of the form: # $ORACLE_SID:$ORACLE_HOME:<N|Y>: # # The first and second fields are the system identifier and home # directory of the database respectively. The third filed indicates # to the dbstart utility that the database should , "Y", or should not, # "N", be brought up at system boot time. # # Multiple entries with the same $ORACLE_SID are not allowed. # # orcl:/u01/app/oracle/product/11.2.0/dbhome_1:Y
創(chuàng)建 /etc/init.d/oracle
在 /etc/init.d/下創(chuàng)建文件 oracle,此為 oracle 自啟動腳本。內(nèi)容如下:
#!/bin/sh # chkconfig: 345 61 61 # description: Oracle 11g R2 AutoRun Servimces # /etc/init.d/oracle # # Run-level Startup script for the Oracle Instance, Listener, and # Web Interface ORACLE_HOME="/u01/app/oracle/product/11.2.0/dbhome_1" ORA_OWNR="oracle" # if the executables do not exist -- display error if [ ! -f "$ORACLE_HOME/bin/dbstart" ] then echo "Oracle startup: cannot start" exit 1 fi # parameter: start, stop, restart case "$1" in start) # Oracle listener and instance startup su $ORA_OWNR -s /bin/bash $ORACLE_HOME/bin/dbstart $ORACLE_HOME echo "Oracle Start Succesful!OK." ;; stop) # Oracle listener and instance shutdown su $ORA_OWNR -s /bin/bash $ORACLE_HOME/bin/dbshut $ORACLE_HOME echo "Oracle Stop Succesful!OK." ;; restart) $0 stop $0 start ;; *) echo $"Usage: `basename $0` {start|stop|restart}" exit 1 esac exit 0
賦予啟動腳本執(zhí)行權限并鏈接好:
# chmod 750 /etc/init.d/oracle # ln -s /etc/init.d/oracle /etc/rc1.d/K61oracle # ln -s /etc/init.d/oracle /etc/rc3.d/S61oracle
啟動腳本設置好了之后,可以使用 service 命令來啟動停止 oracle 了,這時候 oracle 已經(jīng)是系統(tǒng)服務了。
service oracle start service oracle stop service oracle restart
設置 oracle 服務為自啟動
# chkconfig --add oracle # chkconfig --level 345 oracle on
總結
好了,重啟機器試試吧。以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流。
- centos7下安裝oracle11gR2的詳細步驟
- Linux下安裝Oracle(CentOS-Oracle 12c)的方法
- CentOS命令行下裝oracle 12c的方法(命令行模式安裝)
- CentOS系統(tǒng)上安裝配置Oracle數(shù)據(jù)庫的詳細教程
- CentOS下PHP安裝Oracle擴展
- CentOS6.2上安裝Oracle10g報ins_emdb.mk錯誤處理方法
- CentOS 6.3下安裝部署Oracle服務器圖文教程
- Linux+php+apache+oracle環(huán)境搭建之CentOS下安裝Oracle數(shù)據(jù)庫
- Linux+php+apache+oracle環(huán)境搭建之CentOS下源碼編譯安裝PHP
- centos下Oracle11G圖文安裝教程
相關文章
Orcle的package中訪問其它Schema的表報錯ORA-00942解決方法
package要訪問其它Schema的表,但編譯報錯ORA-00942,經(jīng)過搜索了一下找到了解決方法下面與大家分享下2013-05-05關于Oracle Dataguard 日志傳輸狀態(tài)監(jiān)控問題
ORACLE DATAGUARD的主備庫同步,主要是依靠日志傳輸?shù)絺鋷欤瑐鋷鞈萌罩净驓w檔來實現(xiàn)。這篇文章主要給大家介紹了關于Oracle Dataguard 日志傳輸狀態(tài)監(jiān)控問題,感興趣的朋友跟隨小編一起看看吧2019-05-05oracle截取字符(substr)檢索字符位置(instr)示例介紹
本節(jié)主要介紹了oracle截取字符(substr)檢索字符位置(instr)的使用,需要的朋友可以參考下2014-07-07Oracle 子程序參數(shù)模式,IN,OUT,NOCOPY
Oracle 子程序參數(shù)模式主要有IN,OUT,NOCOPY,IN和OUT可以組合,OUT和NOCOPY也可以組合使用.2009-10-10