RHEL6 搭建部署共享存储服务

搭建存储服务器

什么是存储

存储是根据不同的应用环境通过采取合理,安全,有效的方式将数据保存到某些介质上并能保证有效的访问

一方面它是数据临时或长期驻留的物理媒介

另一方面,它是保证数据完整安全存放的方式或行为

存储就是把这两方面结合起来,向客户提供一套数据存放解决方案

存储介质: 内存(临时存储)  磁盘(永久存储)

数据存储位置: 云存储 本地 共享存储 分布式存储

存储技术分类

SCSI 小型计算机系统接口

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

配置iSCSI服务

在存储设备端  主机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://blog.51cto.com/13558754/2060950

[[email protected] ~]# 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

[[email protected] ~]# 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

[[email protected] ~]# service keepalived stop

停止 keepalived:                                          [确定]

[[email protected] ~]# ip addr show | grep 192.168.4

inet 192.168.4.53/24 brd 192.168.4.255 scope global eth0

[[email protected] ~]# 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

[[email protected] ~]# echo "123" > /var/www/html/one.html

[[email protected] ~]# ls /var/www/html/

lost+found  one.html  test.html

[[email protected] ~]# ls /var/www/html/

lost+found  test.html

[[email protected] ~]# umount /var/www/html/

[[email protected] ~]# mount -a

[[email protected] ~]# ls /var/www/html/

lost+found  one.html  test.html

所以说 不能同时挂载

应该给VIP设备挂载 从而达到实现数据实时同步

可以写一个监控脚本 监控当前机器是否获得VIP地址

当其刚刚获得 VIP时 进行挂载

iSCSI服务多路径 

   环境准备

存储服务器 有两个网络地址

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

配置后端存储

[[email protected] ~]# 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>

[[email protected] ~]# /etc/init.d/tgtd restart

[[email protected] ~]# 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

[[email protected] ~]# 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

[[email protected] ~]# 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

[[email protected] ~]# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskd --portal 192.168.4.56:3260 -l

[[email protected] ~]# ls /dev/sd*

/dev/sda

[[email protected] ~]# iscsiadm --mode node --targetname iqn.2018-01.com.www:pc56.diskd --portal 192.168.2.56:3260 -l

[[email protected] ~]# ls /dev/sd*

/dev/sda  /dev/sdb

// /dev/sda  和 /dev/sdb 时后端的同一个设备

[[email protected] ~]# which scsi_id

/sbin/scsi_id

[[email protected] ~]# scsi_id --whitelisted --device=/dev/sda //获取WWID

1IET     00030001

[[email protected] ~]# scsi_id --whitelisted --device=/dev/sdb

1IET     00030001

装包  安装提供多路径需要的软件包

[[email protected] ~]# yum -y install device-mapper-multipath

[[email protected] ~]# rpm -q device-mapper-multipath

device-mapper-multipath-0.4.9-87.el6.x86_64

创建并修改配置文件

[[email protected] ~]# mpathconf --user_friendly_names n //生成配置文件

[[email protected] ~]# ls /etc/multipath.conf

/etc/multipath.conf

[[email protected] ~]# 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 }

[[email protected] ~]# /etc/init.d/multipathd start

正在启动守护进程multipathd:                               [确定]

[[email protected] ~]# chkconfig multipathd on

[[email protected] ~]# ls /dev/mapper/mpatha

/dev/mapper/mpatha

格式化

[[email protected] ~]# 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.

[roo[email protected] ~]# blkid /dev/mapper/mpatha

/dev/mapper/mpatha: UUID="cbdb1867-a537-4349-9c9d-f7ab08e917cb" TYPE="ext4"

查看多路径信息

[[email protected] ~]# 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

[[email protected] ~]# multipath -rr

[[email protected] ~]# 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"

//配置开机自动挂载

[[email protected] ~]# vim /etc/fstab

[[email protected] ~]# tail -1 /etc/fstab

UUID=e3dad5d2-eae2-4290-ba5e-935e6eda59c7 /sharespace ext4 defaults 0 0

//挂载 分区

[[email protected] ~]# mount -a

//查看挂载情况

[[email protected] ~]# 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

[[email protected] ~]# 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 *

[[email protected] ~]# mount -t nfs 192.168.4.56:/sharespace /var/www/html/

[[email protected] ~]# 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)

[[email protected] ~]# mount -t nfs 192.168.4.56:/sharespace /var/www/html/

[[email protected] ~]# 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)

[[email protected] ~]# ls /var/www/html/

lost+found

[[email protected] ~]# echo "hello" > /var/www/html/index.html

[[email protected] ~]# ls /var/www/html/

index.html  lost+found

//会在pc52 端会生成同样的文件  实现了实时同步

[[email protected] ~]# 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/   nfs defaults   0 0

原文地址:http://blog.51cto.com/13558754/2061297

时间: 2024-08-19 01:37:12

RHEL6 搭建部署共享存储服务的相关文章

搭建nfs共享存储服务之三客户端配置及实战测试故障总结

在客户端操作的: 1. 检查客户端有没有安装nfs-utils和rpcbind软件程序 (这两个必须安装) [[email protected] ~]# rpm -qa nfs-utils rpcbindnfs-utils-1.2.3-75.el6.x86_64rpcbind-0.2.0-13.el6_9.1.x86_64 如果没有安装,需要用yum安装.安装方法参考:搭建nfs共享存储服务之二 [[email protected] ~]# /etc/init.d/rpcbind statusr

搭建nfs共享存储服务之二nfs服务端配置语法及配置实战详解

1.1.NFS服务端配置文件路径为: /etc/exports,并且默认为空,需要用户自行配置. /etc/exports文件配置格式为: NFS共享的目录 NFS客户端地址1(参数1,参数2...)客户端地址2(参数1,参数2) 1.NFS共享的目录:为NFS服务端要共享的实际目录,要用绝对路径,如(/data),注意共享目录的本地权限,如果需要读写共享,一点要让本地目录可以被NFS客户端的用户(nfsnobody)读写. 2.NFS客户端地址:为NFS服务端授权的可访共享目录的NFS客户端地

搭建nfs共享存储服务之一nfs服务端搭建

NFS相当于房源,RPC相当于中介. nfs-utils:  NFS服务的主程序,包括rpc.nfsd.rpc.mountd这两个daemon和相关文件说明,以及执行命令文件等. rpcbind:  centos6.x下面RPC的主程序.NFS可以视为一个RPC程序,在启动任何一个RPC程序之前,需要做好端口和功能的对应映射工作,这个映射工作就是由rpcbind服务来完成的.因此,在提供NFS服务之前必须先启动rpcbind服务才行. 1.查看NFS软件包 : 可使用如下命令查看默认情况下cen

部署NFS存储服务(下)

作者:Georgekai 归档:学习笔记 2018/1/25 部署NFS存储服务(下) 2.1 服务端有关的配置 2.1.1 练习题:共享不同的俩个目录,分别赋予读和写权限 服务端部署过程: 第一个里程:编写nfs配置文件 vim /etc/exports /data/w  172.16.1.0/24(rw,sync,all_squash) /data/r  172.16.1.0/24(ro,sync,all_squash) 注:服务端配置文件中,尽量避免继承权限的发生(因权限大的会生效) 第二

Linux下搭建iSCSI共享存储的方法 TGT 方式 CentOS6.9系统下

iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速千兆以太网上进行路由选择.iSCSI技术是一种新储存技术,该技术是将现有SCSI接口与以太网络(Ethernet)技术结合,使服务器可与使用IP网络的储存装置互相交换资料. iSCSI分为服务端和客户端,服务端需要安装scsi target用来共享存储设备,客户端需要安装iscsi initiato

Linux下搭建iSCSI共享存储的方法 TGT 方式 Debian9.5系统下

iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速千兆以太网上进行路由选择.iSCSI技术是一种新储存技术,该技术是将现有SCSI接口与以太网络(Ethernet)技术结合,使服务器可与使用IP网络的储存装置互相交换资料. iSCSI分为服务端和客户端,服务端需要安装scsi target用来共享存储设备,客户端需要安装iscsi initiato

Linux下搭建iSCSI共享存储的方法 Linux-IO Target 方式 Debian9.5下实现

iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速千兆以太网上进行路由选择.iSCSI技术是一种新储存技术,该技术是将现有SCSI接口与以太网络(Ethernet)技术结合,使服务器可与使用IP网络的储存装置互相交换资料. iSCSI分为服务端和客户端,服务端需要安装scsi target用来共享存储设备,客户端需要安装iscsi initiato

Linux下搭建iSCSI共享存储的方法 Linux-IO Target 方式CentOS7-1810下实现

iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速千兆以太网上进行路由选择.iSCSI技术是一种新储存技术,该技术是将现有SCSI接口与以太网络(Ethernet)技术结合,使服务器可与使用IP网络的储存装置互相交换资料. iSCSI分为服务端和客户端,服务端需要安装scsi target用来共享存储设备,客户端需要安装iscsi initiato

NFS共享存储服务

NFS是一种基于TCP/IP传输的网络文件系统协议.通过使用NFS协议,NFS客户机可以像访问本地目录一样访问远程NFS服务器中的共享资源.但是,NFS没有用户认证机制,而且数据在网络上明文传输,所以安全性很差,一般只能在局域网中中使用.NFS服务的实现依赖于RPC机制,RPC充当NFS客户端和NFS服务器的中介,以完成远程到本地的映射过程.下面我将在VMware虚拟机中使用两台Redhat6.5 Linux模拟NFS共享存储服务,一台为Redhat6-2提供服务,一台为Redhat6-4访问测