Centos搭建 TFS Nameserver HA,centosnameserver

來源:互聯網
上載者:User

Centos搭建 TFS Nameserver HA,centosnameserver
背景    

tfs要求用gcc 4.1.2編譯,兩種方案1是用centos5(內建gcc 4.1.2),  2使用centos6 把gcc降到4.1.2。我使用的是第一個方法成功運行tfs,當做HA的時候問題來了,官方要求是用heartbeat 3.x,centos5是2.x。開始選擇在centos5下編譯heartbeat 3成功,但還需要編譯pacemaker,編譯的時候遇到些問題,可能是版本匹配,依賴不全等,就算編譯通過考慮後續還需要編譯XXX豈不浪費時間,畢竟centos5已經很老了。

    於是決定把centos5編譯的tfs放到centos6裡成功運行,在centos6裡搭建HA。

     這種方式存在問題是在centos6的tfs部分營運命令不好用,無法載入xxx依賴庫。解決方案是使用centos5中的營運命令即可。(從長遠看還是把centos6 gcc降到4.1.2,有空再說吧)

好了言歸正傳。

系統內容

  nameserver1  master 192.168.6.129eth0

                  nameserver2  slave 192.168.6.128 eth0

                  vip192.168.6.100 (vip eth0:0)

(開啟方貌似不用手動執行 ifconfig eth0:0 192.168.6.100 netmask 255.255.255.0 up)

系統都是vmware安裝的centos6.6.。

 

首先安裝包

     yuminstall heartbeat

     還需要安裝pacemaker這裡需注意不要用yum安裝,因為安裝的pacemaker是1.1.12版本,pacemaker在1.1.8版本之後把crm分離出去了,所以下載了pacemaker-1.1.7版本編譯安裝(http://down1.chinaunix.net/distfiles/pacemaker-1.1.7.tar.gz)

編譯前先安裝依賴

yum install perl-TimeDate OpenIPMI-libs lm_sensors libxslt libibverbs librdmacm pkgconfig libtool intltool gettext-devel glib2-devel python-devel libxml2-devel pam-devel ncurses-devel pygtk2  libtool-ltdl libqb clusterlib libtool-ltdl-devel swig gnutls-devel resource-agents clusterlib cluster-glue-libs-devel heartbeat-devel  

(注意使用了epel源。)


#tar –vxf pacemaker-1.1.7.tar.gz

#cd ClusterLabs-pacemaker-b5b0a7b

#./ autogen.sh

#./ configure

#make && make install

以上兩台主機都要裝。



配置namesever

兩台主機的namesever的ns.conf 

 [public]

#vip

ip_addr = 192.168.6.100

#監聽連接埠

port =8108

[nameserver]

ip_addr_list = 192.168.6.129|192.168.6.128 

上面幾項在兩台主機寫法一樣,其他項都不變,只關注這些就行。

 

配置hearbeat

假設兩台主機名稱為

192.168.6.129 test1

192.168.6.128 test2

(test1,test2修改成你的主機名稱,在test1上直接執行ping test2能通表示正確,修改主機名稱參照http://blog.csdn.net/l241002209/article/details/42269435)

 

然後在test1上執行

#cd $TBLIB_ROOT/scripts/ha/

#vi ha.cf

debugfile /var/log/ha-debug

debug 1

keepalive 2

warntime 5

deadtime 10

initdead 30

auto_failback off

autojoin none

ucast eth0 192.168.6.128   <--注意這裡是對端的地址

udpport 694

node tes1

node test2

compression bz2

logfile /var/log/ha-log

logfacility     local0

crm respawn

(修改完成儲存退出:wq)

#./deploy

#./nsdep

 

然後在test2上執行

#cd $TBLIB_ROOT/scripts/ha/

#vi ha.cf

debugfile /var/log/ha-debug

debug 1

keepalive 2

warntime 5

deadtime 10

initdead 30

auto_failback off

autojoin none

ucast eth0 192.168.6.129   <--注意這裡是對端的地址

udpport 694

node tes1

node test2

compression bz2

logfile /var/log/ha-log

logfacility     local0

crm respawn

(修改完成儲存退出:wq)

#./deploy

#./nsdep 

 

兩台主機的authkeys必須統一

在test1執行

#sudo scp /etc/ha.d/authkeys  root@192.168.6.128:/etc/ha.d/

(root使用者不加sudo,下面不在贅述)

  

配置crm

在test1,test2分別執行

#sudo vi /etc/passwd

找到hacluster:x:498:498:heartbeat user:/var/lib/heartbeat/cores/hacluster: /sbin/nologin(基本上在最後一行)

把最後的/sbin/nologin改成/bin/bash

(修改完成儲存退出:wq)

#sudo passwd hacluster

密碼自己設,輸入兩遍。

#su hacluster

輸密碼

#crm_attribute --type crm_config--attr-name symmetric-cluster --attr-value true 

#crm_attribute --type crm_config--attr-name stonith-enabled --attr-value false

#crm_attribute --type rsc_defaults --nameresource-stickiness --update 100

 

(注意如果提示連不上什麼的錯誤,請先啟動heartbeat, #sudo service heartbeat start)

# exit

#vi ns.xml

…………

<instance_attributesid="ip-alias-instance_attributes">

       <nvpair id="ip-alias-instance_attributes-ip"name="ip" value="192.168.6.100"/>

       <nvpair id="ip-alias-instance_attributes-nic"name="nic" value="eth0:0"/>

     </instance_attributes>

     <operations>

…………..

 

<primitive class="ocf"id="tfs-name-server" provider="heartbeat"type="NameServer">

     <instance_attributesid="tfs-name-server-instance_attributes">

       <nvpair id="tfs-name-server-instance_attributes-basedir"name="basedir" value="這裡寫tfs的安裝路徑"/>

       <nvpair id="tfs-name-server-instance_attributes-nsip"name="nsip" value="192.168.6.129"/>(注意tes1寫192.168.6.129,test2寫192.168.6.128,其他標紅的地方也要根據主機實際情況寫。作者其他都是相同的)

       <nvpair id="tfs-name-server-instance_attributes-nsport"name="nsport" value="8108"/>

       <nvpair id="tfs-name-server-instance_attributes-user"name="user" value="啟動tfs的使用者名稱"/>

     </instance_attributes>


………………

(修改完成儲存退出:wq) 

#sudo cp ns.xml /var/lib/heartbeat/crm/

#sudo chown hacluster:haclient/var/lib/heartbeat/crm/ns.xml

#su hacluster

#cibadmin --replace --obj_type=resources--xml-file /var/lib/heartbeat/crm/ns.xml

#exit

#sudo service heartbeat start   (注意之前啟動過了就是restart)

 

驗證HA

啟動後需等待片刻或

# sudo tail -f /var/log/ha-log (即時查看,不想看了ctrl+c)

在test1,test2分別執行netstat –lntp

會發現只有一台主機有nameserver進程


在有此進程的主機上執行(換成你的進程號)

#sudo kill 49148

然後去另一台主機上執行(可能需要等幾秒)

#netstat –lntp

會發現nameserver啟動了。

說明當有一台主機的nameserver暴走,HA的另一台主機會啟動nameserver來保證tfs正常運作。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.