搭建存儲服務器html
什麼是存儲:前端
存儲是根據不一樣的應用環境經過採起合理,安全,有效的方式將數據保存到某些介質上並能保證有效的訪問node
一方面它是數據臨時或長期駐留的物理媒介vim
另外一方面,它是保證數據完整安全存放的方式或行爲後端
存儲就是把這兩方面結合起來,向客戶提供一套數據存放解決方案安全
存儲介質: 內存(臨時存儲) 磁盤(永久存儲)服務器
數據存儲位置: 雲存儲 本地 共享存儲 分佈式存儲網絡
存儲技術分類:session
SCSI 小型計算機系統接口 app
DAS 直連式存儲
NAS 網絡技術存儲
SAN 存儲區域網絡
FC 光纖通道
SCSI技術
Small Computer System Interface的簡稱
做爲輸入/輸出接口
主要用於硬盤,光盤,磁帶機等設備
DAS技術
Direct-Attached Storage的簡稱
將存儲設備經過SCSI接口或光纖通道直接鏈接到計算機上
不能實現數據與其餘主機的共享
佔用服務器操做系統資源,如CPU,IO
數據量越大,性能越差
NAS技術
Network-Attached Storage的簡稱
一種專用數據存儲服務器,以數據爲中心,將存儲設備與服務器完全分離,集中管理數據,從而釋放帶寬,提取性能,下降總擁有成分,保護投資
用戶經過TCP/IP協議訪問數據
SAN技術
Storage Area Network的簡稱
— 經過光纖交換機,光纖路由器,光纖集線器等設備將磁盤陣列,磁帶等存儲設備與相關服器鏈接起來,造成高速專用網絡
組成部分
— 如路由器,光纖交換機
— 接口:如SCSI,FC
— 通用協議:如IP,SCSI
FC技術
Fibre Channel
— 一種合適千兆數據傳輸的,成熟而安全解決方案
— 與傳統的SCSI相比,FC提供更高的數據傳輸速率,更遠的傳輸速率,更遠的傳輸距離,更多的設備鏈接支持以及更穩定的性能,更簡易的安裝
FC主要組件
— 光纖
— HBA (主機總線適配置器 )
— FC交換機
FC交換機交換拓撲
— 點到點:point-to-point
簡單將兩個設備互連
— 已裁定的環路:arbitrated loop
可多達126個設備共享一段信或環路
— 交換式拓撲:switched fabric
全部設備經過光纖交換機互連
ISCI技術
Inetnet SCSI
IETF制定的標準,將SCSI數據塊映射爲以太網數據包
是一種基於IP Storage理論的新型存儲技術
將存儲行業普遍應用的SCSI接口技術與IP網絡像結合
能夠在IP網絡上構建SAN
最初由Cisco和IBM開放
isci優點
— 基於IP協議技術的標準
— 容許網絡在TCP/IP協議上傳輸SCSI命令
— 相對了傳輸效率,存儲容量,兼容性,開放性,安全性等方面的問題
— 沒有距離限制
客戶端
— ISCSI Initiator : 軟件實現,成本低,性能較低
— ISCSI HBA:硬件實現,性能好,成本較高
存儲設備端
— ISCSI Target
在存儲設備端 主機56 上添加 三塊 3G 硬盤
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
...
vdb 252:16 0 3G 0 disk
vdc 252:32 0 3G 0 disk
vdd 252:48 0 3G 0 disk
在56 主機上使用SAN技術共享存儲空間
(/dev/vdb /dev/vdc) 給前端應服務器 53 和 54
一 配置後端存儲
裝包
# yum list | grep -i scsi
iscsi-initiator-utils.x86_64 6.2.0.873-14.el6 dvd
lsscsi.x86_64 0.23-3.el6 dvd
scsi-target-utils.x86_64 1.0.24-16.el6 dvd
# yum -y install scsi-target-utils
# rpm -q scsi-target-utils
scsi-target-utils-1.0.24-16.el6.x86_64
# rpm -qc scsi-target-utils
/etc/sysconfig/tgtd
/etc/tgt/targets.conf //主配置文件
# cp /etc/tgt/targets.conf /root/ //備份主配置文件
# chkconfig tgtd on
# chkconfig --list tgtd
tgtd 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
修改配置文件
# vim /etc/tgt/targets.conf
.. ..
<target iqn.2018-01.com.www:pc56.diskb> //iqn描述信息
backing-store /dev/vdb //定義存儲設備/dev/vdb
write-cache off
#initiator-address 192.168.4.53 //限制只有此ip能夠訪問 這裏註釋是採起默認共享給全部人
vendor_id xuenqlve //生產廠家
product_id disk1 //型號
</target>
<target iqn.2018-01.com.www:pc56.diskc>
backing-store /dev/vdc
write-cache off
#initiator-address 192.168.4.54
vendor_id xuenqlve
product_id disk2
</target>
.. ..
啓動服務
# service tgtd start
正在啓動 SCSI target daemon: [肯定]
# netstat -pantu | grep tgtd
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 2728/tgtd
tcp 0 0 :::3260 :::* LISTEN 2728/tgtd
查看共享信息
# tgt-admin --show //查看共享信息 命令行輸出配置文件內容
Target 1: iqn.2018-01.com.www:pc56.diskb
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 3221 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/vdb
Backing store flags:
Account information:
ACL information:
ALL
Target 2: iqn.2018-01.com.www:pc56.diskc
System information:
Driver: iscsi //設備
State: ready //狀態
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00020000
SCSI SN: beaf20
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00020001
SCSI SN: beaf21
Size: 3221 MB, Block size: 512
Online: Yes //當前是否可用
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/vdc //共享盤
Backing store flags:
Account information:
ACL information: //訪問控制列表
ALL
二 配置前端
裝包
# yum list | grep -i scsi
iscsi-initiator-utils.x86_64 6.2.0.873-14.el6 dvd
lsscsi.x86_64 0.23-3.el6 dvd
scsi-target-utils.x86_64 1.0.24-16.el6 dvd =
# yum -y install iscsi-initiator-utils
# rpm -qc iscsi-initiator-utils
/etc/iscsi/iscsid.conf
/etc/logrotate.d/iscsiuiolog
# /etc/init.d/iscsi status //當前爲啓動
iscsi 已停
# chkconfig --list iscsid //默認開機自啓
iscsid 0:關閉 1:關閉 2:關閉 3:啓用 4:啓用 5:啓用 6:關閉
發現設備
# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.4.56 --discover
正在啓動 iscsid: [肯定]
192.168.4.56:3260,1 iqn.2018-01.com.www:pc56.diskb
192.168.4.56:3260,1 iqn.2018-01.com.www:pc56.diskc
登陸設備
# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskb --portal 192.168.4.56:3260 --login
Logging in to [iface: default, target: iqn.2018-01.com.www:pc56.diskb, portal: 192.168.4.56,3260] (multiple)
Login to [iface: default, target: iqn.2018-01.com.www:pc56.diskb, portal: 192.168.4.56,3260] successful.
查看登陸信息
# fdisk -l
...
Disk /dev/sda: 3221 MB, 3221225472 bytes
100 heads, 62 sectors/track, 1014 cylinders
Units = cylinders of 6200 * 512 = 3174400 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
# ls /dev/sd*
/dev/sda
登出設備
# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskb --portal 192.168.4.56:3260 --logout
Logging out of session [sid: 1, target: iqn.2018-01.com.www:pc56.diskb, portal: 192.168.4.56,3260]
Logout of [sid: 1, target: iqn.2018-01.com.www:pc56.diskb, portal: 192.168.4.56,3260] successful.
//--mode 能夠用 -m --type 能夠換用 -t --login 能夠換用 -l --logout 能夠換用 -u
登陸共享磁盤 順序會影響設備在本機的命名名稱
三. 配置UDV
1 獲取硬件設備的參數信息
# ls /dev/sd*
/dev/sda
# ls /etc/udev/rules.d/ UDV程序目錄 文件名命名規則 數字-描述信息.rules 數字越小 運行時優先級越高
# which udevadm
/sbin/udevadm
# udevadm --help
Usage: udevadm [--help] [--version] [--debug] COMMAND [COMMAND OPTIONS]
info query sysfs or the udev database
trigger request events from the kernel
settle wait for the event queue to finish
control control the udev daemon
monitor listen to kernel and udev events
test simulation run
//獲取 加載設備 路徑信息
# udevadm info --query=path --name=/dev/sda
/devices/platform/host3/session2/target3:0:0/3:0:0:1/block/sda
//獲取路徑信息對應的設備參數
# udevadm info --path=/devices/platform/host3/session2/target3:0:0/3:0:0:1/block/sda --attribute-walk
...
SUBSYSTEM=="block"
ATTR{size}=="6291456"
...
ATTRS{vendor}=="xuenqlve"
ATTRS{model}=="disk1 "
...
//登陸另外一個設備
# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskc --portal 192.168.4.56:3260 --login
# ls /dev/sd*
/dev/sda /dev/sdb
# udevadm info --query=path --name=/dev/sdb
/devices/platform/host4/session3/target4:0:0/4:0:0:1/block/sdb
# udevadm info --path=/devices/platform/host4/session3/target4:0:0/4:0:0:1/block/sdb --attribute-walk
...
SUBSYSTEM=="block"
ATTR{size}=="6291456"
...
ATTRS{vendor}=="xuenqlve"
ATTRS{model}=="disk2 "
...
2 編寫存放硬件設備的參數的UDV程序的配置文件
# vim /etc/udev/rules.d/70-iscsidisk.rules
SUBSYSTEM=="block", ATTR{size}=="6291456", ATTRS{vendor}=="xuenqlve", ATTRS{model}=="disk1 ", SYMLINK+="iscsi/sdb"
SUBSYSTEM=="block", ATTR{size}=="6291456", ATTRS{vendor}=="xuenqlve", ATTRS{model}=="disk2 ", SYMLINK+="iscsi/sdc"
// SYMLINK+="" 生成一個連接文件
3 啓動UDV
# start_udev
正在啓動 udev: [肯定]
# ls /dev/iscsi/ -l
總用量 0
lrwxrwxrwx. 1 root root 6 1月 13 06:13 sdb -> ../sda
lrwxrwxrwx. 1 root root 6 1月 13 06:13 sdc -> ../sdb
4 查看命名信息
//測試 所有登出
# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskb --portal 192.168.4.56:3260 --logout
# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskc --portal 192.168.4.56:3260 --logout
# ls /dev/sd*
ls: 沒法訪問/dev/sd*: 沒有那個文件或目錄
//先登陸 diskc
# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskc --portal 192.168.4.56:3260 --login
# ls /dev/sd*
/dev/sda
# ls /dev/iscsi/ -l
總用量 0
lrwxrwxrwx. 1 root root 6 1月 13 06:16 sdc -> ../sda
//再登陸 diskb
# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskb --portal 192.168.4.56:3260 --login
# ls /dev/sd*
/dev/sda /dev/sdb
# ls /dev/iscsi/ -l
總用量 0
lrwxrwxrwx. 1 root root 6 1月 13 06:17 sdb -> ../sdb
lrwxrwxrwx. 1 root root 6 1月 13 06:16 sdc -> ../sda
四 . 使用共享存儲磁盤存儲數據
分區 — > 格式化 — > 掛載 —> 存儲數據
分區
# fdisk /dev/iscsi/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x23b0ff1a.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1014, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-1014, default 1014):
Using default value 1014
Command (m for help): p
Disk /dev/iscsi/sdb: 3221 MB, 3221225472 bytes
100 heads, 62 sectors/track, 1014 cylinders
Units = cylinders of 6200 * 512 = 3174400 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x23b0ff1a
Device Boot Start End Blocks Id System
/dev/iscsi/sdb1 1 1014 3143369 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
格式化
# ls /dev/iscsi/
sdb sdc
# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sdb
# mkfs.ext4 /dev/sda1
mke2fs 1.41.12 (17-May-2010)
文件系統標籤=
操做系統:Linux
塊大小=4096 (log=2)
分塊大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
196608 inodes, 785842 blocks
39292 blocks (5.00%) reserved for the super user
第一個數據塊=0
Maximum filesystem blocks=805306368
24 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
正在寫入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
# blkid /dev/sda1
/dev/sda1: UUID="342994ac-4bce-4b21-9755-3377a79bb453" TYPE="ext4"
# vim /etc/fstab
# tail -1 /etc/fstab
UUID=342994ac-4bce-4b21-9755-3377a79bb453 /var/www/html ext4 defaults 0 0
# mount -a
# mount | grep var
/dev/sda1 on /var/www/html type ext4 (rw)
# ls /var/www/html/
lost+found
# echo "Hello World" > /var/www/html/test.html
另外一端測試
# ls /dev/sd*
/dev/sda /dev/sdb
# ls /dev/iscsi/ -l
總用量 0
lrwxrwxrwx. 1 root root 6 1月 13 06:17 sdb -> ../sdb
lrwxrwxrwx. 1 root root 6 1月 13 06:16 sdc -> ../sda
# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskc --portal 192.168.4.56:3260 -u
# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskb --portal 192.168.4.56:3260 -u
# ls /dev/sd*
ls: 沒法訪問/dev/sd*: 沒有那個文件或目錄
# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskb --portal 192.168.4.56:3260 -l
# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskc --portal 192.168.4.56:3260 -l
# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sdb
# ls /dev/iscsi/sd*
/dev/iscsi/sdb /dev/iscsi/sdc
# ls /dev/iscsi/sd* -l
lrwxrwxrwx. 1 root root 6 1月 13 07:27 /dev/iscsi/sdb -> ../sda
lrwxrwxrwx. 1 root root 6 1月 13 07:27 /dev/iscsi/sdc -> ../sdb
# blkid /dev/sda1 // 會發現uuid相同
/dev/sda1: UUID="342994ac-4bce-4b21-9755-3377a79bb453" TYPE="ext4"
# vim /etc/fstab
# tail -1 /etc/fstab
UUID=342994ac-4bce-4b21-9755-3377a79bb453 /var/www/html ext4 defaults 0 0
# mount -a
# mount | grep var
/dev/sda1 on /var/www/html type ext4 (rw)
# ls /var/www/html/
lost+found test.html
pc53 和 pc 54 配置keepalived 高可用集羣
具體步驟能夠參考: http://www.javashuo.com/article/p-zxhaycft-dd.html
[root@pc53 ~]# ip addr show | grep 192.168.4
inet 192.168.4.53/24 brd 192.168.4.255 scope global eth0
inet 192.168.4.251/32 scope global eth0
[root@pc54 ~]# ip addr show | grep 192.168.4
inet 192.168.4.54/24 brd 192.168.4.255 scope global eth0
//客戶端測試
# elinks --dump 192.168.4.251/test.html
Hello World
[root@pc53 ~]# service keepalived stop
中止 keepalived: [肯定]
[root@pc53 ~]# ip addr show | grep 192.168.4
inet 192.168.4.53/24 brd 192.168.4.255 scope global eth0
[root@pc54 ~]# ip addr show | grep 192.168.4
inet 192.168.4.54/24 brd 192.168.4.255 scope global eth0
inet 192.168.4.251/32 scope global eth0
# elinks --dump 192.168.4.251/test.html
Hello World
[root@pc53 ~]# echo "123" > /var/www/html/one.html
[root@pc53 ~]# ls /var/www/html/
lost+found one.html test.html
[root@pc54 ~]# ls /var/www/html/
lost+found test.html
[root@pc54 ~]# umount /var/www/html/
[root@pc54 ~]# mount -a
[root@pc54 ~]# ls /var/www/html/
lost+found one.html test.html
因此說 不能同時掛載
應該給VIP設備掛載 從而達到實現數據實時同步
能夠寫一個監控腳本 監控當前機器是否得到VIP地址
當其剛剛得到 VIP時 進行掛載
環境準備
存儲服務器 有兩個網絡地址
eth0 192.168.4.56/24
eth1 192.168.2.56/24
應用服務器
pc 53
eth0 192.168.4.53/24
eth1 192.168.2.53/24
pc 54
eth0 192.168.4.54/24
eth1 192.168.2.54/24
配置後端存儲
[root@pc56 ~]# vim /etc/tgt/targets.conf
<target iqn.2018-01.com.www:pc56.diskd>
backing-store /dev/vdd
write-cache off
#initiator-address 192.168.4.54
#vendor_id xuenqlve
#product_id disk2
</target>
[root@pc56 ~]# /etc/init.d/tgtd restart
[root@pc56 ~]# tgt-admin --show
....
Target 3: iqn.2018-01.com.www:pc56.diskd
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00030000
SCSI SN: beaf30
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00030001
SCSI SN: beaf31
Size: 3221 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/vdd
Backing store flags:
Account information:
ACL information:
ALL
[root@pc53 ~]# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.4.56 --discover
192.168.4.56:3260,1 iqn.2018-01.com.www:pc56.diskb
192.168.4.56:3260,1 iqn.2018-01.com.www:pc56.diskc
192.168.4.56:3260,1 iqn.2018-01.com.www:pc56.diskd
[root@pc53 ~]# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.2.56 --discover
192.168.2.56:3260,1 iqn.2018-01.com.www:pc56.diskb
192.168.2.56:3260,1 iqn.2018-01.com.www:pc56.diskc
192.168.2.56:3260,1 iqn.2018-01.com.www:pc56.diskd
[root@pc53 ~]# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskd --portal 192.168.4.56:3260 -l
[root@pc53 ~]# ls /dev/sd*
/dev/sda
[root@pc53 ~]# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskd --portal 192.168.2.56:3260 -l
[root@pc53 ~]# ls /dev/sd*
/dev/sda /dev/sdb
// /dev/sda 和 /dev/sdb 時後端的同一個設備
[root@pc53 ~]# which scsi_id
/sbin/scsi_id
[root@pc53 ~]# scsi_id --whitelisted --device=/dev/sda //獲取WWID
1IET 00030001
[root@pc53 ~]# scsi_id --whitelisted --device=/dev/sdb
1IET 00030001
裝包 安裝提供多路徑須要的軟件包
[root@pc53 ~]# yum -y install device-mapper-multipath
[root@pc53 ~]# rpm -q device-mapper-multipath
device-mapper-multipath-0.4.9-87.el6.x86_64
建立並修改配置文件
[root@pc53 ~]# mpathconf --user_friendly_names n //生成配置文件
[root@pc53 ~]# ls /etc/multipath.conf
/etc/multipath.conf
[root@pc53 ~]# vim /etc/multipath.conf
25 defaults {
26 user_friendly_names no
27 getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
38 # getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
102 multipaths{
103 multipath{
104 wwid "1IET 00030001"
105 alias mpatha
106 }
107 }
[root@pc53 ~]# /etc/init.d/multipathd start
正在啓動守護進程multipathd: [肯定]
[root@pc53 ~]# chkconfig multipathd on
[root@pc53 ~]# ls /dev/mapper/mpatha
/dev/mapper/mpatha
格式化
[root@pc53 ~]# mkfs.ext4 /dev/mapper/mpatha
mke2fs 1.41.12 (17-May-2010)
文件系統標籤=
操做系統:Linux
塊大小=4096 (log=2)
分塊大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
196608 inodes, 786432 blocks
39321 blocks (5.00%) reserved for the super user
第一個數據塊=0
Maximum filesystem blocks=805306368
24 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
正在寫入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@pc53 ~]# blkid /dev/mapper/mpatha
/dev/mapper/mpatha: UUID="cbdb1867-a537-4349-9c9d-f7ab08e917cb" TYPE="ext4"
查看多路徑信息
[root@pc53 ~]# multipath -ll //查看多路徑信息
mpatha (1IET 00030001) dm-2 IET,VIRTUAL-DISK
size=3.0G features='0' hwhandler='0' wp=rw
|-+- policy='round-robin 0' prio=1 status=active
| `- 5:0:0:1 sda 8:0 active ready running
`-+- policy='round-robin 0' prio=1 status=enabled
`- 6:0:0:1 sdb 8:16 active ready running
[root@pc53 ~]# multipath -rr
[root@pc53 ~]# multipath -ll
mpatha (1IET 00030001) dm-2 IET,VIRTUAL-DISK
size=3.0G features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
`- 5:0:0:1 sda 8:0 active ready running
NFS網絡文件系統
主要軟件包 nfs-utils rpcbind
配置NFS服務器 pc56
分區 格式化 掛載(開機掛載)
//分區
# fdisk /dev/vde
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x1daab7a9.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-6241, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-6241, default 6241):
Using default value 6241
Command (m for help): p
Disk /dev/vde: 3221 MB, 3221225472 bytes
16 heads, 63 sectors/track, 6241 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1daab7a9
Device Boot Start End Blocks Id System
/dev/vde1 1 6241 3145432+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
//格式化分區
# mkfs.ext4 /dev/vde1
mke2fs 1.41.12 (17-May-2010)
文件系統標籤=
操做系統:Linux
塊大小=4096 (log=2)
分塊大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
196608 inodes, 786358 blocks
39317 blocks (5.00%) reserved for the super user
第一個數據塊=0
Maximum filesystem blocks=805306368
24 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
正在寫入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
//建立掛載文件
# mkdir /sharespace
//查看分區UUID
# blkid /dev/vde1
/dev/vde1: UUID="e3dad5d2-eae2-4290-ba5e-935e6eda59c7" TYPE="ext4"
//配置開機自動掛載
[root@pc56 ~]# vim /etc/fstab
[root@pc56 ~]# tail -1 /etc/fstab
UUID=e3dad5d2-eae2-4290-ba5e-935e6eda59c7 /sharespace ext4 defaults 0 0
//掛載 分區
[root@pc56 ~]# mount -a
//查看掛載狀況
[root@pc56 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
47G 1.4G 43G 4% /
tmpfs 499M 0 499M 0% /dev/shm
/dev/vda1 477M 36M 416M 8% /boot
/dev/sr0 3.6G 3.6G 0 100% /mnt/2018-01-15
/dev/vde1 2.9G 4.5M 2.8G 1% /sharespace
[root@pc56 ~]# mount | grep /dev/vde1
/dev/vde1 on /sharespace type ext4 (rw)
使用nfs 服務共享掛載目錄:
裝包 修改配置文件 啓動服務
# yum -y install rpcbind
# /etc/init.d/rpcbind start
正在啓動 rpcbind: [肯定]
# chkconfig rpcbind on
# yum -y install nfs-utils
# vim /etc/exports
# tail -1 /etc/exports
/sharespace *(rw)
# chmod o+w /sharespace/
# /etc/init.d/nfs start
啓動 NFS 服務: [肯定]
關掉 NFS 配額: [肯定]
啓動 NFS mountd: [肯定]
啓動 NFS 守護進程: [肯定]
正在啓動 RPC idmapd: [肯定]
# chkconfig nfs on
# showmount -e localhost
Export list for localhost:
/sharespace *
Web服務器 訪問查看共享信息 pc 51 / pc 52
# yum -y install nfs-uits
# showmount -e 192.168.4.56
Export list for 192.168.4.56:
/sharespace *
[root@pc51 ~]# mount -t nfs 192.168.4.56:/sharespace /var/www/html/
[root@pc51 ~]# mount | tail -1
192.168.4.56:/sharespace on /var/www/html type nfs (rw,vers=4,addr=192.168.4.56,clientaddr=192.168.4.51)
[root@pc52 ~]# mount -t nfs 192.168.4.56:/sharespace /var/www/html/
[root@pc52 ~]# mount | tail -1
192.168.4.56:/sharespace on /var/www/html type nfs (rw,vers=4,addr=192.168.4.56,clientaddr=192.168.4.52)
[root@pc51 ~]# ls /var/www/html/
lost+found
[root@pc51 ~]# echo "hello" > /var/www/html/index.html
[root@pc51 ~]# ls /var/www/html/
index.html lost+found
//會在pc52 端會生成一樣的文件 實現了實時同步
[root@pc52 ~]# ls /var/www/html/
index.html lost+found
//完成 pc51 和 pc52 上的開機自動掛載
# vim /etc/fstab
# tail -1 /etc/fstab
192.168.4.56:/sharespace /var/www/html/ nfsdefaults 0 0