heartbeat+httpd 双机热备解决方案
来源:互联网 发布:淘宝返利怎么弄 编辑:程序博客网 时间:2024/05/22 10:55
Pre-Configuration Requirements
Assign hostname node01 to primary node with IP address 172.16.4.80 to eth0.
Assign hostname node02 to slave node with IP address 172.16.4.81.
on node01
#uname -n
must return node01.
On node02
#uname -n
must return node02.
172.16.4.82 is the virtual IP address that will be used for our Apache webserver
(i.e., Apache will listen on that address).
Configuration
1. Download and install the heartbeat package. In our case we are using CentOS so we will install heartbeat with yum:
#yum install heartbeat
or download these packages:
---------------------------
heartbeat-x.x
heartbeat-pils-x.x
heartbeat-stonith-x.x
----------------------------
2. Now we have to configure heartbeat on our two node cluster. We will deal with three files. These are:
authkeys
ha.cf
haresources
3. Now moving to our configuration. But there is one more thing to do, that is to copy these files to the /etc/ha.d directory. In our case we copy these files as given below:
#cp /usr/share/doc/heartbeat-x.x.x/authkeys /etc/ha.d/
#cp /usr/share/doc/heartbeat-x.x.x/ha.cf /etc/ha.d/
#cp /usr/share/doc/heartbeat-x.x.x/haresources /etc/ha.d/
4. Now let's start configuring heartbeat. First we will deal with the authkeys file, we will use authentication method 2 (sha1). For this we will make changes in the authkeys file as below.
#vi /etc/ha.d/authkeys
Then add the following lines:
-------------------------------------------------
auth 2
2 sha1 test-ha
-------------------------------------------------
Change the permission of the authkeys file:
#chmod 600 /etc/ha.d/authkeys
5. Moving to our second file (ha.cf) which is the most important. So edit the ha.cf file with vi:
#vi /etc/ha.d/ha.cf
Add the following lines in the ha.cf file:
----------------------------
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
initdead 120
bcast eth0
udpport 694
auto_failback on
node node01
node node02
----------------------------
Note: node01 and node02 is the output generated by
#uname -n
6. The final piece of work in our configuration is to edit the haresources file. This file contains the information about resources which we want to highly enable. In our case we want the webserver (httpd) highly available:
#vi /etc/ha.d/haresources
Add the following line:
--------------------------------
node01 IPaddr::172.16.4.82/24/eth0:0 httpd
--------------------------------
7. Copy the /etc/ha.d/ directory from node01 to node02:
#scp -r /etc/ha.d/ root@node02:/etc/
8. As we want httpd highly enabled let's start configuring httpd:
#vi /etc/httpd/conf/httpd.conf
Add this line in httpd.conf:
----------------------
Listen 172.16.4.82:80
----------------------
9. Copy the /etc/httpd/conf/httpd.conf file to node02:
#scp /etc/httpd/conf/httpd.conf root@node02:/etc/httpd/conf/
10. Create the file index.html on both nodes (node01 & node02):
On node01:
#echo "node01 apache test server" > /var/www/html/index.html
On node02:
#echo "node02 apache test server" > /var/www/html/index.html
11. Now start heartbeat on the primary node01 and slave node02:
#/etc/init.d/heartbeat start
12. Open web-browser and type in the URL:
http://172.16.4.82
It will show node01 apache test server.
13. Now stop the hearbeat daemon on node01:
#/etc/init.d/heartbeat stop
In your browser type in the URL http://172.16.4.82 and press enter.
It will show node02 apache test server.
14. We don't need to create a virtual network interface and assign an IP address (172.16.4.82) to it. Heartbeat will do this for you, and start the service (httpd) itself. So don't worry about this.
Don't use the IP addresses 172.16.4.80 and 172.16.4.81 for services. These addresses are used by heartbeat for communication between node01 and node02. When any of them will be used for services/resources, it will disturb hearbeat and will not work. Be carefull!!!
Assign hostname node01 to primary node with IP address 172.16.4.80 to eth0.
Assign hostname node02 to slave node with IP address 172.16.4.81.
on node01
#uname -n
must return node01.
On node02
#uname -n
must return node02.
172.16.4.82 is the virtual IP address that will be used for our Apache webserver
(i.e., Apache will listen on that address).
Configuration
1. Download and install the heartbeat package. In our case we are using CentOS so we will install heartbeat with yum:
#yum install heartbeat
or download these packages:
---------------------------
heartbeat-x.x
heartbeat-pils-x.x
heartbeat-stonith-x.x
----------------------------
2. Now we have to configure heartbeat on our two node cluster. We will deal with three files. These are:
authkeys
ha.cf
haresources
3. Now moving to our configuration. But there is one more thing to do, that is to copy these files to the /etc/ha.d directory. In our case we copy these files as given below:
#cp /usr/share/doc/heartbeat-x.x.x/authkeys /etc/ha.d/
#cp /usr/share/doc/heartbeat-x.x.x/ha.cf /etc/ha.d/
#cp /usr/share/doc/heartbeat-x.x.x/haresources /etc/ha.d/
4. Now let's start configuring heartbeat. First we will deal with the authkeys file, we will use authentication method 2 (sha1). For this we will make changes in the authkeys file as below.
#vi /etc/ha.d/authkeys
Then add the following lines:
-------------------------------------------------
auth 2
2 sha1 test-ha
-------------------------------------------------
Change the permission of the authkeys file:
#chmod 600 /etc/ha.d/authkeys
5. Moving to our second file (ha.cf) which is the most important. So edit the ha.cf file with vi:
#vi /etc/ha.d/ha.cf
Add the following lines in the ha.cf file:
----------------------------
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
initdead 120
bcast eth0
udpport 694
auto_failback on
node node01
node node02
----------------------------
Note: node01 and node02 is the output generated by
#uname -n
6. The final piece of work in our configuration is to edit the haresources file. This file contains the information about resources which we want to highly enable. In our case we want the webserver (httpd) highly available:
#vi /etc/ha.d/haresources
Add the following line:
--------------------------------
node01 IPaddr::172.16.4.82/24/eth0:0 httpd
--------------------------------
7. Copy the /etc/ha.d/ directory from node01 to node02:
#scp -r /etc/ha.d/ root@node02:/etc/
8. As we want httpd highly enabled let's start configuring httpd:
#vi /etc/httpd/conf/httpd.conf
Add this line in httpd.conf:
----------------------
Listen 172.16.4.82:80
----------------------
9. Copy the /etc/httpd/conf/httpd.conf file to node02:
#scp /etc/httpd/conf/httpd.conf root@node02:/etc/httpd/conf/
10. Create the file index.html on both nodes (node01 & node02):
On node01:
#echo "node01 apache test server" > /var/www/html/index.html
On node02:
#echo "node02 apache test server" > /var/www/html/index.html
11. Now start heartbeat on the primary node01 and slave node02:
#/etc/init.d/heartbeat start
12. Open web-browser and type in the URL:
http://172.16.4.82
It will show node01 apache test server.
13. Now stop the hearbeat daemon on node01:
#/etc/init.d/heartbeat stop
In your browser type in the URL http://172.16.4.82 and press enter.
It will show node02 apache test server.
14. We don't need to create a virtual network interface and assign an IP address (172.16.4.82) to it. Heartbeat will do this for you, and start the service (httpd) itself. So don't worry about this.
Don't use the IP addresses 172.16.4.80 and 172.16.4.81 for services. These addresses are used by heartbeat for communication between node01 and node02. When any of them will be used for services/resources, it will disturb hearbeat and will not work. Be carefull!!!
0 0
- heartbeat+httpd 双机热备解决方案
- linux 双机热备 Heartbeat
- RedHat AS4 + HeartBeat 双机热备方案
- linux下的heartbeat 双机热备
- HA双机热备的实现(heartbeat)
- Heartbeat做apache双机热备
- HA双机热备的实现(heartbeat)
- 使用Heartbeat实现双机热备
- ipvsadm heartbeat 双机热备 Ubuntu
- 双机热备解决方案
- CentOS7,keepalived+ httpd 搭建双机热备
- 双机热备解决方案--思路
- 服务器双机热备解决方案
- 利用 HeartBeat 实现双机热备的网关接入
- linux上的 heartbeat 双机热备服务架设
- linux上的 heartbeat 双机热备服务架设
- 在linux系统用heartbeat实现双机热备
- CENTOS中heartbeat加mon实现双机热备
- 关于Cannot send session cache limiter - headers already sent错误解决方法
- 趣谈算法 --- 从程序猿把妹说起
- 搭建maven android 项目环境
- centos 将python升级到2.7
- js-jQuery对象与dom对象相互转换
- heartbeat+httpd 双机热备解决方案
- POJ 1949
- jQuery 选择器大全
- Binary Tree Inorder Traversal (Java)
- 第三方集成那些事 - 吐槽篇
- 如何隐藏table的左/右/上/下边框
- CCS+C6678LE开发记录05:编译并使用开源JPEG图像(解)压缩库libjpeg
- Phonegap解决错误:Error initializing Cordova:Class not found
- PHP反射机制实现动态代理的代码