Lab Environment:
Two hosts: centos6.5+httpd2.4+php5.5 the basic environment that makes up the web, and the Web page is accessed properly, and ensures that the HTTPD24 service does not boot up.
Node1.mylinux.com 10.204.80.79
Node2.mylinux.com 10.204.80.80
I am here to enable ansible to facilitate the management of two nodes, enable a host as a management node, ip:10.204.80.71, in the hosts of the three hosts to add the corresponding name resolution, management node to node1,node2 two nodes enable SSH trust mechanism, Add Node1 and Node2 to the Webservers group in the ansible configuration file.
Install the Software:
Installing Corosync and pacemaker on both hosts and installing the Yum module with the ansible command on the management host will take some time to install.
# ansible webservers-m yum-a ' Name=corosync,pacemaker state=installed '
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857765mxmo.png "width=" 635 "height=" 334 "/>
This shows that Corosync and pacemaker have already been installed, and here pacemaker is done as a plug-in for Corosync, and in the later versions of RHEL7, pacemaker will be run as a standalone daemon.
Configuration Corosync:
After installing Corosync, there will be a default corosync.config.example in the/etc/corosync directory, instead of Corosync.config
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857765reyd.png "width=" 611 "height="/>
Add the Corosync.config configuration file back to pacemaker as a Corosync plugin. Add the following content
Service {
ver:0
Name:pacemaker
# Use_mgmtd:yes
}
aisexec {
User:root
Group:root
}
and set the IP address of bindnetaddr in this profile is my host's network address, node network segment in the 10.204.80 network segment, set to 10.204.80.0 segment bindnetaddr:10.204.80.0, the configuration file is as follows
# Please read the COROSYNC.CONF.5 manual Pagecompatibility:whitetanktotem {version:2secauth:onthreads:0interface {ring number:0bindnetaddr:10.204.80.0mcastaddr:226.94.13.10mcastport:5405ttl:1}}logging {fileline:offto_stderr:noto_ Logfile:yesto_syslog:yeslogfile:/var/log/cluster/corosync.logdebug:offtimestamp:onlogger_subsys {subsys: AMFDEBUG:OFF}}AMF {mode:disabled}service { ver:0 name:pacemaker # use_mgmtd:yes}aisexec { User: Root Group:root}
Note Here is BINDNETADDR address only set local network segment, otherwise there may be an error corosync [TOTEM] The network interface is down, so that the node heartbeat can not pass over. Refer to the official documentation for a very clear word.
Bindnetaddr
This specifies the network address the Corosync executive should bind to. For example, if the local interface are 192.168.5.92 with netmask
255.255.255.0, set Bindnetaddr to 192.168.5.0. If The local interface is 192.168.5.92 with netmask 255.255.255.192 and set Bindnetaddr to
192.168.5.64, and so forth.
The authentication key file when generating communication between nodes:
#corosync-kegen Press A few carriage returns, the Authkey key file is generated
Copy the corosync.conf and Authkey to the/etc/corosync/directory of the Node2 node.
To configure the interface:
In rhel6.3 before the commonly used version is CRMSH, is a Resource manager configuration interface, in the rhel6.4 after the use of PCs, here can be used in two, contrast. So Crmsh is not in centos6.5 's Yum library, so go to download install CRMSH or build your own installation Crmsh.
: http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/x86_64/
There are three files that need to be downloaded crmsh-2.1-1.6.x86_64.rpm, pssh-2.3.1-4.1.x86_64.rpm, python-pssh-2.3.1-4.1.x86_64.rpm; because CRMSH need to rely on PSSH, So also need to download
Install the Configuration interface: Install CRMSSH In addition to several files downloaded, there are other Python dependencies, so use Yum Localinstall to install to resolve dependencies. Put these three files in the/root directory and install
# yum--nogpgcheck localinstall crmsh-2.1-1.6.x86_64.rpm pssh-2.3.1-4.1.x86_64.rpm python-pssh-2.3.1-4.1.x86_64.rpm
Installation complete, enter CRM into CRM Shell
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 14108577652voe.png "width=" 158 "height="/>
Start Corosync on the Node1
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857766pmd6.png "width=" 484 "height="/>
Start Node 2 on Node 1
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857766wm83.png "width=" 423 "height=" "/>"
Start complete, use the command # CRM status to view node status
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 14108577660ba6.png "width=" 496 "height=" 179 "/>
Both node 1 and Node 2 have started normally, and the cluster is in a normal working state.
Perform the PS auxf command to see the related processes Corosync initiated
650) this.width=650; "Style=" background-image:none; border-right-0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857767a3s5.png "width=" 613 "height=" 103 "/>
To configure the working properties of a cluster:
Corosync enabled by default Stonith, the current cluster does not have a corresponding stonith device, so the first to disable Stonith
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857767lxyt.png "width=" 494 "height=" 145 "/>
#crm Configure show Displays the configuration information for the current cluster, you can see that Stonith has been disabled
To add resources to a cluster:
Corosync supported resource agents are LSB and OCF, and LSB is the startup script class for some services, such as some scripts under the/etc/init.d/directory. To view the types supported by the current cluster system:
#crm RA Classes
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857768nkip.png "width=" 271 "height=" "/>"
Stonith is specifically designed for the configuration of Stonith devices
To view a list of all resource proxies under a type, you can use the #crm RA list LSB | OCF (Heartbeat | pacmemaker) | Stonith to view.
650) this.width=650; "Style=" background-image:none; border-right-0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 14108577685yec.png "width=" 774 "height=" 138 "/>
The resources required for a Web cluster are vip,web services,
The VIP of my two nodes is: 10.204.80.88 Web service is HTTP24
The syntax of the configuration command for CRM:
Primitive <rsc> [<class>:[<provider>:]]<type>
[Params attr_list]
[Operations Id_spec]
[Op op_type [<attribute>=<value> ...]
Op_type:: Start | Stop | Monitor
Primitive Master Resources
Format Primitive ID (resource name) resource Agent
Parametric params
Meta META attribute information
Utilization usage Information
Operations Operation information operation type start |stop | Monitor (monitoring, define if the resource stops if it will be discovered and passed to the cluster and whether it is re-shipped)
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857768068c.png "width=" 601 "height=" 187 "/>
Add a ip=10.204.80.88 Master resource
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857769jnij.png "width=" 476 "height=" 245 "/>
Make the HTTPD24 resource a Web service resource. Detection service verify, and commit commit
View resource Status
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857769haek.png "width=" 518 "height=" 223 "/>
The display has two nodes, two resource settings,
Because the resource is not defined as a group and no constraints are defined, the default two resources are run on two nodes respectively.
Define these two resources to the same group
In #crm then enter configure to enter configuration mode, then enter Help Group
You can view the Help documentation with a detailed description of the group command and an example
Group syntax
Group <name> <rsc> [<rsc> ...]
[Description=<description>]
[Meta Attr_list]
[Params attr_list]
Attr_list:: [$id =<id>] <attr>=<val> [<attr>=<val> ...] | $id-ref=<id>
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857770l49m.png "width=" 493 "height=" 296 "/>
Define WEBIP and Webserverf in the same group Webgroup, then view the cluster status
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857770dblf.png "width=" 545 "height=" 246 "/>
Two resources are running on the same node Node1, accessing the test
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857771eiik.png "width=" 618 "height=" 195 "/>
After the Node1 is turned off, the discovery resource is not transferred to the Node2 node, and the cluster status is checked #crm status
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 14108577717r21.png "Width=" 520 "height=" 193 "/>
Found in the cluster status is already "without quorum" has lost the legal votes, is not in the cluster state, but I have only two nodes here, this is unreasonable, you can ignore the following command quorum the cluster status check cannot be satisfied;
# CRM Configure Property No-quorum-policy=ignore
View cluster status
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857772dbe5.png "width=" 535 "height=" 260 "/>
The cluster status is already running on Node 2.
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857772m486.png "width=" 595 "height=" 137 "/>
Web page Access OK
Start the Node1 node.
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857772vluu.png "width=" 525 "height=" 243 "/>
Node1 and Node2 are both online, but the resources are not transferred back to the Node1 node because the resource stickiness is not defined here
There are three constraints to defining resources:
Location constraint: Defines which nodes a resource can, cannot, or should run on as much as possible
Order order constraint: Constraints define the order in which cluster resources are started on nodes
colocation arrangement constraints: Arranging constraints to define cluster resources or to run concurrently on a node
I define here webgroup default run on Node1 node
#crm Configure Prefer_node1 webserver 200:node1.mylinux.com
Note Here is: the back with the node must have the exact interval, or will error,
View configuration Files
650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857773b0pp.png "" 536 "height=" 293 "/>
Order constraints, to define the mandatory requirement to start WEBIP before starting the HTTP service, the command is as follows
#crm Configure Order Httpd-after-ip Mandatory:webip webserver
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201409/16/287547_ 1410857773aefu.png "width=" 488 "height="/>
Corosync and pacemaker have other powerful features, if health checks, how often do you check, and so on, here comes the first
Corosync+pacemaker making a highly available Web cluster