实验环境
node1:ip:172.16.11.5 centos6.5+httpd+corosync+pacemaker+crm
node2:ip:172.16.11.6 centos6.5+httpd+corosync+pacemaker+crm
node3:ip:172.16.11.7 nfs
1、时间同步
时间同步机制
ssh node2.www.org.com "date -s '20140914 23:12:30'";date -s '20140914 23:12:30'
2、基于密钥认证
3、修改hosts
ping测试
ssh node1.www.org.com 'date';date
4、vim /etc/sysconfig/network
使主机名与root@xxxxx#一致
5、软件安装
yum install pacemaker -y
yum install pssh-2.3.1-2.el6.x86_64.rpm crmsh-1.2.6-4.el6.x86_64.rpm
server corosync restart
注意这里第一次安装的会有熵池的东西,需要你敲键盘,不要意外。
6、提供配置文件
cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf
vim /etc/corosync/corosync.conf
# Please read the corosync.conf.5 manual page
compatibility: whitetank
totem {
version: 2
secauth: on
threads: 0
interface {
ringnumber: 0
bindnetaddr: 172.16.0.0 #重点就是这个是网段地址,不同网段配置不同网络地址
mcastaddr: 226.194.21.156 #组播地址保持
mcastport: 5405
ttl: 1
}
}
logging {
fileline: off
to_stderr: no
to_logfile: yes
to_syslog: no
logfile: /var/log/cluster/corosync.log
debug: off
timestamp: on
logger_subsys {
subsys: AMF
debug: off
}
}
amf {
mode: disabled
}
service {
ver: 0
name: pacemaker #重要信息
}
aisexec { #以啥身份认证
user: root
group: root
}
scp /etc/corosync/corosync.cnf 172.16.11.6:/etc/corosync/
7、crm的配置使服务能够提供httpd的高可用
crm configure
stonith-enabled=false
no-quorum-policy=ignore
primitive webip ocf:IPaddr params ip=172.16.11.148 op monitor timeout=20s interval=60s
primitive webserver lsb:httpd op monitor timeout=20s interval=30s
primitive webserver lsb:httpd op monitor timeout=20s interval=30s
group webservice webip webserver
8、命令的基本练习
clearstate node2
primitive webip ocf:IPaddr params ip=172.16.11.148 op monitor timeout=20s interval=60s
resource
cleanup webserver
delect webserver
delect webserver_with_webip
colocation webip_with_webserver inf: webip webserver
order webip_before_webserver mandatory: webip webserver
location webip_on_node2 webip inf: node2.www.org.com
location webip_on_node2 webip rule inf: #uname eq node2.www.org.com
location webserver_on_node2 webserver rule -inf: #uname eq node2.www.org.com
colocation 排序 资源在一起 建议用group来定义
order 顺序 先启动那个,先关闭那个
location 位置 节点挂了,重新上线,更加倾向于那个节点,主要用在服务器性能不一致的场景中,
如果资源本身出问题啦,我们必须修改监控时间,不然主页是不能访问,,它不会自动起来,节点资源httpd本身挂啦,HA节点都在好着,不定义时间监控服务室起不来的
9、资源
资源:主资源,组资源,克隆资源,主从资源
10、节点3提供nfs
vim/etc/exports
/www/html 172.16.1.0/16(no_root_squash,root)
service nfs restart
11、各节点测试挂载
showmount -e 节点3的ip
mount -t nfs 172.16.11.7:/www/html /post
umount
12、扩展nfs共享安装网页
crm configuer
primitive webstore ocf:Filesystem params device="172.16.11.7:/www/html" directory="/var/www/html" fstype="nfs" op monitor interval=60 timeout=30
group webservice webip webstore webserver
order webip_before_webstore_before_webservice inf: webip webstore webservice
show xml 查看先后顺序
网页测试
crm node online #强制资源上线
crm node standby #强制资源下线
13、全部配置
node node1.www.org.com \
attributes standby="off"
node node2.www.org.com
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.1.10" \
op monitor timeout="20s" interval="60s"
primitive webserver lsb:httpd \
op monitor timeout="20s" interval="30s"
primitive webstore ocf:heartbeat:Filesystem \
params device="192.168.1.7:/www/html" directory="/var/www/html" fstype="nfs" \
op monitor interval="60s" timeout="40s" \
op start timeout="60s" interval="0" \
op stop timeout="60s" interval="0"
group webservice webip webstore webserver
order webip_before_webstore_before_webservice inf: webip webstore webservice
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6-368c726" \
cluster-infrastructure="classic openais (with plugin)" \
expected-quorum-votes="2" \
stonith-enabled="false" \
no-quorum-policy="ignore"