Test multipath feature by hand (by quqi99)

Linux Application 专栏收录该内容
75 篇文章 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/0

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_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 -v

ssh 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/lv1

sudo 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:storage

sudo 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 running

sudo fdisk -l
sudo mkfs.ext4 /dev/mapper/360000000000000000e00000000010001
sudo mkdir /test
sudo mount -o _netdev /dev/mapper/360000000000000000e00000000010001 /test
  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 打赏
    打赏
  • 扫一扫,分享海报

©️2022 CSDN 皮肤主题:Age of Ai 设计师:meimeiellie 返回首页

打赏作者

quqi99

你的鼓励就是我创造的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值