Use Heartbeat V1 to achieve high availability of nfs as shared storage

Source: Internet
Author: User

High Availability is divided into three layers:

1. Implementation of the underlying information layer:
Heartbeat
Corosync
Cman
2. Resource Management, implementation method:
Heartbeat-V1: haresource
Heartbeat-V2: crm
Heartbeat-V3: pacemaker
RHCS: rgmanager
Note: Resource Manager pacemaker can be used in combination with all underlying communication implementation methods.
3. Resource proxy layer, implementation method:
Heartbeat-v1
LSB
OCF
STONITH


To achieve high availability, You need to configure the following content:
1. Resources:
Primitive (or native): primary resource, the basis of all other resources, that is, to configure other types of resources, you must first have primary resources.
Group: group resources
MS: Master/Slave Resources
Clone: clone Resources
2. constraints:
Location: location constraints, for nodes.
Colocation: Arrangement constraints for resources.
Order: order constraint.

3. If there are two (even) nodes, You need to configure ping node or quorum disk.

Environment:
System: CentOS 6.5
High-availability node: node1: 192.168.0.11
Node2: 192.168.0.12
Shared storage node: node3: 192.168.0.13

Heartbeat configuration file:
Configuration File Path:/etc/ha. d/
Configuration File: 1. authkeys (V1, V2, V3): used to configure authentication methods between cluster nodes.
2. ha. cf (V1, V2, V3): Master configuration file.
3. haresource (V1): used to configure and manage cluster resources.
/Var/lib/heartbeat/crm/cib. xml (V2)
Note: The preceding three configuration files must be copied from the/usr/shared/doc/heartbeat-2.1.4/directory to the configuration file path.

1. Configure shared storage on node3
1. Create a shared directory
Mkdir/mysqldata
2. Export the shared directory and configure/etc/exports as follows:
/Mysqldata192.168.0.0/24 (rw, no_root_squash)
3. Start the nfs service
Service nfs start
4. Create a mysql user
Useradd-r-u 306 mysql
Note: This user is used for mysql users on node1 and node2 nodes to perform write operations.

 


2. Configure node1 and node2 as follows:
Heartbeat V1:

Steps:
1. Configure authkeys as follows:
Auth 2 # specify which authentication method to use. The authentication method has three types of crc, sha1, and md5. Number 2, indicating that the second method is used. 2 sha1 51aefbc42e9976fe # A string following a random number is used as the authentication information.
2. Modify the authkeys permission to 600.
Chmod 600 authkeys
3. Modified ha. cf. the following items:
Logfile/var/log/ha-log
Keepalive 1 # used to set the interval for sending heartbeat information
Deadtime 30 # It is used to set how long the host will not receive the heartbeat information, and the host will be considered dead.
Warntime 10 # It is used to set how long the Heartbeat message is not received, and an alarm is triggered.
Initdead 120 # Sometimes the network startup may be delayed after the machine is restarted or just started, so it takes a longer time.
Mcast eth0 225.10.10.100 694 1 0 # defines the multicast address and the port for sending heartbeat information.
Auto_failback on
Node node1
Node node2
Ping 192.168.0.200
Compression bz2
Compression_threshold 2

4. Configure haresource as follows:
Node1 192.168.0.100/24/eth0 Filesystem: 192.168.0.13:/mysqldata:/mydata: nfs mysqld

5. Add a mysql user
Useradd-r-u 306 mysql

6. install and configure mysql
1. tar mysql-5.5.33-linux2.6-x86_64.tar.gz-C/usr/local/
2. cd/usr/local/
3. ln-sv mysql-5.5.33-linux2.6-x86_64 mysql
4. cd mysql
5. chown-R root. mysql.
6. mkdir/mydata
7. mount-t nfs 192.168.0.13:/mysqldata/mydata
8. mkdir/mydata/data
9. chown-R mysql. mysql/mydata/data
10 ../scripts/mysql_install_db -- user = mysql -- datadir =/mydata/data
12. cp support-files/my-huge.cnf/etc/my. cnf
13. cp support-files/mysql. server/etc/rc. d/init. d/mysqld
14. Modify/etc/my. cnf and add the following two items in the mysqld area:
Datadir =/mydata/data
Innodb_file_per_table = 1
15. chkconfig mysqld off
16. service mysqld start
17. Enter mysql and add the test account
Grant all on test. * TO 'root' @ '%' identified by '123 ';
Iii. Test
1. Use mysql connection on node3
Mysql-uroot-p123-h 192.168.0.100
2. Create a table in the database test for testing.
Create table mytest (id int );
3. Use the hb_standby script to convert node1 to a slave node.
/Usr/lib64/heartbeat/hb_standby
4. Check whether the table mytest exists again.

Note: heartbeat V1 cannot monitor resources. Therefore, third-party software is required.

Recommended reading:

Heartbeat for Linux high availability (HA) Cluster Based on crm

Heartbeat + httpd + NFS for highly available Web Servers

Heartbeat for Linux high availability (HA) CLUSTERS

Heartbeat CRM configuration for Linux high availability solution

High-availability cluster Heartbeat v1 instance

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.