The main purpose of this article is to help you step-by-step configuration of a set of RHEL7 dual-machine services come out, which will not talk about the concept of dual-machine and why do so, parameters why so write, why knock this command, and then detailed article, and so on, I will certainly out
System version: RHEL7
ha1::192.168.1.80
ha2:192.168.1.81
vip:192.168.1.82
1: First install two RHEL7 operating system, installation steps slightly, online image and article a lot of, I do not repeat, the only thing to note is that the installation package where we choose the most basic installation is done, do not need to be graphical.
2: Configure IP, note that RHEL7 minimized installation by default is no Ifconfig command, because starting from RHEL7, is already a new network management, the recommended use of IP commands to operate, so we'd better also Romans, if you have to use Ifconfig command, Install Net-toos This package, then configure the IP method I will not repeat, directly modify the configuration file can be
[Email protected] ~]# Cat/etc/sysconfig/network-scripts/ifcfg-eth0
hwaddr=00:1a:4a:cf:b4:5c
Type=ethernet
Bootproto=static
Defroute=yes
Peerdns=yes
Peerroutes=yes
Ipv4_failure_fatal=no
Name=eth0
uuid=7e983225-8a8e-4c5f-bb5b-ffa160b3bf93
Onboot=yes
ipaddr=192.168.1.80
netmask=255.255.255.0
gateway=192.168.1.1
3: Modify host name and write to hosts inside
[Email protected] ~]# cat/etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.80 HA1
192.168.1.81 HA2
192.168.1.82 app
[Email protected] ~]# Cat/etc/hostname
Ha1
4: Turn off SELinux and shut down the firewall
We need to change the SELinux configuration file into disable, such as
[Email protected] ~]# Cat/etc/selinux/config
# This file controls the state of the SELinux on the system.
# selinux= can take one of these three values:
# Enforcing-selinux security policy is enforced.
# Permissive-selinux Prints warnings instead of enforcing.
# disabled-no SELinux policy is loaded.
Selinux=disabled
Then shut down the firewall
Systemctl Stop Firewalld
Systemctl Disable FIREWALLD
Restart your server, both need to do
5: Install the two-machine software, we do this here through Yum, put your CD into the system, and mount it under the/iso directory, and then write the Yum configuration file
[Email protected] ~]# Cat/etc/yum.repos.d/wuhao.repo
[RHEL7]
Name=rhel7
Baseurl=file:///iso
Enable=1
[1]
Name=cluster
Baseurl=file:///iso/addons/highavailability
Enable=1
[2]
Name=cluster1
Baseurl=file:///iso/addons/resilientstorage
Enable=1
And then we started installing
Yum Install Lvm2-cluster corosync pacemaker PCs fenceagents-all-y--nogpgcheck
Both sides are going to operate.
6: Start configuring cluster software
First of all, we installed the operating system did not choose a graphical interface, that is, all of our configuration will be done with the command line, the graphical configuration method of my own research, found that the button is not the point of reflection, is the point after the report inexplicable error, completely no command line to come fast, This may be my comparative dish 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0016.gif "alt=" J_0016.gif "/> It could be 7.0, and it's not a stable version of it. So let's start by configuring our own HA service.
Start the PCS service on both units first
Systemctl Start PCSD
Then set a unified password for Hacluster users, this user is the unified management of the cluster, but also responsible for the authentication cluster node.
passwd Hacluster
Xx
Xx
We verify that the two nodes
[Email protected] ~]# pcs cluster auth HA1 HA2
Ha1:already Authorized
Ha2:already Authorized
Because I've verified it, I've verified it here. The first time to verify that you lose the user and password remember is the above hacluster, not root Oh!
PCS cluster setup--name wuhaocluster ha1 ha2 (Wuhaocluster fill in the name you want to take)
Then we start the cluster
[Email protected] ~]# pcs cluster start--all
View our cluster status
[[Email protected] ~]# pcs status
Cluster Name:wuhaocluster
Last Updated:mon Jan 5 14:59:34 2015
Last Change:mon Jan 5 14:25:46 via cibadmin on HA1
Stack:corosync
Current DC:HA2 (2)-Partition with quorum
version:1.1.10-29.el7-368c726
2 Nodes configured
2 Resources configured
Online: [HA1 HA2]
Pay attention to my red place, indicating that your ha has started successfully, in fact, here, your dual machine has been well-equipped, the rest is just add some resources to go
So this time we're going to use only two resources, Apache and a floating ip,let ' s do it!
PCs property Set Stonith-enabled=false This command means that the dual machine does not use the Stonith device, what is the stonith? Self g, or you do not need to tube, you follow the knock on the line, I will put the concept of the article
[Email protected] ~]# pcs resource create CLUSTERIPOCF:HEARTBEAT:IPADDR2 ip=192.168.1.82cidr_netmask=24 op Monitor in terval=30s
The only thing you want to change here is the IP and cidr_netmask two values, change to your virtual IP and mask on the line, the other you don't have to understand what meaning, at least for the present
Then we look at the dual-machine status!
[[Email protected] ~]# pcs status
Cluster Name:wuhaocluster
Last Updated:mon Jan 5 15:05:20 2015
Last Change:mon Jan 5 14:25:46 via cibadmin on HA1
Stack:corosync
Current DC:HA2 (2)-Partition with quorum
version:1.1.10-29.el7-368c726
2 Nodes configured
2 Resources configured
Online: [HA1 HA2]
Full list of resources:
Clusterip (OCF::HEARTBEAT:IPADDR2): Started ha2
Note The red part, you successfully added the virtual IP into your cluster!
Below, we also want to add the HTTP service into your cluster, you need to install him first, and write a home file
Yum Install httpd
[Email protected] ~]# cat/var/www/html/index.html
This is machine number 1th.
[Email protected] ~]# cat/var/www/html/index.html
This is machine number 2nd.
Writing this file is not necessary, but it is more intuitive to test.
Another thing to note is that we need to configure the Apache monitoring method, here we follow a method of the official website, is to configure the Apache-status, the two nodes are to be modified to the following Oh!
Vi/etc/httpd/conf/httpd.conf
<Location/server-status>
SetHandler Server-status
Orderdeny,allow
Denyfrom All
Allowfrom 127.0.0.1
</Location>
And then we add them into the cluster.
[Email protected]~] #pcs resource Create Webocf:heartbeat:apache configfile=/etc/httpd/conf/httpd.conf statusurl= "HT Tp://localhost/server-status "OP Monitor interval=30s
View cluster status
[[Email protected] ~]# pcs status
Cluster Name:wuhaocluster
Last Updated:mon Jan 5 15:13:21 2015
Last Change:mon Jan 5 14:25:46 via cibadmin on HA1
Stack:corosync
Current DC:HA2 (2)-Partition with quorum
version:1.1.10-29.el7-368c726
2 Nodes configured
2 Resources configured
Online: [HA1 HA2]
Full list of resources:
Clusterip (OCF::HEARTBEAT:IPADDR2): Started HA2
Web (Ocf::heartbeat:apache): Started HA1
Pay attention to the red part, here, congratulations your HA has been configured, the rest is only a few adjustments, have you noticed that your two services are running on two machines above each other? In fact, this is a better place for the RHEL7, he believes that the hardware resources of each node should be used, so it will be intelligent to run the service in the various nodes, but for our HTTP architecture, a stake in your virtual IP and your Apache is not on a machine, how customers access your page? So we need to change
PCs constraintcolocation add Web clusterip INFINITY
The above command is to force the web and Clusterip two services tied to a machine, in addition we need to ensure that the IP service must be running before the HTTP service, you think, no IP, you httpd what is the point? If it is a special scenario, such as a database, where your data is stored, if the store is not mounted before the database startup script, how can the Oracle startup script succeed?
[Email protected] ~]# pcs constraint order Clusterip then Web
Okay, let's look at the two-machine status again.
[[Email protected] ~]# pcs status
Cluster Name:wuhaocluster
Last Updated:mon Jan 5 15:13:21 2015
Last Change:mon Jan 5 14:25:46 via cibadmin on HA1
Stack:corosync
Current DC:HA2 (2)-Partition with quorum
version:1.1.10-29.el7-368c726
2 Nodes configured
2 Resources configured
Online: [HA1 HA2]
Full list of resources:
Clusterip (OCF::HEARTBEAT:IPADDR2): Started HA2
Web (Ocf::heartbeat:apache): Started HA2
PCSD Status:
Ha1:online
Ha2:online
Daemon Status:
Corosync:active/disabled
Pacemaker:active/disabled
Pcsd:active/disabled
Now all running on the 2 machine above, open your browser, we access your virtual IP, should be the following results
This is machine number 2nd.
Well, to this your Rhel7+apache service is configured, you can try to restart, stop the network and other services to test whether the switch is smooth, the purpose of this article is to help those who have contact with the Redhat dual-machine Quick Start, more basic articles, I will release in the future, the other PCs very powerful, There is a study can be in my blog under the message, we learn to progress together! Have questions add my QQ
447040885
RHEL7 Configuring the HA for Apache services