Ha-web-services Experiment

Source: Internet
Author: User
Tags node server

One, HA deployment

The program selection for this experiment is heartbeat v2 + hearesources. Resources have IP and Httpd,filesystem not included.

Prerequisites for configuring an HA cluster:

(1) Consistent resources of each node, hardware or software environment

(2) The time of each node is consistent to facilitate heartbeat transmission, using the NTP protocol to achieve

#使用ntpdate命令同步时间, and set up a recurring task # can use any node server as an NTP time server, such as each node can be on the public network, you can directly specify the public network NTP server 1, installation ntp[[email protected] ~]#  yum install -y ntp[[email protected] ~]# vim /etc/ntp.conf             #修改配置文件允许本网段客户端获取地址将下面的语句restrict  default  kod nomodify notrap nopeer noquery modified to restrict default nomodify  restrict 192.168.0.0 mask 255.255.255.0 nomodify[[email protected] ~]#  service ntpd startstarting ntpd:                                               [   ok  ] View the synchronization process [[email protected] ~]# ntpq -p      Remote           refid      st t when poll  reach   delay   offset  jitter======================================== ======================================*202.118.1.81    202.118.1.47      2 u   30   64    1   92.249     8.602   0.714 202.112.31.197  . init.          16 u    -    64    0    0.000    0.000    0.0002, client creation cycle task, sync time every 3 seconds [[email protected] ~]# crontab -e*/3 * * *  * /usr/sbin/ntpdate 192.168.0.16 &> /dev/null[[email protected] ~]#  service crond start# manual synchronization is successful because NTP is generally automatic, manually kill all NTP processes before killing [[email protected] ~]# ntpdate 192.168.0.1614 nov 20:26:09  NTPDATE[3786]: ADJUST TIME SERVER 192.168.0.16 OFFSET -0.004440 SEC3, Time synchronization [[email protected] ~]# date; ssh 192.168.0.15  ' date ' Mon Nov 14  20:36:17 cst 2016[email protected] ' s password: mon nov 14  20:36:20 cst 2016

(3) Between nodes need to communicate with each other through the host name, must resolve the host to the IP address

(a) The recommended name resolution feature uses the hosts file to implement

(b) The name used in the communication must be consistent with the name of the node "uname-n" or hostname display

[Email protected] ~]# vim/etc/hosts192.168.0.15 centfils192.168.0.16 jymlinux

(4) about the quorum device (shared hard disk or gateway), if there are even several nodes, such as 2, should enable the quorum device, odd number does not need to be enabled, large even can also without the quorum device

(5) Configure the root user between each node to give the key authentication

1. Generate Key Pair [[email protected] ~]# ssh-keygen -t rsagenerating public/private  Rsa key pair. enter file in which to save the key  (/ROOT/.SSH/ID_RSA):  Enter  passphrase  (empty for no passphrase): enter same passphrase  Again: your identification has been saved in /root/.ssh/id_rsa. your public key has been saved in /root/.ssh/id_rsa.pub.the key  Fingerprint is:a8:ad:2c:23:83:60:ff:36:73:9d:09:24:37:ae:da:c9 [email protected]the key ' s  RANDOMART IMAGE IS:+--[ RSA 2048]----+|                  | |                  | |                  | |      . =         | |       * s        | |.    o o         | | + . . o o o      | | + ooo*.  +       | |  o +*e+          |+-----------------+ 2, Transfer the public key to the home directory of the remote server corresponding to the user [[Email protected] ~]# ssh-copy-id -i .ssh/id_rsa.pub [email  protected]The authenticity of host  ' 192.168.0.16  (192.168.0.16) '  can ' t  be established. rsa key fingerprint is e5:84:6c:f7:c0:60:3d:0b:39:b6:1e:12:0d:48:8b:07.are you  sure you want to continue connecting  (yes/no)?  yeswarning: permanently added  ' 192.168.0.16 '   (RSA)  to the list of known hosts. [email protected] ' s password: now try logging into the machine,  with  "ssh  ' [email protected] '",  and check in:  .ssh/authorized_keysto  make sure we haven ' T added extra keys that you weren ' t  expecting.3, Test [[email protected] ~]# date; ssh [email protected]  ' Date ' mon nov 14 21:02:30 cst 2016mon nov 14 21:02:30 cst  2016

(6) Resources defined as clusters are not powered on, but are managed by CRM

Configuration list:

node1:192.168.0.15

node2:192.168.0.16

fip:192.168.0.17


Second, installation Heartbeat

Because heartbeat, Red Hat and CentOS officially do not provide rpm, so download and install the Epel package first

[Email protected] ~]# wget [[email protected] ~]# RPM-IVH epel-release-6-8.noarch.rpm [[email protected] ~]# Yum Install heartbeat* #安装依赖包 [[email protected] ~]# Yum install libnet

The heartbeat configuration file is in the/ETC/HA.D directory, and its primary configuration file is HA.CF, which defines the basic properties of the heartbeat HA cluster on each node. Authkeys configuration file, the encryption algorithm and key used to pass messages to each other within the cluster.

Haresources, configure the interface for the resource manager provided by Heartbeat V1, dedicated to the V1 version.

#将配置文件模板复制到/ETC/HA.D directory [[email protected] ha.d]# Cp/usr/share/doc/heartbeat-3.0.4/{ha.cf,haresources,authkeys}/ etc/ha.d/
#节点间认证配置文件权限必须为400 [[email protected] ha.d]# chmod Authkeys


Third, configuration Hea rtbeat

1. Configure the Authkeys file to indicate what algorithm is enabled and what key to use #auth 1#1 crc2 sha1 dpcdbsaie31fz6d5mhm0/a#3 md5  Hello! generates a random string as a key [[email protected] ha.d]# openssl rand -base64  16dpcdbsaie31fz6d5mhm0/a==2, configuring HA.CF files, defining the basic way to work with highly available clusters define the log file location (optional)  logfacility for logging to syslog management       logfile        /var/log/ha-log#logfacility      local0 how long to send a heartbeat message, the default is 2 seconds #keepalive 2 how long to announce a node died, default 30 seconds #deadtime  30 how long to warn the other side of the heartbeat information is delayed, the default 10 seconds #warntime 10 the first time to die, to avoid network problems caused by death #initdead 120 use the udp694 port to pass the heartbeat, and choose which way to pass the heartbeat # udpport        694 Serial cable transfer heartbeat #serial /dev/ttys0       # linux#serial /dev/cuaa0      # freebsd#serial  /dev/cuad0      # FreeBSD 6.x#serial /dev/cua/a       # solaris the operating frequency of the serial cable #baud   19200 Broadcast pass Heartbeat #bcast  eth0             # linux#bcast  eth1 eth2       # linux #bcast   le0             #  solaris#bcast  le1 le2         #  Solaris Multicast delivery heartbeat, NIC must support multicast, ifconfig | grep multicastmcast eth0 225.0.0.1 694 1  0           #端口694, TTL of 1, do not allow backhaul for 0# enable NIC support Multicast [[email  Protected] ~]# ip link set eth0 multicast on Thin Pass the heartbeat #ucast eth0  192.168.1.2 Automatic fault back auto_failback on indicates node #node   ken3#node   kathynode     centfilsnode    jymlinux indicates that the gateway is a Ping node device (quorum device) #ping   10.10.10.254ping 192.168.0.1 indicates that a group is ping&Nbsp;node device (quorum device) #ping_group  group1 10.10.10.254 10.10.10.253 indicates the compression algorithm that transmits between nodes compression      BZ2 indicates that the minimum data to transmit data compression between nodes is 2kbcompression_threshold 2
3, configure the Haresources file, define the cluster resources directly into the resources Centfils 192.168.0.17/24/eth0/192.168.0.255 httpd
4, set httpd to boot does not start [[email protected] ~]# chkconfig httpd off
5. Start service [[email protected] ~]# service heartbeat start


Iv. Testing

After starting the service, the browser enters fip192.168.0.17 access, down 192.168.0.15, then appears

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/8A/2E/wKiom1gp19-gRZZZAAAh4NCiUr0228.png "title=" Qq20161114232514.png "alt=" Wkiom1gp19-grzzzaaah4nciur0228.png "/>


Test success




This article with Marco to make, for note form, for later look, forgive me! Excuse me!

This article is from the "Linux Sailing" blog, make sure to keep this source http://jiayimeng.blog.51cto.com/10604001/1872759

Ha-web-services Experiment

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.