HA Configuration of Linux architectures

Source: Internet
Author: User

Brief introduction

By installing the Linux-ha software, we can realize the high availability solution of the Linux dual-machine system, realize the hot backup of the dual-machine system, and be able to switch seamlessly between the two machines, thus external

Provide stable and reliable service, and finally realize the System High performance RAS (reliability, availability, and serviceability).

Experimental environment

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/8C/78/wKioL1ht48KxNpH7AAHvvrDzldU315.png-wh_500x0-wm_3 -wmp_4-s_4023506461.png "title=" unnamed picture. png "alt=" wkiol1ht48kxnph7aahvvrdzldu315.png-wh_50 "/>

Here the heartbeat is used to do the HA cluster, and the Nginx service is served as the HA counterpart.


chumjtest01 eth0 172.31.24.199  eth0:1   192.168.1.109 vip: 172.31.24.202
Chumjtest02 Eth0 172.31.24.200 Eth0:1 192.168.1.110 VIP: 172.31.24.202

Lab Prep work

1. Edit and modify the Hosts file to add the IP of two servers

2. Close the firewall iptables-f;
Close Selinux:setenforce 0

3. Install the EPRL, install the heartbeat, libnet

Master configuration

[[email protected] ~]# Cd/usr/share/doc/heartbeat-3.0.4/[[email protected] heartbeat-3.0.4]# CP Authkeys HA.CF Haresour Ces/etc/ha.d/[[email protected] heartbeat-3.0.4]# cd/etc/ha.d/[[email protected] ha.d]# Lsauthkeys ha.cf harc Hares           Ources rc.d readme.config resource.d shellfuncs[[email protected] ha.d]# vim Authkeys//authkeys is verified master-slave auth 3      Option 3 Use MD5 to verify # crc#2 SHA1 hi!3 MD5 hello! Remove the # sign to open MD5 to verify [[email protected] ha.d]# chmod Authkeys//give root read and write permissions.


Configure VIP

[[email protected] ha.d]# cd /etc/sysconfig/network-scripts/[[email protected]  network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1  //Create a new IP profile, the same NIC can be configured with multiple ip[[email  protected] network-scripts]# vim ifcfg-eth0:1    //Edit Vipdevice=eth0:1type= ethernetonboot=yesnm_controlled=yesbootproto=noneipaddr=172.31.24.202    //change the IP address to the VIP address, Remove some of the content you don't want. prefix=24#gateway=172.31.24.1defroute=yes[[email protected] network-scripts]# service  network restart    //Restart the Network service shutting down interface eth0:                                [  ok  ]shutting down  loopback interface:                            [  ok  ]bringing up  loopback interface:                             [  ok   ]bringing up interface eth0:  determining if ip address  172.31.24.199 is already in use for device eth0 ... Determining if ip address 172.31.24.198 is already in use for  device eth0...                                                               [  OK  ] [[email protected] network-scripts]# ifconfig     //can see that the VIP NIC has been shown eth0       Link encap:Ethernet  HWaddr 00:50:56:B3:79:E3             inet addr:172.31.24.199   bcast:172.31.24.255  mask:255.255.255.0           inet6 addr: fe80::250:56ff:feb3:79e3/64 scope:link           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1           RX packets:22 errors:0 dropped:0  overruns:0 frame:0          tx packets:24  Errors:0 dropped:0 overruns:0 carrier:0         &nBsp;collisions:0 txqueuelen:1000           rx  bytes:2130  (2.0 kib)   TX bytes:3428  (3.3 kib) eth0:1     Link encap:Ethernet  HWaddr 00:50:56:B3:79:E3             inet addr:172.31.24.198  Bcast:172.31.24.255   Mask:255.255.255.0          up broadcast running  multicast  mtu:1500  metric:1lo        link  encap:local loopback            inet  addr:127.0.0.1  Mask:255.0.0.0           Inet6 addr: ::1/128 scope:host          up  loopback running &nbsp mtu:16436  metric:1          rx packets:0  errors:0 dropped:0 overruns:0 frame:0           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:0            RX bytes:0  (0.0 b)   TX bytes:0  (0.0 b)


Configure node files

[Email protected]/]# cd/etc/ha.d/[[email protected] ha.d]# vim haresources#node1 10.0.0.170 filesystem::/dev/sda1::/d ata1::ext2chumjtest01 172.31.24.198:/24/eth0:0 nginx//Add host name, VIP and services that require clustering


Configuring the HA configuration file

[Email protected] ha.d]# vim ha.cfdebugfile/var/log/ha-debug logfile/var/log/ha-loglogfacility local0keepalive 2deadtime 30warntime 10initdead 60udpport 694ucast eth0 172.31.24.200//each other's IP address auto_failback onnode chumjtest01/ /node1 Address node chumjtest02//node2 address ping 172.31.24.1//quorum address, general with router or switch respawn hacluster/usr/lib64/heartbeat/i Pfail


From the machine configuration

Copy the configuration file on the host computer to the slave

[[email protected] HA.D]SCP Authkeys ha.cf haresources chumjtest02:/etc/ha.d/just modify VI/ETC/HA.D/HA.CF//only need to change one place ucast et H1 172.31.24.200 Change to Ucast eth1 172.31.24.199


Start Heartbeat

Start the master first, start from the

Host boot situation:

[Email protected] ha.d]# service heartbeat startstarting high-availability Services:INFO:Resource is stoppeddone.

Check if the Nginx service has started.

[[email protected] ha.d]# ps aux |grep nginxroot       6989  0.0  0.0 109336  2036 ?         ss   17:40   0:00 nginx: master process / usr/sbin/nginx -c /etc/nginx/nginx.confnginx     6990  0.0   0.0 109760  2704 ?        S     17:40   0:00 nginx: worker process                    nginx      6991  0.0  0.0 109760  2756 ?         S    17:40   0:00 nginx: worker  Process                   root       6995  0.0  0.0 103252   824 pts/1     s+   17:41   0:00 grep nginx


Slave Boot Condition:

[Email protected] ha.d]# service heartbeat startstarting high-availability Services:INFO:Resource is stoppeddone.

Test

Write a simple HTML file under the Nginx of the host, and access the next

[[email protected]/]# cd/usr/share/nginx/html[[email protected] html]# vim 1.htmlchumjtest01[[email protected] ha.d]# C URL http://172.31.24.199/1.html//test display chumjtest01chumjtest01

Also write a simple HTML file on the slave machine

[[email protected] html]# vim 1.htmlchumjtest02[[email protected] html]# Curl http://172.31.24.200/1.html//webpage cannot be displayed, description ng Inx didn't start <!. DOCTYPE HTML public '-//ietf//dtd HTML 2.0//en ' >

Under test VIP access, instructions now running on Nginx on the host

[Email protected] ha.d]# Curl http://172.31.24.202/1.htmlchumjtest01

Turn on the firewall and disable ping on the host

[Email protected] html]# iptables-i input-p icmp-j DROP

View host chumjtest01 ha logs, see "We are Dead", indicating that the host thinks that he is dead, to be cut off the machine

Jan 13:55:29 chumjtest01 ipfail: [21826]: Info:NS:We is dead. :<

View the HA logs from the machine chumjtest02, boot Ngix from the machine.

ResourceManager (default) [3176]: 2017/01/05_13:55:44 info:running/etc/init.d/nginx start

Under the access VIP's address, has switched to from the machine up.

[Email protected] html]# Curl http://172.31.24.202/1.htmlchumjtest02

Note:

Heartbeat Log in /var/log/ha-log, If there is a problem with startup, try to view the log.


1.error:client child command [/usr/lib/heartbeat/ipfail] was not executable

Description of the 64-bit system, to be under HA.CF/usr/lib64/heartbeat/ipfail


2.error:illegal directive [node] In/etc/ha.d//ha.cf

Ucast eth0 172.31.24.200 to notice if the network port matches under HA.CF

This article is from the "first. com" blog, make sure to keep this source http://jimac.blog.51cto.com/401206/1889279

HA Configuration of Linux architectures

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.