High-availability storage with glusterfs on Ubuntu 9.10-Automatic File Replication (mirror)

Source: Internet
Author: User
Tags glusterfs
Document directory
  • 1 Preliminary Note
  • 2 setting up the glusterfs servers
  • 3 setting up the glusterfs Client
  • 4 testing

 

This tutorial shows how to set up a high-availability storage with two storage servers (Ubuntu 9.10) that use glusterfs. each storage server will be a mirror of the other storage server, and files will be replicated automatically stored SS both storage servers. the Client System (Ubuntu 9.10 as well) will be able to access the storage as if it was a local filesystem. glusterfs is a clustered file-system capable of scaling to several peta-bytes. it aggregates various storage bricks over InfiniBand rdma or TCP/IP interconnect into one large Parallel Network File System. storage bricks can be made of any commodity hardware such as x86_64 servers with SATA-II raid and InfiniBand HBA.

 

I do not issue any guarantee that this will work for you!

 

 

 

1 Preliminary Note

In this tutorial I use three systems, two servers and a client:

  • Server1.example.com: IP address 192.168.0.100 (server)
  • Server2.example.com: IP address 192.168.0.101 (server)
  • Client1.example.com: IP address 192.168.0.102 (client)

Because we will run all the steps from this tutorial with root privileges, we can either prepend all commands in this tutorial with the string sudo, or we become root right now by typing

Sudo Su

All three systems shocould be able to resolve the other systems 'hostnames. if this cannot be done through DNS, you should edit the/etc/hosts file so that it looks as follows on all three systems:

VI/etc/hosts

127.0.0.1       localhost.localdomain   localhost192.168.0.100   server1.example.com     server1192.168.0.101   server2.example.com     server2192.168.0.102   client1.example.com     client1# The following lines are desirable for IPv6 capable hosts::1     localhost ip6-localhost ip6-loopbackfe00::0 ip6-localnetff00::0 ip6-mcastprefixff02::1 ip6-allnodesff02::2 ip6-allroutersff02::3 ip6-allhosts

(It is also possible to use IP addresses instead of hostnames in the following setup. if you prefer to use IP addresses, you don't have to care about whether the hostnames can be resolved or not .)

 

2 setting up the glusterfs servers

Server1.example.com/server2.example.com:

Glusterfs is available as a package for Ubuntu 9.10, therefore we can install it as follows:

Aptitude install glusterfs-Server

 

The command

Glusterfs -- version

Shocould now show the glusterfs version that you 've just installed (2.0.2 in this case ):

Root @ server1 :~ # Glusterfs -- version
Glusterfs 2.0.2 built on Jun 29 2009 23:49:59
Repository revision: 07019da2e16534d527215a91904298ede09bb798
Copyright (c) 2006-2009 Z Research Inc. Glusterfs comes with absolutely no warranty.
You may redistribute copies of glusterfs under the terms of the GNU General Public License.
Root @ server1 :~ #

 

Next we create a few directories:

Mkdir/data/
Mkdir/data/Export
Mkdir/data/export-NS

 

Now we create the glusterfs server configuration file/etc/glusterfs/glusterfsd. VOL (we make a backup of the original/etc/glusterfs/glusterfsd. volfile first) which defines which directory will be exported (/data/export) and what client is allowed to connect (192.168.0.102 = client1.example.com ):

CP/etc/glusterfs/glusterfsd. vol/etc/glusterfs/glusterfsd. vol_orig
CAT/dev/null>/etc/glusterfs/glusterfsd. Vol
VI/etc/glusterfs/glusterfsd. Vol

volume posix  type storage/posix  option directory /data/exportend-volumevolume locks  type features/locks  subvolumes posixend-volumevolume brick  type performance/io-threads  option thread-count 8  subvolumes locksend-volumevolume server  type protocol/server  option transport-type tcp  option auth.addr.brick.allow *  subvolumes brickend-volume

Please note that it is possible to use wildcards for the IP addresses (like 192. 168. *) and that you can specify multiple IP addresses separated by comma (e.g. 192.168.0.102, 192.168.0.103 ).

 

Afterwards we start the glusterfs Server:

/Etc/init. d/glusterfs-Server start

 

 

 

 

3 setting up the glusterfs Client

Client1.example.com:

On the client, we can install the glusterfs client as follows:

Aptitude install glusterfs-client glusterfs-Server

 

Then we create the following directory:

Mkdir/mnt/glusterfs

 

Next we create the file/etc/glusterfs. Vol (we make a backup of the original/etc/glusterfs. Vol file first ):

CP/etc/glusterfs. vol/etc/glusterfs. vol_orig
CAT/dev/null>/etc/glusterfs. Vol
VI/etc/glusterfs. Vol

volume remote1  type protocol/client  option transport-type tcp  option remote-host server1.example.com  option remote-subvolume brickend-volumevolume remote2  type protocol/client  option transport-type tcp  option remote-host server2.example.com  option remote-subvolume brickend-volumevolume replicate  type cluster/replicate  subvolumes remote1 remote2end-volumevolume writebehind  type performance/write-behind  option window-size 1MB  subvolumes replicateend-volumevolume cache  type performance/io-cache  option cache-size 512MB  subvolumes writebehindend-volume

Make sure you use the correct server hostnames or IP addresses in the option remote-host lines!

That's it! Now we can mount the glusterfs filesystem to/mnt/glusterfs with one of the following two commands:

Glusterfs-F/etc/glusterfs. vol/mnt/glusterfs

Or

Mount-T glusterfs/etc/glusterfs. vol/mnt/glusterfs

You shoshould now see the new share in the outputs...

Mount

Root @ Client1 :~ # Mount
/Dev/mapper/client1-root on/type ext4 (RW, errors = remount-Ro)
Proc on/proc type proc (RW)
None on/sys type sysfs (RW, noexec, nosuid, nodev)
None on/sys/fs/fuse/connections type fusectl (RW)
None on/sys/kernel/debug type debugfs (RW)
None on/sys/kernel/security type securityfs (RW)
Udev on/dev type tmpfs (RW, mode = 0755)
None on/dev/PTS type devpts (RW, noexec, nosuid, gid = 5, mode = 0620)
None on/dev/SHM type tmpfs (RW, nosuid, nodev)
None on/var/run type tmpfs (RW, nosuid, mode = 0755)
None on/var/lock type tmpfs (RW, noexec, nosuid, nodev)
None on/lib/init/RW Type tmpfs (RW, nosuid, mode = 0755)
/Dev/sda5 on/boot type ext2 (RW)
/Etc/glusterfs. Vol on/mnt/glusterfs type fuse. glusterfs (RW, max_read = 131072, allow_other, default_permissions)
Root @ Client1 :~ #

... And...

DF-H

Root @ Client1 :~ # DF-H
Filesystem size used avail use % mounted on
/Dev/mapper/client1-root
29G 808 m 27G 3%/
Udev 122 m 152 K 121 m 1%/dev
None 122 M 0 122 m 0%/dev/SHM
None 122 M 36 K 122 m 1%/var/run
None 122 M 0 122 m 0%/var/lock
None 122 M 0 122 m 0%/lib/init/RW
/Dev/sda5 228 m 15 m 202 m 7%/boot
/Etc/glusterfs. Vol
18g 805 m 16g 5%/mnt/glusterfs
Root @ Client1 :~ #

 

 

 

(Server1.example.com and server2.example.com each have 18 GB of space for the glusterfs filesystem, but because the data is mirrored, the client doesn't see 36 GB (2x18 GB ), but only 18 GB .)

Instead of mounting the glusterfs share manually on the client, you cocould Modify/etc/fstab so that the share gets mounted automatically when the client boots.

Open/etc/fstab and append the following line:

VI/etc/fstab

[...]/etc/glusterfs/glusterfs.vol  /mnt/glusterfs  glusterfs  defaults  0  0

To test if your modified/etc/fstab is working, reboot the client:

Reboot

After the reboot, you should find the share in the outputs...

DF-H

... And...

Mount

 

4 testing

Now let's create some test files on the glusterfs share:

Client1.example.com:

Touch/mnt/glusterfs/test1
Touch/mnt/glusterfs/Test2

 

Now let's check the/data/export directory on server1.example.com and server2.example.com. The test1 and Test2 files shocould be present on each node:

Server1.example.com/server2.example.com:

Ls-L/data/Export

Root @ server1 :~ # Ls-L/data/Export
Total 0
-RW-r -- 1 Root 0 2009-12-18 :37 test1
-RW-r -- 1 Root 0 2009-12-18 :37 Test2
Root @ server1 :~ #

 

Now we shut down server1.example.com and add/delete some files on the glusterfs share on client1.example.com.

Server1.example.com:

Shutdown-H now

Client1.example.com:

Touch/mnt/glusterfs/test3
Touch/mnt/glusterfs/test4
Rm-F/mnt/glusterfs/Test2

 

The changes shoshould be visible in the/data/export directory on server2.example.com:

Server2.example.com:

Ls-L/data/Export

Root @ server2 :~ # Ls-L/data/Export
Total 0
-RW-r -- 1 Root 0 2009-12-18 :37 test1
-RW-r -- 1 Root 0 2009-12-18 :39 test3
-RW-r -- 1 Root 0 2009-12-18 :39 test4
Root @ server2 :~ #

Let's boot server1.example.com again and take a look at the/data/export directory:

Server1.example.com:

Ls-L/data/Export

Root @ server1 :~ # Ls-L/data/Export
Total 0
-RW-r -- 1 Root 0 2009-12-18 :37 test1
-RW-r -- 1 Root 0 2009-12-18 :37 Test2
Root @ server1 :~ #

As you see, server1.example.com hasn't noticed the changes that happened while it was down. this is easy to fix, all we need to do is invoke a READ command on the glusterfs share on client1.example.com, e.g.:

Client1.example.com:

Ls-L/mnt/glusterfs/

Root @ Client1 :~ # Ls-L/mnt/glusterfs/
Total 0
-RW-r -- 1 Root 0 2009-12-18 :37 test1
-RW-r -- 1 Root 0 2009-12-18 :39 test3
-RW-r -- 1 Root 0 2009-12-18 :39 test4
Root @ Client1 :~ #

Now take a look at the/data/export directory on server1.example.com again, And You shoshould see that the changes have been replicated to that node:

Server1.example.com:

Ls-L/data/Export

Root @ server1 :~ # Ls-L/data/Export
Total 0
-RW-r -- 1 Root 0 2009-12-18 :37 test1
-RW-r -- 1 Root 0 2009-12-18 :39 test3
-RW-r -- 1 Root 0 2009-12-18 :39 test4
Root @ server1 :~ #

 

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.