First, the test environment
| Host Name |
IP Address |
Role |
| Node1.example.com |
192.168.86.185 |
Node1 |
| Node2.example.com |
192.168.86.186 |
Node2 |
| Fs.example.com |
192.168.86.111 |
Fileserver |
|
|
|
Two, configure three server time synchronization and modify crontab to synchronize with NTP server automatically
Crontab-e
*/2 * * * */usr/sbin/ntpdate cn.pool.ntp.org
Third, edit/etc/hosts file configuration ssh Trust
1.vim/etc/hosts
192.168.86.185 node1.example.com node1192.168.86.186 node2.example.com node2192.168.86.111 fs.example.com Fs
Scp/etc/hosts 192.168.86.186:/etc/scp/etc/hosts 192.168.86.111:/etc/
2. Configure the SSH certificate
Run Ssh-keygen--Ssh-copyid node2 on each server
Four, prepare for NFS Server
1. Mount after adding a new disk partition
Fdisk/dev/sdbmkfs.ext4/dev/sdb1mkdir/mydata; Mount/dev/sdb1/mydata
2. Edit the/etc/exports file
Vim/etc/exports
/mydata 192.168.86.0/24 (Rw,no_root_squash)
Start the NFS service
Service NFS Start
Establish the/mydata directory on the Node1,node2 node and perform a test mount
Mkdir/mydata; Mount-t NFS Fs:/mydata/mydata; Mkdir/mydata/{db,webdoc}
Five, install HEARTBEAT+CRM+HTTPD+MARIADB on the Node1,node2 node
Will download the heartbeat-gui-2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm heartbeat-2.1.4-12.el6.x86_ 64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm for installation
It is recommended that you use the Yum Localinstall installation to resolve dependencies, or you can install heartbeat after the yum remove heartbeat resolves the dependencies after installing it with the Yum install.
httpd with Yum installation
Yum Install httpd PHP php-mysql-y
MARIADB with a compiled tarball installation
Tar xvf mariadb-5.5.46-linux-x86_64.tar.gz-c/usr/local; Ln-s/usr/local/mariadb-5.5.46/mysql
1.mysql Configuration
Groupadd-r-G mysqluseradd-r-G MySQL mysqlchown-r root.mysql/usr/local/mysql
Copy MySQL configuration file
Cp/usr/local/mysql/support-fils/my-medium.cnf/etc/my.cnf
Editing a configuration file
Vim/etc/my.cnf
DataDir =/mydata/db Specify the database location
Innodb_file_per_table = on Specifies how the InnoDB table space is stored
Skip_name_resolve = on skips domain name resolution
Copy startup script
Cp/usr/local/mysql/mysql.server/etc/init.d/mysqld; chmod +x/etc/init.d/mysqld
Initializing the database
/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql--user=mysql
Test start MySQL
Service mysqld Start
Build WordPress library, and give WordPress user authorization
MariaDB [(None)]> CREATE database WordPress; Query OK, 1 row affected (0.01 sec) MariaDB [(none)]> grant all privileges on wordpress.* to ' WordPress ' @ ' 192.168.86.% ' Identified by ' WordPress '; Query OK, 0 rows affected (0.01 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.01 sec)
Turn off MySQL after normal startup
Service Mysqld Stop
2.HTTPD Configuration
Edit httpd configuration file
Vim/etc/httpd/conf/httpd.conf
DocumentRoot "/mydata/webdoc"
Six, configure Heartbeat
CP/USR/SHARE/DOC/HEARTBEAT-2.1.4/{AUTHKEYS,HA.CF}/etc/ha.d/
1. Edit Authkeys
First, you need to generate a random number for the most
OpenSSL rand-base64 10abb7qpdgzvxdravim/etc/ha.d/authkeysauth 2#1 crc2 SHA1 Abb7qpdgzvxdra
Modify to generated random number
#3 MD5 hello!
Copy Authkeys to Node2
Scp/etc/ha.d/authkeys NODE2:/ETC/HA.D
2. Edit HA.CF
Vim/etc/ha.d/ha.cf
LogFile/var/log/ha-log turn on log function
Logfacilitylocal0
Udpport694 listening on UDP 694 port
Mcast eth0 225.0.0.1 694 1 0 Configure multicast address, TTL value
Auto_failback on repair auto turn back function on
Node node1.example.com defines two nodes respectively
Node node2.example.com
Ping 192.168.86.2 Pingnode Device
CRM on open Heartbeat 2.x CRM
Copy ha.cf to Node2
SCP/ETC/HA.D/HA.CF node2:/etc/ha.d/
Modify Hacluster Password
echo linuxha|passwd Hacluster--stdin
Seven. Configuring cluster resources
Start Hb_gui Add a group of resources 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M01/74/CF/ Wkiom1yprnjzsgmmaaizbpeidzc735.jpg "title=" Qq20151023113523.png "alt=" Wkiom1yprnjzsgmmaaizbpeidzc735.jpg "/>
Adding VIP,STORE,DB,HTTPD resources within a group resource
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/74/CF/wKiom1YprczS66uWAAB3095mfvk025.jpg "title=" Qq20151023113539.png "alt=" Wkiom1yprczs66uwaab3095mfvk025.jpg "/>
Add VIP
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/74/CB/wKioL1YprgfSM96AAAK57eSt6KY711.jpg "title=" Qq20151023113612.png "alt=" Wkiol1yprgfsm96aaak57est6ky711.jpg "/>
Add Store
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/74/CF/wKiom1Yprf3BoYmwAAKMOulW0cM176.jpg "title=" Qq20151023113630.png "alt=" Wkiom1yprf3boymwaakmoulw0cm176.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/CB/wKioL1YprligmVCAAALcQYsDFdk871.jpg "style=" float: none; "title=" Qq20151023113729.png "alt=" Wkiol1yprligmvcaaalcqysdfdk871.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/CF/wKiom1YpriuzYSA8AAKQ3aOY4C4674.jpg "style=" float: none; "title=" Qq20151023113829.png "alt=" Wkiom1ypriuzysa8aakq3aoy4c4674.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/CB/wKioL1YprljQZpYqAAK4vQsIUo4900.jpg "style=" float: none; "title=" Qq20151023113901.png "alt=" Wkiol1yprljqzpyqaak4vqsiuo4900.jpg "/>
Start Lamp Resource
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/CF/wKiom1YpriujXDLVAAKJpNCwcWs258.jpg "style=" float: none; "title=" Qq20151023113919.png "alt=" Wkiom1ypriujxdlvaakjpncwcws258.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/CB/wKioL1YprljRxgW1AAMQa55ki3w351.jpg "style=" float: none; "title=" Qq20151023114621.png "alt=" Wkiol1yprljrxgw1aamqa55ki3w351.jpg "/>
Eight, install WordPress
Unzip WordPress to/mydata/webdoc
[Email protected] src]# cp-r wordpress/*/mydata/webdoc
Browser input HA cluster IP address
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/CF/wKiom1Ypvn2z3ChpAAMpxrOBvXg817.jpg "style=" float: none; "title=" Qq20151023120207.png "alt=" Wkiom1ypvn2z3chpaampxrobvxg817.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/CF/wKiom1Ypvn3wwvEdAAHHcpPUEd8876.jpg "style=" float: none; "title=" Qq20151023120236.png "alt=" Wkiom1ypvn3wwvedaahhcppued8876.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/CC/wKioL1YpvqrTv-MiAADCvgjdO8E654.jpg "style=" float: none; "title=" Qq20151023125644.png "alt=" Wkiol1ypvqrtv-miaadcvgjdo8e654.jpg "/>
Test resource Migration
Stop Heartbeat on the Node2
Service Heartbeat Stop
Re-visit the page test is normal 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M02/74/CF/wKiom1Ypv1Oio9cuAAKPDIyB0us233.jpg " Title= "Qq20151023130150.png" alt= "wkiom1ypv1oio9cuaakpdiyb0us233.jpg"/> test found that the resource has been successfully migrated to Node1, and the page will be accessed normally
Enable high-availability lamp with heartbeat 2.X