Linux搭建ISCSI服務器全過程
1、簡介
iSCSI主要是通過TCP/IP的技術,將存儲設備端通過iSCSI target功能,組成可以提供磁盤的服務器端,再通過iSCSI initiator(iSCSI初始化用戶)功能,成為能夠掛載使用iSCSI target的客戶端,如此便能夠通過iSCSI協(xié)議來進行磁盤的應用。
iSCSI target:存儲設備端,存放磁盤的RAID設備,可將Linux主機仿真為iSCSI target,以供其他主機使用;iSCSI initiator:安裝iSCSI initiator之后才能夠使用target提供的磁盤服務,通常為服務器
2、目標規(guī)劃
Server主機名 | 服務端ip | iscsi名稱 | 訪問權限控制列表 |
iscsi01.brick.com | 192.168.79.131 | iqn.2022-11.com.brick.iscsi01:server | iqn.2022-11.com.brick:client01 |
| 192.168.79.134 | iqn.2022-11.com.brick.iscsi02:server | iqn.2022-11.com.brick:client01 | |
| 雙網(wǎng)卡,主要是模擬2個 iSCSI target存儲設備端 | |||
Client主機名 | 客戶端ip | 訪問服務端ip | |
test01.brick.com | 192.168.79.132 | 192.168.79.131 | 192.168.79.134 |
| 模擬連接2個 iSCSI targe | |||
3、壞境準備
虛擬機添加一塊磁盤,劃分為3個LV
[root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 30G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 29G 0 part ├─centos-root 253:0 0 27G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 10G 0 disk [root@localhost ~]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created. [root@localhost ~]# vgcreate /dev/iscsi01 /dev/sdb Volume group "iscsi01" successfully created [root@localhost ~]# lvcreate -L 2G -n test1 iscsi01 Logical volume "test1" created. [root@localhost ~]# lvcreate -L 2G -n test2 iscsi01 Logical volume "test2" created. [root@localhost ~]# lvcreate -l 100%FREE -n test3 iscsi01 Logical volume "test3" created. [root@localhost ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao---- 26.99g swap centos -wi-ao---- 2.00g test1 iscsi01 -wi-a----- 2.00g test2 iscsi01 -wi-a----- 2.00g test3 iscsi01 -wi-a----- <6.00g [root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 30G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 29G 0 part ├─centos-root 253:0 0 27G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 10G 0 disk ├─iscsi01-test1 253:2 0 2G 0 lvm ├─iscsi01-test2 253:3 0 2G 0 lvm └─iscsi01-test3 253:4 0 6G 0 lvm
4、配置ISCSI服務端
[root@localhost ~]# mount /dev/cdrom /mnt/ #掛載鏡像 mount: /dev/sr0 寫保護,將以只讀方式掛載 [root@localhost ~]# mkdir -p /etc/yum.repos.d/back [root@localhost ~]# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/back/ #對原有的yum源進行備份 [root@localhost ~]# cd /etc/yum.repos.d/back/ [root@localhost back]# cp CentOS-Base.repo ../ [root@localhost back]# cd ../ [root@localhost yum.repos.d]# vi CentOS-Base.repo #修改yum源 [root@localhost yum.repos.d]# cat CentOS-Base.repo [root@test01 mnt]# cat /etc/yum.repos.d/CentOS-Base.repo [base] name=CentOS-Base baseurl=file:///mnt gpgcheck=1 gpgkey=file:///RPM-GPG-KEY-CentOS-7 [root@localhost yum.repos.d]# yum clean all 已加載插件:fastestmirror Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast 正在清理軟件源: base Cleaning up list of fastest mirrors Other repos take up 156 M of disk space (use --verbose for details) [root@localhost yum.repos.d]# yum repolist 已加載插件:fastestmirror Determining fastest mirrors base | 3.6 kB 00:00:00 (1/2): base/group_gz | 153 kB 00:00:00 (2/2): base/primary_db | 6.1 MB 00:00:00 源標識 源名稱 狀態(tài) base CentOS-7 - Base 10,073 repolist: 10,073 [root@localhost yum.repos.d]# yum install targetcli -y #安裝ISCSI服務端 已加載插件:fastestmirror Loading mirror speeds from cached hostfile 正在解決依賴關系 --> 正在檢查事務 ---> 軟件包 targetcli.noarch.0.2.1.53-1.el7_9 將被 安裝 --> 正在處理依賴關系 python-rtslib >= 2.1.fb41,它被軟件包 targetcli-2.1.53-1.el7_9.noarch 需要 --> 正在處理依賴關系 python-ethtool,它被軟件包 targetcli-2.1.53-1.el7_9.noarch 需要 --> 正在處理依賴關系 python-configshell,它被軟件包 targetcli-2.1.53-1.el7_9.noarch 需要 --> 正在檢查事務 ---> 軟件包 python-configshell.noarch.1.1.1.26-1.el7 將被 安裝 --> 正在處理依賴關系 python-urwid,它被軟件包 1:python-configshell-1.1.26-1.el7.noarch 需要 --> 正在處理依賴關系 python-six,它被軟件包 1:python-configshell-1.1.26-1.el7.noarch 需要 --> 正在處理依賴關系 pyparsing,它被軟件包 1:python-configshell-1.1.26-1.el7.noarch 需要 ---> 軟件包 python-ethtool.x86_64.0.0.8-8.el7 將被 安裝 --> 正在處理依賴關系 libnl.so.1()(64bit),它被軟件包 python-ethtool-0.8-8.el7.x86_64 需要 ---> 軟件包 python-rtslib.noarch.0.2.1.74-1.el7_9 將被 安裝 --> 正在處理依賴關系 python-kmod,它被軟件包 python-rtslib-2.1.74-1.el7_9.noarch 需要 --> 正在檢查事務 ---> 軟件包 libnl.x86_64.0.1.1.4-3.el7 將被 安裝 ---> 軟件包 pyparsing.noarch.0.1.5.6-9.el7 將被 安裝 ---> 軟件包 python-kmod.x86_64.0.0.9-4.el7 將被 安裝 ---> 軟件包 python-six.noarch.0.1.9.0-2.el7 將被 安裝 ---> 軟件包 python-urwid.x86_64.0.1.1.1-3.el7 將被 安裝 --> 解決依賴關系完成 依賴關系解決 =========================================================================================================================================================== Package 架構 版本 源 大小 =========================================================================================================================================================== 正在安裝: targetcli noarch 2.1.53-1.el7_9 base 75 k 為依賴而安裝: libnl x86_64 1.1.4-3.el7 base 128 k pyparsing noarch 1.5.6-9.el7 base 94 k python-configshell noarch 1:1.1.26-1.el7 base 68 k python-ethtool x86_64 0.8-8.el7 base 34 k python-kmod x86_64 0.9-4.el7 base 57 k python-rtslib noarch 2.1.74-1.el7_9 base 104 k python-six noarch 1.9.0-2.el7 base 29 k python-urwid x86_64 1.1.1-3.el7 base 654 k 事務概要 =========================================================================================================================================================== 安裝 1 軟件包 (+8 依賴軟件包) 總下載量:1.2 M 安裝大小:5.2 M Downloading packages: ----------------------------------------------------------------------------------------------------------------------------------------------------------- 總計 5.8 MB/s | 1.2 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 警告:RPM 數(shù)據(jù)庫已被非 yum 程序修改。 正在安裝 : python-six-1.9.0-2.el7.noarch 1/9 正在安裝 : pyparsing-1.5.6-9.el7.noarch 2/9 正在安裝 : python-kmod-0.9-4.el7.x86_64 3/9 正在安裝 : python-rtslib-2.1.74-1.el7_9.noarch 4/9 正在安裝 : libnl-1.1.4-3.el7.x86_64 5/9 正在安裝 : python-ethtool-0.8-8.el7.x86_64 6/9 正在安裝 : python-urwid-1.1.1-3.el7.x86_64 7/9 正在安裝 : 1:python-configshell-1.1.26-1.el7.noarch 8/9 正在安裝 : targetcli-2.1.53-1.el7_9.noarch 9/9 驗證中 : python-urwid-1.1.1-3.el7.x86_64 1/9 驗證中 : libnl-1.1.4-3.el7.x86_64 2/9 驗證中 : python-ethtool-0.8-8.el7.x86_64 3/9 驗證中 : python-rtslib-2.1.74-1.el7_9.noarch 4/9 驗證中 : targetcli-2.1.53-1.el7_9.noarch 5/9 驗證中 : python-kmod-0.9-4.el7.x86_64 6/9 驗證中 : python-six-1.9.0-2.el7.noarch 7/9 驗證中 : pyparsing-1.5.6-9.el7.noarch 8/9 驗證中 : 1:python-configshell-1.1.26-1.el7.noarch 9/9 已安裝: targetcli.noarch 0:2.1.53-1.el7_9 作為依賴被安裝: libnl.x86_64 0:1.1.4-3.el7 pyparsing.noarch 0:1.5.6-9.el7 python-configshell.noarch 1:1.1.26-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.74-1.el7_9 python-six.noarch 0:1.9.0-2.el7 python-urwid.x86_64 0:1.1.1-3.el7 完畢! [root@localhost yum.repos.d]# systemctl start target #啟動 [root@localhost yum.repos.d]# systemctl status target #查詢服務狀態(tài) ● target.service - Restore LIO kernel target configuration Loaded: loaded (/usr/lib/systemd/system/target.service; disabled; vendor preset: disabled) Active: active (exited) since 日 2022-11-13 00:22:34 CST; 9s ago Process: 1388 ExecStart=/usr/bin/targetctl restore (code=exited, status=0/SUCCESS) Main PID: 1388 (code=exited, status=0/SUCCESS) 11月 13 00:22:34 localhost.localdomain systemd[1]: Starting Restore LIO kernel target configuration... 11月 13 00:22:34 localhost.localdomain target[1388]: No saved config file at /etc/target/saveconfig.json, ok, exiting 11月 13 00:22:34 localhost.localdomain systemd[1]: Started Restore LIO kernel target configuration. [root@localhost yum.repos.d]# systemctl enable target #開機自啟 Created symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/target.service. [root@localhost yum.repos.d]# systemctl disable firewalld #開機補啟動防火墻 Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. [root@localhost yum.repos.d]# systemctl stop firewalld #關閉防火墻 [root@localhost yum.repos.d]# vi /etc/selinux/config #關閉selinux [root@localhost yum.repos.d]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted [root@localhost yum.repos.d]# hostnamectl set-hostname iscsi01.brick.com #修改主機名 [root@localhost yum.repos.d]# init 6 #重啟 Connection closing...Socket close. Connection closed by foreign host. Disconnected from remote host(inter_test_192.168.79.131) at 00:28:25. Type `help' to learn how to use Xshell prompt. [root@iscsi01 /]# targetcli Warning: Could not load preferences file /root/.targetcli/prefs.bin. targetcli shell version 2.1.53 Copyright 2011-2013 by Datera, Inc and others. For help on commands, type 'help'. /> ls o- / ....................................................................... [...] o- backstores ............................................................ [...] | o- block ................................................ [Storage Objects: 0] | o- fileio ............................................... [Storage Objects: 0] | o- ramdisk .............................................. [Storage Objects: 0] o- iscsi .......................................................... [Targets: 0] o- loopback ....................................................... [Targets: 0] />
注:targetcli是用于管理iSCSI服務端存儲資源的專用配置命令,它提供交互式配置功能,將iSCSI共享資源的配置內容抽象成“目錄”的形式,只需將各類配置信息填入到相應的“目錄”中即可。
#以下步驟涉及到的目錄
/backstores/block:iSCSI服務端配置共享設備的位置(在這里添加要共享的磁盤設備并重命名)
/> backstores/block create test1 /dev/iscsi01/test1 Created block storage object test1 using /dev/iscsi01/test1. /> backstores/block create test2 /dev/iscsi01/test2 Created block storage object test2 using /dev/iscsi01/test2. /> backstores/block create test3 /dev/iscsi01/test3 Created block storage object test3 using /dev/iscsi01/test3. /> ls o- / ......................................................................................................................... [...] o- backstores .............................................................................................................. [...] | o- block .................................................................................................. [Storage Objects: 3] | | o- test1 ................................................................ [/dev/iscsi01/test1 (2.0GiB) write-thru deactivated] | | | o- alua ................................................................................................... [ALUA Groups: 1] | | | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized] | | o- test2 ................................................................ [/dev/iscsi01/test2 (2.0GiB) write-thru deactivated] | | | o- alua ................................................................................................... [ALUA Groups: 1] | | | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized] | | o- test3 ................................................................ [/dev/iscsi01/test3 (6.0GiB) 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] />
注:/iscsi/iqn......xxx/tpg1:通過在/iscsi目錄執(zhí)行create命令生成iSCSI target名稱時自動生成的與iSCSI target名稱同名的目錄的子目錄
acls:用于存放能夠訪問iSCSI服務端共享存儲資源的驗證信息luns:用于存放可共享的硬盤設備(/backstores/block只是一個預備資源池,但沒聲明可共享)portals:用于存放iscsi服務端的ip地址5
/> #模擬兩臺ISCSI服務器 /> iscsi/ create iqn.2022-11.com.brick.iscsi01:server Created target iqn.2022-11.com.brick.iscsi01:server. Created TPG 1. Global pref auto_add_default_portal=true Created default portal listening on all IPs (0.0.0.0), port 3260. /> iscsi/ create iqn.2022-11.com.brick.iscsi02:server Created target iqn.2022-11.com.brick.iscsi02:server. Created TPG 1. Global pref auto_add_default_portal=true Created default portal listening on all IPs (0.0.0.0), port 3260. /> #創(chuàng)建ACL控制列表,兩臺服務的列表名稱必須一樣,否則客戶端無法連接兩臺服務器 /> iscsi/iqn.2022-11.com.brick.iscsi01:server/tpg1/acls create iqn.2022-11.com.brick:client01 Created Node ACL for iqn.2022-11.com.brick:client01 /> iscsi/iqn.2022-11.com.brick.iscsi01:server/tpg1/luns create /b /backstores/block/test1 /backstores/block/test2 /backstores/block/test3 /bin/ /boot/ /> iscsi/iqn.2022-11.com.brick.iscsi01:server/tpg1/luns create /backstores/block/test1 Created LUN 0. Created LUN 0->0 mapping in node ACL iqn.2022-11.com.brick:client01 /> iscsi/iqn.2022-11.com.brick.iscsi01:server/tpg1/luns create /backstores/block/test2 Created LUN 1. Created LUN 1->1 mapping in node ACL iqn.2022-11.com.brick:client01 /> iscsi/iqn.2022-11.com.brick.iscsi02:server/tpg1/acls create iqn.2022-11.com.brick:client01 Created Node ACL for iqn.2022-11.com.brick:client01 /> iscsi/iqn.2022-11.com.brick.iscsi02:server/tpg1/luns create /backstores/block/test3 Created LUN 0. Created LUN 0->0 mapping in node ACL iqn.2022-11.com.brick:client01 /> #修改portals /> iscsi/iqn.2022-11.com.brick.iscsi01:server/tpg1/portals/ delete 0.0.0.0 3260 Deleted network portal 0.0.0.0:3260 /> iscsi/iqn.2022-11.com.brick.iscsi02:server/tpg1/portals/ delete 0.0.0.0 3260 Deleted network portal 0.0.0.0:3260 /> iscsi/iqn.2022-11.com.brick.iscsi01:server/tpg1/portals/ create 192.168.79.131 3260 Using default IP port 3260 Created network portal 192.168.79.131:3260. /> iscsi/iqn.2022-11.com.brick.iscsi02:server/tpg1/portals/ create 192.168.79.134 3260 Using default IP port 3260 Created network portal 192.168.79.134:3260. /> #最初始化的/> ls o- / ......................................................................................................................... [...] o- backstores .............................................................................................................. [...] | o- block .................................................................................................. [Storage Objects: 3] | | o- test1 .................................................................. [/dev/iscsi01/test1 (2.0GiB) write-thru activated] | | | o- alua ................................................................................................... [ALUA Groups: 1] | | | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized] | | o- test2 .................................................................. [/dev/iscsi01/test2 (2.0GiB) write-thru activated] | | | o- alua ................................................................................................... [ALUA Groups: 1] | | | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized] | | o- test3 .................................................................. [/dev/iscsi01/test3 (6.0GiB) write-thru activated] | | 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: 2] | o- iqn.2022-11.com.brick.iscsi01:server .............................................................................. [TPGs: 1] | | o- tpg1 ............................................................................................... [no-gen-acls, no-auth] | | o- acls .......................................................................................................... [ACLs: 1] | | | o- iqn.2022-11.com.brick:client01 ....................................................................... [Mapped LUNs: 2] | | | o- mapped_lun0 ................................................................................. [lun0 block/test1 (rw)] | | | o- mapped_lun1 ................................................................................. [lun1 block/test2 (rw)] | | o- luns .......................................................................................................... [LUNs: 2] | | | o- lun0 ............................................................ [block/test1 (/dev/iscsi01/test1) (default_tg_pt_gp)] | | | o- lun1 ............................................................ [block/test2 (/dev/iscsi01/test2) (default_tg_pt_gp)] | | o- portals .................................................................................................... [Portals: 1] | | o- 192.168.79.131:3260 .............................................................................................. [OK] | o- iqn.2022-11.com.brick.iscsi02:server .............................................................................. [TPGs: 1] | o- tpg1 ............................................................................................... [no-gen-acls, no-auth] | o- acls .......................................................................................................... [ACLs: 1] | | o- iqn.2022-11.com.brick:client01 ....................................................................... [Mapped LUNs: 1] | | o- mapped_lun0 ................................................................................. [lun0 block/test3 (rw)] | o- luns .......................................................................................................... [LUNs: 1] | | o- lun0 ............................................................ [block/test3 (/dev/iscsi01/test3) (default_tg_pt_gp)] | o- portals .................................................................................................... [Portals: 1] | o- 192.168.79.134:3260 .............................................................................................. [OK] o- loopback ......................................................................................................... [Targets: 0] /> #配置完成 /> saveconfig 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
5、ISCSI服務客戶端配置
[root@localhost ~]# #修改主機名
[root@localhost ~]# hostnamectl set-hostname test01.brick.com
[root@localhost ~]# #關閉防火墻
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# #關閉Selinux
[root@localhost ~]# vi /etc/selinux/config
[root@localhost ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@localhost ~]# init 6
Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(test1_192.168.79.132) at 12:56:26.
Type `help' to learn how to use Xshell prompt.
[root@test01 ~]# #掛載yum源
[root@test01 ~]# mount /dev/cdrom /mnt
mount: 在 /dev/sr0 上找不到媒體
[root@test01 ~]# #查看虛擬機是否連接ISO鏡像
[root@test01 ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 寫保護,將以只讀方式掛載
[root@test01 ~]# rm -rf /etc/yum.repos.d/*
[root@test01 ~]# cd /etc/yum.repos.d/
[root@test01 yum.repos.d]# scp root@192.168.79.131:/etc/yum.
yum.conf yum.repos.d/
[root@test01 yum.repos.d]# scp root@192.168.79.131:/etc/yum.repos.d/*.repo ./
The authenticity of host '192.168.79.131 (192.168.79.131)' can't be established.
ECDSA key fingerprint is SHA256:RqX2HnBB90KNzIrKyY7yCTJRMwibwXa8rvZ1BOqizLk.
ECDSA key fingerprint is MD5:12:76:62:cb:44:18:7a:92:fd:45:bc:84:8d:bd:dd:54.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.79.131' (ECDSA) to the list of known hosts.
root@192.168.79.131's password:
CentOS-Base.repo 100% 537 200.5KB/s 00:00
[root@test01 yum.repos.d]# cat CentOS-Base.repo
[root@test01 mnt]# cat /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-Base
baseurl=file:///mnt
gpgcheck=1
gpgkey=file:///RPM-GPG-KEY-CentOS-7
[root@test01 yum.repos.d]# #也可以自己創(chuàng)建一個文件,按照格式書寫。
[root@test01 mnt]# yum install iscsi-initiator-utils
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 iscsi-initiator-utils.x86_64.0.6.2.0.874-22.el7_9 將被 安裝
--> 正在處理依賴關系 iscsi-initiator-utils-iscsiuio >= 6.2.0.874-22.el7_9,它被軟件包 iscsi-initiator-utils-6.2.0.874-22.el7_9.x86_64 需要
--> 正在檢查事務
---> 軟件包 iscsi-initiator-utils-iscsiuio.x86_64.0.6.2.0.874-22.el7_9 將被 安裝
--> 解決依賴關系完成
依賴關系解決
===========================================================================================================================================================
Package 架構 版本 源 大小
===========================================================================================================================================================
正在安裝:
iscsi-initiator-utils x86_64 6.2.0.874-22.el7_9 base 423 k
為依賴而安裝:
iscsi-initiator-utils-iscsiuio x86_64 6.2.0.874-22.el7_9 base 94 k
事務概要
===========================================================================================================================================================
安裝 1 軟件包 (+1 依賴軟件包)
總下載量:517 k
安裝大小:2.5 M
Is this ok [y/d/N]: Y
Downloading packages:
-----------------------------------------------------------------------------------------------------------------------------------------------------------
總計 92 MB/s | 517 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安裝 : iscsi-initiator-utils-iscsiuio-6.2.0.874-22.el7_9.x86_64 1/2
正在安裝 : iscsi-initiator-utils-6.2.0.874-22.el7_9.x86_64 2/2
驗證中 : iscsi-initiator-utils-6.2.0.874-22.el7_9.x86_64 1/2
驗證中 : iscsi-initiator-utils-iscsiuio-6.2.0.874-22.el7_9.x86_64 2/2
已安裝:
iscsi-initiator-utils.x86_64 0:6.2.0.874-22.el7_9
作為依賴被安裝:
iscsi-initiator-utils-iscsiuio.x86_64 0:6.2.0.874-22.el7_9
完畢!
[root@test01 mnt]# 添加acl訪問控制列表
[root@test01 mnt]# echo InitiatorName=iqn.2022-11.com.brick:client01 > /etc/iscsi/initiatorname.iscsi
[root@test01 mnt]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2022-11.com.brick:client01
[root@test01 mnt]# systemctl restart iscsid
[root@test01 mnt]# systemctl enable iscsid
Created symlink from /etc/systemd/system/multi-user.target.wants/iscsid.service to /usr/lib/systemd/system/iscsid.service.
[root@test01 mnt]# systemctl status iscsid
● iscsid.service - Open-iSCSI
Loaded: loaded (/usr/lib/systemd/system/iscsid.service; enabled; vendor preset: disabled)
Active: active (running) since 日 2022-11-13 13:15:03 CST; 11s ago
Docs: man:iscsid(8)
man:iscsiuio(8)
man:iscsiadm(8)
Main PID: 1343 (iscsid)
Status: "Ready to process requests"
CGroup: /system.slice/iscsid.service
└─1343 /sbin/iscsid -f
11月 13 13:15:03 test01.brick.com systemd[1]: Starting Open-iSCSI...
11月 13 13:15:03 test01.brick.com systemd[1]: Started Open-iSCSI.
iscsiadm命令詳解
- iscsiadm是個模式化的工具,其模式可通過-m或--mode選項指定,
- 常見的模式有discoverydb、node、fw、session、host、iface幾個,
- 如果沒有額外指定其它選項,則discoverydb和node會顯示其相關的所有記錄;
- session用于顯示所有的活動會話和連接,fw顯示所有的啟動固件值,host顯示所有的iSCSI主機,
- iface顯示/var/lib/iscsi/ifaces目錄中的所有ifaces設定。
-l --login | 登入節(jié)點(服務器) |
-t --type=type | 這里可以使用的類型為sendtargets(可簡寫為st)、slp、fw和 isns,此選項僅用于discovery模式,且目前僅支持st、fw和isns;其中st表示允許每個iSCSItarget發(fā)送一個可用target列表給initiator; |
-p --portal=ip[:port] | 指定target服務的IP和端口 |
-m --mode | 可用的mode有discovery, node, fw, host iface 和 session |
-T --targetname=targetname | 用于指定target的名字 |
-u --logout | 登出節(jié)點(服務器) |
-o --op=OPEARTION | 指定針對discoverydb數(shù)據(jù)庫的操作,其僅能為new、delete、update、show和nonpersistent其中之一 |
[root@test01 ~]# iscsiadm -m discovery -t st -p 192.168.79.131 #查詢發(fā)現(xiàn)記錄 192.168.79.131:3260,1 iqn.2022-11.com.brick.iscsi01:server 192.168.79.134:3260,1 iqn.2022-11.com.brick.iscsi02:server [root@test01 ~]# iscsiadm -m node show #查看iscsi發(fā)現(xiàn)記錄,show 可以忽略 192.168.79.131:3260,1 iqn.2022-11.com.brick.iscsi01:server 192.168.79.134:3260,1 iqn.2022-11.com.brick.iscsi02:server [root@test01 ~]# iscsiadm -m node -o delete -T iqn.2022-11.com.brick.iscsi02:server #刪除目標iscsi發(fā)現(xiàn)記錄 [root@test01 ~]# iscsiadm -m node -o delete #刪除所有目標 [root@test01 ~]# iscsiadm -m node -T iqn.2022-11.com.brick.iscsi01:server -p 192.168.79.131 -l #登陸記錄 [root@test01 ~]# iscsiadm -m node -L all #登錄所有記錄 [root@test01 ~]# iscsiadm -m node -u #退出所有登陸 [root@test01 ~]# iscsiadm -m session #查看連接記錄 [root@test01 ~]# iscsiadm -m node -o show -T iqn.2022-11.com.brick.iscsi01:server #查看數(shù)據(jù)結構的樹狀信息 [root@test01 ~]# iscsiadm -m node –T iqn.2022-11.com.brick.iscsi01:server -p 192.168.79.131 -o update -n node.startup -v automatic #開機自動登陸或者修改/etc/iscsi/iscsid.conf文件,將:#node.startup = automatic 一行前面的#去掉改成node.startup = automatic #操作步驟 1發(fā)現(xiàn)2登錄3開機啟動5掛載硬盤6配置開機自動掛載 [root@test01 ~]# iscsiadm -m discovery -t st -p 192.168.79.131 #發(fā)現(xiàn)目標 192.168.79.131:3260,1 iqn.2022-11.com.brick.iscsi01:server 192.168.79.134:3260,1 iqn.2022-11.com.brick.iscsi02:server [root@test01 ~]# iscsiadm -m node -T iqn.2022-11.com.brick.iscsi01:server -p 192.168.79.131 -l #登陸目標 Logging in to [iface: default, target: iqn.2022-11.com.brick.iscsi01:server, portal: 192.168.79.131,3260] (multiple) Login to [iface: default, target: iqn.2022-11.com.brick.iscsi01:server, portal: 192.168.79.131,3260] successful. [root@test01 ~]# iscsiadm -m session tcp: [13] 192.168.79.131:3260,1 iqn.2022-11.com.brick.iscsi01:server (non-flash) [root@test01 ~]# iscsiadm -m node –T iqn.2022-11.com.brick.iscsi01:server -p 192.168.79.131 -o update -n node.startup -v automatic #開機自動登陸 [root@test01 ~]# iscsiadm -m session tcp: [13] 192.168.79.131:3260,1 iqn.2022-11.com.brick.iscsi01:server (non-flash) [root@test01 ~]# lsblk #查看是否成功,多了 /dev/sdb /dev/sdc NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 19G 0 part ├─centos-root 253:0 0 17G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 2G 0 disk sdc 8:32 0 2G 0 disk sr0 11:0 1 9.6G 0 rom [root@test01 ~]# init 6 #重啟確認是否成功 Connection closing...Socket close. Connection closed by foreign host. Disconnected from remote host(test1_192.168.79.132) at 16:16:10. Type `help' to learn how to use Xshell prompt. Connecting to 192.168.79.132:22... Connection established. To escape to local shell, press 'Ctrl+Alt+]'. WARNING! The remote SSH server rejected X11 forwarding request. Last login: Sun Nov 13 16:21:36 2022 from 192.168.79.1 [root@test01 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 19G 0 part ├─centos-root 253:0 0 17G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 2G 0 disk sdc 8:32 0 6G 0 disk sdd 8:48 0 2G 0 disk sr0 11:0 1 9.6G 0 rom
總結
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
詳解Linux使用ss命令結合zabbix對socket做監(jiān)控
zabbix是一個基于WEB界面的提供分布式系統(tǒng)監(jiān)視以及網(wǎng)絡監(jiān)視功能的企業(yè)級的開源解決方案。這篇文章主要分為三塊進行說明:介紹ss命令;對機器總體的socket進行監(jiān)控;某些機器連接該機器的數(shù)量進行監(jiān)控2021-06-06
linux系統(tǒng)下MongoDB單節(jié)點安裝教程
這篇文章主要給大家介紹了在linux系統(tǒng)下mongo在單節(jié)點安裝的方法教程,文中將實現(xiàn)的方法一步步介紹的非常詳細,對大家學習或者使用具有一定的參考學習價值,需要的朋友們下面隨著小編來一起看看吧。2017-10-10
Windows 10 下安裝 Apache 2.4.41的教程
這篇文章主要介紹了Windows 10 下安裝 Apache 2.4.41的教程,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2020-01-01
UNEXPECTED INCONSISTENCY: RUN fsck MANUALLY
這篇文章主要介紹了UNEXPECTED INCONSISTENCY: RUN fsck MANUALLY,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-07-07
基于centos 6.5使用varnish實現(xiàn)網(wǎng)站動靜分離
這篇文章主要介紹了基于centos6.5使用varnish實現(xiàn)網(wǎng)站動靜分離,需要的朋友可以參考下2014-11-11

