Sie sind auf Seite 1von 3

29th December 2010

Say GNU/Linux
Linux The Choice of GNU Generation
Home Album About Contact Me Openx Management
Recent Entries Recent Comments Archives

cPremote : cPanel/whm remote DRBD Heartbeat (rsync backup plugin Active/Passive High Availability Cluster )
(4 votes, average: 4.75 out of 5) Overview Software Requirements Pre configuration DRDB installation Heartbeat Installation Testing Conclusion Overview: DRBD Heartbeat cluster a good Active / Passive cluster solution for small scale applications using two servers in active and passive mode. This means , only one server will work at a time while keeping the other server as a backup with realtime data updates. DRBD is a kernel level service which will replicate y our block devices ( HDD partition ) with the second server. So all the data that required for working y our application must be need to place in that hard disk partition. Also make sure that both of y our servers need same amount of free space. Heartbeat is a service which will manage the IP high availability and other services in y our servers. You can also integrate CRM along with heartbeat for y our big cluster projects. Please see the pictorial representation of this cluster below.

checkpcidss.com New py thon project cPanel Nginx Plugin 4.1 released Disable sslv2 in cPanel/whm services How to avoid TCP time stamp issues in linux Updated Profile Upgrade php in plesk easy way Linux-tech.net The bad company ever seen on the internet. Stay away from them How to enable gzip compression in cPanel server via mod_deflate and Apache Nginx : accept() failed (24: Too many open files)

Recent Posts
checkpcidss.com New py thon project cPanel Nginx Plugin 4.1 released Disable sslv2 in cPanel/whm services How to avoid TCP time stamp issues in linux Updated Profile

Categories
Articles Cluster cPremote Openx

Archives
December 2010 November 2010 June 2010 HA IP: 10.0.0.100 -> This will be the high availability IP. Your website/application may need to point to this IP. This IP will be available only in the Active server . If the active server go down it will be switched to Passive server Active Server : 10.0.0.101 -> This is y our active server Passive Server : 10.0.0.102 -> This will be y our passive server , means backup server. May 2010 April 2010 March 2010

In both active and passive server we need a hard disk partition , let us say /dev/sdb1 with equal amount of disk space. The October 2009 DRDB service will sy nchronize the hdd partitions via a drdb block file called /dev/drbd0. So keep in mind that this drdb September 2009 block files is alway s refers to y our original disk partition. So we are going to build this Active passive services with high March 2009 availability . Software Requirements: You may need Centos 5.x or later version , because Centos already have drbd and heartbeat as binary distributions, otherwise y ou need to compile and install drbd and heartbeat from source. Pre configuration: You may need to disable SELinux y our server and remove iptable firewalls. Also y ou need to edit /etc/hosts file in y our active and passive servers as follows and make sure it is pointing to correct IPs. 10.0.0.101 active.yourserver.com 10.0.0.102 passice.yourserver.com Now y ou need to unmount y our disk partition /dev/sdb1 and remove it from /etc/fstab too. We will erase this partition in the coming sessions. Also create a folder called /data, which we will use as mount point of drbd devic. DRDB installation: Let us install drbd first . You may need to install it in both servers and the drdb configuration must be unique. # yum -y install kmod-drbd drbd Now Edit /etc/drbd.conf as follows, resource mydrdb { protocol C; handlers { pri-on-incon-degr echo DRBD: primary requested but inconsistent! | wall; /etc/init.d/heartbeat stop; #halt -f; pri-lost-after-sb echo DRBD: primary requested but lost!| wall; /etc/init.d/heartbeat stop; #halt -f; February 2009

Blogroll
My Album My Profile/Resume Subhosting vcPanel

converted by Web2PDFConvert.com

} startup { degr-wfc-timeout 30; # 30 seconds } disk { on-io-error detach; } net { timeout 120; connect-int 20; ping-int 20; max-buffers 2048; max-epoch-size 2048; ko-count 30; cram-hmac-alg sha1; shared-secret drdbTest1gKey; } syncer { rate 50M; # synchronization data transfer rate al-extents 257; } on active.yourserver.com { device /dev/drbd0; disk /dev/sdb1; address 10.0.0.101:7789; meta-disk internal; } on passive.yourserver.com { device /dev/drbd0; disk /dev/sdb1; address 10.0.0.102:7789; meta-disk internal; } } Hope y ou already umounted the partition /dev/sdb1 . Let us make it clear using the following command # dd if=/dev/zero of= /dev/sdb1 bs=1M count=50 Now create the DRDB partition as follows, # drbdadm create-md mydrbd Format the drbd partition /dev/drbd0 with label my drdb # mkfs.ext3 -L mydrdb /dev/drbd0 Now let us start DRDB in both servers as follows, # /etc/init.d/drbd start Now login to y our active server and do the following command , this command will tell the DRDB that current server is primary # drbdadm primary mydrbd Now y ou can check the status of drdb either from /proc/drdb or using the command etc/init.d/drbd status. You can see the DRDB started sy ncing in /proc/drdb If it is not working, there will be some issues in y our installation procedure. If all ok let us proceed with the next step. Heartbeat Installation: You can use y um itself to install heartbeat # yum -y install heartbeat heartbeat-pils heartbeat-stonith There are 3 main configuration files and one resource script folders for heartbeat as follows, /etc/ha.d/ha.cf -> The heartbeat configuration file /etc/ha.d/haresources -> The hearbeat resource file , in which we specify high availability IP and services lists which need to start automatically by heartbeat /etc/ha.d/authkeys -> Hearbeat servers authentication key s. /etc/ha.d/resource.d/ -> This contain a set of init scripts which we use in haresource file for managing services First let us create the heartbeat configuration file , /etc/ha.d/ha.cf , as follows, # Heartbeat logging configuration logfacility daemon # Heartbeat cluster members node active.yourserver.com node passive.yourserver.com # Heartbeat communication timing keepalive 1 warntime 10 deadtime 30 initdead 120 # Heartbeat communication paths udpport 694 ucast eth0 10.0.0.101 # make sure this ips are on eth0 ucast eth0 10.0.0.102 baud 19200 # fail back automatically auto_failback on # Monitoring of network connection to default gateway ping 10.0.0.1 # ping to gate way for network testing

converted by Web2PDFConvert.com

respawn hacluster /usr/lib/heartbeat/ipfail Now let us create an haresource file as follows, active.yourserver.com IPaddr::10.0.0.100/24 drbddisk::mydrdb Filesystem::/dev/drbd0::/data::ext3 mysqld httpd Let me explain the above terms, The first term active.yourserver.com means all the following services must be available in active server, if that server is available. IPaddr::10.0.0.100/24 -> This term will call the init script /etc/ha.d/resource.d/IPaddr and activate the HA IP 10.0.0.100 drbddisk::mydrdb -> This term will call the init script /etc/ha.d/resource.d/drbddisk and make the switching to primary or seconday to drdb disk labeled my drdb Filesystem::/dev/drbd0::/data::ext3 -> This term will call the init script /etc/ha.d/resource.d/Filesy stem and which will mount the drdb disk /dev/drbd0 to the folder /data as a file sy stem ext3 mysqld -> This term is pointing to /etc/ha.d/resource.d/my sqld , it is a soft link to my sql startup script httpd -> This term is pointing to /etc/ha.d/resource.d/httpd , it is a soft link to httpd startup script Now let us make the soft links for my sqld and httpd init scripts under heartbeat resource folder as follows, # cd /etc/ha.d/resource.d # ln -sf /etc/init.d/mysqld ./mysqld # ln -sf /etc/init.d/httpd ./httpd Now we need to add the auth key /etc/ha.d/authkey s as follows, auth 1 1 sha1 PutYourSuperSecretKeyHere Make it little secure lol # chmod 600 /etc/ha.d/authkeys So our heartbeat installation completed. Testing: The DRBD is already running. Let us start hearbeat service in both servers. # /etc/init.d/heartbeat start You can monitor the log from /var/log/messages Within one minute the HA IP will be available in y our active server, also y ou can see the drbd partition /dev/drbd0 mounted to /data and my sql and httpd services are up and running. Now stop the heartbeat server in active node and y ou can see the IP is activating in the passive server and it is starting the my sql and httpd services . Also the DRDB partition will be mounted in y our passive server. So now y ou can put what ever data to the folder /data, after mounting the partition /dev/drbd0 by the heartbeat. It will be replicated to other sever. This is a block replication method. So if y ou have a corrupted file in one server, it will be same in y our other server too. So take care with y our application. Conclusion: You can use the above active/passive high availability cluster for service like atmail , vbulletin , openx, etc,. It is also possible to move the my sql database to the DRBD partition too. But my sql master-master replication cluster is also good. Also make sure y ou may meed to connect the NIC with fast switches or cables , to move files faster. I am not sure y ou will read this conclusion lol . If y ou do so , and y ou have any questions, please feel free to ask to me from the above contact page. Popularity : 76% Bookmark It

June 16, 2010 Post Under Articles, Cluster, Openx Post Under Articles, Cluster, Openx

converted by Web2PDFConvert.com

Das könnte Ihnen auch gefallen