Setup GlusterFS using Ansible

Setup GlusterFS using Ansible

GlusterFS is a scalable network filesystem. Using common off-the-shelf hardware, you can create large, distributed storage solutions for media streaming, data analysis, and other data- and bandwidth-intensive tasks. GlusterFS is free and open source software.

GlusterFS is an open source, distributed file system capable of scaling to several petabytes and handling thousands of clients. It is a file system with a modular, stackable design, and a unique no-metadata server architecture. This no-metadata server architecture ensures better performance, linear scalability, and reliability. GlusterFS can be flexibly combined with commodity physical, virtual, and cloud resources to deliver highly available and performant enterprise storage at a fraction of the cost of traditional solutions.
GlusterFS clusters together storage building blocks over Infiniband RDMA and/or TCP/IP interconnect, aggregating disk and memory resources and managing data in a single global namespace.
GlusterFS aggregates various storage servers over network interconnects into one large parallel network file system. Based on a stackable user space design, it delivers exceptional performance for diverse workloads and is a key building block of GlusterFS. The POSIX compatible GlusterFS servers, use any ondisk file system which supports extended attributes (eg: ext4, XFS, etc) to format to store data on disks, can be accessed using industry-standard access protocols including Network File System (NFS) and Server Message Block (SMB).
640px-glusterfs_architecture
GlusterFS is designed for today's high-performance, virtualized cloud environments. Unlike traditional data centers, cloud environments require multi-tenancy along with the ability to grow or shrink resources on demand. Enterprises can scale capacity, performance, and availability on demand, with no vendor lock-in, across on-premise, public cloud, and hybrid environments.
#######################################
Installing GlusterFS
---
- hosts: gluster
  remote_user: root
  vars:
    max_client: 300
  tasks:
  - name: installing gluster server
    yum:
      name: glusterfs,glusterfs-server
      state: latest

Configuration

- hosts: gluster
  remote_user: root
  vars:
    max_client: 300
  tasks:
  - name: starting gluster server service
    service:
      name: glusterd
      state: started
      enabled: yes

    lineinfile: dest=/etc/selinux/config
                regexp='^SELINUX='
                line='SELINUX=disabled'
                state=present

    command: iptables -F

      vg: myvg
      lv: gfslv
      size: 2g

    file: path=/media/gfs state=directory

    filesystem: fstype=xfs dev={{ mountable_share_drive | default('/dev/myvg/gfslv') }} force=yes

    mount: name=/media/gfs src={{ mountable_share_drive | default('/dev/myvg/gfslv') }} fstype=xfs state=mounted

Peer Probing
---
- hosts: peer
  remote_user: root
  tasks:
  - name: commands
    command: '{{ item }}'
    with_items:
    - 'gluster peer probe {{ groups.probing[0] }}'
    - 'gluster peer probe {{ groups.probing[1] }}'
    - 'gluster peer probe {{ groups.probing[2] }}'

#########################################
Create Volume

---
- hosts: gluster
  remote_user: root
  vars:
    gluster_brick_dir: /media/gfs
    gluster_brick_name: gluster
# Note: This is hardcoded for 4 bricks only. Adjust accordingly.
    gluster_brick_config:
      "transport tcp
      {{ groups.gluster[0] }}:{{ gluster_brick_dir }}
      {{ groups.gluster[1] }}:{{ gluster_brick_dir }}
      {{ groups.gluster[2] }}:{{ gluster_brick_dir }}
      {{ groups.gluster[3] }}:{{ gluster_brick_dir }}"

tasks: 
 # Gluster volume configuration.

  - name: Check if Gluster volumes already exist.
    shell: "gluster volume info"
    changed_when: false
    register: gluster_volume_info

  - name: Configure Gluster volume.
    gluster_volume:
      state: present
      name: "{{ gluster_brick_name }}"
      brick: "{{ gluster_brick_dir }}"
      replicas: 2
      cluster: "{{ groups.gluster | join(',') }}"
      force: yes
    run_once: true

  - name: restart rpcbind service
    service: name=rpcbind state=restarted

  - name: restart glusterd server service
    service: name=glusterd state=restarted

  - name: iptables flush
    command: iptables -F

  - name: exportfs
    command: exportfs -r

Post a Comment

0 Comments