NO.A.0002——FreeNAS安装与配置(版本9.3与11.04)/linux客户端iscsi共享存储/FreeNASA配置iscsi/Linux下Targets链接/iscsi自动挂载
- linux客户端iscsi共享存储
- FreeNASA配置iscsi
- Linux下Targets链接
- iscsi自动挂载
1.FreeNAS 是基于 FreeBSD 的
2.
3.
4. 操作系统版本选择“FreeBSD“
因为我下载的 FreeNAS 的版本是 32 位的,所以这里选择 “FreeBSD”。
如果你下载的 FreeNAS 的版本是 64 位的,要选择 "FreeBSD 64位"。
5.
6.选择处理器
7. 内存配置为 1G 就够用了
8.配置网络模式:
9.选择I/O控制器类型:
10. 虚拟磁盘类型-->SCSI(S)
11.
12. 磁盘大小设置为 10G 就够用了,因为这块盘上仅安装 FreeNAS 系统,不需要太大空间。
13.磁盘名称:保持默认
14. 点击“自定义硬件”
15. 删除不必要的设备,如 USB 控制器、声卡。
16. 点击“关闭”
17. 点击“完成”
18. 点击 “编辑虚拟机设置”,添加用于存储数据的硬盘。
19. 点击 "添加"
20. 点击 "硬盘" --> 点击 "下一步"
21. 选择 "SCSI(S)" --> 点击 "下一步"
22.
23. 磁盘容量设置为 100G
24. 点击 "完成"
25. 重复 19-24 的步骤,再添加 3 块同样的磁盘,添加完成后入下图所示。
二、安装 FreeNAS
26.
27.
28. 选择大小为 10G 的硬盘
29. 选择 "Yes",键入回车确认。
30.
31.
32.
三、配置 FreeNAS
33.
34.
35.
36.
37.
38. 确认 FreeNAS 可以和宿主机通信
39. 在浏览器地址栏中输入 http://192.168.147.111,通过 WEB 页面管理 FreeNAS。
40. 右上角 Alert 图标有告警,点击查看,提示你修改 admin 用户密码。
41.
42. 修改 admin 用户密码
43. 密码修改成功
44.
45. 添加卷
卷类型说明:
Stripe: 至少需要一个磁盘
Mirror: 至少需要两个磁盘
RAIDZ1: 至少需要三个磁盘
RAIDZ2: 至少需要四个磁盘
RAIDZ3: 至少需要五个磁盘
log device: 至少需要一个专用设备,建议使用快速,低延迟,电源保护的SSD
cache device: 至少需要一个专用设备,建议使用SSD
在添加卷按钮警告说, 现有的数据将被清除。换句话说,创建新卷将重新格式化选定的磁盘。
如果要保留现有数据,请单击“ 取消”按钮并参考 导入磁盘和导入卷来查看是否支持现有格式。
如果是,请执行该操作。如果当前存储格式不受支持,则需要将数据备份到外部介质,格式化磁盘,
然后将数据恢复到新卷。
4 块硬盘,用 RaidZ2 方式。
46.
47.
48. 开启 iSCSI 服务
49.
50. 12 ≤ 密码长度 ≤ 16
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69. 在 iSCSI 属性中开启 CHAP 验证,选择组1。
三、Winodws 客户端配置
这里以 Winodws 7 为例
70.
71. 点击 "发现门户"
72.
73.
74.
75.
76. 点击 "连接"
77. 点击 "高级"
78.
79.
80.
81.
82. 点击 "取消"
83. 可以看到 iSCSI 磁盘了
二、linux客户端连接iscsi共享存储1、linux访问iscsi详细操作
#安装配置 iscsi-initiator
[root@localhost ~]# yum -y install iscsi-initiator-utils
[root@localhost ~]# service iscsid start
#连接到iscsi共享存储
[root@localhost ~]# iscsiadm -m discovery -t sendtargets -p 192.168.1.230
192.168.1.230:3260,1 iqn.2011-03.org.example.istgt:iscsiwin8
192.168.1.230:3260,1 iqn.2011-03.org.example.istgt:iscsilinux
#登录到iscsi共享存储
[root@localhost ~]#
iscsiadm -m node -T iqn.2011-03.org.example.istgt:iscsilinux -p 192.168.1.230:3260 -l
Logging in to [iface: default, target: iqn.2011-03.org.example.istgt:iscsilinux,
portal: 192.168.1.230,3260] (multiple)
Login to [iface: default, target: iqn.2011-03.org.example.istgt:iscsilinux,
portal: 192.168.1.134,3260] successful.
#查看磁盘信息,可以看到多出一块硬盘设备。
[root@localhost data]# fdisk -l
Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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: 0x000a43f1
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 419430399 209202176 8e Linux LVM
Disk /dev/mapper/centos-root: 205.8 GB, 205759971328 bytes, 401874944 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 /dev/mapper/centos-swap: 8455 MB, 8455716864 bytes, 16515072 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 /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
#对设备进行格式化
[root@localhost data]# 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 0xd96b07f4.
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):
First sector (2048-209715199, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost data]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system).
/dev/sr0 has been opened read-only.
Warning: Unable to open /dev/sr0 read-write (Read-only file system).
/dev/sr0 has been opened read-only.
Warning: Unable to open /dev/sr0 read-write (Read-only file system).
/dev/sr0 has been opened read-only.
2、检查磁盘格式化;文件系统;挂载:
#格式化完成检查
[root@localhost data]# fdisk -l
Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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: 0x000a43f1
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 419430399 209202176 8e Linux LVM
Disk /dev/mapper/centos-root: 205.8 GB, 205759971328 bytes, 401874944 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 /dev/mapper/centos-swap: 8455 MB, 8455716864 bytes, 16515072 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 /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: dos
Disk identifier: 0xd96b07f4
Device Boot Start End Blocks Id System
/dev/sdb1 2048 209715199 104856576 83 Linux
#指定分区格式
[root@localhost data]# mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=256 blocks
6553600 inodes, 26214144 blocks
1310707 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
#挂载并写入文件
[root@localhost ~]# mkdir /data/iscsi
[root@localhost ~]# mount -t ext4 /dev/sdb1 /data/iscsi/
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 192G 1.4G 191G 1% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 8.7M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 497M 108M 390M 22% /boot
tmpfs 797M 0 797M 0% /run/user/0
/dev/sdb1 99G 61M 94G 1% /data/iscsi
#设置开机自动挂载
[root@localhost mnt]# echo "/dev/sdb1 /data/iscsi/ ext4 defaults 0 0" >> /etc/fstab
#检查
[root@localhost mnt]# cat /etc/fstab
# /etc/fstab
# Created by anaconda on Fri Nov 10 19:40:13 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=115aec57-6962-443e-9878-943f3e207a84 /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
/dev/sdb1 /data/iscsi/ ext4 defaults 0 0
#查看并创建文件
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 192G 1.4G 191G 1% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 8.6M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 497M 108M 390M 22% /boot
tmpfs 797M 0 797M 0% /run/user/0
/dev/sdb1 99G 61M 94G 1% /data/iscsi
[root@localhost ~]# cd /data/iscsi/
[root@localhost iscsi]# touch test2
[root@localhost iscsi]# ll
total 16
drwx------ 2 root root 16384 Nov 22 11:30 lost+found
-rw-r--r-- 1 root root 0 Nov 22 11:59 test2
#卸载挂载的分区
[root@localhost ~]# umount /dev/sdb1
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 192G 1.4G 191G 1% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 8.6M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 497M 108M 390M 22% /boot
tmpfs 797M 0 797M 0% /run/user/0
三、FreeNas11.04 配置iscsi
1、全局配置
2、采用不认证的方式
3、配置后的效果
4、配置认证网络
5、ALL 或192.168.1.1/24 (某一网段)
6、配置共享账号
配置共享账号效果如下:
7、配置Targent不认证方式访问
8、配置共享目录名称,位置,大小,硬盘RPM.
9、Extents配置完成效果图
10、设置Associated Targets
11、点发现(Discovery)---->Discover Portal:输入IP和端口号--->ok。(其它地方直接用默认设置,即可)
12、Targets(查看连接状态)
13、点磁盘管理,会弹出(检测到了新硬盘),指定GPT格式,再分区格式化,即可使用。
如果之前挂载过相同的iscsi磁盘,再挂载时会报错,只需点再Rescan Disks即可,修复。
14、linux下 Targets连接方法
注意他们的端口号是不一样的(备注:默认3260时,可以不指定端口号 )
[root@template ~]# iscsiadm -m discovery -t sendtargets -p 192.168.1.140
#如果改了端口号,在后面要指定端口号
[root@template ~]# iscsiadm -m discovery -t sendtargets -p 192.168.1.140:3261
192.168.1.140:3261,2 iqn.gitlab.11.0
15、登录到共享存储(备注:这里测试登录不同端口的共享盘)
[root@template ~]# iscsiadm -m node -T iqn.gitlab.11.0 -p 192.168.1.140:3261 -l
Logging in to [iface: default, target: iqn.gitlab.11.0, portal: 192.168.1.140,3261] (multiple)
Login to [iface: default, target: iqn.gitlab.11.0, portal: 192.168.1.140,3261] successful.
16、卸载iscsi
[root@next-cloud-server ~]# iscsiadm -m node -T iqn.netcloud.11.0 -u
Logging out of session [sid: 1, target: iqn.netcloud.11.0, portal: 10.0.101.6,3261]
Logout of [sid: 1, target: iqn.netcloud.11.0, portal: 10.0.101.6,3261] successful.
17、实现iscsi自动挂载磁盘(Fedora25设置开机自动挂载)
#配置iscsi自动发现
[root@localhost ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.netcloud.11.0
#重新启动服务
[root@localhost ~]# systemctl restart iscsid
[root@localhost ~]# systemctl status iscsid
systemctl enable iscsid
#设置开机自动挂载
[root@next-cloud-server ~]# vi /etc/rc.d/rc.local
#!/bin/sh
#mount iscsi disk 5TB
sleep 10
[root@localhost ~]# mount -t xfs /dev/sda /data
#授权
[root@localhost ~]# chmod +x /etc/rc.d/rc.local
#添加服务
[root@next-cloud-server ~]# vim /usr/lib/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.d/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.d/rc.local
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.d/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
#添加下面两行代码,实现rc-local作为服务启动
[Install]
WantedBy=multi-user.target
#启动服务
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl start rc-local.service (备注:去掉这行)
[root@localhost ~]# systemctl enable rc-local.service
18、挂载分区5T
[root@localhost ~]# fdisk /dev/sda
g #大于5tb
再回车分区到完成
[root@localhost ~]# partprobe
[root@localhost ~]# mkfs.xfs -f /dev/sda
[root@localhost ~]# mount -t xfs /dev/sda /data/
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
<wiz_marker id="wiz-painter-root" style="">
posted on 2020-11-18 14:02 yanqi_vip 阅读(2825) 评论(0) 编辑 收藏 举报
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)