RAC --------真应用集群
集群的计算分类:
1、高性能计算集群
计算任务分配到不同计算机节点来提高整体计算能力,主要应用在科学计算领域。主要利用的是并行计算。
2、高可用性集群
目的是提高系统的可用性,集成硬件和软件的容错性来实现整体服务的高可用性。采用SOA的思想,提供资源池服务。
3、负载均衡集群
将负载流量尽可能合理地分配到集群的各个节点上,每个节点都可以处理一部分负载,并且可以根据负载情况进行动态的平衡。
RAC的安装
OS: linux Redhat 4 U8 64bit
DB: oracle 10.2.0.1
建立用户与组
节点1 [root@ rac1 ~]# groupadd -g 1001 dba [root@ rac1 ~]# groupadd -g 1002 oinstall [root@ rac1 ~]# useradd -u 1001 -g oinstall -G dba oracle [root@ rac1 ~]# passwd oracle [root@ rac1 ~]# id nobody uid=99(nobody) gid=99(nobody) groups=99(nobody) [root@ rac1 ~]#
节点2 [root@ rac2 ~]# groupadd -g 1001 dba [root@ rac2 ~]# groupadd -g 1002 oinstall [root@ rac2 ~]# useradd -u 1001 -g oinstall -G dba oracle [root@ rac2 ~]# passwd oracle [root@ rac2 ~]# id nobody uid=99(nobody) gid=99(nobody) groups=99(nobody) [root@ rac2 ~]# |
网络的配置
节点1 [root@ rac1 ~]# ifconfig eth0 Link encap:Ethernet HWaddr 08:00:27:C0:3B:F2 inet addr:192.168.56.50 Bcast:192.168.56.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fec0:3bf2/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:162 errors:0 dropped:0 overruns:0 frame:0 TX packets:107 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:14353 (14.0 KiB) TX bytes:11093 (10.8 KiB)
eth1 Link encap:Ethernet HWaddr 08:00:27:6E:75:FC inet addr:10.10.10.1 Bcast:10.10.10.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe6e:75fc/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:53 errors:0 dropped:0 overruns:0 frame:0 TX packets:13 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4064 (3.9 KiB) TX bytes:714 (714.0 b)
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:12 errors:0 dropped:0 overruns:0 frame:0 TX packets:12 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:900 (900.0 b) TX bytes:900 (900.0 b) [root@ rac1 ~]# vi /etc/hosts
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 192.168.56.50 rac1 192.168.56.52 vip1 10.10.10.1 priv1 192.168.56.51 rac2 192.168.56.53 vip2 10.10.10.2 priv2
节点2 [root@ rac2 ~]# ifconfig eth0 Link encap:Ethernet HWaddr 08:00:27:D6:3E:6D inet addr:192.168.56.51 Bcast:192.168.56.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fed6:3e6d/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:95 errors:0 dropped:0 overruns:0 frame:0 TX packets:73 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:8535 (8.3 KiB) TX bytes:7713 (7.5 KiB)
eth1 Link encap:Ethernet HWaddr 08:00:27:5B:1A:14 inet addr:10.10.10.2 Bcast:10.10.10.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe5b:1a14/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:24 errors:0 dropped:0 overruns:0 frame:0 TX packets:13 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1492 (1.4 KiB) TX bytes:714 (714.0 b)
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:12 errors:0 dropped:0 overruns:0 frame:0 TX packets:12 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:900 (900.0 b) TX bytes:900 (900.0 b) [root@rac2 ~]# cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 192.168.56.50 rac1 192.168.56.52 vip1 10.10.10.1 priv1 192.168.56.51 rac2 192.168.56.53 vip2 10.10.10.2 priv2 |
配置用户安全的shell通道
节点1 [root@ rac1 oracle]# su - oracle [oracle@ rac1 ~]$ mkdir .ssh [oracle@ rac1 ~]$ chmod 700 .ssh [oracle@ rac1 ~]$ cd .ssh [oracle@ rac1 .ssh]$ ssh-keygen -t rsa --生成秘钥 密码为空 Generating public/private rsa key pair. Enter file in which to save the key (/home/oracle/.ssh/id_rsa): Enter—全部回车 Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/oracle/.ssh/id_rsa. Your public key has been saved in /home/oracle/.ssh/id_rsa.pub. The key fingerprint is: ae:49:e6:cd:a6:7e:98:e0:26:6f:c3:6b:e6:6d:77:56 oracle@ rac1 [oracle@rac1 .ssh]$
节点2 [root@ rac2 ~]# su - oracle [oracle@ rac2 ~]$ mkdir .ssh [oracle@ rac2 ~]$ chmod 700 .ssh [oracle@ rac2 ~]$ cd .ssh [oracle@ rac2 .ssh]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/oracle/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/oracle/.ssh/id_rsa. Your public key has been saved in /home/oracle/.ssh/id_rsa.pub. The key fingerprint is: 70:42:f6:f3:24:a3:a7:a0:51:05:74:b6:0a:6c:c5:35 oracle@ rac2 [oracle@rac2 .ssh]$
生成 authorized_keys 文件其中包括节点1与节点2的秘钥
节点1 [oracle@ rac1 .ssh]$ ls id_rsa id_rsa.pub [oracle@ rac1 .ssh]$ ssh rac1 cat /home/oracle/.ssh/id_rsa.pub >> authorized_keys The authenticity of host 'rac1 (192.168.56.50)' can't be established. RSA key fingerprint is d1:04:e6:04:3c:85:b7:93:f9:aa:5f:49:70:58:88:20. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'rac1,192.168.56.50' (RSA) to the list of known hosts. oracle@ rac1's password: 节点1 oracle用户密码 [oracle@ rac1 .ssh]$ [oracle@ rac1 .ssh]$ ssh rac2 cat /home/oracle/.ssh/id_rsa.pub >> authorized_keys The authenticity of host 'rac2 (192.168.56.51)' can't be established. RSA key fingerprint is f5:eb:27:6d:85:5e:46:cd:d0:9b:41:f4:0e:35:e8:1c. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'rac2,192.168.56.51' (RSA) to the list of known hosts. oracle@ rac2's password: 节点2oracle用户密码 [oracle@ rac1 .ssh]$
将生成的authorized_keys文件传到节点2 [oracle@rac1 .ssh]$ cat authorized_keys ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEApcThdWeDZnLnG9LCenyOOstB9OEZuU9pwAQh1Mx1dtPN2/92CaveIizpqdgj7v hH1LQgvBGOBKRKcwVERaKcTjTx0ymu0d0QHlCB6ukXLC0W88Rq4dnyP7L/WEn5x5sDhPXyPusgQy9l9aK9zPVguoheAHDIAs5BH0b8XJ044fs= oracle@rac1 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAtZW18RkmewHxM4eYt4RfixiqW1GUP4UzXp495AsjNyGpuMXaEtlwJDYpMJQgxDeRYzpj +//Ip1EYQ5HnJFb4DrHqCMPyxza/fcMvCK0nqVyTfp+pHGOjxnCg+nEHHD3hY9O93UIy7ctNHj1NMDB0pnTGXhba7OALmPT1Zuo9o68= oracle@rac2 [oracle@ rac1 .ssh]$ scp authorized_keys rac2:/home/oracle/.ssh/ oracle@rac2's password: 节点2 oracle用户密码 autbhrized_keys 100% 458 0.5KB/s 00:00 [oracle@rac1 .ssh]$
修改两个节点 autborized_keys文件的权限 [oracle@rac1 .ssh]$ chmod 600 authorized_keys [oracle@rac2 .ssh]$ chmod 600 authorized_keys
验证秘钥队是否正常 节点1 [oracle@rac1 .ssh]$ ssh rac1 date Tue May 20 02:53:43 CST 2014 [oracle@rac1 .ssh]$ ssh rac2 date ----没有输入密码证明成功 Tue May 20 02:53:55 CST 2014 [oracle@rac1 .ssh]$ 节点2 [oracle@rac2 .ssh]$ ssh rac1 date The authenticity of host 'rac1 (192.168.56.50)' can't be established. RSA key fingerprint is d1:04:e6:04:3c:85:b7:93:f9:aa:5f:49:70:58:88:20. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'rac1,192.168.56.50' (RSA) to the list of known hosts. Tue May 20 02:55:39 CST 2014 [oracle@rac2 .ssh]$ ssh rac2 date The authenticity of host 'rac2 (192.168.56.51)' can't be established. RSA key fingerprint is f5:eb:27:6d:85:5e:46:cd:d0:9b:41:f4:0e:35:e8:1c. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'rac2,192.168.56.51' (RSA) to the list of known hosts. Tue May 20 02:55:45 CST 2014 [oracle@rac2 .ssh]$ |
进行软件包认证
节点1 [root@rac1 ~]# rpm -q binutils- compat-db control-center- gcc- gcc-c++- glibc- glibc-common- gnome-libs- libstdc++- libstdc++-devel make binutils-2.15.92.0.2-25 compat-db-4.1.25-9 compat-db-4.1.25-9 control-center-2.8.0-12.rhel4.5 gcc-3.4.6-11.0.1 gcc-c++-3.4.6-11.0.1 glibc-2.3.4-2.43 glibc-2.3.4-2.43 glibc-common-2.3.4-2.43 gnome-libs-1.4.1.2.90-44.2 libstdc++-3.4.6-11.0.1 libstdc++-3.4.6-11.0.1 libstdc++-devel-3.4.6-11.0.1 libstdc++-devel-3.4.6-11.0.1 make-3.80-7.EL4
节点2 [root@rac2 ~]# rpm -q binutils- compat-db control-center- gcc- gcc-c++- glibc- glibc-common- gnome-libs- libstdc++- libstdc++-devel make binutils-2.15.92.0.2-25 compat-db-4.1.25-9 compat-db-4.1.25-9 control-center-2.8.0-12.rhel4.5 gcc-3.4.6-11.0.1 gcc-c++-3.4.6-11.0.1 glibc-2.3.4-2.43 glibc-2.3.4-2.43 glibc-common-2.3.4-2.43 gnome-libs-1.4.1.2.90-44.2 libstdc++-3.4.6-11.0.1 libstdc++-3.4.6-11.0.1 libstdc++-devel-3.4.6-11.0.1 make-3.80-7.EL4 [root@rac2 ~]# rpm -q binutils compat-db control-center gcc gcc-c++ glibc glibc-common gnome-libs libstdc++ libstdc++-devel make pdksh sysstat xscreensaver libaio openmotif21
|
配置内核参数
节点1 [root@rac1 ~]# 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 = 262144
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
[root@rac1 ~]# /sbin/sysctl –p ---使刚设置的参数生效
节点2同样操作
|
设置Shell对oracle用户的限制
节点1 [root@rac1 ~]# vi /etc/security/limits.conf --添加以下内容 oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
节点2 同样配置 |
节点1 [root@rac1 ~]# vi /etc/pam.d/login -添加以下内容 session required /lib/security/pam_limits.so 节点2 [root@rac2 ~]# vi /etc/pam.d/login -添加以下内容
session required /lib/security/pam_limits.so
|
节点1 根据oracle默认shell更改 Bourne, Bash, or Korn [root@rac1 ~]# 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
C shell (csh or tcsh) [root@rac1 ~]# vi /etc/csh.login --添加以下内容 if ( $USER == "oracle" ) then
limit maxproc 16384
limit descriptors 65536
endif
节点2 相同配置 |
配置时间同步
节点1配置成时间同步服务器: 节点2配置:
|
配置环境变量
节点1 [oracle@rac1 ~]$ vi .bash_profile
# .bash_profile
# Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi
# User specific environment and startup programs
umask=022 export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1 export ORA_CRS_HOME=$ORACLE_BASE/product/10.2.0/crs export ORACLE_SID=rac1 export PATH=$ORACLE_HOME/bin:$PATH export TNS_ADMIN=$ORACLE_HOME/network/admin export LD_LIBRARY_PATH=$ORACLE_HOME/lib export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib export CLASSPATH=$ORACLE_HOME/JRE export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib export TEMP=/tmp export TMPDIR=/tmp export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK [oracle@rac1 ~]$
节点2 [root@rac2 ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi
# User specific environment and startup programs
k=022 export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1 export ORA_CRS_HOME=$ORACLE_BASE/product/10.2.0/crs export ORACLE_SID=rac2 export PATH=$ORACLE_HOME/bin:$PATH export TNS_ADMIN=$ORACLE_HOME/network/admin export LD_LIBRARY_PATH=$ORACLE_HOME/lib export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib export CLASSPATH=$ORACLE_HOME/JRE export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib export TEMP=/tmp export TMPDIR=/tmp export NLS_LANG=AMERICAN_AMERICA.ZHS16GBKATH=$PATH:$HOME/bin ".bash_profile" 26L, 854C written [root@rac2 ~]# |
将共享磁盘分区
[root@rac1 mnt]# fdisk /dev/sdc Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-522, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-522, default 522): Using default value 522
Command (m for help): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks. [root@rac1 mnt]# [root@rac1 mnt]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sda1 * 1 130 1044193+ 83 Linux /dev/sda2 131 2610 19920600 8e Linux LVM
Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sdb1 1 500 4016218+ 83 Linux /dev/sdb2 501 1044 4369680 83 Linux
Disk /dev/sdc: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sdc1 1 522 4192933+ 83 Linux [root@rac1 mnt]# |
选择使用哪种存储方式
OCFS2
下载包
https://oss.oracle.com/projects/ocfs2-tools/files/ https://oss.oracle.com/projects/ocfs2/files/
|
[root@rac1 ~]# ls anaconda-ks.cfg ocfs2-2.6.9-89.0.11.EL-1.2.9-1.el4.x86_64.rpm Desktop ocfs2console-1.2.4-1.x86_64.rpm install.log ocfs2-tools-1.2.4-1.x86_64.rpm install.log.syslog [root@rac1 ~]# [root@rac1 ~]# rpm –ivh ocfs2-tools-1.2.4-1.x86_64.rpm [root@rac1 ~]# rpm –ivh ocfs2-2.6.9-89.0.11.EL-1.2.9-1.el4.x86_64.rpm [root@rac1 ~]# rpm –ivh ocfs2console-1.2.4-1.x86_64.rpm 节点2 同样安装
创建分区 [root@rac1 ~]# fdisk /dev/sdc 因为是共享磁盘 所以一个节点创建就可以了
重启计算机
开启Xmanager – Passive并设置变量
[root@rac1 ~]# export DISPLAY=192.168.56.1:0.0 启动图形界面 [root@rac1 ~]# confs2console
选择 Iasks 添加两个磁盘组
在选择 Cluster 中 Propagate Configuration
将节点1的文件拷贝到节点2
验证 [root@rac1 ~]# cat /etc/ocfs2/clunter.conf [root@rac2 ~]# cat /etc/ocfs2/clunter.conf
创建目录将磁盘挂载 [root@rac1 ~]# mkdir -p / orac/orahome [root@rac1 ~]# mkdir -p / orac/oradata [root@rac1 ~]# mount –t ocfs2 /dev/hdc1 /orac/orahome [root@rac1 ~]# mount –t ocfs2 -o datavolume,nointr /dev/hdc2 / orac/oradata [root@rac1 ~]# mounted.ocfs2 –f --查看ocfs2磁盘状态 系统启动时ocfs2同时启动 (两个节点都执行) [root@rac1 /]# /etc/init.d/o2cb configure [root@rac1 /]# vi /etc/fstab /dev/sdc1 / orac/orahome ocfs2 _netdev 0 0 /dev/sdc2 / orac/oradata ocfs2 _netdev, datavolume,nointr 0 0 节点2挂载 [root@rac2 /]# /etc/init.d/o2cb online [root@rac2 ~]# mount –t ocfs2 /dev/hdc1 / orac/orahome [root@rac2 ~]# mount –t ocfs2 -o datavolume,nointr /dev/hdc2 / orac/oradata
修改权限 [root@rac1 orcl]# chown root.oinstall crs [root@rac1 orcl]# chown oracle.oinstall oradata [root@rac1 orcl]# chown oracle.oinstall orahome [root@rac1 orcl]# chmod 775 crs [root@rac1 orcl]# chmod 775 oradata [root@rac1 orcl]# chmod 775 orahome
|
ASM
在每个节点配置裸设备与磁盘关联 [root@rac1 ~]# vi /etc/sysconfig/rawdevices
/dev/raw/raw1 /dev/sdb1 /dev/raw/raw2 /dev/sdb2 重启裸设备服务 [root@rac1 ~]# /sbin/service rawdevices restart Assigning devices: /dev/raw/raw1 --> /dev/sdb1 /dev/raw/raw1: bound to major 8, minor 17 /dev/raw/raw2 --> /dev/sdb2 /dev/raw/raw2: bound to major 8, minor 18 done [root@rac1 ~]# 在每个节点修改裸设备的权限和所属者 [root@rac1 ~]# chown root:oinstall /dev/raw/raw1 [root@rac1 ~]# chmod 660 /dev/raw/raw1 [root@rac1 ~]# chown oracle:oinstall /dev/raw/raw2 [root@rac1 ~]# chmod 644/dev/raw/raw2
[root@rac1 ~]# vi /etc/rc.local
touch /var/lock/subsys/local chown root:oinstall /dev/raw/raw1 chmod 660 /dev/raw/raw1 chown oracle:oinstall /dev/raw/raw2 chmod 644 /dev/raw/raw2
在每个节点安装ASMLIB包 [root@rac1 RPMS]# rpm -ivh oracleasm-support-2.1.3-1.el4.x86_64.rpm
[root@rac1 RPMS]# rpm -ivh oracleasm-2.6.9-89.0.0.0.1.EL-2.0.5-1.el4.x86_64.rpm
[root@rac1 ~]# rpm -ivh oracleasmlib-2.0.4-1.el4.x86_64.rpm
在每个节点配置 [root@rac1 mnt]# /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]: y Writing Oracle ASM library driver configuration: done Initializing the Oracle ASMLib driver: [ OK ] Scanning the system for Oracle ASMLib disks: [ OK ] [root@rac1 mnt]# [root@rac1 mnt]# /etc/init.d/oracleasm enable Writing Oracle ASM library driver configuration: done Initializing the Oracle ASMLib driver: [ OK ] Scanning the system for Oracle ASMLib disks: [ OK ] [root@rac1 mnt]#
为ASM配置磁盘 [root@rac1 ~]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdc1 Marking disk "VOL1" as an ASM disk: [ OK ] [root@rac1 ~]#显示配置的所有磁盘 [root@rac1 mnt]# /etc/init.d/oracleasm listdisks VOL1 VOL2 [root@rac1 mnt]# 创建安装目录 [root@rac1 ~]# mkdir -p /u01/app/oracle [root@rac1 oracle]#chown oracle:oinstall /u01 -R 重启OS
开始安装
在每个节点配置用户等效性 #su – oracle
[oracle@rac2 ~]$ export DISPLAY=192.168.56.1:0.0 [oracle@rac2 ~]$ exec /usr/bin/ssh-agent $SHELL [oracle@rac2 ~]$ /usr/bin/ssh-add Identity added: /home/oracle/.ssh/id_rsa (/home/oracle/.ssh/id_rsa) [oracle@rac2 ~]$
先使用 gunzip 解压后缀.cpio.gz的包。 在使用cpio –idcmv<压缩包name 解压。Coip的压缩包。
1565626 blocks [oracle@rac1 ~]$ ls 10201_clusterware_linux_x86_64.cpio clusterware 10201_database_linux_x86_64.cpio database [oracle@rac1 ~]$ 在节点1 安装clusterware [oracle@rac1 ~]$ cd clusterware/ [oracle@rac1 clusterware]$ ls cluvfy install rootpre runInstaller upgrade doc response rpm stage welcome.html [oracle@rac1 clusterware]$ ./runInstaller ********************************************************************************
Has 'rootpre.sh' been run by root? [y/n] (n) 这里输入Y
Crs安装路径: 与设置的变量一致
系统检查全部通过下一步
这里的设置与/etc/hosts中一直 有几个节点添加几个节点
添加完成下一步
将eth0的网卡改为公用
根据自己的需求选择冗余方式我选择的是外部冗余 这里指定的是OCR的位置 这里可以选择正常冗余或外部冗余,效果一样,正常冗余提供了一个OCR的镜像位置,而外部冗余没有提供OCR镜像,只需要OCR位置就可以,我这里选择的是外部冗余
同样的选择冗余方式:这里存放的是表决磁盘位置
这里出现你安装的所有设置:点击安装
等待安装完成
这里提示使用root用户执行两个脚本 :注意要先执行节点1
[root@rac1 ~]# /u01/app/oracle/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oracle/oraInventory to 770. Changing groupname of /u01/app/oracle/oraInventory to oinstall. The execution of the script is complete [root@rac1 ~]# [root@rac2 ~]# /u01/app/oracle/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oracle/oraInventory to 770. Changing groupname of /u01/app/oracle/oraInventory to oinstall. The execution of the script is complete [root@rac2 ~]# [root@rac1 ~]# /u01/app/oracle/product/10.2.0/crs/root.sh WARNING: directory '/u01/app/oracle/product/10.2.0' is not owned by root WARNING: directory '/u01/app/oracle/product' is not owned by root WARNING: directory '/u01/app/oracle' is not owned by root WARNING: directory '/u01/app' is not owned by root WARNING: directory '/u01' is not owned by root Checking to see if Oracle CRS stack is already configured /etc/oracle does not exist. Creating it now.
Setting the permissions on OCR backup directory Setting up NS directories Oracle Cluster Registry configuration upgraded successfully WARNING: directory '/u01/app/oracle/product/10.2.0' is not owned by root WARNING: directory '/u01/app/oracle/product' is not owned by root WARNING: directory '/u01/app/oracle' is not owned by root WARNING: directory '/u01/app' is not owned by root WARNING: directory '/u01' is not owned by root Successfully accumulated necessary OCR keys. Using ports: CSS=49895 CRS=49896 EVMC=49898 and EVMR=49897. node : node 1: rac1 priv1 rac1 node 2: rac2 priv2 rac2 Creating OCR keys for user 'root', privgrp 'root'.. Operation successful. Now formatting voting device: /dev/raw/raw2 Format of 1 voting devices complete. Startup will be queued to init within 90 seconds. Adding daemons to inittab Expecting the CRS daemons to be up within 600 seconds. CSS is active on these nodes. rac1 CSS is inactive on these nodes. rac2 Local node checking complete. Run root.sh on remaining nodes to start CRS daemons. [root@rac1 ~]# [root@rac2 ~]# /u01/app/oracle/product/10.2.0/crs/root.sh WARNING: directory '/u01/app/oracle/product/10.2.0' is not owned by root WARNING: directory '/u01/app/oracle/product' is not owned by root WARNING: directory '/u01/app/oracle' is not owned by root WARNING: directory '/u01/app' is not owned by root WARNING: directory '/u01' is not owned by root Checking to see if Oracle CRS stack is already configured /etc/oracle does not exist. Creating it now.
Setting the permissions on OCR backup directory Setting up NS directories Oracle Cluster Registry configuration upgraded successfully WARNING: directory '/u01/app/oracle/product/10.2.0' is not owned by root WARNING: directory '/u01/app/oracle/product' is not owned by root WARNING: directory '/u01/app/oracle' is not owned by root WARNING: directory '/u01/app' is not owned by root WARNING: directory '/u01' is not owned by root clscfg: EXISTING configuration version 3 detected. clscfg: version 3 is 10G Release 2. Successfully accumulated necessary OCR keys. Using ports: CSS=49895 CRS=49896 EVMC=49898 and EVMR=49897. node : node 1: rac1 priv1 rac1 node 2: rac2 priv2 rac2 clscfg: Arguments check out successfully.
NO KEYS WERE WRITTEN. Supply -force parameter to override. -force is destructive and will destroy any previous cluster configuration. Oracle Cluster Registry for cluster has already been initialized Startup will be queued to init within 90 seconds. Adding daemons to inittab Expecting the CRS daemons to be up within 600 seconds. CSS is active on these nodes. rac1 rac2 CSS is active on all nodes. Waiting for the Oracle CRSD and EVMD to start Waiting for the Oracle CRSD and EVMD to start Oracle CRS stack installed and running under init(1M) Running vipca(silent) for configuring nodeapps The given interface(s), "eth0" is not public. Public interfaces should be used to configure virtual IPs. [root@rac2 ~]# 这里需要手工配置vipca [root@rac1 ~]# cd /u01/app/oracle/product/10.2.0/crs/bin [root@rac1 bin]# export DISPLAY=192.168.56.1:0.0 [root@rac1 bin]# ./vipca 配置完成 进入安装界面点击OK 会进行自动检查: 成功会会提示以下界面 在下面安装错误中提到vipca的步骤
下面安装数据库软件
在节点1 执行 [oracle@rac1 clusterware]$ cd .. [oracle@rac1 ~]$ ls 10201_clusterware_linux_x86_64.cpio clusterware 10201_database_linux_x86_64.cpio database [oracle@rac1 ~]$ cd database/ [oracle@rac1 database]$ ls doc install response runInstaller stage welcome.html [oracle@rac1 database]$ ./runInstaller
选择安装版本:企业版、标准版与自定义。我选择的是企业版
选择安装路径:环境变量ORACLE_HOME
这里选择集群安装: 将所有节点都选中
这里进行检查:这里没有通过 我的swap只有2047MB 没有达到3006MB的需求
在每个节点操作 [root@rac1 ~]# free -m total used free shared buffers cached Mem: 2007 1511 495 0 32 1304 -/+ buffers/cache: 174 1832 Swap: 2047 0 2047 [root@rac1 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VGoracle-LVroot 14G 5.6G 6.9G 45% / /dev/sda1 1012M 39M 923M 4% /boot none 1004M 0 1004M 0% /dev/shm [root@rac1 ~]# mkdir /swapimage [root@rac1 ~]# cd /swapimage/ [root@rac1 swapimage]# dd if=/dev/zero of=/swapimage/swap bs=1024 count=1024000 1024000+0 records in 1024000+0 records out [root@rac1 swapimage]# mkswap /swapimage/swap Setting up swapspace version 1, size = 1048571 kB [root@rac1 swapimage]# free -m total used free shared buffers cached Mem: 2007 1978 28 0 11 1773 -/+ buffers/cache: 193 1813 Swap: 3047 0 2047 选择只安装数据库软件
点击安装
可以在进行重新安装尝试 执行脚本 [root@rac1 ~]# cd /u01/app/oracle/product/10.2.0/db_1/ [root@rac1 db_1]# ./root.sh Running Oracle10 root.sh script...
The following environment variables are set as: ORACLE_OWNER= oracle ORACLE_HOME= /u01/app/oracle/product/10.2.0/db_1
Enter the full pathname of the local bin directory: [/usr/local/bin]: Copying dbhome to /usr/local/bin ... Copying oraenv to /usr/local/bin ... Copying coraenv to /usr/local/bin ...
Creating /etc/oratab file... Entries will be added to the /etc/oratab file as needed by Database Configuration Assistant when a database is created Finished running generic part of root.sh script. Now product-specific root actions will be performed.
[root@rac1 db_1]# 配置netca 全部下一步。 最后可以配置命名为本地命名
配置数据库 [oracle@rac1 ~]$ dbca
|
安装错误
第二个节点执行 root.sh 报错: Waiting for the Oracle CRSD and EVMD to start
解决方法: 手工配置vipca root@rac1 # cd /u01/app/oracle/product/10.2.0/crs/bin |
检查未通过
Checking Network Configuration requirements ...
Check complete. The overall result of this check is: Not executed <<<<
Recommendation: Oracle supports installations on systems with DHCP-assigned public IP addresses. However, the primary network interface on the system should be configured with a static IP address in order for the Oracle Software to function properly. See the Installation Guide for more details on installing the software on systems configured with DHCP.(推荐系统采用静态的IP设置)
解决方法: 将所有节点的eth0网卡设置为静态 vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=static IPADDR=192.168.56.50 NETMASK=255.255.255.0 GATEWAY=192.168.56.1 #HWADDR=00:0c:29:c9:31:a9 ONBOOT=yes TYPE=Ethernet
|
配置客户端
在windows 编辑 C:\Windows\System32\drivers\etc\hosts 文件
添加linux /etc/hosts中的配置
192.168.56.50 rac1
192.168.56.52 vip1
10.10.10.1 priv1
192.168.56.51 rac2
192.168.56.53 vip2
10.10.10.2 priv2
使用windows的cmd工具 ping vip1 与vip2 看是否能ping通
同过OK。编辑oracle10g客户端中tnsnames.ora 文件
添加linux 主机中/u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora中 rac内容
RAC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vip1)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = vip2)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rac)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
)
)
)
故障查询语句
以下SQL 查询可以用来查看一个会话的故障切换类型、故障切换方法和是否发生了故障切换。在这个例子中自始至终使用这个查询。
Sql>COLUMN instance_name FORMAT a13 Sql>COLUMN host_name FORMAT a9 Sql>COLUMN failover_method FORMAT a15 Sql>COLUMN failed_over FORMAT a11 Sql>SELECT instance_name,host_name, NULL AS failover_type,NULL AS failover_method, NULL AS failed_over FROM v$instance UNION SELECT NULL,NULL,failover_type,failover_method,failed_over FROM v$session WHERE username = 'SYSTEM';
|
集群基本命令
停止Oracle RAC 10g环境
第一步是停止Oracle 实例。当此实例(和相关服务)关闭后,关闭ASM实例。最后,关闭节点应用程序(虚拟IP、GSD、TNS 监听器和 ONS)
$ export ORACLE_SID=rac1
$ emctl stop dbconsole
$ srvctl stop instance -d rac -i rac1
$ srvctl stop asm –n rac1
$ srvctl stop nodeapps -n rac1
启动Oracle RAC 10g环境
第一步是启动节点应用程序(虚拟 IP、GSD、TNS 监听器和 ONS)。当成功启动节点应用程序后,启动ASM 实例。最后,启动Oracle 实例(和相关服务)以及企业管理器数据库控制台。
$ export ORACLE_SID=rac2
$ srvctl start nodeapps -n rac1
$ srvctl start asm -n rac1
$ srvctl start instance -d rac -i rac1
$ emctl start dbconsole
使用SRVCTL 启动/停止所有实例
$ srvctl start database -d rac1
$ srvctl stop database -d rac1
所有实例和服务的状态
$ srvctl status database -d rac
单个实例的状态
$ srvctl status instance -d rac -i rac2
在数据库全局命名服务的状态
$ srvctl status service -d rac -s rac
特定节点上节点应用程序的状态
$ srvctl status nodeapps -n rac1
ASM
实例的状态
$ srvctl status asm -n rac1
列出配置的所有数据库
$ srvctl config database
显示
RAC
数据库的配置
$ srvctl config database -d rac
显示指定集群数据库的所有服务
$ srvctl config service -d rac
显示节点应用程序的配置-(VIP、GSD、ONS、监听器)
$ srvctl config nodeapps -n oradb 1 -a -g -s -l
VIP
exists.:/vip- rac 1/192.168.1.200/255.255.255.0/eth0:eth1
GSD exists.
ONS daemon exists.
Listener exists.
显示
ASM
实例的配置
$ srvctl config asm -n rac1
+ASM1 /home/oracle/product/10.2.0/db_1
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29532781/viewspace-1174777/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29532781/viewspace-1174777/