Ubuntu下Gluster 安装部署
(镜像)
1. 环境准备
机器名 |
eth0 |
说明 |
server01 |
192.168.100.30/24 |
Centos 6.3 64bit ,多准备一块磁盘 |
server02 |
192.168.100.31/24 |
Centos 6.3 64bit,多准备一块磁盘 |
Client |
192.168.100.60/24 |
Centos 6.3 64bit |
2. 格式磁盘并挂载(在两个节点上均做如下设置)
安装mkfs.xfs命令包
apt install xfsprogs
mkfs.xfs -i size=512 /dev/sdb
mkdir -p /export/brick1
修改分区表 vi /etc/fstab 末尾添加
/dev/sdb /export/brick1 xfs defaults 1 2
mount –a &&mount
3. 安装gluster(所有节点均需安装)
安装gluster
apt install glusterfs-server
启动服务
service glusterd start
service gluster status
4. 配置gluster
注:以下配置在任何一个节点上操作即可
配置对端信任节点(即镜像服务器)
gluster peer probe 192.168.100.31
1.创建一个功能为镜像的集群卷(可以使用域名)
gluster volume create gv0 replica 2 192.168.100.30:/export/brick1 192.168.100.31:/export/brick1 gluster volume start gv0
2.查看卷信息
[root@server01 brick1]# gluster volume info
Volume Name: gv0
Type: Replicate
Volume ID: 3bf26a6a-63ce-44ed-bd57-fffd52352130
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: 192.168.100.30:/export/brick1
Brick2: 192.168.100.31:/export/brick1
3.运行卷
gluster volume start gv0
5. 验证
在客户端192.168.100.60上验证gluster,
1.安装gluster也就是步骤3的server组件就包含了客户端
apt install gluster-server
2.自动挂载
修改/etc/fstab 文件
格式:eserver1:/test-volume /mnt/glusterfs glusterfs defaults,_netdev 0 0
例如:192.168.100.30:/gv0 /mnt glusterfs defaults,netdev 0 0
执行:
mount -t glusterfs 192.168.100.30:/gv0 /mnt
[root@node mnt]# mount -l
/dev/mapper/VolGroup-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sr0 on /media/CentOS_6.3_Final type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=500,gid=500,iocharset=utf8,mode=0400,dmode=0500) [CentOS_6.3_Final]
/dev/sr0 on /media/cdrom type iso9660 (ro) [CentOS_6.3_Final]
192.168.100.30:/gv0 on /mnt type fuse.glusterfs (rw,default_permissions,allow_other,max_read=131072)
已经将gv0挂载至/mnt目录,在客户端目录下创建100个文件
for i in `seq -w 1 100`; do cp -rp /var/log/messages /mnt/copy-test-$i; done
[root@node mnt]# ls
copy-test-001 copy-test-013
[root@node mnt]# ls -lA /mnt | wc -l
101
到服务器192.168.100.30上查看验证
[root@server01 brick1]# ls
copy-test-001 copy-test-013
[root@server01 brick1]# ls -l | wc -l
101
服务器192.168.100.31上查看验证
[root@server02 brick1]# ls
copy-test-001 copy-test-013
[root@server02 brick1]# ls -l | wc -l
101
说明:上述例子用2台服务器上的一块硬盘做了镜像冗余,客户端上传文件会自动同步到2台服务器的gluster卷上。
若中途遇到错误,可去/var/log/glusterfs查看日志排查错误原因来恢复
参考文章:https://blog.csdn.net/robberboyboy/article/details/8468508