rs1 172.16.1.11 hostname rs1.laoguang.me rs2 172.16.1.12 hostname rs2.laoguang.me rs3 172.16.1.13 hostname rs3.laoguang.me target 172.16.1.14 hostname target.laoguang.me VIP 172.16.1.1
hostname rs1.laoguang.me vim /etc/hosts 172.16.1.11 rs1.laoguang.me rs1 172.16.1.12 rs2.laoguang.me rs2 172.16.1.13 rs3.laoguang.me rs3 172.16.1.14 target.laoguang.me target
ssh-keygen -t rsa -P "" ##會生成密鑰在/root/.ssh下,公鑰拷貝到rs2的/root/.ssh/authorized_keys ssh-copy-id -i /root/.ssh/id_rsa.pub rs2 ##rs1登錄rs2不再需要密碼 ssh-copy-id -i /root/.ssh/id_rsa.pub target
date -s 20121127;ssh rs2 'date -s 20121127';ssh rs3 'date -s 20121127';\ ssh target 'date -s 20121127'
yum -y install httpd
echo "<h1>RS1</h1>" > /var/www/html/index.html echo "<h1>RS2</h1>" > /var/www/html/index.html echo "<h1>RS3</h1>" > /var/www/html/index.html
service httpd start
service httpd stop chkconfig httpd off
yum -y install cman rgmanager gfs2-utils
ccs_tool create WebCluster ##會在/etc/cluster中生成cluster.conf集群的配置文件(xml格式)
ccs_tool addfence Manual fence_manual ##RHCS需要先定義隔離設備 ccs_tool addnode -v 1 -n 1 -f Manual rs1.laoguang.me ##加入rs1 ccs_tool addnode -v 1 -n 2 -f Manual rs2.laoguang.me ##加入rs2 ccs_tool addnode -v 1 -n 3 -f Manual rs3.laoguang.me ##加入rs3 -v 指定每個節點的票數 -n 指定節點ID -f 指定fence設備
service cman start; ##注:如果局域網內多台機器玩cman的話cman可能啟動不成功,其它機器可能是同步的其它主機的CIB service rgmanager start; ##啟動rgmanager
system-config-cluster
clustat
Cluster Status for WebCluster @ Wed Nov 28 18:38:19 2012 Member Status: Quorate Member Name ID Status ------ ---- ---- ------ rs1.laoguang.me 1 Online, rgmanager rs2.laoguang.me 2 Online, rgmanager rs3.laoguang.me 3 Online, Local, rgmanager Service Name Owner (Last) State ------- ---- ----- ------ ----- service:WebService rs1.laoguang.me started
yum -y install scsi-target-utils
<target iqn.2012-11.me.laoguang.target:sda5> backing-store /dev/sda5 ##後備存儲,一般指一個分區,或lvm設備 initiator-address 172.16.0.0/16 ##指定intiaor只能是這個地址范圍 #direct-store /dev/sdb ##直接存儲,通常指一個磁盤如/dev/sda5 #incominguser hadoop redhat ##定義基於賬戶認證Initiator,後面的是賬號與密碼 #outgoinguser userA secretpassA ##Initiator也可以驗證target,這個target的賬號密碼 </target> ##targetname 格式 iqn-name: iqn.yyyy-mm.<reversed domain name>[identifer]
我們也可以有命令行來配置,只不過重啟後會失效哦 用法:tgtadm --lld [driver] --op [operation] --mode [mode] [OPTION].. 新增target: tgtadm --lld iscsi --op new --mode target --tid 1 --targetname iqn.2012-11.me.laoguang.target:sda5 tgtadm --lld iscsi --op show --mode target 新增一localunit: tgtadm --lld -iscsi --op new --mode localunit --tid 1 --lun 1 --backing-store /dev/sda5 新增ACL允許172.16.0.0/16網段使用: tgtadm --lld iscsi --op bind --tid 1 --initiator-address 172.16.0.0/16 新增賬戶認證: 建立賬戶: tgtadm --lld iscsi --op new --mode account --user hadoop --password redhat 查看新建賬戶: tgtadm --lld iscsi --op show --mode account 綁定賬戶到target: tgtadm --lld iscsi --op bind --mode account --tid 1 --user hadoop 查看target信息: tgtadm --lld iscsi --op show --mode target
service tgtd start tgtadm --lld iscsi --op show --mode target Target 1: iqn.2012-11.me.laoguang.target:sda5 System information: Driver: iscsi State: ready I_T nexus information: LUN information: LUN: 0 Type: controller SCSI ID: IET 00010000 SCSI SN: beaf10 Size: 0 MB, Block size: 1 Online: Yes Removable media: No Readonly: No Backing store type: null Backing store path: None Backing store flags: LUN: 1 Type: disk SCSI ID: IET 00010001 SCSI SN: beaf11 Size: 1012 MB, Block size: 512 Online: Yes Removable media: No Readonly: No Backing store type: rdwr Backing store path: /dev/sda5 Backing store flags: Account information: ACL information: 172.16.0.0/16
chkconfig tgtd off
yum -y install iscsi-initator-utils ##很可能已經安裝了 echo "InitiatorAlias=rs1" >> /etc/iscsi/initiatorname.iscsi ##分別給個別名 echo "InitiatorAlias=rs2" >> /etc/iscsi/initiatorname.iscsi echo "InitiatorAlias=rs3" >> /etc/iscsi/initiatorname.iscsi
3.1 啟動iscsi,發現共享磁盤target
service iscsi start iscsiadm -m discovery -t sendtargets -p 172.16.1.14 ##發現target 172.16.1.14:3260,1 iqn.2012-11.me.laoguang.target:sda5
iscsiadm -m node -T iqn.2012-11.me.laoguang.target:sda5 -p 172.16.1.14 -l -m 指定模式 man 一下 -t sendtargets 在discovery模式下使用 -p portal 指定target的IP與端口,如果是默認端口3260可省略 -l login 登錄 -u logout 個為登出
fdisk -l ##查看新磁盤我的是sda5
chkconfig iscsi off;chkconfig iscsid off
lvmconf --enable-cluster service clvmd start
pvcreate /dev/sdb vgcreate myvg /dev/sdb lvcreate -L 800M --name mydata myvg
ls /dev/myvg/mydata
mkfs.gfs2 -p lock_dlm -t WebCluster:mylvm -j 3 /dev/myvg/mydata
mount /dev/myvg/mydata /var/www/html echo "GFS Storage" > /var/www/html/index.html