Linux 下安装oracle 数据库的准备

注:不做特别说明,则全由root执行
1.linux检查安装包是否全

rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n" binutils \
compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc \
glibc-common glibc-devel-2.5 libaio libaio-devel libgcc libstdc++ libstdc++-devel \
make sysstat unixODBC glibc-headers unixODBC-devel oracleasm oracleasmlib oracleasm-support |grep not

其中oracleasm oracleasmlib oracleasm-support可以从官网下载:
http://www.oracle.com/technetwork/topics/linux/downloads/rhel5-084877.html
当然如果不用asm存储管理的话,就不必下载asm包!!

2.修改OS参数修改
2.1向/etc/sysctl.conf 添加或修改如下参数:
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 48719476736
kernel.shmmni = 4096
kernel.sem = 250 32000 200 200
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144

net.core.wmem_default = 262144
net.core.wmem_max = 1048586
net.core.rmem_max = 4194304

执行/sbin/sysctl -p

2.2 向/etc/security/limits.conf 添加如下参数
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

2.3 向/etc/pam.d/login  添加如下参数:
session required pam_limits.so

2.4修改/etc/profile 添加:
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
 ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi

3.创建用户和相应的目录:
groupadd -g 501 oinstall
groupadd -g 502 dba
groupadd -g 601 asmadmin
groupadd -g 602 asmdba
groupadd -g 603 asmoper

useradd -u 501 -g oinstall -G asmadmin,asmdba,asmoper grid
useradd -u 601 -g oinstall -G dba,asmdba,asmadmin   oracle
目录的创建,可以根据自己的实际情况调整:
这个是创建RAC的例子:
mkdir -p /opt/rac/grid
mkdir -p /opt/rac/11.2.0/grid
chown -R grid:oinstall /opt/rac
mkdir -p /opt/rac/oracle
chown -R oracle:oinstall /opt/rac/oracle
chmod -R 775 /opt/rac/

4.grid和Oracle环境变量
---grid .bash_profile
PATH=$PATH:$HOME/bin:/opt/rac/grid/opatch/OPatch
export PATH
umask 022                                                                   
export PS1=$LOGNAME@`hostname`:'$PWD>'                                      
export ORACLE_BASE=/opt/rac/grid                                            
export ORACLE_HOME=/opt/rac/11.2.0/grid
export ORACLE_SID=+ASM1                                              
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH                                
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib                       
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib 
export SQLPATH=/home/oracle/admin/sql:$ORACLE_HOME/sqlplus/ADMIN:~/admin/sql
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8                                   
export ORA_CRS_HOME=/opt/rac/11.2.0/grid                                                                            

alias sql='sqlplus "/ as sysasm"'                                                     
alias sqln="sqlplus /nolog"                                                 
alias rm='rm -i --'
alias tf="tail -f /opt/rac/grid/diag/asm/+asm/+ASM2/trace/alert_+ASM2.log"
alias crsdl="tail -f /opt/rac/11.2.0/grid/log/dbname/crsd/crsd.log"
alias cssdl="tail -f /opt/rac/11.2.0/grid/log/dbname/cssd/ocssd.log"
alias gridl="tail -f /opt/rac/11.2.0/grid/log/dbname/alert_dbname.log"
stty erase ^h
esc="\033["
echo " "
echo " "
echo -e "${esc}31;1m******************************************************************${esc}0m"
echo -e "${esc}31;1m**This is RAC TEST  ASM,  Please be careful of your operation!***${esc}0m"
echo -e "${esc}31;1m******************************************************************${esc}0m"
echo " "
echo " "

---oracle .bash_profile 

# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/opt/rac/oracle/opatch/OPatch
export PATH
umask 022
export PS1=$LOGNAME@`hostname`:'$PWD>'
export ORACLE_BASE=/opt/rac/oracle
export ORACLE_HOME=$ORACLE_BASE/11.2.0/db
export ORACLE_SID=orcl
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NLS10=$ORACLE_HOME/nls/data
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export PS1=$LOGNAME@`hostname`:'$PWD>'
export SQLPATH=$ORACLE_HOME/sqlplus/admin:/home/oracle/admin/sql

alias bdump="cd /opt/rac/oracle/diag/rdbms/orcl/rac1/trace/"
alias udump="cd /opt/rac/oracle/diag/rdbms/orcl/rac1/trace/"
alias home="cd $ORACLE_HOME"
alias tf="tail -f /opt/rac/oracle/diag/rdbms/orcl/rac1/trace/alert_rac1.log"
alias sql='sqlplus "/"'
alias sqln="sqlplus /nolog"
alias rm='rm -i --'
ulimit -u 16384 -n 63536  #linux
tty -s && stty erase '^H'
esc="\033["
echo " "
echo " "
echo -e "${esc}31;1m******************************************************************${esc}0m"
echo -e "${esc}31;1m***This is a TEST  ENV ,   Please be careful of your operation!***${esc}0m"
echo -e "${esc}31;1m******************************************************************${esc}0m"
echo " "
echo " "



5.ntpd configure 

--这是搭建RAC的时候需要的步骤
--同步ntpd,模板里已有,不需要修改,根据自己的情况调整
修改文件/etc/ntp.conf,添加如下信息,ntp1 为时间同步服务器
server  ntp1
server  ntp2
server  ntp3

修改文件 /etc/sysconfig/ntpd 
OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid" --加入 -x
重新启动,并设置为开机启动ntpd 服务:
service ntpd restart
chkconfig ntpd on

6 修改 /etc/rc.local文件:添加如下语句:
modprobe hangcheck-timer hangcheck-tick=30 hangcheck_margin=180

7.配置asm configure,如果选择使用asm做存储的话需要此步骤!
--注意oracleasm的版本,必须和uname -r的版本一致
/etc/init.d/oracleasm configure -i

做完以上工作基本上可以进行oracle rac 或者database的安装了!
上一篇:让智能家居产品操控更简单 快捷键来了


下一篇:LeetCode 235. 二叉搜索树的最近公共祖先