Setting riak to store data in an EBS volume in Amazon EC2
These days I've performed some tests in a riak cluster configuration, involving about a million write operations from many virtual machines hosted in EC2. Due to the database replication and the number and size of the records to be written, the default storage space coming with an Ubuntu Server 12.04LT instance was insufficient, so the solution was to add extra storage space through Elastic Storage Blocks (EBS).
The procedure is quite simple and will be described below in order to save the time for those who need to do this storage extension.
First of all a new volume must be created from AWS console and attach it to the desired instance.
See how the volume is attached in Ubuntu by isuing the command:
df
sudo mount /dev/xvdb
Find out how was the EBS volume mounted:
df
Find the riak_core setting and modify
{platform_data_dir, "/var/lib/riak"} to:
/mnt/var/lib/riak/bitcask/mnt/var/lib/riak/kv_node
and make them writable.
Then, start the riak service by issuing the command:
sudo service riak start
After these steps, riak will use the new EBS volume to store data instead the default storage space offered by the Ubuntu Server instance.
These days I've performed some tests in a riak cluster configuration, involving about a million write operations from many virtual machines hosted in EC2. Due to the database replication and the number and size of the records to be written, the default storage space coming with an Ubuntu Server 12.04LT instance was insufficient, so the solution was to add extra storage space through Elastic Storage Blocks (EBS).
The procedure is quite simple and will be described below in order to save the time for those who need to do this storage extension.
First of all a new volume must be created from AWS console and attach it to the desired instance.
See how the volume is attached in Ubuntu by isuing the command:
df
The result of the command is:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda1 8256952 793960 7043564 11% /
udev 838328 8 838320 1% /dev
tmpfs 338520 172 338348 1% /run
none 5120 0 5120 0% /run/lock
none 846300 0 846300 0% /run/shm
/dev/xvdb 153899044 192068 145889352 1% /mnt
The new volume is /dev/xvdb and prior to use it it must be formatted appropriately. For doing this:
Unmount the /dev/xvdb volume:
sudo umount /dev/xvdb
Format the partition using ext4
/dev/xvda1 8256952 793960 7043564 11% /
udev 838328 8 838320 1% /dev
tmpfs 338520 172 338348 1% /run
none 5120 0 5120 0% /run/lock
none 846300 0 846300 0% /run/shm
/dev/xvdb 153899044 192068 145889352 1% /mnt
The new volume is /dev/xvdb and prior to use it it must be formatted appropriately. For doing this:
Unmount the /dev/xvdb volume:
sudo umount /dev/xvdb
Format the partition using ext4
sudo mkfs.ext4 -j /dev/xvdb
Mount back the volume:
Mount back the volume:
sudo mount /dev/xvdb
Find out how was the EBS volume mounted:
df
The result of the command is:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda1 8256952 860640 6976884 11% /
udev 838328 8 838320 1% /dev
tmpfs 338520 172 338348 1% /run
none 5120 0 5120 0% /run/lock
none 846300 0 846300 0% /run/shm
/dev/xvdb 153899044 191936 145889484 1% /mnt
Modify riak configuration file /etc/riak/app.config:
/dev/xvda1 8256952 860640 6976884 11% /
udev 838328 8 838320 1% /dev
tmpfs 338520 172 338348 1% /run
none 5120 0 5120 0% /run/lock
none 846300 0 846300 0% /run/shm
/dev/xvdb 153899044 191936 145889484 1% /mnt
Modify riak configuration file /etc/riak/app.config:
Find the riak_core setting and modify
{platform_data_dir, "/var/lib/riak"} to:
{platform_data_dir, "/mnt/var/lib/riak"}
and bitcask setting
{data_root, "/var/lib/riak/bitcask"} to:
and bitcask setting
{data_root, "/var/lib/riak/bitcask"} to:
{data_root, "/mnt/var/lib/riak/bitcask"}
On the new formatted volume mounted under /mnt prepare the directories that will hold the date on the new volume:
On the new formatted volume mounted under /mnt prepare the directories that will hold the date on the new volume:
/mnt/var/lib/riak/bitcask/mnt/var/lib/riak/kv_node
and make them writable.
Then, start the riak service by issuing the command:
sudo service riak start
After these steps, riak will use the new EBS volume to store data instead the default storage space offered by the Ubuntu Server instance.