查看文章 |
Building up a High-Available Server-environment hosting Windows- and Linux-ServerWork in heavily progress - plz be patient I will use the following software:
MotivationThink of the High-End-Solutions which just cost a bunch of money. Just a Short Example: Today, fibre channel is one of the most popular solutions for shared storage. Fibre channel is a high-speed serial-transfer interface that is used to connect systems and storage devices in either point-to-point (FC-P2P), arbitrated loop (FC-AL), or switched topologies (FC-SW). Protocols supported by Fibre Channel include SCSI and IP. Fibre channel configurations can support as many as 127 nodes and have a throughput of up to 2.12 gigabits per second in each direction, and 4.25 Gbps is expected. Fibre channel, however, is very expensive. With the popularity of Gigabit Ethernet and the demand for lower cost, Fibre Channel has recently been given a run for its money by iSCSI-based storage systems. Today, iSCSI SANs remain the leading competitor to FC SANs. Ratified on February 11th, 2003 by the Internet Engineering Task Force (IETF), the Internet Small Computer System Interface, better known as iSCSI, is an Internet Protocol (IP)-based storage networking standard for establishing and managing connections between IP-based storage devices, hosts, and clients. iSCSI is a data transport protocol defined in the SCSI-3 specifications framework and is similar to Fibre Channel in that it is responsible for carrying block-level data over a storage network. Block-level communication means that data is transferred between the host and the client in chunks called blocks. High-Performance-Servers depend on this type of communication in order to work properly. Like a FC SAN, an iSCSI SAN should be a separate physical network devoted entirely to storage, however, its components can be much the same as in a typical IP network (LAN). Also consider that 10-Gigabit Ethernet is a reality today! So we will follow these Rule: C.R.E.A.M. - Cash Rulez Everything Around Me Please send questions and critics to thohal@linuxfellaz.net until the work is in progress. © by Thomas Halinka Goal :Creating a dynamic scalable, flexible and high-available Server-Environment hosting virtualized Windows Server (VMware Server) and Linux-Server(XEN). I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I love Debian GNU/Linux because of my enormous affinity towards this command apt-get. As a starter knowing this one command, It is so easy to install packages and you dont need to worry about package dependency and configuration. The Debian-Packages are still in beta-phase - so use them only, when you what you’re doing The Setupscreenshot….. RequirementsTo install such an Environment you will need the following:
Installing the HA-CLUSTER (MASTER/SLAVE)Insert your Debian Etch Netinstall CD into your system and boot from it. Just install a “Standard System” on a small Partition (6 GB should be enough). We will store the DATA on a flexible Logical Volume (which you can expand later…) Also all the other required Packages would be installed later… Regarding the partitioning, I use the following partition scheme: /dev/sda1 – 100 MB /boot (primary, ext3, Bootable flag: on) /dev/sda5 – 5000 MB / (logical, ext3) /dev/sda6 – 1000 MB swap (logical) /dev/sda7 – 150 MB unmounted (logical, ext3) (will contain DRBD’s meta data) /dev/dm-0 – 260 GB unmounted (logical, ext3) (will contain the /data directory) You can vary the sizes of the partitions depending on your hard disk size, and the names of your partition might also vary, depending on your hardware (e.g. you might have /dev/hda1 instead of /dev/sda1 and so on). However, it is important that /dev/sda7 has a little more than 128 MB because we will use this partition for DRBD’s meta data which uses 128 MB. Also, make sure /dev/sda7 as well as /dev/dm-0 are identical in size on MASTER and SLAVE, and please do not mount them (when the installer asks you: No mount point is assigned for the ext3 file system in partition #7 of SCSI1 (0,0,0) (sda). Do you want to return to the partitioning menu? please answer No)! /dev/md-0 is going to be our data partition (i.e., our NFS share). I prefer LVM2 so i got md-0. LVM2 refers to a new userspace toolset that provide logical volume management facilities on linux. Short LVM-Howto:Create a Partition of the Type lvm (partition-ID “8e”) cfdisk /dev/hdX Create the Physical-Volume pvcreate /dev/hdXx And another one (optional) pvcreate /dev/hdYy And finally create the Volume-Group “vol” vgcreate vol /dev/hdXx /dev/hdYy I’ve created one Volume-Group and one Logical-Volume and left some space for snapshotz…. Don’t set any Mountpoint for this Volume! DRBD will mount this drive later. After the basic installation make sure that you give MASTER and SLAVE static IP addresses. Afterwards, you should check /etc/fstab on both systems. Mine looks like this on both systems: # /etc/fstab: static file system information. Synchronize System TimeIt’s important that MASTER and SLAVE have the same system time. Therefore we install an NTP client on both: MASTER/SLAVE: apt-get install ntp ntpdate Afterwards you can check that both have the same time by running MASTER/SLAVE: date High-Available NFS-ServerNext we install the NFS server on MASTER and SLAVE: MASTER/SLAVE: apt-get install nfs-kernel-server Then we remove the system bootup links for NFS because NFS will be started and controlled by heartbeat in our setup: MASTER/SLAVE: update-rc.d -f nfs-kernel-server remove We want to export the directory / (this will be our NFS share that our nodes will use), so we edit /etc/exports on server1 and server2. It should contain only the following line: MASTER/SLAVE: # cat /etc/exports: /data/export/ 192.168.178.0/255.255.255.0(rw,no_root_squash,no_all_squash,sync) This means that / will be accessible by all systems from the 192.168.178.x subnet. See # man 5 exports to learn more about this. Later we will create /data/exports on our empty (and still unmounted!) partition /dev/md-0. Install DRBDNext we install DRBD on MASTER and SLAVE: MASTER/SLAVE: apt-get install kernel-headers-`uname -r` drbd0.7-module-source drbd0.7-utils Then edit /etc/drbd.conf on MASTER and SLAVE. It must be identical on both systems and looks like this: MASTER/SLAVE: # cat /etc/drbd.conf: resource r0 {
As resource name you can use whatever you like. Here it’s r0. Please make sure you put the correct hostnames of MASTER and SLAVE into /etc/drbd.conf. DRBD expects the hostnames as they are shown by the command uname -n If you have set MASTER and SLAVE respectively as hostnames during the basic Debian installation, then the output of uname -n should be MASTER and SLAVE. Also make sure you replace the IP addresses and the disks appropriately. If you use /dev/hda instead of /dev/sda, please put /dev/hda8 instead of /dev/md-0 into /etc/drbd.conf (the same goes for the meta-disk where DRBD stores its meta data). /dev/md-0 (or /dev/hda8…) will be used as our NFS share later on. Configure DRBDNow we load the DRBD kernel module on both Servers. We need to do this only now because afterwards it will be loaded by the DRBD init script. MASTER/SLAVE: # modprobe drbd Let’s configure DRBD: MASTER/SLAVE: # drbdadm up all The last command should show something like this (on both server1 and server2): version: 0.7.10 (api:77/proto:74) You see that both NFS servers say that they are secondary and that the data is inconsistant. This is because no initial sync has been made yet. I want to make MASTER the primary server and SLAVE the “hot-standby”, If MASTER fails, SLAVE takes over, and if MASTER comes back then all data that has changed in the meantime is mirrored back from SLAVE to MASTER so that data is always consistent. This next step has to be done only on MASTER! MASTER: # drbdadm -- --do-what-I-say primary all Now we start the initial sync between server1 and server2 so that the data on both servers becomes consistent. On server1, we do this: MASTER: # drbdadm -- connect all The initial sync is going to take a few hours (depending on the size of /dev/md-0 (/dev/hda8…)) so please be patient. You can see the progress of the initial sync like this on server1 or server2: MASTER/SLAVE: # cat /proc/drbd The output should look like this: When the initial sync is finished, the output should look like this: SVN Revision: 1743 build by phil@mescal, 2005-01-31 12:22:07 NFS stores some important information (e.g. information about file locks, etc.) in /var/lib/nfs. Now what happens if MASTER goes down? SLAVE takes over, but its information in /var/lib/nfs will be different from the information in MASTER’s /var/lib/nfs directory. Therefore we do some tweaking so that these details will be stored on our /data partition (/dev/md-0) which is mirrored by DRBD between MASTER and SLAVE. So if MASTER goes down SLAVE can use the NFS details of SLAVE. MASTER/SLAVE: mkdir /data MASTER: mount -t ext3 /dev/drbd0 /data SLAVE: rm -fr /var/lib/nfs/ Install And Configure heartbeatheartbeat is the control instance of this whole setup. It is going to be installed on MASTER and SLAVE, and it monitors the other server. For example, if MASTER goes down, heartbeat on SLAVE detects this and makes SLAVE take over. heartbeat also starts and stops the NFS server on both MASTER and SLAVE. It also provides NFS as a virtual service via the IP address 192.168.0.174 so that the nodes see only one NFS server. First we install heartbeat: MASTER/SLAVE: apt-get install heartbeat Now we have to create three configuration files for heartbeat. They must be identical on server1 and server2! MASTER/SLAVE: # /etc/heartbeat/ha.cf: logfacility local0 As nodenames we must use the output of uname -n on MASTER and SLAVE. MASTER/SLAVE: # cat /etc/heartbeat/haresources: server1 IPaddr::192.168.xxx.xxx/24/eth0 drbddisk::r0 Filesystem::/dev/drbd0::/data::ext3 nfs-kernel-server The first word is the output of uname -n on MASTER, no matter if you create the file on MASTER or SLAVE! After IPaddr we put our virtual IP address 192.168.xxxx.xxx, and after drbddisk we use the resource name of our DRBD resource which is r0 here (remember, that is the resource name we use in /etc/drbd.conf - if you use another one, you must use it here, too). MASTER/SLAVE: # cat /etc/heartbeat/authkeys: auth 3 somerandomstring is a password which the two heartbeat daemons on MASTER and SLAVE use to authenticate against each other. Use your own string here. You have the choice between three authentication mechanisms. I use md5 as it is the most secure one. /etc/heartbeat/authkeys should be readable by root only, therefore we do this: MASTER/SLAVE: # chmod 600 /etc/heartbeat/authkeys Finally we start DRBD and heartbeat on server1 and server2: MASTER/SLAVE: /etc/init.d/drbd start First TestsNow we can do our first tests. ifconfig In the output, the virtual IP address 192.168.xxx.xxx should be shown up. Preparation of the ClusterInstall further needed packagesAfter the Base-Installation you have to install some packages. apt-get update && apt-get install ifenslave linux-headers-`uname -r` libssl-dev make gcc build-essential ruby lvm2 mysql-server Prepare mySQLroot-password for mysql has to be blank! So you have to flush the root-password if you set one! # mysql -u root You need to modify your TRANSACTION ISOLATION LEVEL to READ COMMITED. # mysql -u root And link mysql.sock # ln -s /var/run/mysql/mysqld.sock /var/lib/mysql/mysql.sock For Security-Issues: The network is disabled by default in debian # cat /etc/mysql/my.cnf #!? Setup NIC-BondingFor higher Performance on the iSCSI-Target we will use network-bonding. You have to edit /etc/modutils/aliases # vim /etc/modutils/aliases Then you have to edit /etc/modprobe.d/arch/i386 # vim /etc/modprobe.d/arch/i386 edit the Network-Interfaces. I use these ones in the Howto # cat /etc/network/interfaces # This file describes the network interfaces available on your system and reboot now reboot -n Setup of ISCSINext we will setup the iSCSI-Target and an optionally iSCSI-Software-Initiator. ISCSI-Targetwget http://dfn.dl.sourceforge.net/sourceforge/iscsitarget/iscsitarget-0.4.15.tar.gz A Minimal-config without Authentication - plz consider the Manual for further Configuration! Create some Big Filez for the iSCSI-LUNs i.e. 40 GB # dd if=/dev/zero of=/home/iSCSI/LUN0 bs=1024 count=40000 You can expand them later with the seek-option of dd. Next we will export our LUNs # cat /etc/ietd.conf Target iqn.2001-04.com.example:storage.disk2.sys1.xyz ISCSI-InitiatoriSCSI-Initiator isn’t really needed on the QRM-Server but it makes live much easier apt-get install openiscsi iscsiadm -m discovery -tst -p xxxxxx -d3 iscsiadm -m node -T iqn.2001-04.com.example:storage.disk2.sys1.xyz -p xxxxx -l fdisk -l | grep sd* Here /dev/sda is the iscsi-target! |