cat >> /home/oracle/.bash_profile << EOF
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=rac11g
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/oracle/.bash_profile
#创建安装目录
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
partprobe
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
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
#配置ssh信任登陆.这里也配置了root的信任关系,是为了方便在rac11g03下直接操作rac11g04,可在安装完之后去掉.
#这里使用expect来响应输入,这里的脚本可能不够健壮,可考虑在自动安装之前就配置好root的信任关系
cat > /root/tempexpect.sh <<EOF
set timeout -1
spawn scp 192.108.56.104:/root/.ssh/authorized_keys /root/.ssh/authorized_keys2
expect "(yes/no)?"
send "yes\r"
expect "password:"
send "selectshen\r"
interact
EOF
expect /root/tempexpect.sh
cat /root/.ssh/authorized_keys2 >> /root/.ssh/authorized_keys
cat > /root/tempexpect.sh <<EOF
set timeout -1
spawn scp /root/.ssh/authorized_keys 192.108.56.104:/root/.ssh/authorized_keys
expect "password:"
send "selectshen\r"
interact
EOF
expect /root/tempexpect.sh
cat > /root/tempexpect.sh <<EOF
set timeout -1
spawn ssh rac11g03 date
expect "(yes/no)?"
send "yes\r"
interact
spawn ssh rac11g03-priv date
expect "(yes/no)?"
send "yes\r"
interact
spawn ssh rac11g04 date
expect "(yes/no)?"
send "yes\r"
interact
spawn ssh rac11g04-priv date
expect "(yes/no)?"
send "yes\r"
interact
EOF
expect /root/tempexpect.sh
scp /root/tempexpect.sh 192.108.56.104:/root/tempexpect.sh
ssh 192.108.56.104 expect /root/tempexpect.sh
cp -R /root/.ssh /home/oracle/
cp -R /root/.ssh /home/grid/
chown -R oracle.oinstall /home/oracle/.ssh
chown -R grid.oinstall /home/grid/.ssh
ssh 192.108.56.104 cp -R /root/.ssh /home/oracle/
ssh 192.108.56.104 cp -R /root/.ssh /home/grid/
ssh 192.108.56.104 chown -R oracle.oinstall /home/oracle/.ssh
ssh 192.108.56.104 chown -R grid.oinstall /home/grid/.ssh
#解压安装文件
mv /root/p13390677_112040_Linux-x86-64_3* /home/grid/
mv /root/p13390677_112040_Linux-x86-64_* /home/oracle/
chown -R grid.oinstall /home/grid/p13390677_112040_Linux-x86-64_*
chown -R oracle.oinstall /home/oracle/p13390677_112040_Linux-x86-64_*
su - grid -c "unzip /home/grid/p13390677_112040_Linux-x86-64_3of7.zip"
su - oracle -c "unzip /home/oracle/p13390677_112040_Linux-x86-64_1of7.zip"
su - oracle -c "unzip /home/oracle/p13390677_112040_Linux-x86-64_2of7.zip"
#安装缺少的包
rpm -ivh /root/pdksh-5.2.14-30.x86_64.rpm
rpm -ivh /home/grid/grid/rpm/cvuqdisk-1.0.9-1.rpm
scp /root/pdksh-5.2.14-30.x86_64.rpm 192.108.56.104:~/
ssh 192.108.56.104 rpm -ivh /root/pdksh-5.2.14-30.x86_64.rpm