日文設(shè)計(jì)網(wǎng)站自動(dòng)點(diǎn)擊器下載
FreeNAS配置教程:
linux客戶(hù)端iscsi共享存儲(chǔ)FreeNASA配置iscsiLinux下Targets鏈接iscsi自動(dòng)掛載
一、環(huán)境準(zhǔn)備:創(chuàng)建虛擬機(jī):
1.FreeNAS 是基于 FreeBSD 的
2.
3.
4. 操作系統(tǒng)版本選擇“FreeBSD“
因?yàn)槲蚁螺d的 FreeNAS 的版本是 32 位的,所以這里選擇 “FreeBSD”。
如果你下載的 FreeNAS 的版本是 64 位的,要選擇 "FreeBSD 64位"。
5.
6.選擇處理器
7. 內(nèi)存配置為 1G 就夠用了
8.配置網(wǎng)絡(luò)模式:
9.選擇I/O控制器類(lèi)型:
10. 虛擬磁盤(pán)類(lèi)型-->SCSI(S)
11.
12. 磁盤(pán)大小設(shè)置為 10G 就夠用了,因?yàn)檫@塊盤(pán)上僅安裝 FreeNAS 系統(tǒng),不需要太大空間。
13.磁盤(pán)名稱(chēng):保持默認(rèn)
14. 點(diǎn)擊“自定義硬件”
15. 刪除不必要的設(shè)備,如 USB 控制器、聲卡。
16. 點(diǎn)擊“關(guān)閉”
17. 點(diǎn)擊“完成”
18. 點(diǎn)擊 “編輯虛擬機(jī)設(shè)置”,添加用于存儲(chǔ)數(shù)據(jù)的硬盤(pán)。
19. 點(diǎn)擊 "添加"
20. 點(diǎn)擊 "硬盤(pán)" --> 點(diǎn)擊 "下一步"
21. 選擇 "SCSI(S)" --> 點(diǎn)擊 "下一步"
22.
23. 磁盤(pán)容量設(shè)置為 100G
24. 點(diǎn)擊 "完成"
25. 重復(fù) 19-24 的步驟,再添加 3 塊同樣的磁盤(pán),添加完成后入下圖所示。
二、安裝 FreeNAS
26.
27.
28. 選擇大小為 10G 的硬盤(pán)
29. 選擇 "Yes",鍵入回車(chē)確認(rèn)。
30.
31.
32.
三、配置 FreeNAS
33.
34.
35.
36.
37.
38. 確認(rèn) FreeNAS 可以和宿主機(jī)通信
39. 在瀏覽器地址欄中輸入 http://192.168.147.111,通過(guò) WEB 頁(yè)面管理 FreeNAS。
40. 右上角 Alert 圖標(biāo)有告警,點(diǎn)擊查看,提示你修改 admin 用戶(hù)密碼。
41.
42. 修改 admin 用戶(hù)密碼
43. 密碼修改成功
44.
45. 添加卷
卷類(lèi)型說(shuō)明:
Stripe: 至少需要一個(gè)磁盤(pán)
Mirror: 至少需要兩個(gè)磁盤(pán)
RAIDZ1: 至少需要三個(gè)磁盤(pán)
RAIDZ2: 至少需要四個(gè)磁盤(pán)
RAIDZ3: 至少需要五個(gè)磁盤(pán)
log device: 至少需要一個(gè)專(zhuān)用設(shè)備,建議使用快速,低延遲,電源保護(hù)的SSD
cache device: 至少需要一個(gè)專(zhuān)用設(shè)備,建議使用SSD
在添加卷按鈕警告說(shuō), 現(xiàn)有的數(shù)據(jù)將被清除。換句話(huà)說(shuō),創(chuàng)建新卷將重新格式化選定的磁盤(pán)。
如果要保留現(xiàn)有數(shù)據(jù),請(qǐng)單擊“ 取消”按鈕并參考 導(dǎo)入磁盤(pán)和導(dǎo)入卷來(lái)查看是否支持現(xiàn)有格式。
如果是,請(qǐng)執(zhí)行該操作。如果當(dāng)前存儲(chǔ)格式不受支持,則需要將數(shù)據(jù)備份到外部介質(zhì),格式化磁盤(pán),
然后將數(shù)據(jù)恢復(fù)到新卷。
4 塊硬盤(pán),用 RaidZ2 方式。
46.
47.
48. 開(kāi)啟 iSCSI 服務(wù)
49.
50. 12 ≤ 密碼長(zhǎng)度 ≤ 16
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69. 在 iSCSI 屬性中開(kāi)啟 CHAP 驗(yàn)證,選擇組1。
三、Winodws 客戶(hù)端配置
這里以 Winodws 7 為例
70.
71. 點(diǎn)擊 "發(fā)現(xiàn)門(mén)戶(hù)"
72.
73.
74.
75.
76. 點(diǎn)擊 "連接"
77. 點(diǎn)擊 "高級(jí)"
78.
79.
80.
81.
82. 點(diǎn)擊 "取消"
83. 可以看到 iSCSI 磁盤(pán)了
二、linux客戶(hù)端連接iscsi共享存儲(chǔ)1、linux訪問(wèn)iscsi詳細(xì)操作
#安裝配置 iscsi-initiator[root@localhost ~]# yum -y install iscsi-initiator-utils [root@localhost ~]# service iscsid start #連接到iscsi共享存儲(chǔ)[root@localhost ~]# iscsiadm -m discovery -t sendtargets -p 192.168.1.230192.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共享存儲(chǔ) [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. #查看磁盤(pán)信息,可以看到多出一塊硬盤(pán)設(shè)備。[root@localhost data]# fdisk -lDisk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x000a43f1 Device Boot Start End Blocks Id System/dev/sda1 * 2048 1026047 512000 83 Linux/dev/sda2 1026048 419430399 209202176 8e Linux LVMDisk /dev/mapper/centos-root: 205.8 GB, 205759971328 bytes, 401874944 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 8455 MB, 8455716864 bytes, 16515072 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 4096 bytes / 1048576 bytes#對(duì)設(shè)備進(jìn)行格式化[root@localhost data]# fdisk /dev/sdbWelcome 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 tableBuilding a new DOS disklabel with disk identifier 0xd96b07f4.Command (m for help): nPartition type: p primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): pPartition number (1-4, default 1): First sector (2048-209715199, default 2048): Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): Using default value 209715199Partition 1 of type Linux and of size 100 GiB is setCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.[root@localhost data]# partprobeWarning: 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、檢查磁盤(pán)格式化;文件系統(tǒng);掛載:
#格式化完成檢查[root@localhost data]# fdisk -lDisk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x000a43f1 Device Boot Start End Blocks Id System/dev/sda1 * 2048 1026047 512000 83 Linux/dev/sda2 1026048 419430399 209202176 8e Linux LVMDisk /dev/mapper/centos-root: 205.8 GB, 205759971328 bytes, 401874944 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 8455 MB, 8455716864 bytes, 16515072 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 4096 bytes / 1048576 bytesDisk label type: dosDisk identifier: 0xd96b07f4 Device Boot Start End Blocks Id System/dev/sdb1 2048 209715199 104856576 83 Linux#指定分區(qū)格式[root@localhost data]# mkfs.ext4 /dev/sdb1mke2fs 1.42.9 (28-Dec-2013)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=256 blocks6553600 inodes, 26214144 blocks1310707 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=2174746624800 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done #掛載并寫(xiě)入文件[root@localhost ~]# mkdir /data/iscsi[root@localhost ~]# mount -t ext4 /dev/sdb1 /data/iscsi/[root@localhost ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/centos-root 192G 1.4G 191G 1% /devtmpfs 3.9G 0 3.9G 0% /devtmpfs 3.9G 0 3.9G 0% /dev/shmtmpfs 3.9G 8.7M 3.9G 1% /runtmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup/dev/sda1 497M 108M 390M 22% /boottmpfs 797M 0 797M 0% /run/user/0/dev/sdb1 99G 61M 94G 1% /data/iscsi#設(shè)置開(kāi)機(jī)自動(dòng)掛載[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 0UUID=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 #查看并創(chuàng)建文件[root@localhost ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/centos-root 192G 1.4G 191G 1% /devtmpfs 3.9G 0 3.9G 0% /devtmpfs 3.9G 0 3.9G 0% /dev/shmtmpfs 3.9G 8.6M 3.9G 1% /runtmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup/dev/sda1 497M 108M 390M 22% /boottmpfs 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]# lltotal 16drwx------ 2 root root 16384 Nov 22 11:30 lost+found-rw-r--r-- 1 root root 0 Nov 22 11:59 test2#卸載掛載的分區(qū)[root@localhost ~]# umount /dev/sdb1[root@localhost ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/centos-root 192G 1.4G 191G 1% /devtmpfs 3.9G 0 3.9G 0% /devtmpfs 3.9G 0 3.9G 0% /dev/shmtmpfs 3.9G 8.6M 3.9G 1% /runtmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup/dev/sda1 497M 108M 390M 22% /boottmpfs 797M 0 797M 0% /run/user/0
三、FreeNas11.04 配置iscsi
1、全局配置
2、采用不認(rèn)證的方式
3、配置后的效果
4、配置認(rèn)證網(wǎng)絡(luò)
5、ALL 或192.168.1.1/24 (某一網(wǎng)段)
6、配置共享賬號(hào)
配置共享賬號(hào)效果如下:
7、配置Targent不認(rèn)證方式訪問(wèn)
8、配置共享目錄名稱(chēng),位置,大小,硬盤(pán)RPM.
9、Extents配置完成效果圖
10、設(shè)置Associated Targets
11、點(diǎn)發(fā)現(xiàn)(Discovery)---->Discover Portal:輸入IP和端口號(hào)--->ok。(其它地方直接用默認(rèn)設(shè)置,即可)
12、Targets(查看連接狀態(tài))
13、點(diǎn)磁盤(pán)管理,會(huì)彈出(檢測(cè)到了新硬盤(pán)),指定GPT格式,再分區(qū)格式化,即可使用。
如果之前掛載過(guò)相同的iscsi磁盤(pán),再掛載時(shí)會(huì)報(bào)錯(cuò),只需點(diǎn)再Rescan Disks即可,修復(fù)。
14、linux下 Targets連接方法
注意他們的端口號(hào)是不一樣的(備注:默認(rèn)3260時(shí),可以不指定端口號(hào) )[root@template ~]# iscsiadm -m discovery -t sendtargets -p 192.168.1.140 #如果改了端口號(hào),在后面要指定端口號(hào)[root@template ~]# iscsiadm -m discovery -t sendtargets -p 192.168.1.140:3261192.168.1.140:3261,2 iqn.gitlab.11.0
15、登錄到共享存儲(chǔ)(備注:這里測(cè)試登錄不同端口的共享盤(pán))
[root@template ~]# iscsiadm -m node -T iqn.gitlab.11.0 -p 192.168.1.140:3261 -lLogging 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 -uLogging 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、實(shí)現(xiàn)iscsi自動(dòng)掛載磁盤(pán)(Fedora25設(shè)置開(kāi)機(jī)自動(dòng)掛載)
#配置iscsi自動(dòng)發(fā)現(xiàn)[root@localhost ~]# cat /etc/iscsi/initiatorname.iscsiInitiatorName=iqn.netcloud.11.0#重新啟動(dòng)服務(wù)[root@localhost ~]# systemctl restart iscsid[root@localhost ~]# systemctl status iscsidsystemctl enable iscsid#設(shè)置開(kāi)機(jī)自動(dòng)掛載[root@next-cloud-server ~]# vi /etc/rc.d/rc.local #!/bin/sh#mount iscsi disk 5TBsleep 10[root@localhost ~]# mount -t xfs /dev/sda /data#授權(quán)[root@localhost ~]# chmod +x /etc/rc.d/rc.local#添加服務(wù)[root@next-cloud-server ~]# vim /usr/lib/systemd/system/rc-local.service[Unit]Description=/etc/rc.d/rc.local CompatibilityConditionFileIsExecutable=/etc/rc.d/rc.localAfter=network.target[Service]Type=forkingExecStart=/etc/rc.d/rc.local startTimeoutSec=0RemainAfterExit=yesGuessMainPID=no#添加下面兩行代碼,實(shí)現(xiàn)rc-local作為服務(wù)啟動(dòng)[Install]WantedBy=multi-user.target#啟動(dòng)服務(wù)[root@localhost ~]# systemctl daemon-reload[root@localhost ~]# systemctl start rc-local.service (備注:去掉這行)[root@localhost ~]# systemctl enable rc-local.service18、掛載分區(qū)5T[root@localhost ~]# fdisk /dev/sdag #大于5tb再回車(chē)分區(qū)到完成[root@localhost ~]# partprobe [root@localhost ~]# mkfs.xfs -f /dev/sda[root@localhost ~]# mount -t xfs /dev/sda /data/
聲明:JavaBBS論壇主要用于IT技術(shù)專(zhuān)題的交流學(xué)習(xí),為開(kāi)源技術(shù)愛(ài)好者提供廣泛、權(quán)威的技術(shù)資料。若您在技術(shù)專(zhuān)題有更好的想法或者建議,歡迎交流!!!