Thứ Sáu, 19 tháng 6, 2015

HA (High Avaibility) trong Linux với Heartbeat


  1. Yêu cầu cài đặt
Cài đặt phần mềm:
  • heartbeat-2.1.4-11.el5
  • heartbeat-pils-2.1.4-11.el5
  • heartbeat-stonith-2.1.4-11.el5
  • libnet-1.1.5-1.el5
  1. Điều kiện đảm bảo
Quy hoạch IP trên server:


Mailbox1
Mailbox2
Mailbox3
Mailbox4
DCN
10.x.x.136
10.x.x.137
10.x.x.138
10.x.x.139
VIP
10.x.x.154
10.x.x.155


  1. Hướng dẫn cài đặt
  1. Cài đặt các gói bổ sung
  • Openhpi-libs
  • Libltdl3-1.5.26
  • Glibc-2.14.1-14.28.3
  • Openssl098e-0.9.8e-18.el6_5.2
  1. Cài đặt các gói của phần mềm
  • Heartbeat-2.1.4-11.el5
  • Heartbeat-pils-2.1.4-11.el5
  • Heartbeat-stonith-2.1.4-11.el5
  • Libnet-1.1.5-1.el5
  1. Cấu hình
  1. Mailbox 1 và Mailbox 2
  • Tạo file authkeys trong thư mục /etc/ha.d/
auth 1 #Chọn cơ chế xác thực số 1 được mô tả bên dưới
1 sha1 Company@123 #Cơ chế 1: Xác thực sử dụng SHA1 với passkey là Company@123
  • Tạo file ha.cf trong thư mục /etc/ha.d/
debugfile /var/log/ha-debug #Ghi các thông tin debug vào /var/log/ha-debug
logfile /var/log/ha-log #Ghi log hoạt động của cluster vào /var/log/ha-log
logfacility local0 #Mô tả loại facility khi sử dụng cùng với syslog
keepalive 3 #Tần suất gửi heartbeat giữa các node (3 giây một lần)
deadtime 15 #Thời gian chờ để xác nhận một host đã chết (15 giây)
initdead 20 #Thời gian xác nhận một host đã chết khi mới khởi động
udpport 693 #Port sử dụng để gửi heartbeat
bcast bond0 #Interface sẽ sử dụng để gửi heartbeat
auto_failback on #Có tự động failback dịch vụ hay không
node mailbox1.viettel.com.vn #Liệt kê các node có trong môi trường cluster
node mailbox2.viettel.com.vn
  • Tạo file haresources trong thư mục /etc/ha.d/
mailbox1.test.com.vn IPaddr::10.x.x.154 drbddisk::r0 Filesystem::/dev/drbd0::/opt::ext4 zimbra
  • Tạo script zimbra trong thư mục /etc/ha.d/resource.d
#!/bin/sh
# -q quiet
# -c nb of pings to perform


ping -q -c5 10.x.x.154 > /dev/null


if [ $? -eq 0 ]
then
su - zimbra -c '/opt/zimbra/bin/zmcontrol restart'
echo "ok"
else
echo "not ok"
fi


  1. Mailbox 3 và Mailbox 4
  • Tạo file authkeys trong thư mục /etc/ha.d/
auth 1 #Chọn cơ chế xác thực số 1 được mô tả bên dưới
1 sha1 Company@123 #Cơ chế 1: Xác thực sử dụng SHA1 với passkey là Company@123
  • Tạo file ha.cf trong thư mục /etc/ha.d/
debugfile /var/log/ha-debug #Ghi các thông tin debug vào /var/log/ha-debug
logfile /var/log/ha-log #Ghi log hoạt động của cluster vào /var/log/ha-log
logfacility local0 #Mô tả loại facility khi sử dụng cùng với syslog
keepalive 3 #Tần suất gửi heartbeat giữa các node (3 giây một lần)
deadtime 15 #Thời gian chờ để xác nhận một host đã chết (15 giây)
initdead 20 #Thời gian xác nhận một host đã chết khi mới khởi động
udpport 694 #Port sử dụng để gửi heartbeat
bcast bond0 #Interface sẽ sử dụng để gửi heartbeat
auto_failback on #Có tự động failback dịch vụ hay không
node mailbox3.test.com.vn #Liệt kê các node có trong môi trường cluster
node mailbox4.test.com.vn
  • Tạo file haresources trong thư mục /etc/ha.d/
mailbox3.test.com.vn IPaddr::10.30.182.155 drbddisk::r0 Filesystem::/dev/drbd0::/opt::ext4 zimbra
  • Tạo script zimbra trong thư mục /etc/ha.d/resource.d
#!/bin/sh
# -q quiet
# -c nb of pings to perform


ping -q -c5 10.x.x.154 > /dev/null


if [ $? -eq 0 ]
then
su - zimbra -c '/opt/zimbra/bin/zmcontrol restart'
echo "ok"
else
echo "not ok"
fi
  1. Kiểm tra trạng thái
  1. Trên mailbox 1
[root@mailbox1 resource.d]# /etc/init.d/heartbeat status
heartbeat OK [pid 7801 et al] is running on mailbox1.test.com.vn [mailbox1.test.com.vn]...
  1. Check Log mailbox1( /var/log/ha-log )
heartbeat[30991]: 2015/05/05_07:36:27 info: Daily informational memory statistics
heartbeat[30991]: 2015/05/05_07:36:27 info: MSG stats: 6/1036889 ms age 0 [pid30991/MST_CONTROL]
heartbeat[30991]: 2015/05/05_07:36:27 info: cl_malloc stats: 559/33915278 88708/44950 [pid30991/MST_CONTROL]
heartbeat[30991]: 2015/05/05_07:36:27 info: RealMalloc stats: 150320 total malloc bytes. pid [30991/MST_CONTROL]
heartbeat[30991]: 2015/05/05_07:36:27 info: Current arena value: 0
heartbeat[30991]: 2015/05/05_07:36:27 info: MSG stats: 0/1 ms age 863912370 [pid31008/HBFIFO]
heartbeat[30991]: 2015/05/05_07:36:27 info: cl_malloc stats: 324/381 46768/23720 [pid31008/HBFIFO]
heartbeat[30991]: 2015/05/05_07:36:27 info: RealMalloc stats: 49840 total malloc bytes. pid [31008/HBFIFO]
heartbeat[30991]: 2015/05/05_07:36:27 info: Current arena value: 0
heartbeat[30991]: 2015/05/05_07:36:27 info: MSG stats: 0/0 ms age 5298032160 [pid31009/HBWRITE]
heartbeat[30991]: 2015/05/05_07:36:27 info: cl_malloc stats: 341/367583 49612/25512 [pid31009/HBWRITE]
heartbeat[30991]: 2015/05/05_07:36:27 info: RealMalloc stats: 59380 total malloc bytes. pid [31009/HBWRITE]
heartbeat[30991]: 2015/05/05_07:36:27 info: Current arena value: 0
heartbeat[30991]: 2015/05/05_07:36:27 info: MSG stats: 0/0 ms age 5298032160 [pid31010/HBREAD]
heartbeat[30991]: 2015/05/05_07:36:27 info: cl_malloc stats: 344/1382900 50016/25718 [pid31010/HBREAD]
heartbeat[30991]: 2015/05/05_07:36:27 info: RealMalloc stats: 51984 total malloc bytes. pid [31010/HBREAD]
heartbeat[30991]: 2015/05/05_07:36:27 info: Current arena value: 0
heartbeat[30991]: 2015/05/05_07:36:27 info: These are nothing to worry about.

Không có nhận xét nào:

Đăng nhận xét