其他分享
首页 > 其他分享> > iscsi ntp

iscsi ntp

作者:互联网

iscsi ntp

1、在iscsi服务端将大小为4G逻辑卷共享给客户端,在客户端系统启动期间,该iscsi设备自动加载。该块设备上包含一个大小为2300MB的分区,文件系统类型为ext4,此分区挂载在/share/disk上。

服务端

1.创建一块新的磁盘,创建大小为4G的逻辑卷

[root@server ~]# pvcreate /dev/sdb1 /dev/sdb2
Physical volume “/dev/sdb1” successfully created.
Physical volume “/dev/sdb2” successfully created.
[root@server ~]# vgcreate vg1 /dev/sdb1 /dev/sdb2
Volume group “vg1” successfully created

[root@server ~]# lvcreate -L 4G -n lv1 vg1
WARNING: ext4 signature detected on /dev/vg1/lv1 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/vg1/lv1.
Logical volume “lv1” created.

2 装包

关闭防火墙关闭selinux

[root@server ~]# systemctl stop firewalld
[root@server ~]# getenforce
Enforcing
[root@server ~]# setenforce 0

[root@server ~]# yum install -y targetcli
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
BaseOS 2.7 MB/s | 2.8 kB 00:00
AppStream 3.1 MB/s | 3.2 kB 00:00
软件包 targetcli-2.1.51-1.el8.noarch 已安装。
依赖关系解决。
无需任何处理。
完毕!

3.配置过程

[root@server ~]# targetcli

/> cd /backstores//block

/backstores/block> create dev=/dev/vg1/lv1 name=lun0
Created block storage object lun0 using /dev/vg1/lv1.

/backstores/block> ls /backstores/
o- backstores … […]
o- block … [Storage Objects: 1]
| o- lun0 … [/dev/vg1/lv1 (4.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]
/backstores/block>

设置共享的iscsi target名称及配置共享资源

/iscsi> create
Created target iqn.2003-01.org.linux-iscsi.server.x8664:sn.0f9f01468102.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi>

/iscsi> ls /iscsi
o- iscsi … [Targets: 1]
o- iqn.2003-01.org.linux-iscsi.server.x8664:sn.0f9f01468102 …… [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>

/iscsi> cd /iscsi/iqn.2003-01.org.linux-iscsi.server.x8664:sn.0f9f01468102/tpg1/luns

/iscsi/iqn.20…102/tpg1/luns>create/backstores/block/lun0
Created LUN 0.

/iscsi/iqn.20…102/tpg1/luns> ls
o- luns … [LUNs: 1]
o- lun0 … [block/lun0 (/dev/vg1/lv1) (default_tg_pt_gp)]

关闭账号的认证,关闭自动生成结点

/iscsi/iqn.20…102/tpg1/luns> cd …/
/iscsi/iqn.20…01468102/tpg1> pwd
/iscsi/iqn.2003-01.org.linux-iscsi.server.x8664:sn.0f9f01468102/tpg1

/iscsi/iqn.20…01468102/tpg1> get attribute authentication
authentication=0

/iscsi/iqn.20…01468102/tpg1> get attribute generate_node_acls
generate_node_acls=0

ACL 实现访问控制

/iscsi/iqn.20…01468102/tpg1> cd acls
/iscsi/iqn.20…102/tpg1/acls> create iqn.2021-10.com.redhat:client
Created Node ACL for iqn.2021-10.com.redhat:client
Created mapped LUN 0.

/iscsi/iqn.20…102/tpg1/acls> cd /
/> ls
o- / … […]
o- backstores … […]
| o- block … [Storage Objects: 1]
| | o- lun0 … [/dev/vg1/lv1 (4.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: 1]
| o- iqn.2003-01.org.linux-iscsi.server.x8664:sn.0f9f01468102 … [TPGs: 1]
| o- tpg1 … [no-gen-acls, no-auth]
| o- acls … [ACLs: 1]
| | o- iqn.2021-10.com.redhat:client … [Mapped LUNs: 1]
| | o- mapped_lun0 … [lun0 block/lun0 (rw)]
| o- luns … [LUNs: 1]
| | o- lun0 … [block/lun0 (/dev/vg1/lv1) (default_tg_pt_gp)]
| o- portals … [Portals: 1]
| o- 0.0.0.0:3260 … [OK]
o- loopback … [Targets: 0]
/>

配置完成退出

/> exit
Global pref auto_save_on_exit=true
Configuration saved to /etc/target/saveconfig.json
[root@server ~]#

重启服务

[root@server ~]# systemctl restart iscsi iscsid
[root@server ~]#

客户端

1.装包

[root@client ~]# yum install -y iscsi-initiator-utils
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
BaseOS 2.7 MB/s | 2.8 kB 00:00
AppStream 3.1 MB/s | 3.2 kB 00:00
软件包 iscsi-initiator-utils-6.2.0.878-4.gitd791ce0.el8.x86_64 已安装。
依赖关系解决。
无需任何处理。
完毕!

2.编辑配置 关闭防火墙 selinux 启动服务

[root@client ~]# vim /etc/iscsi/initatorname.iscsi
[root@client ~]# cat /etc/iscsi/initatorname.iscsi
initatorName=iqn.2021-10.com.redhat:client
关闭防火墙 selinux

[root@client ~]# systemctl stop firewalld
[root@client ~]# setenforce 0
[root@client ~]# systemctl restart iscsi iscsid

3.客户端发现服务端的共享

[root@client ~]# iscsiadm -m discovery -t st -p 192.168.183.128
192.168.183.128:3260,1 iqn.2003-01.org.linux-iscsi.server.x8664:sn.0f9f01468102
[root@client ~]#

4.客户端登录

[root@client ~]# iscsiadm -m node -l
Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.server.x8664:sn.0f9f01468102, portal: 192.168.183.128,3260]
iscsiadm: Could not login to [iface: default, target: iqn.2003-01.org.linux-iscsi.server.x8664:sn.0f9f01468102, portal: 192.168.183.128,3260].
iscsiadm: initiator reported error (24 - iSCSI login failed due to authorization failure)
iscsiadm: Could not log into all portals
[root@client ~]#

然后登不进去然后我不知道呜。。。。

5.对服务器的磁盘进行分区,格式化,挂载

mkfs.ext4 /dev/sdb1 /dev/sdb2

mkdir -p /share/disk

blkid

编辑 配置文件 vim /etc/fstab

挂载 mount -a

df -h

2、搭建时间服务器,客户端可在每天早晨的9:00整从ntp服务器更新自己的时间。

标签:tpg1,ntp,iscsi,dev,server,client,root
来源: https://blog.csdn.net/m0_53102443/article/details/120741628