Ruan Bekker's Blog

From a Curious mind to Posts on Github

Create a ZFS Raidz1 Volume Pool on Ubuntu 16

Setting up ZFS Volume Pool on Ubuntu 16.04

Installation

1
$ sudo apt-get install zfsutils-linux -y

Creating the ZFS Storage Pool

We will create a RAIDZ(1) Volume which is like Raid5 with Single Parity, so we can lose one of the Physical Disks before Raid failure.

Let’s first have a look at our disks that we have on our server:

1
2
3
4
5
6
$ lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   8G  0 disk
└─xvda1 202:1    0   8G  0 part /
xvdf    202:80   0 100G  0 disk 
xvdg    202:80   0 100G  0 disk 

So we will be creating the volume consisting of /dev/xvdf and /dev/xvdg and we will name our pool: storage-pool

1
$ zpool create storage-pool raidz1 xvdf xvdg -f

Listing Pools

1
2
3
$ zpool list
NAME           SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
storage-pool   199G   125K   199G         -     0%     0%  1.00x  ONLINE  -

We can also list the volume with zfs:

1
2
3
$ zfs list
NAME            USED  AVAIL  REFER  MOUNTPOINT
storage-pool    125K  199G   19K    /storage-pool

Mounting the Volume:

You will find that the volume is already mounted:

1
2
3
4
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      7.7G  1.1G  6.7G  14% /
pool            199G  125K  198G   1% /pool

Resources:

See how Brett Kelly from 45 Drives tried to break a Storage Cluster with GlusterFS and ZFS:

Great ZFS Performance Comparison:

Setup MongoDB Client on CentOS 6

I have a bastion host that is still running CentOS6 and epel repos provides mongodb-shell version 2.x and Mlab requires version 3.x

Setup the Repositories

Create the repository:

1
2
3
4
5
6
7
8
$ cat > /etc/yum.repos.d/mongodb.repo << EOF
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
EOF

Update the repository index:

1
$ sudo yum update -y

Install MongoDB-Shell

Install the MongoDB Shell Client:

1
$ sudo yum install mongodb-shell -y

Update: Thanks to Rick, when you use CentOS 7, you can install the Shell Client as instructed below:

1
$ sudo yum install mongodb-org-shell -y

Connect to your Remote MongoDB Instance:

1
$ mongo remotedb.mlab.com:27017/<dbname> -u <user> -p <pass>