Oracle 10g R2 RAC之Linux 安装记录

阅读更多
http://www.oracle.com/technetwork/server-storage/linux/downloads/rhel4-092650.html
http://blog.csdn.net/zzuiezhangqihui/article/details/6153215

hosts文件        IP Alias Name
127.0.0.1       localhost.localdomain   localhost
#Pubilc
192.168.1.101   rac1.boobooke.com       rac1
192.168.1.102   rac2.boobooke.com       rac2
#Private
192.168.150.101   rac1-priv.boobooke.com  rac1-priv
192.168.150.102   rac2-priv.boobooke.com  rac2-priv
#Virtual
192.168.1.111   rac1-vip.boobooke.com   rac1-vip
192.168.1.112   rac2-vip.boobooke.com   rac2-vip

vi /etc/sysctl.conf                        
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144

/sbin/sysctl -p

/etc/security/limits.conf
*              soft    nproc   2047
*              hard    nproc   16384
*              soft    nofile  1024
*              hard    nofile  65536

vi /etc/pam.d/login
session    required     /lib/security/pam_limits.so


cat /etc/selinux/config

service iptables status

/etc/modprobe.conf
options hangcheck-timer hangcheck_tick=30 hangcheck_margin=180

modprobe -v hangcheck-timer

[root@rac1 rpm]# groupadd oinstall
[root@rac1 rpm]# groupadd dba
[root@rac1 rpm]# groupadd oper
[root@rac1 rpm]# useradd -g oinstall -G dba oracle
[root@rac1 rpm]# passwd oracle
[root@rac1 rpm]# mkdir -p /oracle/product/10.2.0/crs
[root@rac1 rpm]# mkdir -p /oracle/product/10.2.0/asm
[root@rac1 rpm]# mkdir -p /oracle/product/10.2.0/db_1
[root@rac1 rpm]# chown -R oracle:oinstall /oracle
[root@rac1 rpm]# chkconfig rsh on
[root@rac1 rpm]# chkconfig rlogin on
[root@rac1 rpm]# service xinetd reload

# Oracle Settions
export PS1="`/bin/hostname -s`->"
export EDITOR=vi
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/oracle
export ASM_HOME=/oracle/product/10.2.0/asm
export ORA_CRS_HOME=/oracle/product/10.2.0/crs
export ORACLE_HOME=/oracle/product/10.2.0/db_1
export ORACLE_SID=king1
export PATH=$ORACLE_HOME/bin:$ORA_CRS_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

alias sqlplus="rlwrap sqlplus"
alias rman="rlwrap ramn"
stty erase ^H
umask 002

if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
      ulimit -p 16384
      ulimit -n 65536
  else
      ulimit -u 16384 -n 65536
  fi
fi

source .bash_profile


rac1/rhel4.vmx

disk.locking = "FALSE"
diskLib.dataCacheMaxSize = "0"
scsi1.sharedBus = "virtual"

scsi1:0.deviceType = "disk"       "plainDisk"


rac2
vi /etc/sysconfig/network


hostname rac2

/etc/init.d/network restart

[root@rac1 ~]# chkconfig ntpd on
[root@rac1 ~]# service ntpd status
ntpd is stopped
[root@rac1 ~]# service ntpd start              rac2要关闭
[root@rac2 ~]# system-config-date 

[root@rac2 ~]# vi /etc/rc.local
while [ 1 ]; do ntpdate rac1 1>/dev/null 2>&1; sleep 2; done &

[root@rac1 ~]# su - oracle
rac1->mkdir ~/.ssh
rac1->chmod 700 ~/.ssh
rac1->ssh-keygen -t rsa
rac1->ssh-keygen -t dsa

[root@rac2 ~]# su - oracle
rac2->mkdir ~/.ssh
rac2->chmod 700 ~/.ssh
rac2->ssh-keygen -t rsa
rac2->ssh-keygen -t dsa

rac1->cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
rac1->cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
rac1->ssh rac2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
rac1->ssh rac2 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

rac1->scp ~/.ssh/authorized_keys rac2:~/.ssh/authorized_keys

rac1->ssh rac1 date
rac1->ssh rac2 date
rac1->ssh rac1.boobooke.com date
rac1->ssh rac2.boobooke.com date
rac1->ssh rac1-priv date
rac1->ssh rac2-priv date
rac1->ssh rac1-priv.boobooke.com date date
rac1->ssh rac2-priv.boobooke.com date date

rac1->exec /usr/bin/ssh-agent $SHELL     当前会话生效
rac1->/usr/bin/ssh-add

rac2->exec /usr/bin/ssh-agent $SHELL
rac2->/usr/bin/ssh-add



[root@rac1 ~]# fdisk -l
[root@rac1 ~]# fdisk /dev/sdb

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-204, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-204, default 204):
Using default value 204

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
-----------------------------------------------
[root@rac2 ~]# partprobe
[root@rac2 ~]# fdisk -l

[root@rac1 ~]# vi /etc/sysconfig/rawdevices
/dev/raw/raw1 /dev/sdb1
/dev/raw/raw2 /dev/sdc1

[root@rac1 ~]# vi /etc/udev/permissions.d/50-udev.permissions
# raw devices
ram*:root:disk:0660
#raw/*:root:disk:0660
raw/*:oracle:dba:0660

[root@rac1 ~]# chkconfig --list rawdevices
[root@rac1 ~]# service rawdevices status
[root@rac1 ~]# service rawdevices start

[root@rac1 ~]# cd /dev/raw
[root@rac1 raw]# ll

[root@rac2 ~]# vi /etc/sysconfig/rawdevices
/dev/raw/raw1 /dev/sdb1
/dev/raw/raw2 /dev/sdc1

[root@rac2 ~]# vi /etc/udev/permissions.d/50-udev.permissions
# raw devices
ram*:root:disk:0660
#raw/*:root:disk:0660
raw/*:oracle:dba:0660

[root@rac2 ~]# chkconfig --list rawdevices
[root@rac2 ~]# service rawdevices status
[root@rac2 ~]# service rawdevices start

[root@rac2 ~]# cd /dev/raw
[root@rac2 raw]# ll


[root@rac1 asm]# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.

This will configure the on-boot properties of the Oracle ASM library
driver.  The following questions will determine whether the driver is
loaded on boot and what permissions it will have.  The current values
will be shown in brackets ('[]').  Hitting without typing an
answer will keep that current value.  Ctrl-C will abort.

Default user to own the driver interface [oracle]:
Default group to own the driver interface [dba]:
Start Oracle ASM library driver on boot (y/n) [y]:
Scan for Oracle ASM disks on boot (y/n) [y]:
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver: [  OK  ]
Scanning the system for Oracle ASMLib disks: [  OK  ]

[root@rac1 asm]# lsmod | grep asm
[root@rac1 asm]# cat /proc/filesystems
[root@rac1 asm]# df -ha

[root@rac1 asm]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdd1
Marking disk "VOL1" as an ASM disk: [  OK  ]
[root@rac1 asm]# /etc/init.d/oracleasm createdisk VOL2 /dev/sde1
Marking disk "VOL2" as an ASM disk: [  OK  ]
[root@rac1 asm]# /etc/init.d/oracleasm createdisk VOL3 /dev/sdf1
Marking disk "VOL3" as an ASM disk: [  OK  ]
[root@rac1 asm]# /etc/init.d/oracleasm createdisk VOL4 /dev/sdg1
Marking disk "VOL4" as an ASM disk: [  OK  ]

[root@rac1 disks]# /etc/init.d/oracleasm listdisks


[root@rac1 disks]# /etc/init.d/oracleasm querydisk VOL1

[root@rac1 asm]# cd /dev/oracleasm/disks
[root@rac1 disks]# ll




[root@rac2 asm]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks: [  OK  ]
[root@rac2 asm]# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.

This will configure the on-boot properties of the Oracle ASM library
driver.  The following questions will determine whether the driver is
loaded on boot and what permissions it will have.  The current values
will be shown in brackets ('[]').  Hitting without typing an
answer will keep that current value.  Ctrl-C will abort.

Default user to own the driver interface []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]:
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver: [  OK  ]
Scanning the system for Oracle ASMLib disks: [  OK  ]

[root@rac2 asm]# /etc/init.d/oracleasm listdisks


rac1->exec /usr/bin/ssh-agent $SHELL
rac1->/usr/bin/ssh-add
rac1->clusterware/cluvfy/runcluvfy.sh stage -pre crsinst -n rac1,rac2

[root@rac2 ~]# export DISPLAY=192.168.1.100:0.0
[root@rac2 ~]# /oracle/product/10.2.0/crs/bin/vipca


rac1-> olsnodes -n -p -i
rac1-> crsctl check crs
rac1-> crs_stat -t -v

rac2-> olsnodes -n -p -i
rac2-> crsctl check crs
rac2-> crs_stat -t -v              完成集群件安装  
Name           Type           R/RA   F/FT   Target    State     Host       
----------------------------------------------------------------------
ora.rac1.gsd   application    0/5    0/0    ONLINE    ONLINE    rac1       
ora.rac1.ons   application    0/3    0/0    ONLINE    ONLINE    rac1       
ora.rac1.vip   application    0/0    0/0    ONLINE    ONLINE    rac1       
ora.rac2.gsd   application    0/5    0/0    ONLINE    ONLINE    rac2       
ora.rac2.ons   application    0/3    0/0    ONLINE    ONLINE    rac2       
ora.rac2.vip   application    0/0    0/0    ONLINE    ONLINE    rac2


rac2->crs_stat -t -v  完成监听安装
Name           Type           R/RA   F/FT   Target    State     Host       
----------------------------------------------------------------------
ora....C1.lsnr application    0/5    0/0    ONLINE    ONLINE    rac1       
ora.rac1.gsd   application    0/5    0/0    ONLINE    ONLINE    rac1       
ora.rac1.ons   application    0/3    0/0    ONLINE    ONLINE    rac1       
ora.rac1.vip   application    0/0    0/0    ONLINE    ONLINE    rac1       
ora....C2.lsnr application    0/5    0/0    ONLINE    ONLINE    rac2       
ora.rac2.gsd   application    0/5    0/0    ONLINE    ONLINE    rac2       
ora.rac2.ons   application    0/3    0/0    ONLINE    ONLINE    rac2       
ora.rac2.vip   application    0/0    0/0    ONLINE    ONLINE    rac2

rac2->crs_stat -t -v           完成ASM安装
Name           Type           R/RA   F/FT   Target    State     Host       
----------------------------------------------------------------------
ora....SM1.asm application    0/5    0/0    ONLINE    ONLINE    rac1       
ora....C1.lsnr application    0/5    0/0    ONLINE    ONLINE    rac1       
ora.rac1.gsd   application    0/5    0/0    ONLINE    ONLINE    rac1       
ora.rac1.ons   application    0/3    0/0    ONLINE    ONLINE    rac1       
ora.rac1.vip   application    0/0    0/0    ONLINE    ONLINE    rac1       
ora....SM2.asm application    0/5    0/0    ONLINE    ONLINE    rac2       
ora....C2.lsnr application    0/5    0/0    ONLINE    ONLINE    rac2       
ora.rac2.gsd   application    0/5    0/0    ONLINE    ONLINE    rac2       
ora.rac2.ons   application    0/3    0/0    ONLINE    ONLINE    rac2       
ora.rac2.vip   application    0/0    0/0    ONLINE    ONLINE    rac2 

rac2->crs_stat -t -v  完成数据库安装
Name           Type           R/RA   F/FT   Target    State     Host       
----------------------------------------------------------------------
ora.king.db    application    0/1    0/1    ONLINE    ONLINE    rac1       
ora....g1.inst application    0/5    0/0    ONLINE    ONLINE    rac1       
ora....g2.inst application    0/5    0/0    ONLINE    ONLINE    rac2       
ora....SM1.asm application    0/5    0/0    ONLINE    ONLINE    rac1       
ora....C1.lsnr application    0/5    0/0    ONLINE    ONLINE    rac1       
ora.rac1.gsd   application    0/5    0/0    ONLINE    ONLINE    rac1       
ora.rac1.ons   application    0/3    0/0    ONLINE    ONLINE    rac1       
ora.rac1.vip   application    0/0    0/0    ONLINE    ONLINE    rac1       
ora....SM2.asm application    0/5    0/0    ONLINE    ONLINE    rac2       
ora....C2.lsnr application    0/5    0/0    ONLINE    ONLINE    rac2       
ora.rac2.gsd   application    0/5    0/0    ONLINE    ONLINE    rac2       
ora.rac2.ons   application    0/3    0/0    ONLINE    ONLINE    rac2       
ora.rac2.vip   application    0/0    0/0    ONLINE    ONLINE    rac2  


rac1->export ORACLE_SID=+ASM1
rac1->asmcmd -p
ASMCMD [+] > help

rac1->srvctl status nodeapps -n rac1
rac1->srvctl status nodeapps -n rac2

rac1->srvctl status asm -n rac1
rac1->srvctl status asm -n rac2

rac1->srvctl status database -d king
rac1->srvctl status service -d king

STARTUP:
node1$ srvctl start nodeapps -n rac1
node1$ srvctl start nodeapps -n rac2
node1$ srvctl start asm -n rac1
node1$ srvctl start asm -n rac2
node1$ srvctl start database -d king
node1$ srvctl start service -d king
node1$ crs_stat -t
SHUTDOWN:
node1$ srvctl stop service -d king
node1$ srvctl stop database -d king
node1$ srvctl stop asm -n rac2
node1$ srvctl stop asm -n rac1
node1$ srvctl stop nodeapps -n rac2
node1$ srvctl stop nodeapps -n rac1
node1$ crs_stat -t

rac1->crsctl check crs

SQL> select instance_name, host_name, archiver, thread#, status from gv$instance;

rac1->sqlplus system/123456@king1
rac1->sqlplus system/123456@king2
rac1->sqlplus system/123456@king

rac1->/etc/init.d/init.crs stop
rac2->/etc/init.d/init.crs stop
rac1->/etc/init.d/init.crs start
rac2->/etc/init.d/init.crs start

SQL> select file_name, bytes/1024/1024 from dba_data_files;


king =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT =1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT =1521))
    )
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVICE_NAME = king)
      (SERVER = DEDICATED)
      (FAILOVER_MODE=
(TYPE = session)
(METHOD = basic)
(RETRIES = 180)
(DELAY = 5)
      )
    )
  )

$ORA_CRS_HOME/bin/crs_start -all
此命令用来启动所有的集群服务,但是启动的前提是 资源状态State不能是UNKNOWN。
$ORA_CRS_HOME/bin/crs_start 集群服务名(集群服务名可以通过$ORA_CRS_HOME/bin/crs_stat得到)
$ORA_CRS_HOME/bin/crs_stop -all
$ORA_CRS_HOME/bin/crs_stop 集群服务名(集群服务名可以通过$ORA_CRS_HOME/bin/crs_stat得到)

[oracle@rac1 ~]$ $ORA_CRS_HOME/bin/crs_stat (此命令可以查看各个资源的完整服务名称)

你可能感兴趣的:(oracle,rac)