LAMP, based on HeartBeat V2 CRM


Experimental environment:

Virtual machine ha1: 192.168.61.130

Virtual machine ha2: 192.168.61.132

< span style="font-size:14px;font-family:'宋体';"> Virtual machine nfsserver: 192.168.61.136

vip:192.168.61.100

Purpose:

Use heartbeat V2 crm(hb_gui)to achieve high availability of lamp+nfs+wordpress.(hb_gui) span>

In order to facilitate the experiment, the lamp environment Configure directly with yum, and remount the configured mysql database storage location to nfs

Notes:

(a). The time between nodes must be synchronized: usentpprotocol implementation;< /p>

Server/etc/ntp .confFor reference:

driftfile /var/lib/ntp/drift

restrict-6 def ault kod nomodify notrap nopeer noquery

restrict restrict 127.0.0.1 p>

restrict -6 ::1

restrict 192.168.61.0 mask 255.255.255.0 nomodify

restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap noquery notrust

server 127.127.1.0

fudge 127.127.1.0 stratum 8

server 220.130.158.71 prefer

server 220.130.158.51

< span style="font-size:14px;"> includefile /etc/n tp/crypto/pw

keys /etc/ntp/keys

Note: You must wait after setting the restart service10-15try to sync again in minutes, command:ntpdata Host name,Compare the two

Whether the machine time is synchronized command:data;ssh 192.168.61.130’data’

(b). Nodes need to communicate with each other through host names, which must be resolved Host toIPAddress;

(1) It is recommended to use the name resolution functionhostsfile to achieve;

(2) The name used in the communication must be consistent with the node name: “uname -n” command, or “hostname“The displayed name

Keep the same;< /span>

(c) .Establish root between each nodeUsers can authenticate based on key;

# ssh-keygen -t rsa -P”

#ssh-copy-id -i /root/.ssh/id_rsa.pub root@HOSTNAME

p>

< span style="font-size:14px;">

(d) .Be sure to close SELINUX and clear iptables

Note: Defined as a resource in the cluster service, it must not be automatically started after booting; because They will be composed ofcrmManage;

nfsserverSet up shared storage

1. Create a mysql database Storage directory:

Mkdir /mysqldata

mkdir /wordpress< /span>

2. Release:< /p>

vim /etc/exports add

/mysqldata192.168.61.0/24(rw,no_root_sqlash)

/wordpress192.168.61.0/24(rw ,no_root_sqlash)

3. Start nfs:

service nfs start< /p>

ha1Configuration< /strong>

1. yum -y install php php-mysqlmysql-server mysql

< p style="margin-left:28px;">

PHP configuration file after installation (php installed by yum uses plug-in mode by default):

/etc/httpd/conf.d/php.conf

MySQL after installation:

/var/lib/mysql/ Default database file storage location

servicemysqld start

servicehttpd start

< span style="font-family:'宋体';font-size:14px;">

< span style="font-size:14px;font-family:'宋体';">2.Test php:

(a). vim/var/www/html/index.php

Add the following content:

(b). Browse the webpage http://localhost/index.php to display php status information. Successfully installed

p>

< /span>3.< /strong>test mysql< /p>

Enter mysql -u root to log in, and change the password by the way, here is 123456

SET PASSWORDFOR’root’@’ localhost’=PASSWORD(‘123456’);

4.Transfer mysql database to nfs

(a). Stop the database service first

servicemysqld stop

span>

(b). Copy the original database information to nfs

scp -r/var/lib/mysql/* 192.168.61.136:/mysqldata

(c). Delete the original database information

Rm -rf/var/lib/mysql/*

(d). Mount nfs

mount -tnfs 192.168. 61.136:/mysqldata /var/lib/mysql/

(e).Edit Permission

chown -Rmysql:mysql /var/lib/mysql/*

(f) .Restart mysql service test

servicemysqld start

5.install wordpress

(a). Mount -t nfs 192.168.61.136: /wordpress/var/www/html/

(b). Download wordpress-4.3.1-zh_CN.tar and unzip it to /var/www/html

(c). Log in to mysql to add wordpress database and user wordpress, password 123456

mysql -uroot -p

createdatabase wordpress;

GRANTALL ON *.* TO wordpress@’127.0.0.1′ IDENTIFIED BY ‘123456’;

(d). Browser run http://localhost/wp-admin/install.php installation< /span>

The following error may be prompted

Copy the content and create wp-config.php manually.

Fill in some information as required, Successful installation

< p style="margin-left:28px;"> 6.Install heartbeat V2

( a). Install the epel source first, the system source does not have libnet

wget ftp://ftp.pbone.net/mirror/dl.iuscommunity.org/ pub/ius/archive/Redhat/6/i386/epel-release-6-5.noarch.rpm

rpm -ivh epel-release-6-5.noarch.rpm

(b). Install dependency package:

yuminstall net-snmp-libs libnet PyXML

rpm-ivh heartbeat-2.1.4-12.el6.x86_64.rpm

heartbeat-pils-2.1.4-12.el6.x86_64.rpm

heartbeat-stonith-2.1.4-12.el6.x86_64.rpm

heartbeat-gui-2.1.4-12.el6.x86_64.rpm

(c). Edit ha.cf file

vim /etc/ha.cf The content is as follows:

crm on #Turn on crm and automatically disable haresources

logfacility local0#The log uses the local0 setting in rsyslog

keepalive 1 #monitoring frequency, every 1 second

deadtime 3 #Death judgment time

warntime 2 #Exception warning time

mcast eth0 225.0.0.1 694 1 0 #Multicast address setting

auto_failback on #Automatically go online after repair

node node ha1 #Node Settings

node ha2#Node Settings

ping 192.168.61.2 #third-party arbitration settings

(d). Edit the authkeys file

Auth 2

#1 crc

2 sha1HI! #The longer the key phrase, the more random the better

#3 md5Hello!

ha2Configuration

1.Install hear tbeat V2 < /strong>

(a). Install epel source, system source does not have libnet

wget ftp://ftp.pbone.net/mirror/dl.iuscommunity.org/pub/ius/archive/Redhat/6/i386/epel-release-6-5.noarch.rpm

rpm -ivh epel-release-6-5.noarch.rpm

(b). Install dependency package:

yuminstall net-snmp-libs libnet PyXML

rpm-ivh heartbeat-2.1.4-12.el6.x86_64.rpm

heartbeat-pils-2.1.4-12.el6.x86_64.rpm

heartbeat-stonith-2.1.4-12.el6.x86_64.rpm

heartbeat-gui-2.1.4-12.el6.x86_64.rpm

(c). Edit ha.cf file

The content of vim /etc/ha.cf is as follows:

crm on #Turn on crm and automatically disable haresources

logfacility local0 #Log use the local0 setting in rsyslog

keepalive1 #monitoring frequency, every 1 second

deadtime3 #Death judgment time

warntime2 #Exception warning time

mcasteth0 225.0.0.1 694 1 0 #Multicast address setting

auto_failbackon #automatically go online after repair

node ha1 #Node Settings

node ha2 #Node Settings

ping 192.168.61.2 #third-party arbitration settings

( d). Edit the authkeys file

auth 2

#1 crc< /p>

2 sha1HI! #The longer the key phrase, the more random the better

#3 md5Hello!

2. yum -y installphp php-mysql mysql-server mysql

PHP configuration file after installation (php installed by yum uses plug-in mode by default):

/etc/httpd/conf.d/php.conf

There is a /usr/lib64/httpd/modules/libphp5.so module file

mysql after installation:

< span style="font-family:'宋体';font-size:14px;"> /var/lib/mysql/ Default database file storage location

servicemysqld start

mysql -uroot -p Log in once to check whether the database is correct

servicehttpd start

3.Test php:

Browse the webpage http://localhost/index .php displays wordpress, you can log in and leave a message that is normal

4. Run hb_gui to set resources

hb_gui requires a specific user to log in to hb_gui to operate, hacluster under /etc/passwd, we must add a password for it, p>

Because it does not allow login with an empty password.

echo “123456” |passwd – stdinhacluster Each node that needs to run hb_gui needs to be set.

Enter hb_gui & run

     

    添加资源:< /span>

         先添加一个组webservice,按顺序把vip,nfs,mysqld,httpd添加进去

 < /p>

 

 

 

 

      然后分别启动ha1和ha2的heartbeat:

         serviceheartbeat start

在其中一台启动hb_gui就可以看到当前的节点和资源的分配。其中一台故障,资源都会自动切换到另一台,wordpress访问实现高可用

 

Leave a Comment

Your email address will not be published.