Centos7 挂载iscsi网络存储

群晖NAS 创建iscsi跟着提示走就好了,设置chap模式,添加账号密码

centos7 

安装依赖

yum install binutils iscsi-initiator-utils kmod-xfs xfsprogs -y

启动并设置开机启动

service iscsi start
systemctl enable iscsi

查看Target

[root@node-02 ~]# iscsiadm -m discovery -t sendtargets -p 10.168.2.195,3260
10.168.2.195:3260,1 iqn.2000-01.com.synology:DS1618.Target-Test.b5f7db4101
[fe80::211:32ff:fe93:86f9]:3260,1 iqn.2000-01.com.synology:DS1618.Target-Test.b5f7db4101
10.168.2.195:3260,1 iqn.2000-01.com.synology:DS1618.Target-1.b5f7db4101
[fe80::211:32ff:fe93:86f9]:3260,1 iqn.2000-01.com.synology:DS1618.Target-1.b5f7db4101
[root@node-02 ~]# 

登陆节点前需验证

1、开启验证

iscsiadm -m node -T iqn.2000-01.com.synology:DS1618.Target-1.b5f7db4101 -p 10.168.2.195:3260 -o update --name node.session.auth.authmethod --value=CHAP

2、添加用户

iscsiadm -m node -T iqn.2000-01.com.synology:DS1618.Target-1.b5f7db4101 -p 10.168.2.195:3260 -o update --name node.session.auth.username --value=xxx

3、添加密码

iscsiadm -m node -T iqn.2000-01.com.synology:DS1618.Target-1.b5f7db4101 -p 10.168.2.195:3260 -o update --name node.session.auth.password --value='xxxxxx'  # 密码有符号请使用引号

 4、登陆节点

[root@node-02 ~]# iscsiadm -d2 -m node -T iqn.2000-01.com.synology:DS1618.Target-1.b5f7db4101 -p 10.168.2.195:3260 --login
iscsiadm: Max file limits 65536 131072 
iscsiadm: default: Creating session 1/1
Logging in to [iface: default, target: iqn.2000-01.com.synology:DS1618.Target-1.b5f7db4101, portal: 10.168.2.195,3260] (multiple)
Login to [iface: default, target: iqn.2000-01.com.synology:DS1618.Target-1.b5f7db4101, portal: 10.168.2.195,3260] successful.
# -d {0-8} #打印调试信息,有0到8这9个等级

开启自动登陆节点

vim /etc/rc.local
iscsiadm -d2 -m node -T iqn.2000-01.com.synology:DS1618.Target-1.b5f7db4101 -p 10.168.2.195:3260 --login

查看当前链接

[root@node-02 ~]# iscsiadm -m session
tcp: [6] 10.168.2.195:3260,1 iqn.2000-01.com.synology:DS1618.Target-1.b5f7db4101 (non-flash)

查看设备

[root@node-02 ~]# fdisk -l

磁盘 /dev/sda:1999.8 GB, 1999844147200 字节,3905945600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x0001f819

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048  3905945599  1952459776   8e  Linux LVM

磁盘 /dev/mapper/centos-root:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos-swap:33.8 GB, 33822867456 字节,66060288 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos-home:1911.7 GB, 1911738597376 字节,3733864448 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/sdb:10995.1 GB, 10995116277760 字节,21474836480 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 8388608 字节

分区

[root@node-02 ~]# parted /dev/sdb
GNU Parted 3.1
使用 /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt                                                      
(parted) mkpart primary 0% 100%                                           
(parted) print                                                            
Model: SYNOLOGY iSCSI Storage (scsi)
Disk /dev/sdb: 11.0TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     标志
 1      8389kB  11.0TB  11.0TB               primary

(parted) quit                                                             
信息: You may need to update /etc/fstab.

格式化

[root@node-02 ~]# mkfs.ext4 -T largefile /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Discarding device blocks: 完成                            
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=2048 blocks
10485760 inodes, 2684350464 blocks
134217523 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
81920 block groups
32768 blocks per group, 32768 fragments per group
128 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
    102400000, 214990848, 512000000, 550731776, 644972544, 1934917632, 
    2560000000

Allocating group tables: 完成                            
正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成 

挂载

[root@node-02 ~]# cd /
[root@node-02 /]# mkdir nas_dir
[root@node-02 /]# mount /dev/sdb1 /nas_dir/
[root@node-02 /]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   50G   13G   38G   26% /
devtmpfs                  16G     0   16G    0% /dev
tmpfs                     16G  1.3M   16G    1% /dev/shm
tmpfs                     16G  569M   16G    4% /run
tmpfs                     16G     0   16G    0% /sys/fs/cgroup
/dev/sda1                497M  130M  367M   27% /boot
/dev/mapper/centos-home  1.8T  1.4T  380G   79% /home
tmpfs                    3.2G     0  3.2G    0% /run/user/0
cm_processes              16G  450M   16G    3% /run/cloudera-scm-agent/process
/dev/sdb1                 10T   73M  9.5T    1% /nas_dir
 [root@node-02 /]#

 开启自动挂载

[root@node-02 /]# blkid /dev/sdb1
/dev/sdb1: UUID="6455c0be-2360-4555-800c-38e6420eb952" TYPE="ext4" PARTLABEL="primary" PARTUUID="1443a59c-7838-4946-bf06-9828c4ead9c5" 
[root@node-02 /]# 
vim /etc/fstab
添加
UUID=6455c0be-2360-4555-800c-38e6420eb952 /nas_dir ext4 defaults,_netdev 0 0

 

posted @ 2019-09-26 14:04  🐳.城南  阅读(4009)  评论(0编辑  收藏  举报