Linux Cluster
2024-07-21 02:35:43
供稿:网友
 
             
  在RedHat下建立群集 
  注明:本安装步骤不是Dell的标准文档,不能直接发给客户,仅供学习参考。 
  环境说明: 
  1. 硬件: 
  说明:按照标准至少需要4块网卡和其他相应硬件,但因为条件限制,故在硬件和设置上做了一些变通。 
                                                                                              服务器:PE4300、PE4600 
  网卡:两个 
  RAID:两块PERC2/SC 
  Storage:PV220S和SCSI cable 
  2. 软件: 
  OS:RedHat Advance Server 2.1 
  Kernel: 2.4.9-e.3smp 
  配制分配: 
  ip: node1: 10.0.0.1/8 
  node2: 10.0.0.2/8 
  Cluster IP: 10.0.0.3 这个地址不同于Microsoft下的Cluster server IP address,该地址是用于治理上用的。 
  基本步骤: 
  一、安装OS 
  说明:为了安装可以顺利进行,建议先移掉RAID卡,否则在拷贝完文件后系统不能正常启动。因为,当使用插卡(RAID/SCSI)连接外置磁盘柜,它们将总是优先于本地硬盘被检测,这个将导致本地的盘符被改变。 
  按照通常的步骤安装OS,在系统安装完后,将RAID或SCSI卡插回主机,在下次重启时系统将自动发现新设备。但为了保证在每次系统引导时该设备能自动启动,你仍需做以下两步: 
  a. 编辑 /etc/modules.conf文件,同时增加下面内容到文件内容中 
  alias scsi_hostadapter megaraid 
  options scsi_mod max_scsi_luns=255 à可提前增加这一行,因为有共享磁盘柜存 
  在,并且有多个LUN在上面时,系统要求这样做。 
  b. 执行 
  Mkinitrd initrd-2.4.9-e.3smp.img 2.4.9-e.3smp à这行的内容主要还是由内核来决定。 
  例: 
  /etc/modules.conf: 
  alias scsi_hostadapter megaraid 
  options scsi_mod max_scsi_luns=255 
  二、物理连接 
  这部份的步骤与W2K一样,即先用一个节点配制LUN,另一个节点从磁盘读LUN配制,同时保证2块RAID卡的Cluster功能开启,SCSI ID 不能冲突,同时将PV220S的开关拨动到Cluster模式。 
  三、安装和配制分区 
  1.建立分驱 
  说明:建议在此时只开一个节点。在系统启动后,系统可以识别在磁盘柜上新建的LUN。设备名通常是在本地硬盘后顺序编排。例如:当本地是/dev/sda,那么新的设备是/dev/sdb 
  分区的原则和要求:Quorum分区的要求:不能小于10M,必须是裸设备,不能有文件系统。 
  Quorum分区只能用于Cluster的状态和配制信息。 
  Quorum要求两个分区,一个为PRimary,另一个为slave 
  Cluster 应用服务的分区:要求一个cluster服务一个分区。例如:你想有SQL、NFS、SAMBA三个Cluster应用服务,那么你必须为三个服务各建一个分区。 
  例:fdisk /dev/sdb 创建新的分区 
  /dev/sdb1 àQuorum primary partition 
  /dev/sdb2 àQuorum slave partition 
  /dev/sdb3 àSql partition 
  /dev/sdb4 àNFS partition 
  /dev/sdb5 àsamba partition 
  注重:在创建完分驱后,一定要重启主机,建议重启所有设备。 
  2.建立文件系统――即格式化分区 
  说明:Quorum 必须是裸设备,所以不需要格式化。但其他分区必须格式化,同时将默认的Block块大小增大到4096,默认为1024。 
  例: 
  mkfs –t ext2 –j –b 4096 /dev/sdbx –-》X代表分区 
  3.为Cluster 创建Quorum分区 
  说明:使用命令 cat /proc/devices 确认系统是否支持裸设备,假如你看到下面的输出,说明系统可以支持裸设备。 
  162 raw 
  在两台服务器上分别编辑/etc/sysconfig/rawdevices文件,以便将分区绑定到裸设备。 
  例: /etc/sysconfig/rawdevices 
  # format: 
  # 
  #example: /dev/raw/raw1 /dev/sda1 
  # /dev/raw/raw2 8 5 
  /dev/raw/raw1 /dev/sdb1 
  /dev/raw/raw2 /dev/sdb2 
  重启服务 service rawdevices restart 
  4.检查和验证Quoram分区 
  在两个节点上分别cludiskutil –p 确保两个节点都能有以下输出: 
  ----- Shared State Header ------ 
  Magic# = 0x39119fcd 
  Version = 1 
  Updated on Thu Sep 14 05:43:18 2000 
  Updated by node 0 
  四、建立Cluster服务 
  说明:确保所有网卡正常工作。
                         同时,设置基本的网络要求。 
  1.编辑/etc/hosts 文件 
  127.0.0.1 localhost.localdomain localhost 
  10.0.0.1 node1.test.com node1 
  10.0.0.2 node2.test.com node2 
  10.0.0.3 Clusteralias.test.com Clusteralias 
  2.运行/sbin/clUConfig 
  说明:系统将自动生成cluster的配制文件/etc/cluster.conf,这一步只需要在其中一个节点上运行。 
  你将看到以下输出: 
  Enter cluster name [Cluster]:Cluster 
  Enter IP address for cluster alias [x.x.x.x]: 10.0.0.3 
  -------------------------------- 
  Information for Cluster Member 0 
  -------------------------------- 
  Enter name of cluster member [storage0]: node1 
  Looking for host storage0 (may take a few seconds)... 
  Enter number of heartbeat channels (minimum = 1) [1]: 1 
  Information about Channel 0 
  Channel type: net or serial [net]: 
  Enter hostname of the cluster member on heartbeat channel 0 / 
  [node1]: node1 
  Looking for host node1 (may take a few seconds)... 
  Information about Quorum Partitions 
  Enter Primary Quorum Partition [/dev/raw/raw1]: /dev/raw/raw1
  Enter Shadow Quorum Partition [/dev/raw/raw2]: /dev/raw/raw2
  Information About the Power Switch That Power Cycles Member ’storage0’ 
  Choose one of the following power switches: 
  o NONE 
  o RPS10 
  o BAYTECH 
  o APCSERIAL 
  o APCMASTER 
  o WTI_NPS 
  Power switch [NONE]: NONE 
  Information for Cluster Member 1 
  -------------------------------- 
  Enter name of cluster member [node2]: node2 
  Looking for host storage1 (may take a few seconds)... 
  Information about Channel 0 
  Enter hostname of the cluster member on heartbeat channel 0 / 
  [node2]: node2 
  Looking for host storage1 (may take a few seconds)... 
  Information about Quorum Partitions 
  Enter Primary Quorum Partition [/dev/raw/raw1]: /dev/raw/raw1
  Enter Shadow Quorum Partition [/dev/raw/raw2]: /dev/raw/raw2
  Information About the Power Switch That Power Cycles Member ’node2’ 
  Choose one of the following power switches: 
  o NONE 
  o RPS10 
  o BAYTECH 
  o APCSERIAL 
  o APCMASTER 
  o WTI_NPS 
  Power switch [NONE]: NONE 
  Cluster name: Development Cluster 
  Cluster alias IP address: 10.0.0.154 
  Cluster alias netmask: 255.255.254.0 
  -------------------- 
  Member 0 Information 
  -------------------- 
  Name: node1 
  Primary quorum partition: /dev/raw/raw1 
  Shadow quorum partition: /dev/raw/raw2 
  Heartbeat channels: 1 
  Channel type: net, Name: node1 
  Power switch IP address or hostname: node1 
  -------------------- 
  Member 1 Information 
  -------------------- 
  Name: node2 
  Primary quorum partition: /dev/raw/raw1 
  Shadow quorum partition: /dev/raw/raw2 
  Heartbeat channels: 1 
  Channel type: net, Name: node2 
  Save the cluster member information?
                          yes/no [yes]: 
  Writing to configuration file...done 
  Configuration information has been saved to /etc/cluster.conf. 
  ---------------------------- 
  Setting up Quorum Partitions 
  ---------------------------- 
  Running cludiskutil -I to initialize the quorum partitions: done 
  Saving configuration information to quorum partitions: done 
  Do you wish to allow remote monitoring of the cluster? yes/no / 
  [yes]: yes 
  ---------------------------------------------------------------- 
  Configuration on this member is complete. 
  To configure the next member, invoke the following command on that system: 
  # /sbin/cluconfig --init=/dev/raw/raw1 
  See the manual to complete the cluster installation 
  3.配制第二个节点 
  只需执行 cluconfig --init=/dev/raw/raw1 
  4.启动Cluster服务 
  分别在两个节点上执行 service cluster start 
  你将看到下面的几个Daemon 
  • cluquorumd — Quorum daemon 
  • clusvcmgrd — Service manager daemon 
  • clupowerd — Power daemon 
  • cluhbd — Heartbeat daemon 
  • clumibd — Administrative system monitoring daemon 
  五、建立Cluster应用服务 
  说明:本次实验只测试了Samba,其他应用服务的建立,