设为首页 收藏本站
查看: 1492|回复: 0

[经验分享] Linux与云计算——第二阶段 第五章:存储Storage服务器架设—分布式存储GlusterFS基础

[复制链接]

尚未签到

发表于 2019-2-1 13:08:52 | 显示全部楼层 |阅读模式
Linux与云计算——第二阶段Linux服务器架设

第五章:存储Storage服务器架设—分布式存储GlusterFS基础

1 GlusterFS GlusterFS安装
Install GlusterFS to Configure Storage Cluster.
It is recommended to use partitions for GlusterFS volumes which are different from the / partition.
The environment on this example is set as that sdb1 is mounted on /glusterfs directory for GlusterFS Configuration on all Nodes.
[1] Install GlusterFS Server on all Nodes in Cluster.
[root@node01 ~]# curl http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo -o /etc/yum.repos.d/glusterfs-epel.repo
# enable EPEL, too
[root@node01 ~]# yum --enablerepo=epel -y install glusterfs-server
[root@node01 ~]# systemctl start glusterd
[root@node01 ~]# systemctl enable glusterd
[2] If Firewalld is running, allow GlusterFS service on all nodes.
[root@node01 ~]# firewall-cmd --add-service=glusterfs --permanent
success
[root@node01 ~]# firewall-cmd --reload
Success
It's OK if you mount GlusterFS volumes from clients with GlusterFS Native Client.
[3] GlusterFS supports NFS (v3), so if you mount GlusterFS volumes from clients with NFS, Configure additinally like follows.
[root@node01 ~]# yum -y install rpcbind
[root@node01 ~]# systemctl start rpcbind
[root@node01 ~]# systemctl enable rpcbind
[root@node01 ~]# systemctl restart glusterd
[4] Installing and Basic Settings of GlusterFS are OK. Refer to next section for settings of clustering.
2 设置Distributed
Configure Storage Clustering.
For example, create a distributed volume with 2 servers.
This example shows to use 2 servers but it's possible to use more than 3 servers.
                                  |
+----------------------+          |          +----------------------+
| [GlusterFS Server#1] |10.0.0.51 | 10.0.0.52| [GlusterFS Server#2] |
|   node01.srv.world   +----------+----------+    node02.srv.world  |
|                      |                     |                      |
+----------------------+                     +----------------------+
It is recommended to use partitions for GlusterFS volumes which are different from the / partition.
The environment on this example is set as that sdb1 is mounted on /glusterfs directory for GlusterFS Configuration on all Nodes.
[1] Install GlusterFS Server on All Nodes, refer to here.
[2] Create a Directory for GlusterFS Volume on all Nodes.
[root@node01 ~]# mkdir /glusterfs/distributed
[3] Configure Clustering like follows on a node. (it's OK on any node)
# probe the node
[root@node01 ~]# gluster peer probe node02
peer probe: success.
# show status
[root@node01 ~]# gluster peer status
Number of Peers: 1

Hostname: node02
Uuid: 2ca22769-28a1-4204-9957-886579db2231
State: Peer in Cluster (Connected)

# create volume
[root@node01 ~]# gluster volume create vol_distributed transport tcp \
node01:/glusterfs/distributed \
node02:/glusterfs/distributed
volume create: vol_distributed: success: please start the volume to access data
# start volume
[root@node01 ~]# gluster volume start vol_distributed
volume start: vol_distributed: success
# show volume info
[root@node01 ~]# gluster volume info

Volume Name: vol_distributed
Type: Distribute
Volume ID: 6677caa9-9aab-4c1a-83e5-2921ee78150d
Status: Started
Number of Bricks: 2
Transport-type: tcp
Bricks:
Brick1: node01:/glusterfs/distributed
Brick2: node02:/glusterfs/distributed
Options Reconfigured:
performance.readdir-ahead: on
[4] To mount GlusterFS volume on clients, refer to here.
3 设置Replication
Configure Storage Clustering.
For example, create a Replication volume with 2 servers.
This example shows to use 2 servers but it's possible to use more than 3 servers.
                                  |
+----------------------+          |          +----------------------+
| [GlusterFS Server#1] |10.0.0.51 | 10.0.0.52| [GlusterFS Server#2] |
|   node01.srv.world   +----------+----------+   node02.srv.world   |
|                      |                     |                      |
+----------------------+                     +----------------------+
It is recommended to use partitions for GlusterFS volumes which are different from the / partition.
The environment on this example is set as that sdb1 is mounted on /glusterfs directory for GlusterFS Configuration on all Nodes.
[1] Install GlusterFS Server on All Nodes, refer to here.
[2] Create a Directory for GlusterFS Volume on all Nodes.
[root@node01 ~]# mkdir /glusterfs/replica
[3] Configure Clustering like follows on a node. (it's OK on any node)
# probe the node
[root@node01 ~]# gluster peer probe node02
peer probe: success.
# show status
[root@node01 ~]# gluster peer status
Number of Peers: 1

Hostname: node02
Uuid: 2ca22769-28a1-4204-9957-886579db2231
State: Peer in Cluster (Connected)

# create volume
[root@node01 ~]# gluster volume create vol_replica replica 2 transport tcp \
node01:/glusterfs/replica \
node02:/glusterfs/replica
volume create: vol_replica: success: please start the volume to access data
# start volume
[root@node01 ~]# gluster volume start vol_replica
volume start: vol_replica: success
# show volume info
[root@node01 ~]# gluster volume info

Volume Name: vol_replica
Type: Replicate
Volume ID: 0d5d5ef7-bdfa-416c-8046-205c4d9766e6
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: node01:/glusterfs/replica
Brick2: node02:/glusterfs/replica
Options Reconfigured:
performance.readdir-ahead: on
[4] To mount GlusterFS volume on clients, refer to here.
4 设置Striping
Configure Storage Clustering.
For example, create a Striping volume with 2 servers.
This example shows to use 2 servers but it's possible to use more than 3 servers.

                                  |
+----------------------+          |          +----------------------+
| [GlusterFS Server#1] |10.0.0.51 | 10.0.0.52| [GlusterFS Server#2] |
|   node01.srv.world   +----------+----------+   node02.srv.world   |
|                      |                     |                      |
+----------------------+                     +----------------------+
It is recommended to use partitions for GlusterFS volumes which are different from the / partition.
The environment on this example is set as that sdb1 is mounted on /glusterfs directory for GlusterFS Configuration on all Nodes.
[1] Install GlusterFS Server on All Nodes, refer to here.
[2] Create a Directory for GlusterFS Volume on all Nodes.
[root@node01 ~]# mkdir /glusterfs/striped
[3] Configure Clustering like follows on a node. (it's OK on any node)
# probe the node
[root@node01 ~]# gluster peer probe node02
peer probe: success.
# show status
[root@node01 ~]# gluster peer status
Number of Peers: 1

Hostname: node02
Uuid: 2ca22769-28a1-4204-9957-886579db2231
State: Peer in Cluster (Connected)

# create volume
[root@node01 ~]# gluster volume create vol_striped stripe 2 transport tcp \
node01:/glusterfs/striped \
node02:/glusterfs/striped
volume create: vol_striped: success: please start the volume to access data
# start volume
[root@node01 ~]# gluster volume start vol_striped
volume start: vol_replica: success
# show volume info
[root@node01 ~]# gluster volume info

Volume Name: vol_striped
Type: Stripe
Volume ID: b6f6b090-3856-418c-aed3-bc430db91dc6
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: node01:/glusterfs/striped
Brick2: node02:/glusterfs/striped
Options Reconfigured:
performance.readdir-ahead: on
[4] To mount GlusterFS volume on clients, refer to here.
5 Distributed+Replication
Configure Storage Clustering.
For example, create a Distributed + Replication volume with 4 servers.
                                  |
+----------------------+          |          +----------------------+
| [GlusterFS Server#1] |10.0.0.51 | 10.0.0.52| [GlusterFS Server#2] |
|   node01.srv.world   +----------+----------+   node02.srv.world   |
|                      |          |          |                      |
+----------------------+          |          +----------------------+
                                  |
+----------------------+          |          +----------------------+
| [GlusterFS Server#3] |10.0.0.53 | 10.0.0.54| [GlusterFS Server#4] |
|   node03.srv.world   +----------+----------+   node04.srv.world   |
|                      |                     |                      |
+----------------------+                     +----------------------+
It is recommended to use partitions for GlusterFS volumes which are different from the / partition.
The environment on this example is set as that sdb1 is mounted on /glusterfs directory for GlusterFS Configuration on all Nodes.
[1] Install GlusterFS Server on All Nodes, refer to here.
[2] Create a Directory for GlusterFS Volume on all Nodes.
[root@node01 ~]# mkdir /glusterfs/dist-replica
[3] Configure Clustering like follows on a node. (it's OK on any node)
# probe the node
[root@node01 ~]# gluster peer probe node02
peer probe: success.
[root@node01 ~]# gluster peer probe node03
peer probe: success.
[root@node01 ~]# gluster peer probe node04
peer probe: success.
# show status
[root@node01 ~]# gluster peer status
Number of Peers: 3

Hostname: node02
Uuid: 2ca22769-28a1-4204-9957-886579db2231
State: Peer in Cluster (Connected)

Hostname: node03
Uuid: 79cff591-1e98-4617-953c-0d3e334cf96a
State: Peer in Cluster (Connected)

Hostname: node04
Uuid: 779ab1b3-fda9-46da-af95-ba56477bf638
State: Peer in Cluster (Connected)

# create volume
[root@node01 ~]# gluster volume create vol_dist-replica replica 2 transport tcp \
node01:/glusterfs/dist-replica \
node02:/glusterfs/dist-replica \
node03:/glusterfs/dist-replica \
node04:/glusterfs/dist-replica
volume create: vol_dist-replica: success: please start the volume to access data
# start volume
[root@node01 ~]# gluster volume start vol_dist-replica
volume start: vol_dist-replica: success
# show volume info
[root@node01 ~]# gluster volume info

Volume Name: vol_dist-replica
Type: Distributed-Replicate
Volume ID: 784d2953-6599-4102-afc2-9069932894cc
Status: Started
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: node01:/glusterfs/dist-replica
Brick2: node02:/glusterfs/dist-replica
Brick3: node03:/glusterfs/dist-replica
Brick4: node04:/glusterfs/dist-replica
Options Reconfigured:
performance.readdir-ahead: on
[4] To mount GlusterFS volume on clients, refer to here.
6 Striping+Replication
Configure Storage Clustering.
For example, create a Striping + Replication volume with 4 servers.
                                  |
+----------------------+          |          +----------------------+
| [GlusterFS Server#1] |10.0.0.51 | 10.0.0.52| [GlusterFS Server#2] |
|   node01.srv.world   +----------+----------+   node02.srv.world   |
|                      |          |          |                      |
+----------------------+          |          +----------------------+
                                  |
+----------------------+          |          +----------------------+
| [GlusterFS Server#3] |10.0.0.53 | 10.0.0.54| [GlusterFS Server#4] |
|   node03.srv.world   +----------+----------+   node04.srv.world   |
|                      |                     |                      |
+----------------------+                     +----------------------+
It is recommended to use partitions for GlusterFS volumes which are different from the / partition.
The environment on this example is set as that sdb1 is mounted on /glusterfs directory for GlusterFS Configuration on all Nodes.
[1] Install GlusterFS Server on All Nodes, refer to here.
[2] Create a Directory for GlusterFS Volume on all Nodes.
[root@node01 ~]# mkdir /glusterfs/strip-replica
[3] Configure Clustering like follows on a node. (it's OK on any node)
# probe the node
[root@node01 ~]# gluster peer probe node02
peer probe: success.
[root@node01 ~]# gluster peer probe node03
peer probe: success.
[root@node01 ~]# gluster peer probe node04
peer probe: success.
# show status
[root@node01 ~]# gluster peer status
Number of Peers: 3

Hostname: node02
Uuid: 2ca22769-28a1-4204-9957-886579db2231
State: Peer in Cluster (Connected)

Hostname: node03
Uuid: 79cff591-1e98-4617-953c-0d3e334cf96a
State: Peer in Cluster (Connected)

Hostname: node04
Uuid: 779ab1b3-fda9-46da-af95-ba56477bf638
State: Peer in Cluster (Connected)

# create volume
[root@node01 ~]# gluster volume create vol_strip-replica stripe 2 replica 2 transport tcp \
node01:/glusterfs/strip-replica \
node02:/glusterfs/strip-replica \
node03:/glusterfs/strip-replica \
node04:/glusterfs/strip-replica
volume create: vol_strip-replica: success: please start the volume to access data
# start volume
[root@node01 ~]# gluster volume start vol_strip-replica
volume start: vol_strip-replica: success
# show volume info
[root@node01 ~]# gluster volume info

Volume Name: vol_strip-replica
Type: Striped-Replicate
Volume ID: ec36b0d3-8467-47f6-aa83-1020555f58b6
Status: Started
Number of Bricks: 1 x 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: node01:/glusterfs/strip-replica
Brick2: node02:/glusterfs/strip-replica
Brick3: node03:/glusterfs/strip-replica
Brick4: node04:/glusterfs/strip-replica
Options Reconfigured:
performance.readdir-ahead: on
[4] To mount GlusterFS volume on clients, refer to here.
7 Clients Settings
It's the settings for GlusterFS clients to mount GlusterFS volumes.
[1] For mounting with GlusterFS Native Client, Configure like follows.
[root@client ~]# curl http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo -o /etc/yum.repos.d/glusterfs-epel.repo
[root@client ~]# yum -y install glusterfs glusterfs-fuse
# mount vol_distributed volume on /mnt
[root@client ~]# mount -t glusterfs node01.srv.world:/vol_distributed /mnt
[root@client ~]# df -hT
Filesystem                           Type            Size  Used Avail Use% Mounted on
/dev/mapper/centos-root              xfs              27G  1.1G   26G   5% /
devtmpfs                             devtmpfs        2.0G     0  2.0G   0% /dev
tmpfs                                tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs                                tmpfs           2.0G  8.3M  2.0G   1% /run
tmpfs                                tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/vda1                            xfs             497M  151M  347M  31% /boot
node01.srv.world:/vol_distributed fuse.glusterfs   40G   65M   40G   1% /mnt
[2] NFS (v3) is also supported, so it's possible to mount with NFS.
Configure for it on GlusterFS Servers first, refer to here.
[root@client ~]# yum -y install nfs-utils
[root@client ~]# systemctl start rpcbind rpc-statd
[root@client ~]# systemctl enable rpcbind rpc-statd
[root@client ~]# mount -t nfs -o mountvers=3 node01.srv.world:/vol_distributed /mnt
[root@client ~]# df -hT
Filesystem                           Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root              xfs        27G  1.1G   26G   5% /
devtmpfs                             devtmpfs  2.0G     0  2.0G   0% /dev
tmpfs                                tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs                                tmpfs     2.0G  8.3M  2.0G   1% /run
tmpfs                                tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/vda1                            xfs       497M  151M  347M  31% /boot
node01.srv.world:/vol_distributed nfs        40G   64M   40G   1% /mnt
  

  

  详细视频课程请戳—→ http://edu.运维网.com/course/course_id-6574.html
  
  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-670476-1-1.html 上篇帖子: ​GlusterFS集群文件系统 下篇帖子: gluster文件系统安装配置说明
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表