CentOS 5.10安裝Oracle 11G R2

操作系統:CentOS 5.10 64位

數據庫:Oracle 11G R2(版本號爲11.02)


安裝操作系統的時候,注意交換分區的大小不得低於2G


1.同步時鐘及修改/etc/hosts
yum -y install ntp
ntpdate time.nist.gov
echo "* */2 * * * /sbin/ntpdate time.nist.gov >/dev/null 2>&1" >> /etc/crontab


修改/etc/hosts

將機器名稱加入,我這裏的是node1,則,可以使用

echo "127.0.0.1 $HOSTNAME" >>/etc/hosts

160550538.png




2.關閉服務:
iptables
selinux
portmap
rpc.statd
cupsd
avahi-daemon
sendmail

killall iptables
chkconfig --level 2345 iptables off
killall portmap
chkconfig --level 2345 portmap off
killall avahi-daemon
chkconfig --level 2345 avahi-daemon off
killall sendmail
chkconfig --level 2345 sendmail off

如果是新服務器,可以執行:

for a in `chkconfig --list|grep 3:on|awk '{print $1}'`; do chkconfig $a off;done

for a in sshd crond network syslog messagebus haldaemon; do chkconfig $a on;done


3.安裝oracle 11gR2 依賴的組件包

yum -y install 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 pdksh numactl-devel glibc-headers libaio-devel libaio libXp libXt compat-libcap1 unzip


/sbin/ldconfig


注意:如果你的系統是CentOS 6以上的話,需要單獨安裝pdksh

rpm -ivh http://vault.centos.org/5.11/os/x86_64/CentOS/pdksh-5.2.14-37.el5_8.1.x86_64.rpm

如果出錯,可能是因爲安裝了mksh衝突了,rpm -e --nodeps mksh

yum -y install libXt.i686 libXtst.i686 libXp libXp.i686 glibc-devel.i686 libaio-devel.i686 libstdc++.i686 libgcc.i686 compat-libstdc* unixODBC-devel.i686 compat-libstdc++-33.i686




4.調整內核參數
vi /etc/sysctl.conf
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1048842240

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
fs.aio-max-nr = 1048576


#讓內核參數生效
sysctl -p


CentOS 6安裝Oracle 10G R2在啓動數據庫的時候

RMAN > startup nomount;

RMAN-04014: startup failed: ORA-27125: unable to create shared memory segment

Linux-x86_64 Error: 1: Operation not permitted

處理過程

$ id oracle

id oracle

uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba)

echo "vm.hugetlb_shm_group = 501">>/etc/sysctl.conf

sysctl -p



5.修改limits.conf
vi /etc/security/limits.conf
#oracle settings
oracle           soft    nproc   2047
oracle           hard    nproc   16384
oracle           soft    nofile  1024
oracle           hard    nofile  65536


6.改/etc/pam.d/login
#添加以下內容:
session    required     /lib64/security/pam_limits.so
session    required     pam_limits.so


注意:如果使用的是32位的操作系統,則上面要寫成

session    required     /lib/security/pam_limits.so
session    required     pam_limits.so


7.修改/etc/profile
vi /etc/profile
#添加以下內容:
if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
     ulimit -p 16384
     ulimit -n 65536
  else
     ulimit -u 16384 -n 65536
  fi
fi


8.改/etc/csh.login
vi /etc/csh.login
#添加以下內容:
if ( $USER == "oracle" ) then
    limit maxproc 16384
    limit deors 65536
endif


9.創建oracle用戶
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle    


mkdir -p /opt/oracle
mkdir -p /opt/oraInventory
mkdir -p /opt/software
chown -R oracle:oinstall /opt/oracle
chown -R oracle:oinstall /opt/software
chown -R oracle:oinstall /opt/oraInventory


10.設置用戶環境變量
#su - oracle


$ vi .bash_profile

#添加以下內容:
ORACLE_SID=luke; export ORACLE_SID
ORACLE_BASE=/opt/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin; export PATH

stty erase ^H

stty kill  ^U


說明:

ORACLE_BASE下是admin和product
ORACLE_HOME下則是ORACLE的命令、連接庫、安裝助手、listener等等一系列的東東。
這只是ORACLE自己的定義習慣。ORACLE_HOME比ORACLE_BASE目錄要更深一些。也就是說:ORACLE_HOME=$ORACLE_BASE/product/version

ORACLE_BASE是oracle的根目錄,ORACLE_HOME是oracle產品的目錄。
簡單說,你如果裝了2個版本的oracle,那麼ORACLE_BASE可以是一個,但ORACLE_HOME是2個

全局數據庫名用於區別分佈式數據庫各個不同機器上的實例。
SID用於區別同一臺機器上的不同實例,
即一個用於外部區分。
一個用於內部區分。


$source .bash_profile


11.安裝oracle
#可以使用winscp上傳oracle安裝文件到/data/software目錄下,並解壓


cd /data/software
unzip linux_11gR2_database_1of2.zip
unzip linux_11gR2_database_2of2.zip
xhost +   (這裏使用root用戶執行,一定要執行以下2步,如果沒有執行,將無法啓動圖形安裝界面)
xhost + localhost
su - oralce
cd /opt/software/database
$./runInstaller  #(到oracle安裝文件所在目錄執行該命令)


安裝過程省略


12.開機啓動設置
#自動啓動和關閉數據庫實例和監聽
vi /opt/oracle/product/11.2.0/db_1/bin/dbstart
ORACLE_HOME_LISTNER=$1
#修改爲:
ORACLE_HOME_LISTNER=$ORACLE_HOME


vi /opt/oracle/product/11.2.0/db_1/bin/dbshut
ORACLE_HOME_LISTNER=$1
#修改爲:
ORACLE_HOME_LISTNER=$ORACLE_HOME


vi /etc/init.d/oracle
#!/bin/sh
# chkconfig: 345 61 61
# description: Oracle 11g AutoRun Services
# /etc/init.d/oracle
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface

export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=luke
export PATH=$PATH:$ORACLE_HOME/bin
ORA_OWNR="oracle"

# if the executables do not exist -- display error


if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
    echo "Oracle startup: cannot start"
    exit 1
fi

# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display

case "$1" in
start)
    # Oracle listener and instance startup
    su $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart
    echo "Oracle Start Succesful!OK."
    ;;
stop)
    # Oracle listener and instance shutdown
    su $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut
    echo "Oracle Stop Succesful!OK."
    ;;
reload|restart)
    $0 stop
    $0 start
    ;;
*)
    echo $"Usage: `basename $0` {start|stop|reload|reload}"
    exit 1
esac
exit 0


chmod 750 /etc/init.d/oracle

chkconfig --level 345 oracle on
chkconfig --add oracle

#啓動oracle
service oracle start


自動啓動和關閉 EM
vi /etc/init.d/oraemctl
#!/bin/sh
# chkconfig: 345 61 61
# description: Oracle 11g AutoRun Services
# /etc/init.d/oraemctl
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface

export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=luke
export PATH=$PATH:$ORACLE_HOME/bin
ORA_OWNR="oracle"

case "$1" in
start)
echo -n $"Starting Oracle EM DB Console:"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
echo "OK"
;;
stop)
echo -n $"Stopping Oracle EM DB Console:"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"
echo "OK"
;;
*)
echo $"Usage: $0 {start|stop}"
esac

chmod 750 /etc/init.d/oraemctl
#啓動EM
service oraemctl start


本文參考http://kerry.blog.51cto.com/172631/568220  只是修正了一些錯誤


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章