当前位置: 代码迷 >> 综合 >> Test multipath feature by hand (by quqi99)
  详细解决方案

Test multipath feature by hand (by quqi99)

热度:60   发布时间:2023-12-13 09:13:36.0

**作者:张华 发表于:2017-02-16
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明
( http://blog.csdn.net/quqi99 )**

1, Create a VM with one NIC ens3 (10.5.9.40) and the second NIC ens7 (10.5.9.41) and the second disk /dev/vdc as iscsi server

nova keypair-add --pub-key ~/.ssh/id_rsa.pub mykey
nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0nova boot --key-name mykey --image auto-sync/ubuntu-yakkety-16.10-amd64-server-20161214-disk1.img --flavor m1.small --nic net-id=$(neutron net-list |grep 'zhhuabj_admin_net' |awk '{print $2}') iscsi_server#add the second NIC ens7
VM_ID=$(nova list |grep 'iscsi_server' |awk '{print $2}')
nova interface-attach $VM_ID --net-id=$(neutron net-list |grep 'zhhuabj_admin_net' |awk '{print $2}')cinder create --display_name iscsi_server_volume 2
nova volume-attach iscsi_server $(cinder list |grep 'iscsi_server_volume' |awk '{print $2}')FLOATING_IP=$(nova floating-ip-create |grep 'ext_net' |awk '{print $4}')
nova add-floating-ip iscsi_server $FLOATING_IP
ssh ubuntu@10.230.69.180 -vssh ubuntu@10.230.69.180 sudo dhclient ens7

2, Login into iscsi server VM and set up target by hand

sudo apt-get install lvm2
sudo pvcreate /dev/vdc
sudo vgcreate cinder-volumes /dev/vdc
#dd if=/dev/zero of=/tmp/test-volume.img bs=1M count=2048
#sudo losetup -f --show /tmp/test-volume.img
#sudo pvcreate /dev/loop0
#sudo vgcreate cinder-volumes /dev/loop0
sudo lvcreate -L 1.5G -n lv1 cinder-volumes  #will create /dev/cinder-volumes/lv1sudo apt-get install tgt
sudo tgtadm --lld iscsi --op new --mode target --tid 1 --targetname iqn.2017-02.com.quqi:storage
#Attach a LUN
sudo tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 --backing-store /dev/cinder-volumes/lv1
#persistent
sudo -i
tgt-admin --dump > /etc/tgt/conf.d/my-targets.conf && exit
sudo service tgt restart
cat /etc/tgt/conf.d/my-targets.conf
default-driver iscsi
<target iqn.2017-02.com.quqi:storage>backing-store /dev/cinder-volumes/lv1
</target>#verify
# sudo tgtadm --mode target --op show

3, Create another VM as iscsi client

nova boot --key-name mykey --image auto-sync/ubuntu-yakkety-16.10-amd64-server-20161214-disk1.img --flavor m1.small --nic net-id=$(neutron net-list |grep 'zhhuabj_admin_net' |awk '{print $2}') iscsi_client
FLOATING_IP=$(nova floating-ip-create |grep 'ext_net' |awk '{print $4}')
nova add-floating-ip iscsi_client $FLOATING_IP
ssh ubuntu@10.230.69.181 -v

4, Set up iscsi client

sudo apt-get install open-iscsi multipath-tools
sudo iscsiadm -m discovery -t sendtargets -p 10.5.9.40
sudo iscsiadm -m discovery -t sendtargets -p 10.5.9.41
$ sudo iscsiadm -m node
10.5.9.41:3260,1 iqn.2017-02.com.quqi:storage
10.5.9.40:3260,1 iqn.2017-02.com.quqi:storagesudo iscsiadm -m node --loginall=all
#sudo iscsiadm -m node --logoutall=all$ sudo iscsiadm -m session
tcp: [1] 10.5.9.41:3260,1 iqn.2017-02.com.quqi:storage (non-flash)
tcp: [2] 10.5.9.40:3260,1 iqn.2017-02.com.quqi:storage (non-flash)$ sudo multipath -l
360000000000000000e00000000010001 dm-0 IET,VIRTUAL-DISK
size=1.5G features='0' hwhandler='0' wp=rw
|-+- policy='round-robin 0' prio=0 status=active
| `- 3:0:0:1 sda 8:0  active undef running
`-+- policy='round-robin 0' prio=0 status=enabled`- 2:0:0:1 sdb 8:16 active undef runningsudo fdisk -l
sudo mkfs.ext4 /dev/mapper/360000000000000000e00000000010001
sudo mkdir /test
sudo mount -o _netdev /dev/mapper/360000000000000000e00000000010001 /test
  相关解决方案