corosync+pacemaker+crm+nfs

實驗環境

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"

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章