文章目录
1 the machine information
172.16.159.130(which is used for server1)
172.16.159.131(which is used for server2)
172.16.159.132 (which is used for client)
2 install for servers
2.1 install software
First,you must use these commands to install gluster on each machine(172.16.159.130,172.16.159.131).
# yum install centos-release-gluster -y
# yum install glusterfs-server glusterfs glusterfs-fuse -y
Second,you can start the gluster,then you can look at the status of the gluster.
# systemctl start glusterd
# systemctl status glusterd
If you see some infos which like this,which means you install successfully.
2.2 Configure the trusted pool
from 172.16.159.130
# gluster peer probe 172.16.159.131
look at the trusted pool
# gluster peer status
2.3 make the volume
from 172.16.159.130,172.16.159.131,you should make the dir on each server.
# mkdir -p /Data/gfsdata
from 172.16.159.130 or from 172.16.159.131,you only execute the command on one server.
# gluster volume create gv0 replica 2 172.16.159.130:/Data/gfsdata 172.16.159.131:/Data/gfsdata force
2.4 start the volume
from 172.16.159.130
[root@localhost src]# gluster volume start gv0
volume start: gv0: success
[root@localhost src]#
2.5 look at the status of volume
from 172.16.159.130
[root@localhost src]# gluster volume info
Volume Name: gv0
Type: Replicate
Volume ID: d2e6c80e-8024-4de4-8306-9d60360df3f2
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: 172.16.159.130:/Data/gfsdata
Brick2: 172.16.159.131:/Data/gfsdata
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
performance.client-io-threads: off
[root@localhost src]#
3 install for client
3.1 install
from 172.16.159.132
# yum -y install glusterfs glusterfs-fuse
3.2 mount the glusterfs
from 172.16.159.132
# mkdir /mnt/glusterfs
# mount -t glusterfs 172.16.159.130:/gv0 /mnt/glusterfs
make sure the mount
[root@localhost ~]# mount -t fuse.glusterfs
172.16.159.130:/gv0 on /mnt/glusterfs type fuse.glusterfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072)
[root@localhost ~]#
``
## 3.3 test
from 172.16.159.132
```bash
# cd /mnt/glusterfs/
# touch file1 file2 file3
Because the architecture which you have used is Replicated,So you will see that the three files on both servers
is in /Data/gfsdata/.
from 172.16.159.130
[root@localhost gfsdata]# cd /Data/gfsdata/
[root@localhost gfsdata]# ll
total 0
-rw-r--r--. 2 root root 0 Jan 8 07:34 file1
-rw-r--r--. 2 root root 0 Jan 8 07:34 file2
-rw-r--r--. 2 root root 0 Jan 8 07:34 file3
[root@localhost gfsdata]#
from 172.16.159.131
[root@localhost gfsdata]# cd /Data/gfsdata/
[root@localhost gfsdata]# ll
total 0
-rw-r--r--. 2 root root 0 Jan 8 07:34 file1
-rw-r--r--. 2 root root 0 Jan 8 07:34 file2
-rw-r--r--. 2 root root 0 Jan 8 07:34 file3
[root@localhost gfsdata]#
If you delete three files,the two servers will delete too.
from 172.16.159.132
# rm file6 file5 file4 -f
from 172.16.159.130 or 172.16.159.131,you will see that
there are only three files.
[root@localhost gfsdata]# cd /Data/gfsdata
[root@localhost gfsdata]# ll
total 0
-rw-r--r--. 2 root root 0 Jan 8 07:34 file1
-rw-r--r--. 2 root root 0 Jan 8 07:34 file2
-rw-r--r--. 2 root root 0 Jan 8 07:34 file3
[root@localhost gfsdata]#
4 Analog high availability
If one server gones away.What will be happened?
First,We choice one server to shutdown. like 172.16.159.131
# shutdown -h now
Send, We touch the other three files on 172.16.159.132
# touch file4 file5 file6
[root@localhost glusterfs]# ll
total 0
-rw-r--r--. 1 root root 0 Jan 8 07:34 file1
-rw-r--r--. 1 root root 0 Jan 8 07:34 file2
-rw-r--r--. 1 root root 0 Jan 8 07:34 file3
-rw-r--r--. 1 root root 0 Jan 8 07:53 file4
-rw-r--r--. 1 root root 0 Jan 8 07:53 file5
-rw-r--r--. 1 root root 0 Jan 8 07:53 file6
[root@localhost glusterfs]#
Third,we go to the 172.16.159.130,you can see the six files.
[root@localhost gfsdata]# cd /Data/gfsdata
[root@localhost gfsdata]# ll
total 0
-rw-r--r--. 2 root root 0 Jan 8 07:34 file1
-rw-r--r--. 2 root root 0 Jan 8 07:34 file2
-rw-r--r--. 2 root root 0 Jan 8 07:34 file3
-rw-r--r--. 2 root root 0 Jan 8 07:53 file4
-rw-r--r--. 2 root root 0 Jan 8 07:53 file5
-rw-r--r--. 2 root root 0 Jan 8 07:53 file6
[root@localhost gfsdata]#
Fourth,start the server,which ip is 172.16.159.130.But we do not start the glusterFS.
you can see the active which is dead.
....start 172.16.159.130........
#[avatar@localhost gfsdata]$ systemctl status glusterd
* glusterd.service - GlusterFS, a clustered file-system server
Loaded: loaded (/usr/lib/systemd/system/glusterd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
There are only three files in /Data/gfsdata/.
[avatar@localhost ~]$ cd /Data/gfsdata/
[avatar@localhost gfsdata]$ ll
总用量 0
-rw-r--r--. 2 root root 0 1月 8 07:34 file1
-rw-r--r--. 2 root root 0 1月 8 07:34 file2
-rw-r--r--. 2 root root 0 1月 8 07:34 file3
Fifth,we start the glusterfs and look at the status.we can see the active which is running.
[root@localhost ~]# systemctl start glusterd
[root@localhost ~]# systemctl status glusterd
饪? glusterd.service - GlusterFS, a clustered file-system server
Loaded: loaded (/usr/lib/systemd/system/glusterd.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2019-01-08 21:49:01 EST; 10s ago
Process: 1787 ExecStart=/usr/sbin/glusterd -p /var/run/glusterd.pid --log-level $LOG_LEVEL $GLUSTERD_OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 1788 (glusterd)
Tasks: 39
Memory: 26.4M
CGroup: /system.slice/glusterd.service
饪????1788 /usr/sbin/glusterd -p /var/run/glusterd.pid --log-level INFO
饪????1799 /usr/sbin/glusterfsd -s 172.16.159.131 --volfile-id gv0.172.16.159.131.Data-gfsdata -p /var/run/gluster/vols/gv0/172.16.159.131-Data-gfsdata.pid -S /var/run/gluster/d3a941588bb87586.socket --brick-name /Data/gfsda...
饪????1808 /usr/sbin/glusterfs -s localhost --volfile-id gluster/glustershd -p /var/run/gluster/glustershd/glustershd.pid -l /var/log/glusterfs/glustershd.log -S /var/run/gluster/ee2795b1e971e9f9.socket --xlator-option *repl...
Jan 08 21:49:01 localhost.localdomain systemd[1]: Starting GlusterFS, a clustered file-system server...
Jan 08 21:49:01 localhost.localdomain systemd[1]: Started GlusterFS, a clustered file-system server.
There are six files in /Data/gfsdata/.
[root@localhost ~]# cd /Data/gfsdata/
[root@localhost gfsdata]# ll
total 0
-rw-r--r--. 2 root root 0 Jan 8 07:34 file1
-rw-r--r--. 2 root root 0 Jan 8 07:34 file2
-rw-r--r--. 2 root root 0 Jan 8 07:34 file3
-rw-r--r--. 2 root root 0 Jan 8 07:53 file4
-rw-r--r--. 2 root root 0 Jan 8 07:53 file5
-rw-r--r--. 2 root root 0 Jan 8 07:53 file6
[root@localhost gfsdata]#
5 The recommended reference
《GlusterFS简单配置》:https://www.cnblogs.com/terrycy/p/5915263.html