一、实验环境
node1:192.168.1.110
node2:192.168.1.120
NFS服务器与仲裁设备:192.168.1.130
VIP:192.168.1.115
二、相关准备工作
1、配置host文件使节点间可通过主机名通信
node1节点配置
[root@node1 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.1.110 node1.cwc.com node1 192.168.1.120 node2.cwc.com node2 [root@node1 ~]# ping node2 PING node2.cwc.com (192.168.1.120) 56(84) bytes of data. 64 bytes from node2.cwc.com (192.168.1.120): icmp_seq=1 ttl=64 time=3.10 ms 64 bytes from node2.cwc.com (192.168.1.120): icmp_seq=2 ttl=64 time=0.645 ms 64 bytes from node2.cwc.com (192.168.1.120): icmp_seq=3 ttl=64 time=0.460 ms
node2节点配置
[root@node2 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.1.120 node2.cwc.com node2 192.168.1.110 node1.cwc.com node1 [root@node2 ~]# ping node1 PING node1.cwc.com (192.168.1.110) 56(84) bytes of data. 64 bytes from node1.cwc.com (192.168.1.110): icmp_seq=1 ttl=64 time=0.451 ms 64 bytes from node1.cwc.com (192.168.1.110): icmp_seq=2 ttl=64 time=0.495 ms 64 bytes from node1.cwc.com (192.168.1.110): icmp_seq=3 ttl=64 time=0.494 msms
2、ssh到相关节点通过root账号基于秘钥认证;
node1节点配置
[root@node1 ~]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 23:3a:bf:f6:1f:6d:42:ae:2a:4b:92:eb:14:1e:2d:af root@node1.cwc.com The key‘s randomart image is: +--[ RSA 2048]----+ | | | | | | | . | | + . . S . | | . * . . + . | | = = + o | | . =.o. . + | | .E .+++o.. | +-----------------+ [root@node1 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@node2 The authenticity of host ‘node2 (192.168.1.120)‘ can‘t be established. RSA key fingerprint is dd:4a:08:9a:15:cc:16:57:2a:4a:8f:73:8e:57:9b:cc. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added ‘node2,192.168.1.120‘ (RSA) to the list of known hosts. root@node2‘s password: Now try logging into the machine, with "ssh ‘root@node2‘", and check in: .ssh/authorized_keys to make sure we haven‘t added extra keys that you weren‘t expecting. [root@node1 ~]# ssh node2 Last login: Tue Oct 27 19:50:41 2015 from node1.cwc.com [root@node2 ~]# exit
node2节点配置
[root@node2 ~]# ssh node1 Last login: Tue Oct 27 19:58:45 2015 from node2.cwc.com [root@node1 ~]# exit
3、配置节点间时间同步
node1节点配置
[root@node1 ~]# rpm -qa | grep ntp ntpdate-4.2.6p5-1.el6.centos.x86_64 fontpackages-filesystem-1.41-1.1.el6.noarch ntp-4.2.6p5-1.el6.centos.x86_64 [root@node1 ~]# ntpdate cn.pool.ntp.org 27 Oct 20:08:19 ntpdate[3048]: step time server 202.112.29.82 offset -12.788115 sec [root@node1 ~]# crontab -e */2 * * * * /usr/sbin/ntpdate cn.pool.ntp.org &> /dev/null
node2节点配置
[root@node2 ~]# rpm -qa | grep ntp fontpackages-filesystem-1.41-1.1.el6.noarch ntp-4.2.4p8-3.el6.centos.x86_64 ntpdate-4.2.4p8-3.el6.centos.x86_64 [root@node2 ~]# ntpdate cn.pool.ntp.org 27 Oct 20:12:09 ntpdate[3147]: step time server 202.112.29.82 offset -13.179396 sec [root@node2 ~]# date; ssh node1 date Tue Oct 27 20:12:45 CST 2015 Tue Oct 27 20:12:45 CST 2015 [root@node2 ~]# crontab -e */2 * * * * /usr/sbin/ntpdate cn.pool.ntp.org &> /dev/null
4、考虑是否用到仲裁设备
三、配置LAMP+heartbeat
1、安装配置LAMP
node1节点配置
[root@node1 ~]# yum install httpd httpd-devel mysql mysql-server mysql-devel php php-devel php-mysql [root@node1 ~]# yum install net-snmp-libs libnet PyXML [root@node1 heartbeat2]# ls -l total 5708 -rw-r--r-- 1 root root 1420924 Oct 27 21:13 heartbeat-2.1.4-12.el6.x86_64.rpm -rw-r--r-- 1 root root 3589552 Oct 27 21:14 heartbeat-debuginfo-2.1.4-12.el6.x86_64.rpm -rw-r--r-- 1 root root 282836 Oct 27 21:13 heartbeat-devel-2.1.4-12.el6.x86_64.rpm -rw-r--r-- 1 root root 168052 Oct 27 21:14 heartbeat-gui-2.1.4-12.el6.x86_64.rpm -rw-r--r-- 1 root root 108932 Oct 27 21:14 heartbeat-ldirectord-2.1.4-12.el6.x86_64.rpm -rw-r--r-- 1 root root 92388 Oct 27 21:14 heartbeat-pils-2.1.4-12.el6.x86_64.rpm -rw-r--r-- 1 root root 166580 Oct 27 21:14 heartbeat-stonith-2.1.4-12.el6.x86_64.rpm [root@node1 heartbeat2]# rpm -ivh heartbeat-2.1.4-12.el6.x86_64.rpm heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm Preparing... ########################################### [100%] 1:heartbeat-pils ########################################### [ 33%] 2:heartbeat-stonith ########################################### [ 67%] 3:heartbeat ########################################### [100%] [root@node1 heartbeat2]# rpm -ivh heartbeat-gui-2.1.4-12.el6.x86_64.rpm Preparing... ########################################### [100%] 1:heartbeat-gui ########################################### [100%]
node2节点配置
[root@node2 ~]# yum install httpd httpd-devel mysql mysql-server mysql-devel php php-devel php-mysql [root@node2 ~]# yum install net-snmp-libs libnet PyXML [root@node2 heartbeat2]# rpm -ivh heartbeat-2.1.4-12.el6.x86_64.rpm heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm Preparing... ########################################### [100%] 1:heartbeat-pils ########################################### [ 33%] 2:heartbeat-stonith ########################################### [ 67%] 3:heartbeat ########################################### [100%] [root@node2 heartbeat2]# rpm -ivh heartbeat-gui-2.1.4-12.el6.x86_64.rpm Preparing... ########################################### [100%] 1:heartbeat-gui ########################################### [100%]
原文:http://c616531043.blog.51cto.com/1397029/1706888