使用ansible命令,部署glusterfs集群


声明:本文转载自https://my.oschina.net/u/1263909/blog/1600910,转载目的在于传递更多信息,仅供学习交流之用。如有侵权行为,请联系我,我会及时删除。

网上部署glusterfs集群,都是采用登录到主机,执行命令的方式。如果了解ansible,使用ansible批量管理主机,部署glusterfs集群更方便。

 

测试环境

有4台虚拟机,所有机器都安装centos7.4系统。

tmaster,tslave1,tslave2作为glusterfs服务器端节点,phn作为glusterfs客户端节点。


10.101.19.12 tmaster
10.101.19.13 tslave1
10.101.19.14 tslave2
10.101.17.54 phn

还有一台ansible节点,用来管理其他主机。(假设你已经装好了ansible节点)

 

ansible的hosts文件

[clusterfs] 10.101.19.12 10.101.19.13 10.101.19.14 10.101.17.54  [clusterfsserver] 10.101.19.12 10.101.19.13 10.101.19.14  [clusterfsclient] 10.101.17.54

 

部署过程

1. 在ansible机器上中执行,初始化主机环境

# ping所有主机
ansible clusterfs -m ping

 

# 修改时区(可选)
ansible clusterfs -m file -a 'path=/etc/localtime src=/usr/share/zoneinfo/Asia/Shanghai state=link'
ansible clusterfs -a 'date -R'

 

# 修改hosts文件
ansible clusterfs -m lineinfile -a 'path=/etc/hosts regexp=tmaster$ line="10.101.19.12 tmaster"'
ansible clusterfs -m lineinfile -a 'path=/etc/hosts regexp=tslave1$ line="10.101.19.13 tslave1"'
ansible clusterfs -m lineinfile -a 'path=/etc/hosts regexp=tslave2$ line="10.101.19.14 tslave2"'
ansible clusterfs -m lineinfile -a 'path=/etc/hosts regexp=phn$ line="10.101.17.54 phn"'

ansible clusterfs -a "ping tmaster -c 1"
ansible clusterfs -a "ping phn -c 1"


2. 在ansible机器上中执行,配置glusterfs服务器节点

# 为clusterfs服务器节点,安装软件
ansible clusterfsserver -m package -a 'name=centos-release-gluster state=present'
ansible clusterfsserver -m package -a 'name=glusterfs state=present'
ansible clusterfsserver -m package -a 'name=glusterfs-server state=present'
ansible clusterfsserver -m package -a 'name=glusterfs-fuse state=present'
ansible clusterfsserver -m package -a 'name=glusterfs-rdma state=present'

 

# 为clusterfs服务器节点,启动服务
ansible clusterfsserver -m service -a 'name=glusterd enabled=yes state=started'
ansible clusterfsserver -a 'systemctl status glusterd'

 

# 为clusterfs服务器节点,创建数据目录
ansible clusterfsserver -m file -a 'path=/opt/gluster/data state=directory'


3. 在master节点上执行,创建集群,和添加volume等
gluster peer probe tmaster 
gluster peer probe tslave1 
gluster peer probe tslave2
gluster peer status

 

gluster volume info
gluster volume create models replica 3 tmaster:/opt/gluster/data tslave1:/opt/gluster/data tslave2:/opt/gluster/data force
gluster volume info
gluster volume start models


4. 在ansible机器上中执行,为客户端节点,安装软件等
ansible clusterfsclient -m package -a 'name=glusterfs state=present'
ansible clusterfsclient -m package -a 'name=glusterfs-fuse state=present'

 

为客户端节点,挂载卷
ansible clusterfsclient -m file -a 'path=/opt/gfsmount  state=directory'
ansible clusterfsclient -m mount -a 'path=/opt/gfsmount  state=mounted fstype=glusterfs src=tmaster:models'
ansible clusterfsclient -a "df -h"


5. 在10.101.17.54客户端测试
time dd if=/dev/zero of=/opt/gfsmount/hello bs=100M count=1 

 

参考

http://blog.csdn.net/phn_csdn/article/details/75153913

本文发表于2018年01月03日 10:32
(c)注:本文转载自https://my.oschina.net/u/1263909/blog/1600910,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如有侵权行为,请联系我们,我们会及时删除.

阅读 2623 讨论 0 喜欢 0

抢先体验

扫码体验
趣味小程序
文字表情生成器

闪念胶囊

你要过得好哇,这样我才能恨你啊,你要是过得不好,我都不知道该恨你还是拥抱你啊。

直抵黄龙府,与诸君痛饮尔。

那时陪伴我的人啊,你们如今在何方。

不出意外的话,我们再也不会见了,祝你前程似锦。

这世界真好,吃野东西也要留出这条命来看看

快捷链接
网站地图
提交友链
Copyright © 2016 - 2021 Cion.
All Rights Reserved.
京ICP备2021004668号-1