Clustering Quick Installation Guide
Total Page:16
File Type:pdf, Size:1020Kb
ClusteringQuickInstallationGuide forPacketFenceversion5.3.1 ClusteringQuickInstallationGuide byInverseInc. Version5.3.1-July2015 Copyright©2015Inverseinc. Permissionisgrantedtocopy,distributeand/ormodifythisdocumentunderthetermsoftheGNUFreeDocumentationLicense,Version 1.2oranylaterversionpublishedbytheFreeSoftwareFoundation;withnoInvariantSections,noFront-CoverTexts,andnoBack-Cover Texts.Acopyofthelicenseisincludedinthesectionentitled"GNUFreeDocumentationLicense". ThefontsusedinthisguidearelicensedundertheSILOpenFontLicense,Version1.1.ThislicenseisavailablewithaFAQat:http:// scripts.sil.org/OFL Copyright©ŁukaszDziedzic,http://www.latofonts.com,withReservedFontName:"Lato". Copyright©RaphLevien,http://levien.com/,withReservedFontName:"Inconsolata". TableofContents AboutthisGuide.............................................................................................................. 1 Assumptions.....................................................................................................................2 Installation....................................................................................................................... 3 Step1:Installthereplicateddatabase........................................................................ 3 Step2:Serverconfiguration..................................................................................... 9 Step3:Createanewcluster.................................................................................. 10 Step4:Connectaslavepacketfenceserver..............................................................11 Advancedconfiguration................................................................................................... 13 Removingaserverfromthecluster.......................................................................... 13 Resynchronizingtheconfigurationmanually.............................................................. 13 Addingfilestothesynchronization...........................................................................14 haproxydashboard..................................................................................................14 Unsupportedfeaturesinactive/active.......................................................................15 Copyright©2015Inverseinc. iii Chapter1 AboutthisGuide Thisguidehasbeencreatedtogiveaquickstarttoinstallactive/activeclusteringinPacketFence 5+.Thisguidedoesnotincludeadvancedtroubleshootingoftheactive/activeclustering.Referto thedocumentationofHAProxyandKeepaliveforadvancedfeatures. Copyright©2015Inverseinc. AboutthisGuide 1 Chapter2 Assumptions ▪ YouhaveatleasttwoserverswithafreshinstallofPacketFence5+ ▪ Bothserversareidenticalcopiesforthenetworkinterfaces ▪ BothserversarerunningCentOS6 ▪ Bothservershaveaccesstothesamelayer2networkonalltheirnetworkinterfaces ▪ Bothservershaveanempty,unformattedpartitionforthedatabase ▪ BothservershostnamemustberesolvableviaaDNSresolution Copyright©2015Inverseinc. Assumptions 2 Chapter3 Installation Step1:Installthereplicateddatabase Note Inthisimplementation,thedatabaseisreplicatedinactive/passiveacrosstwoservers thatarepartofthePacketFencecluster.Active/activereplicationisalsopossibleusing MariaDBGaleraclusterbutthissubjectisnotcoveredinthisguide. InstallingDRBD CreationoftheDRBDpartition DuringtheOSinstallation,reducethesizeofthemainpartitionandcreateanewone(thatwill beusedforthereplicatedMySQLdatabase)of30G.Donotcreatethatpartitionduringtheinstall process,wewilldoitlater. Partitioning After the install, you need to create the extra partition for drbd. Using fdisk, create your new partitionandsavethetable.Youwillprobablyneedtorebootyourserverafterthisstep. DRBDandLinux-HAInstallation CentOS6 AddtherepositoryELRepo. # rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm EdittherepofiletodisableELRepobydefault: /etc/yum.repos.d/elrepo.repo Copyright©2015Inverseinc. Installation 3 Chapter3 [elrepo] name=ELRepo.org Community Enterprise Linux Repository - el6 baseurl=http://elrepo.org/linux/elrepo/el6/$basearch/ mirrorlist=http://elrepo.org/mirrors-elrepo.el6 enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org protect=0 InstallnowthepackageDRBDv8.4enabling. yum install kmod-drbd84 --enablerepo=elrepo DRBDConfigurationandsetup Caution Initializing,configuringandtroubleshootingDRBDisnotstraightforward!Westrongly recommendthatyoureadtheonlinedocumentationavailableonDRBDwebsiteso youhaveabetterideaabouthowitworks. Hereweassumethenameofthepartitionismysql. LoadtheDRBDkernelmodule: modprobe drbd Edit/etc/drbd.d/global_common.confandputthefollowingcontent: global { usage-count yes; } common { protocol C; startup { degr-wfc-timeout 120; } syncer { rate 100M; al-extents 257; } disk { on-io-error detach; } } Copyright©2015Inverseinc. Installation 4 Chapter3 Createthefile/etc/drbd.d/mysql.reswiththefollowingcontent: resource mysql { on <pf1_server_name> { device /dev/drbd0; disk <storage_device>; meta-disk internal; address <ha_interface_ip_address_1>:7788; } on <pf2_server_name> { device /dev/drbd0; disk <storage_device>; meta-disk internal; address <ha_interface_ip_address_2>:7788; } handlers { split-brain "/usr/lib/drbd/notify-split-brain.sh [email protected]"; } } where: ▪ mysqlisthenameofthepartitionyoucreatedwheninstallingtheOS ▪ pf1_server_nameandpf2_server_namebytherealservernames(FQDN) ▪ ha_interface_ip_address_1 and ha_interface_ip_address_2 by the IP addresses of the managementinterfaceonbothservers. ▪ storage_deviceisthedevicetousefortheMySQLpartition(ie./dev/sda2) Theninitializethepartition: [root@pf1 ~]# drbdadm create-md mysql Writing meta data... initializing activity log NOT initialized bitmap New drbd meta data block successfully created. success StartDRBDonbothservers: # /etc/init.d/drbd start Youshouldseesomethingsimilartothiswhentypingcat/proc/drbd: ... 0: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent C r---- ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:30702640 Note Ifyougetconnectivityissuesmakesureyouriptablesaredisabled. Copyright©2015Inverseinc. Installation 5 Chapter3 Synchronizetheserversbyforcingonetobecometheprimary.Soonpf1do: # drbdadm primary --force mysql Afterissuingthiscommand,theinitialfullsynchronizationwillstart.Youwillbeabletomonitorits progressvia/proc/drbd.Itmaytakesometimedependingonthesizeofthedevice.Waituntil itcompletes. Whenthesynciscomplete,createthefilesystemontheprimarynodeonly: # mkfs.ext4 /dev/drbd0 MakesureDRBDisstartedatboottime: # chkconfig --level 2345 drbd on Restartbothservers. Whendone,lookin/proc/drbdandmakesureyousee: ... 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r--- ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0 MySQLConfiguration Note BydefaultMySQLputsitsdatain/var/lib/mysql.Inordertoreplicatedatabetween thetwoservers,wemounttheDRBDpartitionunder/var/lib/mysql. WhenfirststartingMySQL,thepartitionmustbemounted. Inordertodoso: Onthemasterserver(theserveryouareworkingon),tellDRBDtobecometheprimarynodewith: # drbdadm primary mysql mysqlbeingthenameoftheDRBDpartition. Thecommandcat /proc/drbdshoulddisplaysomethinglike: ... 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r---- ns:145068 nr:4448 dw:149516 dr:10490 al:31 bm:14 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0 Copyright©2015Inverseinc. Installation 6 Chapter3 StopandbackuppreviousMySQLdata # service mysqld stop # mkdir /var/lib/mysql.bak # mv /var/lib/mysql/* /var/lib/mysql.bak/ Mountthepartitionwith: # mount /dev/drbd0 /var/lib/mysql StartMySQL # service mysqld start Executethesecureinstallationscriptinordertosettherootpassword,removethetestdatabases andanonymoususercreatedbydefault: # /usr/bin/mysql_secure_installation MakesureMySQLdoesnotstartatboottime: # chkconfig --level 2345 mysqld off Heartbeatconfiguration InstalltheEPELrepository # rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel- release-6-8.noarch.rpm In/etc/yum.repos.d/epel.repo,disabletherepository [epel] name=Extra Packages for Enterprise Linux 6 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch failovermethod=priority enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 NowinstallHeartbeat # yum install heartbeat --enablerepo=epel Create/etc/ha.d/ha.cfwiththefollowingcontent: Copyright©2015Inverseinc. Installation 7 Chapter3 bcast eth0 keepalive 2 warntime 30 deadtime 60 auto_failback off initdead 120 node pf1.example.com node pf2.example.com use_logd yes logfile /var/log/ha-log HereweassumethattheconnectionfortheHeartbeatbetweenthe2serversisoneth0.Make sureyouchangepf1.example.comandpf2.example.comtothehostnamesofyourservers. Create/etc/ha.d/haresourceswiththefollowingcontent: pf1.example.com drbddisk::mysql Filesystem::/dev/drbd0::/var/lib/mysql::ext4 \ mysqld Create/etc/ha.d/authkeyswiththefollowingcontent: auth 1 1 sha1 10abf064f24a3e807dde7b945d0303392f10777d andchangeitsrightslikethis: # chmod 600 /etc/ha.d/authkeys Note Makesureport694isopened(throughiptables)onbothservers StartHeartbeat: # service heartbeat start LookatHeartbeatlogfile/var/log/ha-logtomakesurethateverythingisfine. EnableHBautomaticstart # chkconfig --level 345 heartbeat on MySQLnetworkconfiguration InorderforyourPacketFenceclustertocommunicateproperlywiththeMySQLdatabase,youneed tohaveMySQLbindonthemanagementIPaddress. AdjustyourMySQLconfigurationin/etc/my.cnfonbothserversandmakesurethebind_address lineis: Copyright©2015Inverseinc. Installation 8 Chapter3 bind_address=<management_ip_address>