{"id":1438,"date":"2013-02-01T15:12:57","date_gmt":"2013-02-01T20:12:57","guid":{"rendered":"http:\/\/mossiso.com\/?p=1438"},"modified":"2014-09-22T14:38:05","modified_gmt":"2014-09-22T18:38:05","slug":"setting-up-a-hosting-environment-part-3-redhat-cluster-and-gfs2","status":"publish","type":"post","link":"https:\/\/mossiso.com\/2013\/02\/01\/setting-up-a-hosting-environment-part-3-redhat-cluster-and-gfs2\/","title":{"rendered":"Setting up a Hosting Environment, Part 3: RedHat Cluster and GFS2"},"content":{"rendered":"<p>Previous posts in this series:<\/p>\n<p><a title=\"Setting up a Hosting Environment: Part 1 \u2013 The servers\" href=\"http:\/\/mossiso.com\/2012\/03\/01\/setting-up-a-hosting-environment-part-1-the-servers.html\">Part 1: Setting up the servers<\/a><\/p>\n<p><a title=\"Setting up a Hosting Environment \u2013 Part 2: Connecting the Storage Array\" href=\"http:\/\/mossiso.com\/2012\/03\/09\/setting-up-a-hosting-environment-part-2-connecting-the-storage-array.html\">Part 2: Connecting the Array<\/a><\/p>\n<h2>RedHat Cluster and GFS2 Setup<\/h2>\n<ul>\n<li>Required reading: <a href=\"https:\/\/alteeve.com\/w\/2-Node_Red_Hat_KVM_Cluster_Tutorial\">https:\/\/alteeve.com\/w\/2-Node_Red_Hat_KVM_Cluster_Tutorial<\/a> Seriously. Don&#8217;t do anything until you read his tutorial a couple of times. Might as well read a bunch of his other tutorials, too.<\/li>\n<li>Unless mentioned, the following commands should be done on each server.<\/li>\n<\/ul>\n<h3>Set date\/time to be accurate and within a few minutes of each other.<\/h3>\n<ul>\n<li>Install the ntp program and update to current time.\n<ul>\n<li><code>yum install ntp<\/code><\/li>\n<li><code>ntpdate time.nist.gov<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Set time servers and start ntpd\n<ul>\n<li><code>service ntpd start<\/code><\/li>\n<li>Edit the <code>\/etc\/ntp.conf<\/code> file to use the following servers:<\/li>\n<li>\n<pre>server 0.pool.ntp.org\r\nserver 1.pool.ntp.org\r\nserver 2.pool.ntp.org\r\nserver 3.pool.ntp.org<\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>Restart ntpd\n<ul>\n<li><code>service ntpd restart<\/code><\/li>\n<li><code>chkconfig ntpd on<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Cluster setup<\/h3>\n<p>RedHat Cluster must be set up before the GFS2 File systems can be created and mounted.<\/p>\n<ul>\n<li>Instal the necessary programs\n<ul>\n<li><code>yum install openais cman rgmanager lvm2-cluster gfs2-utils ccs<\/code><\/li>\n<li>Create a <code>\/etc\/cluster\/cluster.conf<\/code> REMEMBER: Always increment the \u201cconfig_version\u201d parameter in the <code>cluster<\/code> tag!\n<ul>\n<li>\n<div>\n<pre class=\"decode-attributes:false lang:xhtml decode:true\">&lt;?xml version=\u201c1.0\u201d?&gt;\r\n    &lt;cluster config_version=\u201c24\u201d name=\u201cweb-production\u201d&gt;\r\n        &lt;cman expected_votes=\u201c1\u201d two_node=\u201c1\u201d\/&gt;\r\n        &lt;fence_daemon clean_start=\u201c1\u201d post_fail_delay=\u201c6\u201d post_join_delay=\u201c3\u201d\/&gt;\r\n        &lt;totem rrp_mode=\u201cnone\u201d secauth=\u201coff\u201d\/&gt;\r\n        &lt;clusternodes&gt;\r\n            &lt;clusternode name=\u201cbill\u201d nodeid=\"1\"&gt;\r\n                &lt;fence&gt;\r\n                    &lt;method name=\"ipmi\"&gt;\r\n                        &lt;device action=\u201creboot\u201d name=\u201cipmi_bill\u201d\/&gt;\r\n                    &lt;\/method&gt;\r\n                &lt;\/fence&gt;\r\n            &lt;\/clusternode&gt;\r\n            &lt;clusternode name=\u201cted\u201d nodeid=\"2\"&gt;\r\n                &lt;fence&gt;\r\n                    &lt;method name=\"ipmi\"&gt;\r\n                        &lt;device action=\u201creboot\u201d name=\u201cipmi_ted\u201d\/&gt;\r\n                    &lt;\/method&gt;\r\n                &lt;\/fence&gt;\r\n            &lt;\/clusternode&gt;\r\n        &lt;\/clusternodes&gt;\r\n        &lt;fencedevices&gt;\r\n            &lt;fencedevice agent=\u201cfence_ipmilan\u201d ipaddr=\u201cbillsp\u201d login=\u201croot\u201d name=\u201cipmi_bill\u201d passwd=\u201cPASSWORD-HERE\u201d\/&gt;\r\n            &lt;fencedevice agent=\u201cfence_ipmilan\u201d ipaddr=\u201ctedsp\u201d login=\u201croot\u201d name=\u201cipmi_ted\u201d passwd=\u201cPASSWORD-HERE\u201d\/&gt;\r\n        &lt;\/fencedevices&gt;\r\n        &lt;rm log_level=\"5\"&gt;\r\n            &lt;resources&gt;\r\n                &lt;clusterfs device=\u201c\/dev\/mapper\/StorageTek2530-sites\u201d fstype=\u201cgfs2\u201d mountpoint=\u201c\/sites\u201d name=\u201csites\u201d\/&gt;\r\n                &lt;clusterfs device=\u201c\/dev\/mapper\/StorageTek2530-databases\u201d fstype=\u201cgfs2\u201d mountpoint=\u201c\/databases\u201d name=\u201cdatabases\u201d\/&gt;\r\n                &lt;clusterfs device=\u201c\/dev\/mapper\/StorageTek2530-logs\u201d fstype=\u201cgfs2\u201d mountpoint=\u201c\/logs\u201d name=\u201clogs\u201d\/&gt;\r\n            &lt;\/resources&gt;\r\n            &lt;failoverdomains&gt;\r\n                &lt;failoverdomain name=\u201cbill-only\u201d nofailback=\u201c1\u201d ordered=\u201c0\u201d restricted=\"1\"&gt;\r\n                    &lt;failoverdomainnode name=\u201cbill\u201d\/&gt;\r\n                &lt;\/failoverdomain&gt;\r\n                &lt;failoverdomain name=\u201cted-only\u201d nofailback=\u201c1\u201d ordered=\u201c0\u201d restricted=\"1\"&gt;\r\n                    &lt;failoverdomainnode name=\u201cted\u201d\/&gt;\r\n                &lt;\/failoverdomain&gt;\r\n            &lt;\/failoverdomains&gt;\r\n        &lt;\/rm&gt;\r\n    &lt;\/cluster&gt;<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li>We\u2019ll be adding more to this later, but this will work for now.<\/li>\n<li>Validate the config file\n<ul>\n<li><code>ccs_config_validate<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Set a password for the ricci user\n<ul>\n<li><code>passwd ricci<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Start ricci, and set to start on boot\n<ul>\n<li><code>service ricci start<\/code><\/li>\n<li><code>chkconfig ricci on<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Start modclusterd and set to start on boot\n<ul>\n<li><code>service modclusterd start<\/code><\/li>\n<li><code>chkconfig modclusterd on<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Sync the cluster.conf file to other node\n<ul>\n<li><code>ccs -f \/etc\/cluster\/cluster.conf -h ted --setconf<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Start cman on both servers at the same time\n<ul>\n<li><code>service cman start<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Set cman to start on boot\n<ul>\n<li><code>chkconfig cman on<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Check the tutorial on testing the fencing\n<ul>\n<li><a href=\"https:\/\/alteeve.com\/w\/2-Node_Red_Hat_KVM_Cluster_Tutorial#Testing_Fencing\">https:\/\/alteeve.com\/w\/2-Node_Red_Hat_KVM_Cluster_Tutorial#Testing_Fencing<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Create GFS2 partitions<\/h3>\n<p>Create a partition on the new scsi device \/dev\/mapper\/mpatha using parted. NOTE: This part only needs to be done once on one server<\/p>\n<ul>\n<li><code>parted \/dev\/mapper\/mpatha<\/code><\/li>\n<li><code>mklabel gpt<\/code><\/li>\n<li><code>mkpart primary 1 -1<\/code><\/li>\n<li><code>set 1 lvm on<\/code><\/li>\n<li><code>quit<\/code><\/li>\n<li>Now you can see a partition for the storage array.\n<ul>\n<li><code>parted -l<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Edit the <code>\/etc\/lvm\/lvm.conf file<\/code> and set the value for <code>locking_type = 3<\/code> to allow for cluster locking.<\/p>\n<p>In order to enable the LVM volumes you are creating in a cluster, the cluster infrastructure must be running and the cluster must be quorate.<\/p>\n<ul>\n<li><code>service clvmd start<\/code><\/li>\n<li><code>chkconfig clvmd on<\/code><\/li>\n<li><code>chkconfig gfs2 on<\/code><\/li>\n<\/ul>\n<p>Create LVM partitions on the raw drive available from the StorageTek. NOTE: This part only needs to be done once on one server.<\/p>\n<ul>\n<li><code>pvcreate \/dev\/mapper\/mpatha1<\/code><\/li>\n<li><code>vgcreate -c y StorageTek2530 \/dev\/mapper\/mpatha1<\/code><\/li>\n<\/ul>\n<p>Now create the different partitions for the system: sites, databases, logs, home, root<\/p>\n<ul>\n<li><code>lvcreate --name sites --size 350GB StorageTek2530<\/code><\/li>\n<li><code>lvcreate --name databases --size 100GB StorageTek2530<\/code><\/li>\n<li><code>lvcreate --name logs --size 50GB StorageTek2530<\/code><\/li>\n<li><code>lvcreate --name root --size 50GB StorageTek2530<\/code><\/li>\n<\/ul>\n<p>Make a temporary directory <code>\/root-b<\/code> and copy everything from root\u2019s home directory to there, because it will be erased when we make the GFS2 file system.<\/p>\n<p>Copy \/root\/.ssh\/known_hosts to \/etc\/ssh\/root_known_hosts so the file is different for both servers.<\/p>\n<p>Before doing the home directory, we have to remove it from the local LVM.<\/p>\n<ul>\n<li><code>unmount \/home<\/code><\/li>\n<li><code>lvremove bill_local\/home<\/code> and on ted <code>lvremove ted_local\/home<\/code><\/li>\n<li>Remove the line from <code>\/etc\/fstab<\/code> referring to the \/home directory on the local LVM<\/li>\n<li>Then add the clustered LV.\n<ul>\n<li><code>lvcreate --name home --size 50GB StorageTek2530<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Create GFS2 files systems on the LVM partitions created on the StorageTek. Make sure they are unmounted, first. NOTE: This part only needs to be done once on one server.<\/p>\n<ul>\n<li><code>mkfs.gfs2 -p lock_dlm -j 2 -t web-production:sites \/dev\/mapper\/StorageTek2530-sites<\/code><\/li>\n<li><code>mkfs.gfs2 -p lock_dlm -j 2 -t web-production:databases \/dev\/mapper\/StorageTek2530-databases<\/code><\/li>\n<li><code>mkfs.gfs2 -p lock_dlm -j 2 -t web-production:logs \/dev\/mapper\/StorageTek2530-logs<\/code><\/li>\n<li><code>mkfs.gfs2 -p lock_dlm -j 2 -t web-production:root \/dev\/mapper\/StorageTek2530-root<\/code><\/li>\n<li><code>mkfs.gfs2 -p lock_dlm -j 2 -t web-production:home \/dev\/mapper\/StorageTek2530-home<\/code><\/li>\n<\/ul>\n<p>Mount the GFS2 partitions<\/p>\n<ul>\n<li>NOTE: GFS2 file systems that have been mounted manually rather than automatically through an entry in the fstab file will not be known to the system when file systems are unmounted at system shutdown. As a result, the GFS2 script will not unmount the GFS2 file system. After the GFS2 shutdown script is run, the standard shutdown process kills off all remaining user processes, including the cluster infrastructure, and tries to unmount the file system. This unmount will fail without the cluster infrastructure and the system will hang.<\/li>\n<li>To prevent the system from hanging when the GFS2 file systems are unmounted, you should do one of the following:\n<ul>\n<li>Always use an entry in the fstab file to mount the GFS2 file system.<\/li>\n<li>If a GFS2 file system has been mounted manually with the mount command, be sure to unmount the file system manually with the umount command before rebooting or shutting down the system.<\/li>\n<\/ul>\n<\/li>\n<li>If your file system hangs while it is being unmounted during system shutdown under these circumstances, perform a hardware reboot. It is unlikely that any data will be lost since the file system is synced earlier in the shutdown process.<\/li>\n<\/ul>\n<p>Make the appropriate folders on each node (\/home is already there).<\/p>\n<ul>\n<li><code>mkdir \/sites \/logs \/databases<\/code><\/li>\n<\/ul>\n<p>Make sure the appropriate lines are in \/etc\/fstab<\/p>\n<pre class=\"\">#GFS2 partitions shared in the cluster\r\n\/dev\/mapper\/StorageTek2530-root        \/root        gfs2   defaults,acl    0 0\r\n\/dev\/mapper\/StorageTek2530-home        \/home        gfs2   defaults,acl    0 0\r\n\/dev\/mapper\/StorageTek2530-databases      \/databases      gfs2   defaults,acl    0 0\r\n\/dev\/mapper\/StorageTek2530-logs        \/logs        gfs2   defaults,acl    0 0\r\n\/dev\/mapper\/StorageTek2530-sites    \/sites    gfs2   defaults,acl    0 0<\/pre>\n<p>Once the GFS2 partitions are set up and in <code>\/etc\/fstab<\/code>, rgmanager can be started. This will mount the GFS2 partions.<\/p>\n<ul>\n<li><code>service rgmanager start<\/code><\/li>\n<li><code>chkconfig rgmanager on<\/code><\/li>\n<\/ul>\n<h3>Starting Cluster Software<\/h3>\n<p>To start the cluster software on a node, type the following commands in this order:<\/p>\n<ul>\n<li><code>service cman start<\/code><\/li>\n<li><code>service clvmd start<\/code><\/li>\n<li><code>service gfs2 start<\/code><\/li>\n<li><code>service rgmanager start<\/code><\/li>\n<\/ul>\n<h3>Stopping Cluster Software<\/h3>\n<p>To stop the cluster software on a node, type the following commands in this order:<\/p>\n<ul>\n<li><code>service ossec-hids stop<\/code>\n<ul>\n<li>(ossec monitors the apache log files, so the \/logs partition will not be unmounted unless ossec is stopped first.)<\/li>\n<\/ul>\n<\/li>\n<li><code>service rgmanager stop<\/code><\/li>\n<li><code>service gfs2 stop<\/code><\/li>\n<li><code>umount -at gfs2<\/code><\/li>\n<li><code>service clvmd stop<\/code><\/li>\n<li><code>service cman stop<\/code><\/li>\n<\/ul>\n<h3>Cluster tips<\/h3>\n<p>If a service shows as \u2018failed\u2019 when checking on services with <code>clustat<\/code><\/p>\n<ul>\n<li>Disable the service first: <code>clusvcadm -d service-name<\/code><\/li>\n<li>Then re-enable it: <code>clusvcadm -e service-name<\/code><\/li>\n<\/ul>\n<p>Have Shorewall start sooner in the boot process.<\/p>\n<ul>\n<li>It was necessary to move shorewall up in the boot process, otherwise cman had no open connection to detect the other nodes.<\/li>\n<li>Edit the <code>\/etc\/init.d\/shorewall<\/code> and change the line near the top from <code># chkconfig: - 28 90<\/code> to\n<ul>\n<li><code># chkconfig: - 18 90<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Then use chkconfig to turn off shorewall and then back on.\n<ul>\n<li><code>chkconfig shorewall off<\/code><\/li>\n<li><code>chkconfig shorewall on<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Previous posts in this series: Part 1: Setting up the servers Part 2: Connecting the Array RedHat Cluster and GFS2 Setup Required reading: https:\/\/alteeve.com\/w\/2-Node_Red_Hat_KVM_Cluster_Tutorial Seriously. Don&#8217;t do anything until you read his tutorial a couple of times. Might as well read a bunch of his other tutorials, too. Unless mentioned, the following commands should be &hellip; <a href=\"https:\/\/mossiso.com\/2013\/02\/01\/setting-up-a-hosting-environment-part-3-redhat-cluster-and-gfs2\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Setting up a Hosting Environment, Part 3: RedHat Cluster and GFS2<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1446,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[243,249,167],"tags":[256,257,258,255,179],"class_list":["post-1438","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howto","category-setting-up-a-hosting-environment","category-technical","tag-cluster","tag-gfs2","tag-lvm","tag-redhat","tag-servers"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/mossiso.com\/wp-content\/uploads\/2013\/02\/redhat-cluster-gfs2.jpg","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9wosP-nc","_links":{"self":[{"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/posts\/1438"}],"collection":[{"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/comments?post=1438"}],"version-history":[{"count":7,"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/posts\/1438\/revisions"}],"predecessor-version":[{"id":1654,"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/posts\/1438\/revisions\/1654"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/media\/1446"}],"wp:attachment":[{"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/media?parent=1438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/categories?post=1438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/tags?post=1438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}