How to Create or Configure iSCSI Server and Clinet
Server: server.example.com
IP Address: 192.168.122.246
OS: CentOS 7.9
Client: client.example.com
IP Address: 192.168.122.245
Server:
[root@server ~]# pvcreate /dev/vdb
[root@server ~]# vgcreate newvg /dev/vdb
[root@server ~]# lvcreate -L 10G -n iscsi newvg
[root@server ~]# yum install targetcli -y
[root@server ~]# targetcli
> cd /backstores/block
/backstores/block> create iscsi_disk1 /dev/newvg/iscsi
Created block storage object iscsi_disk1 using /dev/newvg/iscsi.
/backstores/block> cd /iscsi
/iscsi> create iqn.2016-02.local.cass2.server:disk1
Created target iqn.2016-02.local.cass2.server:disk1.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi> cd /iscsi/iqn.2016-02.local.cass2.server:disk1/tpg1/acls
/iscsi/iqn.20...sk1/tpg1/acls> create iqn.2016-02.local.cass2.server:cass1
Created Node ACL for iqn.2016-02.local.cass2.server:cass1
/iscsi/iqn.20...sk1/tpg1/acls> cd /iscsi/iqn.2016-02.local.cass2.server:disk1/tpg1/luns
/iscsi/iqn.20...sk1/tpg1/luns> create /backstores/block/iscsi_disk1
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2016-02.local.cass2.server:cass1
/iscsi/iqn.20...sk1/tpg1/luns> cd /
/> saveconfig
Last 10 configs saved in /etc/target/backup/.
Configuration saved to /etc/target/saveconfig.json
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup/.
Configuration saved to /etc/target/saveconfig.json
[root@server ~]# systemctl restart target.service
Client:
[root@client ~]# yum install iscsi-initiator-utils -y
[root@client ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2016-02.local.cass2.server:cass1
[root@client ~]# iscsiadm -m discovery -t st -p 192.168.122.246
[root@client ~]# systemctl restart iscsid.service
[root@client ~]# iscsiadm -m node -T iqn.2016-02.local.cass2.server:disk1 -p 192.168.122.246 -l
[root@client ~]# lsblk
Comments
Post a Comment