Created
January 18, 2020 00:58
-
-
Save pulketo/6df76646492c4d4c24e06766145ee5e6 to your computer and use it in GitHub Desktop.
iSCSI montar Centos 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Falta borrar comandos de más | |
Configurando i-SCSI en Centos 7 | |
Guia: https://www.thegeekdiary.com/complete-guide-to-configuring-iscsi-in-centos-rhel-7/ | |
targetcli | |
ls | |
SERVIDOR: | |
$ ssh pk@192.168.0.110 | |
pk@192.168.0.110's password: | |
Last login: Fri Jan 17 17:06:16 2020 from 192.168.0.9 | |
$ sudo lvscan | |
... | |
... | |
ACTIVE '/dev/extra/disco5' [500.00 MiB] inherit | |
ACTIVE '/dev/extra/disco6' [500.00 MiB] inherit | |
... | |
╰─$ mount -l | grep '/disco5' | |
╰─$ sudo yum install targetcli 1 ↵ | |
... | |
... | |
Installed: | |
targetcli.noarch 0:2.1.fb49-1.el7 | |
Dependency Installed: | |
libnl.x86_64 0:1.1.4-3.el7 | |
pyparsing.noarch 0:1.5.6-9.el7 | |
python-configshell.noarch 1:1.1.fb25-1.el7 | |
python-ethtool.x86_64 0:0.8-8.el7 | |
python-kmod.x86_64 0:0.9-4.el7 | |
python-rtslib.noarch 0:2.1.fb69-3.el7 | |
python-six.noarch 0:1.9.0-2.el7 | |
python-urwid.x86_64 0:1.1.1-3.el7 | |
Complete! | |
╰─$ sudo systemctl enable target | |
Created symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/target.service. | |
╰─$ sudo systemctl start target | |
╰─$ targetcli | |
╰─$ lsblk | grep disco5 1 ↵ | |
├─extra-disco5 253:7 0 500M 0 lvm | |
╰─$ sudo targetcli | |
Warning: Could not load preferences file /root/.targetcli/prefs.bin. | |
targetcli shell version 2.1.fb49 | |
Copyright 2011-2013 by Datera, Inc and others. | |
For help on commands, type 'help'. | |
/> ls /backstores | |
o- backstores ............................................................ [...] | |
o- block ................................................ [Storage Objects: 0] | |
o- fileio ............................................... [Storage Objects: 0] | |
o- pscsi ................................................ [Storage Objects: 0] | |
o- ramdisk .............................................. [Storage Objects: 0] | |
/> targetcli ls /backstores | |
/> cd /backstores/block | |
CREAR LUN: | |
/backstores/block> create name=LUN_1 dev=/dev/extra/disco5 | |
Created block storage object LUN_1 using /dev/extra/disco5. | |
/backstores/block> ls | |
o- block .................................................. [Storage Objects: 1] | |
o- LUN_1 ............... [/dev/extra/disco5 (500.0MiB) write-thru deactivated] | |
o- alua ................................................... [ALUA Groups: 1] | |
o- default_tg_pt_gp ....................... [ALUA state: Active/optimized] | |
/backstores/block> cd /iscsi | |
/iscsi> cd / | |
/> ls | |
o- / ..................................................................... [...] | |
o- backstores .......................................................... [...] | |
| o- block .............................................. [Storage Objects: 1] | |
| | o- LUN_1 ........... [/dev/extra/disco5 (500.0MiB) write-thru deactivated] | |
| | o- alua ............................................... [ALUA Groups: 1] | |
| | o- default_tg_pt_gp ................... [ALUA state: Active/optimized] | |
| o- fileio ............................................. [Storage Objects: 0] | |
| o- pscsi .............................................. [Storage Objects: 0] | |
| o- ramdisk ............................................ [Storage Objects: 0] | |
o- iscsi ........................................................ [Targets: 0] | |
o- loopback ..................................................... [Targets: 0] | |
/> cd iscsi | |
/iscsi> create | |
Created target iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791. | |
Created TPG 1. | |
Global pref auto_add_default_portal=true | |
Created default portal listening on all IPs (0.0.0.0), port 3260. | |
/iscsi> ls /iscsi | |
o- iscsi .......................................................... [Targets: 1] | |
o- iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791 .... [TPGs: 1] | |
o- tpg1 ............................................. [no-gen-acls, no-auth] | |
o- acls ........................................................ [ACLs: 0] | |
o- luns ........................................................ [LUNs: 0] | |
o- portals .................................................. [Portals: 1] | |
o- 0.0.0.0:3260 ................................................... [OK] | |
/iscsi> exit | |
Global pref auto_save_on_exit=true | |
Configuration saved to /etc/target/saveconfig.json | |
╭─pk@centoshard ~ | |
╰─$ sudo firewall-cmd --permanent --add-port=3260/tcp | |
[sudo] password for pk: | |
success | |
╭─pk@centoshard ~ | |
╰─$ sudo firewall-cmd -reload | |
usage: see firewall-cmd man page | |
firewall-cmd: error: unrecognized arguments: -reload | |
╭─pk@centoshard ~ | |
╰─$ sudo firewall-cmd --reload 2 ↵ | |
success | |
╭─pk@centoshard ~ | |
╰─$ sudo targetcli | |
targetcli shell version 2.1.fb49 | |
Copyright 2011-2013 by Datera, Inc and others. | |
For help on commands, type 'help'. | |
/iscsi> cd /iscsi/iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791/ | |
/iscsi/iqn.20....de47ad3cd791> cd tpg1/luns | |
/iscsi/iqn.20...791/tpg1/luns> create /backstores/block/LUN_1 lun1 | |
Created LUN 1. | |
/iscsi/iqn.20...791/tpg1/luns> cd /iscsi/iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791/tpg1/acls | |
/iscsi/iqn.20...791/tpg1/acls> cd .. | |
/iscsi/iqn.20...ad3cd791/tpg1> cd .. | |
/iscsi/iqn.20....de47ad3cd791> pwd | |
/iscsi/iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791 | |
/iscsi/iqn.20....de47ad3cd791> ls | |
o- iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791 ...... [TPGs: 1] | |
o- tpg1 ............................................... [no-gen-acls, no-auth] | |
o- acls .......................................................... [ACLs: 0] | |
o- luns .......................................................... [LUNs: 1] | |
| o- lun1 ............. [block/LUN_1 (/dev/extra/disco5) (default_tg_pt_gp)] | |
o- portals .................................................... [Portals: 1] | |
o- 0.0.0.0:3260 ..................................................... [OK] | |
/iscsi/iqn.20....de47ad3cd791> pwd | |
/iscsi/iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791 | |
/iscsi/iqn.20....de47ad3cd791> cd tpg1/luns/ | |
/iscsi/iqn.20...791/tpg1/luns> ls | |
o- luns .............................................................. [LUNs: 1] | |
o- lun1 ................. [block/LUN_1 (/dev/extra/disco5) (default_tg_pt_gp)] | |
/iscsi/iqn.20...791/tpg1/luns> | |
/iscsi/iqn.20...791/tpg1/luns> pwd | |
/iscsi/iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791/tpg1/luns | |
/iscsi/iqn.20...791/tpg1/luns> cd .. | |
/iscsi/iqn.20...ad3cd791/tpg1> cd .. | |
/iscsi/iqn.20....de47ad3cd791> pwd | |
/iscsi/iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791 | |
/iscsi/iqn.20....de47ad3cd791> cd .. | |
/iscsi> ls -lrt | |
No such path /iscsi/-lrt | |
/iscsi> ls | |
o- iscsi .......................................................... [Targets: 1] | |
o- iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791 .... [TPGs: 1] | |
o- tpg1 ............................................. [no-gen-acls, no-auth] | |
o- acls ........................................................ [ACLs: 0] | |
o- luns ........................................................ [LUNs: 1] | |
| o- lun1 ........... [block/LUN_1 (/dev/extra/disco5) (default_tg_pt_gp)] | |
o- portals .................................................. [Portals: 1] | |
o- 0.0.0.0:3260 ................................................... [OK] | |
/iscsi> cd /iscsi/iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791/tpg1/acls | |
/iscsi/iqn.20...791/tpg1/acls> create iqn.1994-05.com.redhat:1fd2cc689879 | |
Created Node ACL for iqn.1994-05.com.redhat:1fd2cc689879 | |
Created mapped LUN 1. | |
/iscsi/iqn.20...791/tpg1/acls> exit | |
/iscsi/iqn.20...791/tpg1/acls> quit | |
Command not found quit | |
/iscsi/iqn.20...791/tpg1/acls> exit | |
Global pref auto_save_on_exit=true | |
Last 10 configs saved in /etc/target/backup/. | |
Configuration saved to /etc/target/saveconfig.json | |
╭─pk@centoshard ~ | |
╰─$ ip a | |
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 | |
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | |
inet 127.0.0.1/8 scope host lo | |
valid_lft forever preferred_lft forever | |
inet6 ::1/128 scope host | |
valid_lft forever preferred_lft forever | |
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 | |
link/ether 00:0c:29:b0:e9:38 brd ff:ff:ff:ff:ff:ff | |
inet 192.168.0.110/24 brd 192.168.0.255 scope global noprefixroute ens33 | |
valid_lft forever preferred_lft forever | |
inet6 fe80::8a67:25e6:be29:f72c/64 scope link noprefixroute | |
valid_lft forever preferred_lft forever | |
3: ens37: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000 | |
link/ether 00:0c:29:b0:e9:42 brd ff:ff:ff:ff:ff:ff | |
4: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 | |
link/ether 00:0c:29:b0:e9:42 brd ff:ff:ff:ff:ff:ff | |
inet 192.168.0.120/24 brd 192.168.0.255 scope global noprefixroute bond0 | |
valid_lft forever preferred_lft forever | |
inet6 fe80::9778:a195:228d:5a47/64 scope link noprefixroute | |
valid_lft forever preferred_lft forever | |
╭─pk@centoshard ~ | |
╰─$ ip a | grep 192 | |
inet 192.168.0.110/24 brd 192.168.0.255 scope global noprefixroute ens33 | |
inet 192.168.0.120/24 brd 192.168.0.255 scope global noprefixroute bond0 | |
╭─pk@centoshard ~ | |
╰─$ sudo targetcli | |
[sudo] password for pk: | |
targetcli shell version 2.1.fb49 | |
Copyright 2011-2013 by Datera, Inc and others. | |
For help on commands, type 'help'. | |
/iscsi/iqn.20...791/tpg1/acls> | |
CLIENTE: | |
490 ssh pk@192.168.0.110 | |
493 ssh pk@192.168.0.120 | |
495 ssh pk@192.168.0.120 | |
496 history | grep ssh | |
DiploTI@Pingo ~ | |
$ ssh pk@192.168.0.109 | |
ssh: connect to host 192.168.0.109 port 22: Connection timed out | |
DiploTI@Pingo ~ | |
$ ssh pk@192.168.0.109 | |
DiploTI@Pingo ~ | |
$ ssh pk@192.168.0.112 | |
The authenticity of host '192.168.0.112 (192.168.0.112)' can't be established. | |
ECDSA key fingerprint is SHA256:iO0oC+vSuSAb2BulxneymbWGY2LtX79407wtdfMyI+c. | |
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes | |
Warning: Permanently added '192.168.0.112' (ECDSA) to the list of known hosts. | |
pk@192.168.0.112's password: | |
Last login: Fri Jan 17 15:08:02 2020 | |
╭─pk@diploseguridad ~ | |
╰─$ | |
Connection to 192.168.0.112 closed. | |
DiploTI@Pingo ~ | |
$ ssh pk@192.168.0.100 | |
pk@192.168.0.100's password: | |
Last login: Fri Jan 17 15:08:37 2020 from 192.168.0.9 | |
╭─pk@diploseguridad ~ | |
╰─$ lvscan | |
WARNING: Running as a non-root user. Functionality may be unavailable. | |
/run/lvm/lvmetad.socket: access failed: Permission denied | |
WARNING: Failed to connect to lvmetad. Falling back to device scanning. | |
╭─pk@diploseguridad ~ | |
╰─$ sudo lsblk | |
[sudo] password for pk: | |
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT | |
sda 8:0 0 30G 0 disk | |
├─sda1 8:1 0 300M 0 part /boot | |
├─sda2 8:2 0 3G 0 part [SWAP] | |
└─sda3 8:3 0 26.7G 0 part / | |
sr0 11:0 1 1024M 0 rom | |
╭─pk@diploseguridad ~ | |
╰─$ sudo yum install iscsi-initiator-utils | |
[sudo] password for pk: | |
Loaded plugins: fastestmirror, langpacks | |
Loading mirror speeds from cached hostfile | |
* base: mirror.hackingand.coffee | |
* epel: mirror.arizona.edu | |
* extras: repos.lax.quadranet.com | |
* updates: repos-tx.psychz.net | |
Package iscsi-initiator-utils-6.2.0.874-11.el7.x86_64 already installed and latest version | |
Nothing to do | |
╭─pk@diploseguridad ~ | |
╰─$ cat /etc/iscsi/initiatorname.iscsi | |
InitiatorName=iqn.1994-05.com.redhat:1fd2cc689879 | |
╭─pk@diploseguridad ~ | |
╰─$ ^Ãsystemctl enable iscsid | |
zsh: systemctl: command not found... | |
zsh: command not found: \M-^Csystemctl | |
╭─pk@diploseguridad ~ | |
╰─$ systemctl start iscsid 127 ↵ | |
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === | |
Authentication is required to manage system services or units. | |
Authenticating as: DiploSeguridadXP (pk) | |
Password: | |
╭─pk@diploseguridad ~ | |
╰─$ sudo systemctl start iscsid 130 ↵ | |
╭─pk@diploseguridad ~ | |
╰─$ sudo systemctl enable iscsid | |
Created symlink from /etc/systemd/system/multi-user.target.wants/iscsid.service to /usr/lib/systemd/system/iscsid.service. | |
╭─pk@diploseguridad ~ | |
╰─$ iscsiadm -m discovery --type sendtargets –p 192.168.12.13 | |
╭─pk@diploseguridad ~ | |
╰─$ iscsiadm -m discovery --type sendtargets –p 192.168.0.110 1 ↵ | |
iscsiadm: Please specify portal as <ipaddr>[:<ipport>] | |
╭─pk@diploseguridad ~ | |
╰─$ sudo iscsiadm -m discovery --type sendtargets –p 192.168.0.110:3260 7 ↵ | |
iscsiadm: Please specify portal as <ipaddr>[:<ipport>] | |
╭─pk@diploseguridad ~ | |
╰─$ sudo iscsiadm -m discovery --type sendtargets –--targetname iqn.2003-01.org.linux-iscsi.centoshard.x8664:lun1 -p 192.168.0.110 -l | |
192.168.0.110:3260,1 iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791 | |
Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791, portal: 192.168.0.110,3260] (multiple) | |
Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791, portal: 192.168.0.110,3260] successful. | |
╭─pk@diploseguridad ~ | |
╰─$ fdisk -l | |
fdisk: cannot open /dev/sda: Permission denied | |
fdisk: cannot open /dev/sdb: Permission denied | |
╭─pk@diploseguridad ~ | |
╰─$ sudo fdisk -l | |
Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectors | |
Units = sectors of 1 * 512 = 512 bytes | |
Sector size (logical/physical): 512 bytes / 512 bytes | |
I/O size (minimum/optimal): 512 bytes / 512 bytes | |
Disk label type: dos | |
Disk identifier: 0x000ddf0b | |
Device Boot Start End Blocks Id System | |
/dev/sda1 * 2048 616447 307200 83 Linux | |
/dev/sda2 616448 6907903 3145728 82 Linux swap / Solaris | |
/dev/sda3 6907904 62914559 28003328 83 Linux | |
Disk /dev/sdb: 524 MB, 524288000 bytes, 1024000 sectors | |
Units = sectors of 1 * 512 = 512 bytes | |
Sector size (logical/physical): 512 bytes / 512 bytes | |
I/O size (minimum/optimal): 512 bytes / 4194304 bytes | |
╭─pk@diploseguridad ~ | |
╰─$ lsblk | |
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT | |
sda 8:0 0 30G 0 disk | |
├─sda1 8:1 0 300M 0 part /boot | |
├─sda2 8:2 0 3G 0 part [SWAP] | |
└─sda3 8:3 0 26.7G 0 part / | |
sdb 8:16 0 500M 0 disk | |
sr0 11:0 1 1024M 0 rom | |
╭─pk@diploseguridad ~ | |
╰─$ sudo fdisk /dev/sdb | |
Welcome to fdisk (util-linux 2.23.2). | |
Changes will remain in memory only, until you decide to write them. | |
Be careful before using the write command. | |
Device does not contain a recognized partition table | |
Building a new DOS disklabel with disk identifier 0xfcb29315. | |
Command (m for help): n | |
Partition type: | |
p primary (0 primary, 0 extended, 4 free) | |
e extended | |
Select (default p): p | |
Partition number (1-4, default 1): 1 | |
First sector (8192-1023999, default 8192): | |
Using default value 8192 | |
Last sector, +sectors or +size{K,M,G} (8192-1023999, default 1023999): | |
Using default value 1023999 | |
Partition 1 of type Linux and of size 496 MiB is set | |
Command (m for help): w | |
The partition table has been altered! | |
Calling ioctl() to re-read partition table. | |
Syncing disks. | |
╭─pk@diploseguridad ~ | |
╰─$ sudo pvcreate /dev/sdb1 | |
Physical volume "/dev/sdb1" successfully created. | |
╭─pk@diploseguridad ~ | |
╰─$ sudo vgcreate vg_iscsi /dev/sdb1 | |
Volume group "vg_iscsi" successfully created | |
╭─pk@diploseguridad ~ | |
╰─$ sudo lvcreate -L 500M -n lv_cliente_iscsi vg_iscsi | |
Volume group "vg_iscsi" has insufficient free space (123 extents): 125 required. | |
╭─pk@diploseguridad ~ | |
╰─$ sudo mkfs.ext4 /dev/vg_iscsi/lv_cliente_iscsi 5 ↵ | |
mke2fs 1.42.9 (28-Dec-2013) | |
Could not stat /dev/vg_iscsi/lv_cliente_iscsi --- No such file or directory | |
The device apparently does not exist; did you specify it correctly? | |
╭─pk@diploseguridad ~ | |
╰─$ sudo lsblk 1 ↵ | |
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT | |
sda 8:0 0 30G 0 disk | |
├─sda1 8:1 0 300M 0 part /boot | |
├─sda2 8:2 0 3G 0 part [SWAP] | |
└─sda3 8:3 0 26.7G 0 part / | |
sdb 8:16 0 500M 0 disk | |
└─sdb1 8:17 0 496M 0 part | |
sr0 11:0 1 1024M 0 rom | |
╭─pk@diploseguridad ~ | |
╰─$ sudo lvcreate -L 470M -n lv_cliente_iscsi vg_iscsi | |
Rounding up size to full physical extent 472.00 MiB | |
WARNING: ext4 signature detected on /dev/vg_iscsi/lv_cliente_iscsi at offset 1080. Wipe it? [y/n]: y | |
Wiping ext4 signature on /dev/vg_iscsi/lv_cliente_iscsi. | |
Logical volume "lv_cliente_iscsi" created. | |
╭─pk@diploseguridad ~ | |
╰─$ sudo mkfs.ext4 /dev/vg_iscsi/lv_cliente_iscsi | |
mke2fs 1.42.9 (28-Dec-2013) | |
Filesystem label= | |
OS type: Linux | |
Block size=1024 (log=0) | |
Fragment size=1024 (log=0) | |
Stride=0 blocks, Stripe width=4096 blocks | |
120832 inodes, 483328 blocks | |
24166 blocks (5.00%) reserved for the super user | |
First data block=1 | |
Maximum filesystem blocks=34078720 | |
59 block groups | |
8192 blocks per group, 8192 fragments per group | |
2048 inodes per group | |
Superblock backups stored on blocks: | |
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409 | |
Allocating group tables: done | |
Writing inode tables: done | |
Creating journal (8192 blocks): done | |
Writing superblocks and filesystem accounting information: done | |
╭─pk@diploseguridad ~ | |
╰─$ lsblk | |
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT | |
sda 8:0 0 30G 0 disk | |
├─sda1 8:1 0 300M 0 part /boot | |
├─sda2 8:2 0 3G 0 part [SWAP] | |
└─sda3 8:3 0 26.7G 0 part / | |
sdb 8:16 0 500M 0 disk | |
└─sdb1 8:17 0 496M 0 part | |
└─vg_iscsi-lv_cliente_iscsi 253:0 0 472M 0 lvm | |
sr0 11:0 1 1024M 0 rom | |
╭─pk@diploseguridad ~ | |
╰─$ sudo lvscan | |
ACTIVE '/dev/vg_iscsi/lv_cliente_iscsi' [472.00 MiB] inherit | |
╭─pk@diploseguridad ~ | |
╰─$ | |
╰─$ sudo iscsiadm -m session | |
[sudo] password for pk: | |
tcp: [1] 192.168.0.110:3260,1 iqn.2003-01.org.linux-iscsi.centoshard.x8664:sn.de47ad3cd791 (non-flash) | |
╭─pk@diploseguridad ~ | |
╰─$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment