VCS基本原理介绍
令。
要查看可用 RAM 和交换空间大小,运行以下命令: grep MemTotal /proc/meminfo grep SwapTotal /proc/meminfo
例如:
# grep MemTotal /proc/meminfo MemTotal:512236 kB
# grep SwapTotal /proc/meminfo SwapTotal:1574360 kB
所需最小 RAM 为 512MB,而所需最小交换空间为 1GB。对于 RAM 小于或等于 2GB 的系统,交换空间应为 RAM 数量的两倍;对于 RAM 大于 2GB 的系统,交换空间应为 RAM 数量的一到两倍。
Oracle 10g 软件还需要 2.5GB 的可用磁盘空间,而数据库则另需 1.2GB 的可用磁盘空间。/tmp 目录至少需要 400MB 的可用空间。
3.2 内核参数
1、内核参数
在/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 = 262144 net.core.wmem_default = 262144 net.core.wmem_max = 262144
然后用执行/sbin/sysctl –p
2、hangcheck-timer设置
RAC节点间通过CSS来判断通信状态,因此需要设定定时器来触发判断。该定时器就是linux内核自带的hangcheck-timer。 具体操作:
在/etc/rc.local中加入(数值以具体情况而定,以下是默认值) insmod hangcheck-timer hangcheck_tick=30 hangcheck_margin=180
表示,每隔30秒检查一下节点状态,如果180秒内仍没有反应,则重启该节点。这也就是说,检查的间隔最长为30+180秒,如果超过这个时间,则系统重启。
第6页 总62页
VCS基本原理介绍
Tip:如果系统尚不稳定,可将数值设置的大一些,这样可以有充分的时间来修复系统,否则系统会进入循环重启状态。
3.3 添加oracle用户和组
# /usr/sbin/groupadd oinstall # /usr/sbin/groupadd dba
# /usr/sbin/useradd -m -g oinstall -G dba oracle # id oracle
uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),6(disk),1001(dba)
设置 oracle 帐户的口令: # passwd oracle
Changing password for user oracle. New password:
Retype new password:
passwd:all authentication tokens updated successfully.
设置oracle的shell限制:
在/etc/security/limits.conf文件中加入:oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536
3.4 网络设置
RAC要求机群内的每个节点至少有两块网卡,一个设置为公用(公网),对外提供服务;一个设置为私用(专用),提供节点内的高速传输。此外还需要为公用网卡配置一个虚拟地址,oracle需要借此为用户提供透明的高可用服务。 公共网络
为维持高可用性,为每个集群节点分配了一个虚拟 IP 地址 (VIP)。 如果主机发生故障,则可以将故障节点的 IP 地址重新分配给一个可用节点,从而允许应用程序通过相同的 IP 地址继续访问数据库。
第7页 总62页
VCS基本原理介绍
修改/etc/hosts加入类似下面内容,:
# Public
10.0.76.2 mainha 10.0.76.3 standbyha #Private
192.168.0.2 mainha-priv 192.168.0.3 standbyha-priv #Virtual
10.0.76.25 mainha-vip 10.0.76.26 standbyha-vip
3.5 为用户等效性设置SSH
在安装 Oracle RAC 10g 期间,OUI 需要把文件复制到集群中的其他主机上并在其上执行程序。 为了允许 OUI 完成此任务,必须配置 SSH 以启用用户等效性。 用 SSH 建立用户等效性就提供了一种在集群中其他主机上复制文件和执行程序时不需要口令提示的安全方式 具体步骤:这里以两个节点rac为例说明创建过程 以oracle用户身份登陆每个系统 进入oracle用户根目录 [oracle@mainha~]# cd
--创建公钥、私钥 主机1上
[oracle@mainha ~]$ mkdir .ssh
[oracle@mainha ~]$ chmod 700 .ssh
[oracle@mainha ~]$ /usr/bin/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:
76:da:4f:6f:4e:29:e3:1f:72:75:cd:26:c7:17:9b:71 oracle@mainha [oracle@mainha ~]$ /usr/bin/ssh-keygen -t dsa Generating public/private dsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again:
Your identification has been saved in /home/oracle/.ssh/id_dsa.
第8页 总62页
VCS基本原理介绍
Your public key has been saved in /home/oracle/.ssh/id_dsa.pub. The key fingerprint is:
44:cf:e1:e4:0b:4c:b0:3b:e1:7f:c0:0b:90:86:d8:45 oracle@mainha 注意:上面提示输入值的地方一路按回车选择默认 [oracle@mainha ~]$ 主机2上
[oracle@standbyha ~]$ mkdir .ssh
[oracle@standbyha ~]$ chmod 700 .ssh
[oracle@standbyha ~]$ /usr/bin/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:
23:db:ae:74:b9:02:9d:50:62:83:7f:71:78:54:c5:2e oracle@standbyha [oracle@standbyha ~]$ /usr/bin/ssh-keygen -t dsa Generating public/private dsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_dsa): Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/oracle/.ssh/id_dsa. Your public key has been saved in /home/oracle/.ssh/id_dsa.pub. The key fingerprint is:
4d:5a:e2:6e:6e:e7:16:6c:59:c6:8d:dc:5e:03:0b:2c oracle@standbyha 注意:上面提示输入值的地方一路按回车选择默认
在主机1上完成密钥文件的copy [oracle@mainha ~]$ cd .ssh
[oracle@mainha .ssh]$ cat id_rsa.pub >> authorized_keys [oracle@mainha .ssh]$ cat id_dsa.pub >> authorized_keys
[oracle@mainha .ssh]$ /usr/bin/ssh standbyha cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys The authenticity of host 'standbyha (10.0.76.3)' can't be established. RSA key fingerprint is 7f:a8:8c:8c:ec:58:da:b3:ac:bb:9c:2f:13:46:25:51. Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'standbyha,10.0.76.3' (RSA) to the list of known hosts. oracle@standbyha's password:
[oracle@mainha .ssh]$ /usr/bin/ssh standbyha cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys oracle@standbyha's password:
[oracle@mainha .ssh]$ /usr/bin/scp authorized_keys standbyha:~/.ssh/authorized_keys oracle@standbyha's password:
authorized_keys
第9页 总62页
VCS基本原理介绍
--使用下列命令测试,在每个机器上分别执行下面的两个命令,如果能够成功输出结果表示配置成功
# [oracle@mainha .ssh]$ ssh mainha date Tue Aug 30 13:28:49 CST 2011
[oracle@mainha .ssh]$ ssh standbyha date Tue Aug 30 13:29:41 CST 2011 [oracle@mainha .ssh]$
4 ASM配置共享磁盘
配置共享磁盘的方法有三种: 1. Oracle 集群文件系统 (OCFS) 2. 自动存储管理器 (ASM) 3. 原始设备(裸设备)
从可扩展性和可管理性方面考虑,我们使用的是用ASM Library Driver配置ASM的共享磁盘。 另外随着oracle版本的不断升级,自动存储管理器将是未来配置共享磁盘的大方向
4.1 安装ASM软件用root权限执行
[root@standbyha rac]# rpm -ivh oracleasm-support-2.1.7-1.el5.x86_64.rpm
warning: oracleasm-support-2.1.7-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID Preparing... ################################## [100%] 1:oracleasm-support ##################################### [100%] [root@standbyha rac]# rpm -ivh oracleasm-2.6.18-164.el5-2.0.5-1.el5.x86_64.rpm
warning: oracleasm-2.6.18-164.15.1.el5-2.0.5-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, Preparing... ################################### [100%] 1:oracleasm-2.6.18-164.15################################## [100%] [root@standbyha rac]# rpm -ivh oracleasmlib-2.0.4-1.el5.x86_64.rpm
warning: oracleasmlib-2.0.4-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159 Preparing... #################################### [100%] 1:oracleasmlib ################################### [100%]
第10页 总62页