Build a distributed cluster with glusterfs

Source: Internet
Author: User

Based on the previously installed glusterfs, two virtual machines test1 and Test2 are used for distributed storage testing. The IP addresses are 192.168.30.6 and 192.168.30.7 respectively.

1. Make sure that the two VMS run sudo/etc/init. d/glusterd start normally.

2. Run the gluster command with one of them to form a distributed cluster. For example, I use the machine test1 (192.168.30.6)

3. on the test1 machine, run the sudo gluster peer probe 192.168.30.7 command. First, add the Test2 machine to the trusted storage pool (simply put, a directory on one machine, can be considered as a storage pool). The glusterd start of Test2 must be started before it can be connected. You can run the sudo gluster peer status command to view the storage pool information. Once this storage pool is added, some operations previously performed on this storage pool will also be performed accordingly. For example, in the past, this storage pool was used to replicate one of the machines in the storage cluster, use sudo gluster volume
The info command will display the corresponding information. In this case, you can use the gluster volume command to extend the storage pool and delete the storage pool directly on this volume (gluster volume. (Gluster volume, simply put, is to integrate resources (such as a directory) on multiple machines to form a volume for unified management of multiple machines, and follow the configuration command to form the corresponding operation, for example, to form a distributed volume or backup (that is, a copy-type) volume of the multiple machines)

4. Only the distributed cluster is described here. The backup-type cluster is similar. For details, see the official documentation. After Test2 succeeds peer probe, run the sudo gluster volume create test-volume transport TCP 192.168.30.6:/home/dir1 192.168.30.7:/home/dir1 on test1, there is no dir1 Directory, which is irrelevant. If this directory is not available, this directory will be automatically created after this command. (Note: because the local machine is already in the pool by default, peer probe is not needed)

5. In Step 2, test1:/home/dir1 and Test2:/home/dir2 form a simple distributed cluster. The following is a test on the client.

 

The client can mount the server volume in three ways: 1.nfs; 2. CIFS; 3. gluster native client (this is the client of glusterfs). The last two methods are described here.

1. gluster native client.

(A). You need to install glusterfs on the client (test3: 192.168.30.8). For details, see "glusterfs installation configuration ". After installation, run the sudo Mount-T glusterfs 192.168.30.6:/test-volume/mnt/gluster command. (You must create this directory first)
(B ). after the mounting is successful, switch to the/mnt/gluster directory of test3, use touch {1, 2, 3, 4, 5, 6, 7}, and return to the/home/dir1 directory of test1, found that there are, 7, in the/home/dir1 directory of Test2, there are 2, 3, 4, 6, indicating that the files have been successfully distributed and stored on different machines

2. CIFS (this is the Network File Transfer Protocol on windows, which is used by network neighbors)

Principle: first, like the gluster native client, mount the server volume to a directory and use Samba to export the mounted directory so that it can be accessed in the network neighbor of windows.

(A). In test1, sudo mkdir/mnt/gluster creates a mount directory.

(B). sudo Vim/etc/samba/smb. conf, add the following content to the end

[Glustertest]
Comment = for testing a gluster volume exported through CIFS
Path =/mnt/gluster
Read Only = No
Guest OK = Yes

(C ). in test1, run the sudo Mount-T glusterfs 192.168.30.6:/test-volume/mnt/gluster command to directly access the volume in the network neighbor of the Windows host. (In fact, The test1 volume is only virtual. It must be mounted to the physical directory to be mapped to the network)

Note:

1. glusterfs mounts volume to a folder in a directory. addition, deletion, modification, and query are all the same as local files, which is transparent to users.

2. sudo/etc/init. after D/gluster start is started, use sudo gluster peer status to view the node status. You can see that if sudo/etc/init is not started on the node machine. d/gluster start is displayed as not connected at this time. If it is started, it will be automatically connected. When you use sudo gluster volume info to view volume information, you can see that, no matter whether the node machine is started or not, the status is displayed as started, that is, the default status is start. Now, you only need to start the gluster daemon on the node machine to mount volume.

3. Samba is a free software for implementing the SMB protocol on Linux systems. The SMB protocol is usually used by Windows series for disk and printer sharing.

4. Detach a mount point: sudo umount/mnt/gluster

5. glusterfs is better to use the same version. I use 3.1 for one and 3.2 for the other. When the peer probe is used, probe failed is displayed, but when I check the status of the peer, the connection is displayed.

6. when the configuration file is used for Distributed File storage, glusterfsd. vol is the server configuration template file, glusterfs. vol is the template configuration file of the client. When the server starts or the client mounts a directory, you can specify which configuration file to start to form unused applications.

7. glusterfsd. does the configuration file vol affect the daemon sudo/etc/init. d/glusterd start: whether the/home/DIR directory exists or does not affect daemon startup. If the directory exoirt is set to 1777, when the daemon is started, an error is reported. At the beginning, it is affected by the Internet. Because gluster is used according to the configuration file, an error occurs when the daemon is used to manage glusterfs.

Note: If you want to add or delete files to and from mounted volumes directly in the network neighbor, you must grant permissions to the mounted directory/mnt/gluster, sudo chmod 777/mnt/gluster

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.