Prepare two machines, three ip
node node01 192.168.1.10 # 1 node02 192.168.1.11 node # 2
# prepare an IP, as a virtual ip
vip 192.168.1.88
Establish interoperability and install software
# Close the two firewalls
systemctl disable firewalld
systemctl STOP firewalld
# in / etc / selinux / config in the enforcing set to disable
enforcing = disable
# Modify the hosts established in node01, and node02 in
192.168.1.10 node01
192.168.1.11 node02
root @ node01: ~ # ssh- keygen # Enter has
root @ node01: ~ # ssh- copy-id node01 # 1 to establish their own exchange, enter yes 2, enter node1 password
root @ node01: ~ # ssh- copy-id node02 node02 # 1 to establish a common input yes 2, enter the password node2
# above is repeated on node02
#建立crmshyum源
root@node01:~#vi /etc/yum.repos.d/crm.repo
name=Stable High Availability/Clustering packages (CentOS_CentOS-7)
type=rpm-md
baseurl=http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-7/
gpgcheck=1
gpgkey=http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-7/repodata/repomd.xml.key
enabled=1
@ amdha01 the root: ~ # yum the install -Y corosync Pacemaker crmsh
# same manner the two machines
So far installed modifications /corosync.conf
root@node01:~#vi /etc/corosync/corosync.conf totem { version: 2 crypto_cipher: none crypto_hash: none interface { ringnumber: 0 bindnetaddr: 192.168.1.0 mcastaddr: 239.255.1.1 mcastport: 5405 ttl: 1 } } logging { fileline: off to_stderr: no to_logfile: yes logfile: /var/log/cluster/corosync.log to_syslog: yes debug: off timestamp: on logger_subsys { subsys: QUORUM debug: off } } quorum { provider: corosync_votequorum two_node: 1 } nodelist{ node{ ring0_addr:192.168.1.10 nodeid: 1 } node{ ring0_addr:192.168.1.11 nodeid:2 } } service { ver: 0 name: pacemaker } #同步node02代码如下 root@node01:~# scp /ect/corosync/corosync.conf node02:/etc/corosync
corosync configured, start corosync
root@node01:~# systemctl start corosync root@node01:~# systemctl enable corosync root@node01:~# systemctl start pacemaker root@node01:~# systemctl enable packmaker node02同样操作 root@node02:~# systemctl start corosync root@node02:~# systemctl enable corosync root@node02:~# systemctl start pacemaker root@node02:~# systemctl enable packmaker
查看一下corosync状态
root@node01:~#crm_mon
Mounting two nodes httpd
root@node01:~#yum install httpd -y root@node01:~#systemctl start httpd root@node01:~#echo '<h1>192.168.1.10<h1>' > /etc/www/html/index.html root@node01:~#curl 192.168.1.10 <h1>192.168.1.10</h1>
root@node02:~#yum install httpd -y root@node02:~#systemctl start httpd root@node02:~#echo '<h1>192.168.1.11<h1>' > /etc/www/html/index.html root@node02:~#curl 192.168.1.11 <h1>192.168.1.11</h1>
Configure Site
You can enter edit directly configure it, edit the configuration file directly
root @ node01: ~ # crm_mon this command to view the status of corosync
primitive webip ocf: heartbeat: IPaddr params ip = 192.168.1.88 # add virtual IP primitive the webserver systemd: the httpd # replenishing container group webservice webip webserver # to establish a group, the above two into them if you want to delete the above content. Please to crm (live) #node which perform or stop webserver webservice or webip inside and then to configure or delete webserver webservice or webip STANDBY amdha02 # dropped manually setting a node line on a node online node02 # specific reference commands using crm . You can also use pcs into cluster management
finish here, have the time to add