{"id":7297,"date":"2018-03-31T08:54:57","date_gmt":"2018-03-31T00:54:57","guid":{"rendered":"http:\/\/rmohan.com\/?p=7297"},"modified":"2018-03-31T08:54:57","modified_gmt":"2018-03-31T00:54:57","slug":"centos-7-cluster","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=7297","title":{"rendered":"centos 7 cluster"},"content":{"rendered":"<p>[root@clusterserver1 ~]# cat \/etc\/hosts<br \/>\n127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4<br \/>\n::1 localhost localhost.localdomain localhost6 localhost6.localdomain6<br \/>\n192.168.1.20 clusterserver1.rmohan.com clusterserver1<br \/>\n192.168.1.21 clusterserver2.rmohan.com clusterserver2<br \/>\n192.168.1.22 clusterserver3.rmohan.com clusterserver3<\/p>\n<p>perl -pi.orig -e &#8216;s\/SELINUX=enforcing\/SELINUX=permissive\/g&#8217; \/etc\/selinux\/config<\/p>\n<p>setenforce 0<\/p>\n<p>timedatectl status<\/p>\n<p>yum install -y ntp<br \/>\nsystemctl enable ntpd ; systemctl start ntpd<\/p>\n<p>run ssh-keygen<\/p>\n<p>[root@clusterserver1 ~]# ssh-keygen<br \/>\nGenerating public\/private rsa key pair.<br \/>\nEnter file in which to save the key (\/root\/.ssh\/id_rsa):<br \/>\nCreated directory &#8216;\/root\/.ssh&#8217;.<br \/>\nEnter passphrase (empty for no passphrase):<br \/>\nEnter same passphrase again:<br \/>\nYour identification has been saved in \/root\/.ssh\/id_rsa.<br \/>\nYour public key has been saved in \/root\/.ssh\/id_rsa.pub.<br \/>\nThe key fingerprint is:<br \/>\ne4:57:e7:7c:2e:dd:82:9f:d5:c7:57:f9:ef:ce:d5:e0 root@clusterserver1.rmohan.com<br \/>\nThe key&#8217;s randomart image is:<br \/>\n+&#8211;[ RSA 2048]&#8212;-+<br \/>\n| |<br \/>\n| |<br \/>\n| . . . |<br \/>\n| o . + .|<br \/>\n| S . +.o|<br \/>\n| . o **|<br \/>\n| . E &amp;|<br \/>\n| . *=|<br \/>\n| oo=|<br \/>\n+&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br \/>\n[root@clusterserver1 ~]#<\/p>\n<p>for i in clusterserver1 clusterserver2 clusterserver3 ; do ssh-copy-id $i; done<\/p>\n<p>\/usr\/bin\/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed<br \/>\n\/usr\/bin\/ssh-copy-id: INFO: 1 key(s) remain to be installed &#8212; if you are prompted now it is to install the new keys<br \/>\nroot@clusterserver1&#8217;s password:<br \/>\nPermission denied, please try again.<br \/>\nroot@clusterserver1&#8217;s password:<\/p>\n<p>Number of key(s) added: 1<\/p>\n<p>Now try logging into the machine, with: &#8220;ssh &#8216;clusterserver1&#8242;&#8221;<br \/>\nand check to make sure that only the key(s) you wanted were added.<\/p>\n<p>The authenticity of host &#8216;clusterserver2 (192.168.1.21)&#8217; can&#8217;t be established.<br \/>\nECDSA key fingerprint is 43:25:9c:32:53:18:33:a9:25:f7:cd:bb:b0:64:80:fd.<br \/>\nAre you sure you want to continue connecting (yes\/no)? yes<br \/>\n\/usr\/bin\/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed<br \/>\n\/usr\/bin\/ssh-copy-id: INFO: 1 key(s) remain to be installed &#8212; if you are prompted now it is to install the new keys<br \/>\nroot@clusterserver2&#8217;s password:<\/p>\n<p>Number of key(s) added: 1<\/p>\n<p>Now try logging into the machine, with: &#8220;ssh &#8216;clusterserver2&#8242;&#8221;<br \/>\nand check to make sure that only the key(s) you wanted were added.<\/p>\n<p>The authenticity of host &#8216;clusterserver3 (192.168.1.22)&#8217; can&#8217;t be established.<br \/>\nECDSA key fingerprint is 62:79:b1:c7:9b:de:a3:5e:a4:3d:e0:15:2b:f8:c2:f7.<br \/>\nAre you sure you want to continue connecting (yes\/no)? yes<br \/>\n\/usr\/bin\/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed<br \/>\n\/usr\/bin\/ssh-copy-id: INFO: 1 key(s) remain to be installed &#8212; if you are prompted now it is to install the new keys<br \/>\nroot@clusterserver3&#8217;s password:<\/p>\n<p>Number of key(s) added: 1<\/p>\n<p>Now try logging into the machine, with: &#8220;ssh &#8216;clusterserver3&#8242;&#8221;<br \/>\nand check to make sure that only the key(s) you wanted were added.<\/p>\n<p>yum install iscsi-initiator-utils -y<\/p>\n<p>systemctl enable iscsi<br \/>\nsystemctl start iscsi<\/p>\n<p>iscsiadm -m discovery -t sendtargets -p 192.168.1.90:3260<\/p>\n<p>iscsiadm &#8211;mode node &#8211;targetname iqn.2006-01.com.openfiler:tsn.b01850dab96a &#8211;portal 192.168.1.90 &#8211;login<\/p>\n<p>iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.b01850dab96a -p 192.168.1.90:3260 -l<\/p>\n<p>Install corosync and pacemaker on the nodes<\/p>\n<p>yum -y install lvm2-cluster corosync pacemaker pcs fenceagents-all<\/p>\n<p>systemctl enable pcsd.service<\/p>\n<p>systemctl start pcsd.service<\/p>\n<p>echo test123 | passwd &#8211;stdin hacluster<\/p>\n<p>pcs cluster auth clusterserver1 clusterserver2 clusterserver3<\/p>\n<p>[root@clusterserver1 ~]# pcs cluster auth clusterserver1 clusterserver2 clusterserver3<br \/>\nUsername: hacluster<br \/>\nPassword:<br \/>\nclusterserver3: Authorized<br \/>\nclusterserver2: Authorized<br \/>\nclusterserver1: Authorized<br \/>\n[root@clusterserver1 ~]#<\/p>\n<p>[root@clusterserver1 ~]# ls -lt \/var\/lib\/pcsd\/<br \/>\ntotal 20<br \/>\n-rw&#8212;&#8212;- 1 root root 250 Jan 4 03:33 tokens<br \/>\n-rw-r&#8211;r&#8211; 1 root root 1542 Jan 4 03:33 pcs_users.conf<br \/>\n-rwx&#8212;&#8212; 1 root root 60 Jan 4 03:28 pcsd.cookiesecret<br \/>\n-rwx&#8212;&#8212; 1 root root 1233 Jan 4 03:28 pcsd.crt<br \/>\n-rwx&#8212;&#8212; 1 root root 1679 Jan 4 03:28 pcsd.key<br \/>\n[root@clusterserver1 ~]#<\/p>\n<p>pcs cluster setup &#8211;name webcluster clusterserver1 clusterserver2 clusterserver3<\/p>\n<p>[root@clusterserver1 ~]# pcs cluster setup &#8211;name webcluster clusterserver1 clusterserver2 clusterserver3<br \/>\nShutting down pacemaker\/corosync services&#8230;<br \/>\nRedirecting to \/bin\/systemctl stop pacemaker.service<br \/>\nRedirecting to \/bin\/systemctl stop corosync.service<br \/>\nKilling any remaining services&#8230;<br \/>\nRemoving all cluster configuration files&#8230;<br \/>\nclusterserver1: Succeeded<br \/>\nclusterserver2: Succeeded<br \/>\nclusterserver3: Succeeded<br \/>\nSynchronizing pcsd certificates on nodes clusterserver1, clusterserver2, clusterserver3&#8230;<br \/>\nclusterserver3: Success<br \/>\nclusterserver2: Success<br \/>\nclusterserver1: Success<\/p>\n<p>Restaring pcsd on the nodes in order to reload the certificates&#8230;<br \/>\nclusterserver3: Success<br \/>\nclusterserver2: Success<br \/>\nclusterserver1: Success<br \/>\n[root@clusterserver1 ~]#<\/p>\n<p>[root@clusterserver1 ~]# ls \/etc\/corosync\/<br \/>\ncorosync.conf corosync.conf.example corosync.conf.example.udpu corosync.xml.example uidgid.d\/<br \/>\n[root@clusterserver1 ~]# ls \/etc\/corosync\/<br \/>\ncorosync.conf corosync.conf.example corosync.conf.example.udpu corosync.xml.example uidgid.d\/<br \/>\n[root@clusterserver1 ~]# ls \/etc\/corosync\/*<br \/>\n\/etc\/corosync\/corosync.conf \/etc\/corosync\/corosync.conf.example \/etc\/corosync\/corosync.conf.example.udpu \/etc\/corosync\/<\/p>\n<p>\/etc\/corosync\/uidgid.d:<br \/>\n[root@clusterserver1 ~]#<br \/>\n[root@clusterserver1 corosync]# cat corosync.conf<br \/>\ntotem {<br \/>\nversion: 2<br \/>\nsecauth: off<br \/>\ncluster_name: webcluster<br \/>\ntransport: udpu<br \/>\n}<\/p>\n<p>nodelist {<br \/>\nnode {<br \/>\nring0_addr: clusterserver1<br \/>\nnodeid: 1<br \/>\n}<\/p>\n<p>node {<br \/>\nring0_addr: clusterserver2<br \/>\nnodeid: 2<br \/>\n}<\/p>\n<p>node {<br \/>\nring0_addr: clusterserver3<br \/>\nnodeid: 3<br \/>\n}<br \/>\n}<\/p>\n<p>quorum {<br \/>\nprovider: corosync_votequorum<br \/>\n}<\/p>\n<p>logging {<br \/>\nto_logfile: yes<br \/>\nlogfile: \/var\/log\/cluster\/corosync.log<br \/>\nto_syslog: yes<br \/>\n}<br \/>\n[root@clusterserver1 corosync]#<\/p>\n<p>[root@clusterserver2 ~]# pcs status<br \/>\nError: cluster is not currently running on this node<br \/>\n[root@clusterserver2 ~]#<\/p>\n<p>[root@clusterserver3 ~]# pcs status<br \/>\nError: cluster is not currently running on this node<br \/>\n[root@clusterserver3 ~]#<\/p>\n<p>pcs cluster enable &#8211;all<\/p>\n<p>[root@clusterserver1 corosync]# pcs cluster enable &#8211;all<br \/>\nclusterserver1: Cluster Enabled<br \/>\nclusterserver2: Cluster Enabled<br \/>\nclusterserver3: Cluster Enabled<br \/>\n[root@clusterserver1 corosync]#<\/p>\n<p>Start the cluster<br \/>\n\u2022From any node: pcs cluster start &#8211;all<\/p>\n<p>pcsd: active\/enabled<br \/>\n[root@clusterserver1 corosync]# pcs status<br \/>\nCluster name: webcluster<br \/>\nWARNING: no stonith devices and stonith-enabled is not false<br \/>\nLast updated: Mon Jan 4 03:39:26 2016 Last change: Mon Jan 4 03:39:24 2016 by hacluster via crmd on clusterserver1<br \/>\nStack: corosync<br \/>\nCurrent DC: clusterserver1 (version 1.1.13-10.el7-44eb2dd) &#8211; partition with quorum<br \/>\n3 nodes and 0 resources configured<\/p>\n<p>Online: [ clusterserver1 clusterserver2 clusterserver3 ]<\/p>\n<p>Full list of resources:<\/p>\n<p>PCSD Status:<br \/>\nclusterserver1: Online<br \/>\nclusterserver2: Online<br \/>\nclusterserver3: Online<\/p>\n<p>Daemon Status:<br \/>\ncorosync: active\/enabled<br \/>\npacemaker: active\/enabled<br \/>\npcsd: active\/enabled<br \/>\n[root@clusterserver1 corosync]#<\/p>\n<p>Verify Corosync Installation<br \/>\n\u2022corosync-cfgtool -s<\/p>\n<p>[root@clusterserver1 corosync]# corosync-cfgtool -s<br \/>\nPrinting ring status.<br \/>\nLocal node ID 1<br \/>\nRING ID 0<br \/>\nid = 192.168.1.20<br \/>\nstatus = ring 0 active with no faults<br \/>\n[root@clusterserver1 corosync]#<\/p>\n<p>[root@clusterserver2 ~]# corosync-cfgtool -s<br \/>\nPrinting ring status.<br \/>\nLocal node ID 2<br \/>\nRING ID 0<br \/>\nid = 192.168.1.21<br \/>\nstatus = ring 0 active with no faults<br \/>\n[root@clusterserver2 ~]#<\/p>\n<p>Verify Corosync Installation<br \/>\n\u2022corosync-cmapctl | grep members<\/p>\n<p>[root@clusterserver2 ~]# corosync-cfgtool -s<br \/>\nPrinting ring status.<br \/>\nLocal node ID 2<br \/>\nRING ID 0<br \/>\nid = 192.168.1.21<br \/>\nstatus = ring 0 active with no faults<br \/>\n[root@clusterserver2 ~]# corosync-cmapctl | grep members<br \/>\nruntime.totem.pg.mrp.srp.members.1.config_version (u64) = 0<br \/>\nruntime.totem.pg.mrp.srp.members.1.ip (str) = r(0) ip(192.168.1.20)<br \/>\nruntime.totem.pg.mrp.srp.members.1.join_count (u32) = 1<br \/>\nruntime.totem.pg.mrp.srp.members.1.status (str) = joined<br \/>\nruntime.totem.pg.mrp.srp.members.2.config_version (u64) = 0<br \/>\nruntime.totem.pg.mrp.srp.members.2.ip (str) = r(0) ip(192.168.1.21)<br \/>\nruntime.totem.pg.mrp.srp.members.2.join_count (u32) = 1<br \/>\nruntime.totem.pg.mrp.srp.members.2.status (str) = joined<br \/>\nruntime.totem.pg.mrp.srp.members.3.config_version (u64) = 0<br \/>\nruntime.totem.pg.mrp.srp.members.3.ip (str) = r(0) ip(192.168.1.22)<br \/>\nruntime.totem.pg.mrp.srp.members.3.join_count (u32) = 1<br \/>\nruntime.totem.pg.mrp.srp.members.3.status (str) = joined<br \/>\n[root@clusterserver2 ~]#<\/p>\n<p>Verify Corosync Installation<br \/>\n\u2022crm_verify -L -V<\/p>\n<p>[root@clusterserver2 ~]# crm_verify -L -V<br \/>\nerror: unpack_resources: Resource start-up disabled since no STONITH resources have been defined<br \/>\nerror: unpack_resources: Either configure some or disable STONITH with the stonith-enabled option<br \/>\nerror: unpack_resources: NOTE: Clusters with shared data need STONITH to ensure data integrity<br \/>\nErrors found during check: config not valid<br \/>\n[root@clusterserver2 ~]#<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[root@clusterserver1 ~]# cat \/etc\/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.1.20 clusterserver1.rmohan.com clusterserver1 192.168.1.21 clusterserver2.rmohan.com clusterserver2 192.168.1.22 clusterserver3.rmohan.com clusterserver3<\/p>\n<p>perl -pi.orig -e &#8216;s\/SELINUX=enforcing\/SELINUX=permissive\/g&#8217; \/etc\/selinux\/config<\/p>\n<p>setenforce 0<\/p>\n<p>timedatectl status<\/p>\n<p>yum install -y ntp systemctl enable ntpd ; systemctl start ntpd<\/p>\n<p>run ssh-keygen<\/p>\n<p>[root@clusterserver1 ~]# ssh-keygen Generating public\/private rsa key pair. Enter file [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7297"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7297"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7297\/revisions"}],"predecessor-version":[{"id":7298,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7297\/revisions\/7298"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}