CentOS 6.6 x64 自动化安装Oracle Database 11gR2 RAC脚本(2)


#创建安装目录
mkdir -p /u01/app/11.2.0/grid
chown -R grid.oinstall /u01
mkdir -p /u01/app/oracle/product/11.2.0/db_1
chown -R oracle.oinstall  /u01/app/oracle
chmod -R 775 /u01

#配置iscsi连接openfiler存储,此处要根据实际情况设置,这里是一个40G的盘,分成两个20G的区
yum -y install iscsi-initiator-utils
iscsiadm -m discovery -t sendtargets -p 192.108.26.100:3260
service iscsi restart

fdisk /dev/sdb <<EOF
n
p
1

+20G
n
p
2


w
EOF

cat >> /etc/udev/rules.d/60-raw.rules << EOF
ACTION=="add", KERNEL=="/dev/sdb1",RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", ENV{MAJOR}=="8",ENV{MINOR}=="17",RUN+="/bin/raw /dev/raw/raw1 %M %m"
ACTION=="add", KERNEL=="/dev/sdb2",RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", ENV{MAJOR}=="8",ENV{MINOR}=="18",RUN+="/bin/raw /dev/raw/raw2 %M %m"
KERNEL=="raw[1-2]", OWNER="grid", GROUP="oinstall", MODE="660"
EOF

start_udev
ls /dev/raw/ -l


#配置ssh,这里使用expect来自动来响应输入
mkdir ~/.ssh
chmod 700 ~/.ssh
cat > /root/tempexpect.sh <<EOF
set timeout -1
spawn ssh-keygen -t rsa
expect "(/root/.ssh/id_rsa):"
send "\r"
expect "(empty for no passphrase):"
send "\r"
expect "again:"
send "\r"
interact
spawn ssh-keygen -t dsa
expect "(/root/.ssh/id_dsa):"
send "\r"
expect "(empty for no passphrase):"
send "\r"
expect "again:"
send "\r"
interact
EOF

expect /root/tempexpect.sh
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
cat /root/.ssh/id_dsa.pub >> /root/.ssh/authorized_keys

#################################步骤二#################################
####################rac11g03_init.sh,以下内容放到一个文件中,在rac11g03下sh执行即可:
#!/bin/bash
##此处用于加载光驱为之后安装缺少的包,也可改为网络方式.
mkdir /media/cdrom
mount /dev/cdrom /media/cdrom
mv /etc/yum.repos.d/*.repo /root/

cat > /etc/yum.repos.d/CentOS-Media.repo << EOF
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/cdrom/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
EOF

yum clean all
yum makecache

#调整hosts文件
cat >> /etc/hosts << EOF
192.108.56.103  rac11g03
192.108.56.104  rac11g04
192.108.56.203  rac11g03-vip
192.108.56.204  rac11g04-vip
192.108.56.205  rac11g-scan
192.108.96.103  rac11g03-priv
192.108.96.104  rac11g04-priv
EOF

#关闭防火墙,selinux
chkconfig iptables off
service iptables stop
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

#网络参数调整
cat >> /etc/sysctl.conf << EOF
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.aio-max-nr = 1048576
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 1048576
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
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
EOF

#登陆参数调整
cat >> /etc/pam.d/login << EOF
session required /lib64/security/pam_limits.so
EOF

#安装缺少的包
yum -y install  gcc gcc-c++ make binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel unixODBC unixODBC-devel

yum -y install expect

ln -s /lib64/libcap.so.2.16 /lib64/libcap.so.1

#清除NTP服务
service ntpd stop
chkconfig ntpd off
mv /etc/ntp.conf /etc/ntp.conf.bak
mv /var/run/ntpd.pid /var/run/ntpd.pid.bak

##创建配置grid,oracle用户
groupadd -g 1000 oinstall
groupadd -g 1100 asmadmin
groupadd -g 1200 dba
groupadd -g 1300 asmdba
useradd -u 1100 -d /home/oracle -g oinstall -G dba,asmdba oracle
useradd -u 1101 -d /home/grid -g oinstall -G asmadmin,asmdba grid
echo "selectshen"|passwd --stdin oracle
echo "selectshen"|passwd --stdin grid

cat >> /home/grid/.bash_profile << EOF
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export GRID_HOME=/u01/app/11.2.0/grid
export ORACLE_SID=+ASM1
export ORACLE_TERM=xterm
export PATH=/usr/sbin:\$PATH
export PATH=\$ORACLE_HOME/bin:\$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin/
export CLASSPATH=\$ORACLE_HOME/JRE:\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib
ulimit -u 16384 -n 65536
umask 022
EOF

.  /home/grid/.bash_profile

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/10b6c53d450ed7d7cb99779a35aa4be5.html