Deploying GlusterFS in high availability mode
GlusterFS
Use this tutorial to create an infrastructure made up of three segments sharing a common GlusterFS file system. Placing storage disks in three different availability zones will ensure the high availability and fault tolerance of your file system.
To configure a high availability file system:
- Get your cloud ready.
- Configure the CLI profile.
- Set up an environment for deploying the resources.
- Deploy your resources.
- Install and configure GlusterFS.
- Test the solution’s availability and fault tolerance.
If you no longer need the resources you created, delete them.
Get your cloud ready
Sign up for Yandex Cloud and create a billing account:
- Go to the management console
and log in to Yandex Cloud or create an account if you do not have one yet. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not have a billing account, create one.
If you have an active billing account, you can go to the cloud page
Learn more about clouds and folders.
Required paid resources
The infrastructure support costs include:
- Fee for continuously running VMs and disks (see Yandex Compute Cloud pricing).
- Fee for using public IP addresses and outbound traffic (see Yandex Virtual Private Cloud pricing).
Configure the CLI profile
-
If you do not have the Yandex Cloud CLI yet, install it and get authenticated according to instructions provided.
-
Create a service account:
Management consoleCLIAPI- In the management console
, select the folder where you want to create a service account. - In the list of services, select Identity and Access Management.
- Click Create service account.
- Specify the service account name, e.g.,
sa-glusterfs
. - Click Create.
The folder specified in the CLI profile is used by default. You can specify a different folder through the
--folder-name
or--folder-id
parameter.Run the command below to create a service account, specifying
sa-glusterfs
as its name:yc iam service-account create --name sa-glusterfs
Where
name
is the service account name.Result:
id: ajehr0to1g8b******** folder_id: b1gv87ssvu49******** created_at: "2023-06-20T09:03:11.665153755Z" name: sa-glusterfs
To create a service account, use the ServiceAccountService/Create gRPC API call or the create REST API method for the
ServiceAccount
resource. - In the management console
-
Assign the administrator role for the folder to the service account:
Management consoleCLIAPI- On the management console home page
, select a folder. - Go to the Access bindings tab.
- Find the
sa-glusterfs
account in the list and click . - Click Edit roles.
- Click Add role in the dialog that opens and select the
admin
role.
Run this command:
yc resource-manager folder add-access-binding <folder_ID> \ --role admin \ --subject serviceAccount:<service_account_ID>
To assign a role for a folder to a service account, use the setAccessBindings REST API method for the ServiceAccount resource or the ServiceAccountService/SetAccessBindings gRPC API call.
- On the management console home page
-
Set up the CLI profile to run operations on behalf of the service account:
CLI-
Create an authorized key for the service account and save it to the file:
yc iam key create \ --service-account-id <service_account_ID> \ --folder-id <ID_of_folder_with_service_account> \ --output key.json
Where:
service-account-id
: Service account ID.folder-id
: Service account folder ID.output
: Authorized key file name.
Result:
id: aje8nn871qo4******** service_account_id: ajehr0to1g8b******** created_at: "2023-06-20T09:16:43.479156798Z" key_algorithm: RSA_2048
-
Create a CLI profile to run operations on behalf of the service account:
yc config profile create sa-glusterfs
Result:
Profile 'sa-glusterfs' created and activated
-
Configure the profile:
yc config set service-account-key key.json yc config set cloud-id <cloud_ID> yc config set folder-id <folder_ID>
Where:
-
Export your credentials to environment variables:
export YC_TOKEN=$(yc iam create-token) export YC_CLOUD_ID=$(yc config get cloud-id) export YC_FOLDER_ID=$(yc config get folder-id)
-
Set up your resource environment
-
Create an SSH key pair:
ssh-keygen -t ed25519
We recommend using the default key file name.
-
Clone the
yandex-cloud-examples/yc-distributed-ha-storage-with-glusterfs
GitHub repository and go to theyc-distributed-ha-storage-with-glusterfs
folder:git clone https://github.com/yandex-cloud-examples/yc-distributed-ha-storage-with-glusterfs.git cd ./yc-distributed-ha-storage-with-glusterfs
-
Edit the
variables.tf
file, specifying the parameters of the resources you are deploying:Warning
The values set in the file result in deploying a resource-intensive infrastructure.
To deploy the resources within your available quotas, use the values below or adjust the values to your specific needs.- In
disk_size
, changedefault
to30
. - In
client_cpu_count
, changedefault
to2
. - In
storage_cpu_count
, changedefault
to2
. - If you used a non-default name when creating the SSH key pair, change
default
to<public_SSH_key_path>
underlocal_pubkey_path
.
- In
Deploy your resources
- Initialize Terraform:
terraform init
- Check the Terraform file configuration:
terraform validate
- Preview the list of new cloud resources:
terraform plan
- Create the resources:
terraform apply -auto-approve
- Wait until you are notified it has been completed:
Outputs: connect_line = "ssh storage@158.160.108.137" public_ip = "158.160.108.137"
This will create three VMs for hosting client code (client01
, client02
, and client03
) in the folder, as well as three VMs for distributed data storage (gluster01
, gluster02
, and gluster03
) linked to the client VMs and placed in three different availability zones.
Install and configure GlusterFS
-
Connect to the
client01
VM using the command from the process completion output:ssh storage@158.160.108.137
-
Switch to the
root
mode:sudo -i
-
Install ClusterShell
:dnf install epel-release -y dnf install clustershell -y echo 'ssh_options: -oStrictHostKeyChecking=no' >> /etc/clustershell/clush.conf
-
Create the configuration files:
cat > /etc/clustershell/groups.conf <<EOF [Main] default: cluster confdir: /etc/clustershell/groups.conf.d $CFGDIR/groups.conf.d autodir: /etc/clustershell/groups.d $CFGDIR/groups.d EOF cat > /etc/clustershell/groups.d/cluster.yaml <<EOF cluster: all: '@clients,@gluster' clients: 'client[01-03]' gluster: 'gluster[01-03]' EOF
-
Install GlusterFS:
clush -w @all hostname # check and auto add fingerprints clush -w @all dnf install centos-release-gluster -y clush -w @all dnf --enablerepo=powertools install glusterfs-server -y clush -w @gluster mkfs.xfs -f -i size=512 /dev/vdb clush -w @gluster mkdir -p /bricks/brick1 clush -w @gluster "echo '/dev/vdb /bricks/brick1 xfs defaults 1 2' >> /etc/fstab" clush -w @gluster "mount -a && mount"
-
Restart GlusterFS:
clush -w @gluster systemctl enable glusterd clush -w @gluster systemctl restart glusterd
-
Check whether
gluster02
andgluster03
are available:clush -w gluster01 gluster peer probe gluster02 clush -w gluster01 gluster peer probe gluster03
-
Create a
vol0
folder in each data storage VM and configure availability and fault tolerance by connecting to theregional-volume
shared folder:clush -w @gluster mkdir -p /bricks/brick1/vol0 clush -w gluster01 gluster volume create regional-volume disperse 3 redundancy 1 gluster01:/bricks/brick1/vol0 gluster02:/bricks/brick1/vol0 gluster03:/bricks/brick1/vol0
-
Make use of additional performance settings:
clush -w gluster01 gluster volume set regional-volume client.event-threads 8 clush -w gluster01 gluster volume set regional-volume server.event-threads 8 clush -w gluster01 gluster volume set regional-volume cluster.shd-max-threads 8 clush -w gluster01 gluster volume set regional-volume performance.read-ahead-page-count 16 clush -w gluster01 gluster volume set regional-volume performance.client-io-threads on clush -w gluster01 gluster volume set regional-volume performance.quick-read off clush -w gluster01 gluster volume set regional-volume performance.parallel-readdir on clush -w gluster01 gluster volume set regional-volume performance.io-thread-count 32 clush -w gluster01 gluster volume set regional-volume performance.cache-size 1GB clush -w gluster01 gluster volume set regional-volume server.allow-insecure on
-
Mount the
regional-volume
shared folder on the client VMs:clush -w gluster01 gluster volume start regional-volume clush -w @clients mount -t glusterfs gluster01:/regional-volume /mnt/
Test the availability and fault tolerance of the solution
-
Check the status of the
regional-volume
shared folder:clush -w gluster01 gluster volume status
Result:
gluster01: Status of volume: regional-volume gluster01: Gluster process TCP Port RDMA Port Online Pid gluster01: ------------------------------------------------------------------------------ gluster01: Brick gluster01:/bricks/brick1/vol0 54660 0 Y 1374 gluster01: Brick gluster02:/bricks/brick1/vol0 58127 0 Y 7716 gluster01: Brick gluster03:/bricks/brick1/vol0 53346 0 Y 7733 gluster01: Self-heal Daemon on localhost N/A N/A Y 1396 gluster01: Self-heal Daemon on gluster02 N/A N/A Y 7738 gluster01: Self-heal Daemon on gluster03 N/A N/A Y 7755 gluster01: gluster01: Task Status of Volume regional-volume gluster01: ------------------------------------------------------------------------------ gluster01: There are no active volume tasks gluster01:
-
Create a text file:
cat > /mnt/test.txt <<EOF Hello, GlusterFS! EOF
-
Make sure the file is available on all three client VMs:
clush -w @clients sha256sum /mnt/test.txt
Result:
client01: 5fd9c031531c39f2568a8af5512803fad053baf3fe9eef2a03ed2a6f0a884c85 /mnt/test.txt client02: 5fd9c031531c39f2568a8af5512803fad053baf3fe9eef2a03ed2a6f0a884c85 /mnt/test.txt client03: 5fd9c031531c39f2568a8af5512803fad053baf3fe9eef2a03ed2a6f0a884c85 /mnt/test.txt
-
Shut down one of the storage VMs, e.g.,
gluster02
:Management consoleCLIAPI- In the management console
, select the folder this VM belongs to. - Select Compute Cloud.
- Select the
gluster02
VM from the list, click , and select Stop. - In the window that opens, click Stop.
-
See the description of the CLI command for stopping a VM:
yc compute instance stop --help
-
Stop the VM:
yc compute instance stop gluster02
Use the stop REST API method for the Instance resource or the InstanceService/Stop gRPC API call.
- In the management console
-
Make sure the VM is shut down:
clush -w gluster01 gluster volume status
Result:
gluster01: Status of volume: regional-volume gluster01: Gluster process TCP Port RDMA Port Online Pid gluster01: ------------------------------------------------------------------------------ gluster01: Brick gluster01:/bricks/brick1/vol0 54660 0 Y 1374 gluster01: Brick gluster03:/bricks/brick1/vol0 53346 0 Y 7733 gluster01: Self-heal Daemon on localhost N/A N/A Y 1396 gluster01: Self-heal Daemon on gluster03 N/A N/A Y 7755 gluster01: gluster01: Task Status of Volume regional-volume gluster01: ------------------------------------------------------------------------------ gluster01: There are no active volume tasks gluster01:
-
Make sure the file is still available on all three client VMs:
clush -w @clients sha256sum /mnt/test.txt
Result:
client01: 5fd9c031531c39f2568a8af5512803fad053baf3fe9eef2a03ed2a6f0a884c85 /mnt/test.txt client02: 5fd9c031531c39f2568a8af5512803fad053baf3fe9eef2a03ed2a6f0a884c85 /mnt/test.txt client03: 5fd9c031531c39f2568a8af5512803fad053baf3fe9eef2a03ed2a6f0a884c85 /mnt/test.txt
How to delete the resources you created
To stop paying for the resources created, delete them:
terraform destroy -auto-approve