Computer 10: Lesson 10 - Online Crimes and Hazards
testing-nfs
1. Highly Available NFS Server Scenario NFS Server1 nfs1.example.com 192.168.1.X NFS Server2 nfs2.example.com 192.168.1.X Virtual IP-Address 192.168.1.X NFS client For WebServers or FTP Servers
2. Install ubuntu-dapper on both system Crate two seprate partition on both /dev/hdax (For DRBD's meta data /dev/hday ( For Shared Directory like /web) /dev/hdax should be more than 128MB /dev/hday should be identical in size on both system Do not mount /dev/hdax and /dev/hday during installation How To Install Ubuntu
3. Installation and Configuration of DRBD 1) Synchronize System Time with date command or ntp 2) Install NFS server on both nfs1 and nfs2 sudo apt-get install nfs-kernel-server 3) Remove starup scripts , because heartbeat will controll NFS sudo update-rc.d -f nfs-kernel-server remove sudo update-rc.d -f nfs-common remove
4. 4) Create NFS Share on both nfs server /web/site 192.168.1.0/255.255.255.0(rw,no_root_squash,no_all_squash,sync) 5) Install Linux kernel headers and DRDB on both NFS Server sudo apt-get install linux-headers-`uname -r` sudo apt-get install drbd0.7-module-source sudo apt-get install drbd0.7-utils Installation and Configuration of DRBD Contd.....
5. Installation Contd...... cd /usr/src/ sudo tar xvfz drbd0.7.tar.gz cd modules/drbd/drbd sudo make sudo make install 6) Configure /etc/drbd.conf file on both NFS Server , and it must be identical vi /etc/drbd.conf resource r0 { protocol C; incon-degr-cmd "echo '!DRBD! pri on incon-degr' | mail abhishek.singh@fosteringlinux.com ; sleep 60"; startup { degr-wfc-timeout 120; # 2 minutes. }
7. Configuration Contd............... on nfs1 { # ** EDIT ** the hostname of server 1 (uname -n) device /dev/drbd0; # disk /dev/hday; # ** EDIT ** data partition on server 1 address 192.168.1.x:7788; # ** EDIT ** IP address on server 1 meta-disk /dev/hdax[0]; #* EDIT * 128MB partition for DRBD onserver1 } on nfs2 { # ** EDIT ** the hostname of server 2 (uname -n) device /dev/drbd0; # disk /dev/hday; # ** EDIT ** data partition on server 2 address 192.168.1.x:7788; # ** EDIT ** IP address on server 2 meta-disk /dev/hdax[0]; # * EDIT * 128MB partition for DRBD on server 2 } } Replcae with slave NFS Server IP Address Replcae x and y with partition number Replcae with master NFS Server IP Address Replcae x and y with partition number
8. 6) Now load DRBD kernel module in memory modprobe drbd Note: Next time drbd init script will load the module drbdadm up all cat /proc/drbd 7)Make data consistent on both server Run following command on nfs1 machine drbdadm -- --do-what-I-say primary all drbdadm -- connect all cat /proc/drbd ( To check progress of data initial sync )
9. How To sync NFS lock and other information from Primary to Slave Server 1) Create Directory on both server mkdir /web 2) Do following on server nfs1 mount -t ext3 /dev/drbd0 /web mv /var/lib/nfs/ /web/ ln -s /web/nfs/ /var/lib/nfs mkdir /web/site umount /web 3) Do following on server nfs2 rm -fr /var/lib/nfs/ ln -s /web/nfs/ /var/lib/nfs
10. How To install and configure Hearbeat 1 ) Install Hearbeat on both the server sudo apt-get install heartbeat 2) Now Edit following three files on both NFS servers /etc/heartbeat/ha.cf logfacility local0 keepalive 2 deadtime 30 bcast eth0 node nfs1 nfs2 /etc/heartbeat/haresources nfs1 IPaddr::192.168.1.x/24/eth0 drbddisk::r0 Filesystem::/dev/drbd0::/web::ext3 nfs-kernel-server Replace with Virtual Ipaddress
11. Configuration Contd.............. 3)Set Password for heartbeat communication /etc/authkeys auth 3 3 md5 fosteringlinux 4) Make /etc/authkeys readble by root only chmod 600 /etc/authkeys Replace with your string
12. Start DRBD and heartbeat on both NFS server #sudo /etc/init.d/drbd start #sudo /etc/init.d/heartbeat start Testing 1) Check virtual ipaddress on master nfs server (nfs1) ifconfig mount 2) Do same on slave nfs server (nfs2) Note: There should not be virtual ipaddress and mounted /content directory
13. Testing Continued............. 2) Replicate Server Failure Create any directory or file on NFS server (nfs1) mkdir /web/site/failure Stop hearbeat on NFS server (nfs1) #sudo /etc/init.d/heartbeat stop 3) Check slave server Virtual Ipaddess ,exported /web ifconfig mount created failure directory should be there cd /web/site ls
14. 4) Do same on slave Create any file and directory in /web/site mkdir /web/site/success Stop heartbeat on Slave (nfs2) 5) Run these commands on master so now VIP and /web should be on master ifconfig mount df -h -T
15. Configure NFS Client mkdir /web mount -t nfs 192.168.1.x:/web/site /web Note: Replace 192.168.1.x with Virtual Ipaddress vi /etc/fstab 192.168.1.x:/web/site /web nfs rw 0 0 Replace with Virtual IP addess