使用Ansible创建并挂载GlusterFS卷


16

我正在使用GlusterFS在4台计算机上创建和装载卷。比方说,该机器被称为machine1machine2machine3machine4

我的同伴已经被成功探测。

我已经使用以下命令来创建我的卷:

sudo gluster volume create ssl replica 2 transport tcp machine1:/srv/gluster/ssl machine2:/srv/gluster/ssl machine3:/srv/gluster/ssl machine4:/srv/gluster/ssl force

然后,我从以下内容开始音量:

sudo gluster volume start ssl

我已经/myproject/ssl使用以下命令挂载了目录:

sudo mount -t glusterfs machine1:/ssl /myproject/ssl

当安装在每台计算机上时,一切都会按预期进行,并且/myproject/ssl目录具有在所有计算机上共享的数据。

问题是,在地球上我该怎么做?

这是我尝试以Ansible方式执行这两个命令的尝试:

- name: Configure Gluster volume.
  gluster_volume:
    state: present
    name: "{{ gluster.brick_name }}"
    brick: "{{ gluster.brick_dir }}"
    replicas: 2
    cluster: "{{ groups.glusterssl | join(',') }}"
    host: "{{ inventory_hostname }}"
    force: yes
  become: true
  become_user: root
  become_method: sudo
  run_once: true
  ignore_errors: true

- name: Ensure Gluster volume is mounted.
  mount:
    name: "{{ gluster.brick_name }}"
    src: "{{ inventory_hostname }}:/{{ gluster.brick_name }}"
    fstype: glusterfs
    opts: "defaults,_netdev"
    state: mounted
  become: true
  become_user: root
  become_method: sudo

尽管对等探测已成功完成上一个任务,但该Configure Gluster volume任务失败并显示以下信息:

fatal: [machine3]: FAILED! => 
  {"changed": false, 
   "failed": true, 
   "invocation": {
     "module_args": {
       "brick": "/srv/gluster/ssl",
       "bricks": "/srv/gluster/ssl", 
       "cluster": ["machine1", "machine2", "machine3", "machine4"],
       "directory": null, 
       "force": true, 
       "host": "machine3", 
       "name": "ssl", 
       "options": {}, 
       "quota": null, 
       "rebalance": false, 
       "replicas": 2, 
       "start_on_create": true, 
       "state": "present", 
       "stripes": null, 
       "transport": "tcp"}, 
     "module_name": "gluster_volume"}, 
   "msg": "failed to probe peer machine1 on machine3"}

如果我用建议的第一个shell命令替换了该Ansible任务,则一切正常,但是Ensure Gluster volume is mounted失败了:

fatal: [machine3]: FAILED! => 
  {"changed": false, 
   "failed": true, 
   "invocation": {
     "module_args": {
       "dump": null, 
       "fstab": "/etc/fstab", 
       "fstype": "glusterfs", 
       "name": "ssl", "opts": 
       "defaults,_netdev", 
       "passno": null, "src": 
       "machine3:/ssl", 
       "state": "mounted"}, 
     "module_name": "mount"}, 
   "msg": "Error mounting ssl: Mount failed. Please check the log file for more details.\n"}

相关的日志输出为:

[2016-10-17 09:10:25.602431] E [MSGID: 114058] [client-handshake.c:1524:client_query_portmap
_cbk] 2-ssl-client-3: failed to get the port number for remote subvolume. Please run 'gluster volume status' on server to see if brick process is running.
[2016-10-17 09:10:25.602480] I [MSGID: 114018] [client.c:2042:client_rpc_notify] 2-ssl-client-3: disconnected from ssl-client-3. Client process will keep trying to connect to glusterd until brick's port is available
[2016-10-17 09:10:25.602500] E [MSGID: 108006] [afr-common.c:3880:afr_notify] 2-ssl-replicate-1: All subvolumes are down. Going offline until atleast one of them comes back up.
[2016-10-17 09:10:25.616402] I [fuse-bridge.c:5137:fuse_graph_setup] 0-fuse: switched to graph 2

因此,该卷不会由Ansible任务启动。

我的问题本质上是,我该如何以与上述3条命令相同的方式(Ansible方式)创建,装入和启动卷?


6
不知道您是否曾想出这个办法,但想为GlusterFS分享我的Ansible角色,这可能会带您朝正确的方向前进。github.com/mrlesmithjr/ansible-glusterfs
mrlesmithjr

Answers:


2

您应该从以下内容开始音量state: started

- name: Configure Gluster volume.
  gluster_volume:
    state: started
    name: "{{ gluster.brick_name }}"
    brick: "{{ gluster.brick_dir }}"
    replicas: 2
    cluster: "{{ groups.glusterssl | join(',') }}"
    host: "{{ inventory_hostname }}"
    force: yes
  become: true
  become_user: root
  become_method: sudo
  run_once: true
  ignore_errors: true
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.