使用ansible命令,部署glusterfs集群

网上部署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

转载于:https://my.oschina.net/u/1263909/blog/1600910

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用 Ansible 安装部署 ClickHouse 集群,需要完成以下步骤: 1. 确保已经在每个目标主机上安装了 ClickHouse,并确保 ClickHouse 已经可以正常运行。 2. 创建一个 Ansible 的 inventory 文件,该文件列出了所有 ClickHouse 集群中的主机及其 IP 地址。一个简单的 inventory 文件可能如下所示: ``` [clickhouse] ch1.example.com ch2.example.com ch3.example.com ``` 3. 创建一个 Ansible playbook 文件,该文件包含用于安装和配置 ClickHouse 的任务。以下是一个示例 playbook: ``` - name: Install and configure ClickHouse hosts: clickhouse become: true tasks: - name: Install ClickHouse apt: name: clickhouse-server state: present become: true become_user: root - name: Configure ClickHouse template: src: clickhouse-server.xml.j2 dest: /etc/clickhouse-server/config.xml become: true become_user: clickhouse ``` 在这个 playbook 中,我们首先使用 Ansible 的 apt 模块安装 ClickHouse,然后使用 Ansible 的 template 模块将 ClickHouse 配置文件复制到目标主机的 `/etc/clickhouse-server/config.xml` 文件中。 4. 创建一个 ClickHouse 配置模板文件。这个模板文件应该包含用于配置 ClickHouse 的所有参数。以下是一个示例配置文件: ``` <yandex> <clickhouse_server> <interserver_http_host>0.0.0.0</interserver_http_host> <listen_host>0.0.0.0</listen_host> <listen_port>9000</listen_port> <max_connections>1000</max_connections> <max_concurrent_queries>1000</max_concurrent_queries> <distributed_ddl> <num_tries>3</num_tries> <try_delay_sec>3</try_delay_sec> </distributed_ddl> <users> <default> <password></password> <networks> <ip>::/0</ip> </networks> </default> </users> </clickhouse_server> </yandex> ``` 请注意,这个配置文件只包含了一些基本的 ClickHouse 配置选项。您应该根据自己的需求进行修改。 5. 运行 playbook,部署 ClickHouse 集群。要运行 playbook,请使用以下命令: ``` ansible-playbook -i inventory_file playbook_file.yml ``` 这将在 ClickHouse 集群中的所有主机上运行 playbook。 以上就是使用 Ansible 安装部署 ClickHouse 集群的一般步骤。请注意,这只是一个基本的例子。要根据自己的需求对 playbook 进行修改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值