Object storage, as the name suggests, manages data in the form of objects. Each object stores data, metadata, and a unique identifier. Object storage cannot be directly accessed by operating systems as a local or remote filesystem. It can only be accessed via API at application level. Ceph provides an object storage interface known as the RADOS gateway, which has been built on top of the Ceph RADOS layer. The RADOS gateway provides applications with RESTful S3- or Swift-compatible API interfaces to store data in the form of objects into a Ceph cluster.
In a production environment, if you have a huge workload for Ceph object storage, you should configure the RADOS gateway on a physical dedicated machine, else you can consider using any of the monitor nodes as the RADOS gateway. We will now perform a basic RADOS gateway configuration to use Ceph storage cluster as object storage.
In a usual Ceph-based setup, the RADOS gateway is configured on a machine other than MON and OSD. However, if you have limited hardware, you can use MON machines to configure RGW. In this demonstration, we will create a separate virtual machine for Ceph RGW:
# VboxManage createvm --name ceph-rgw --ostype RedHat_64 --register # VBoxManage modifyvm ceph-rgw --memory 1024 --nic1 nat --nic2 hostonly --hostonlyadapter2 vboxnet1 # VBoxManage storagectl ceph-rgw --name "IDE Controller" --add ide --controller PIIX4 --hostiocache on --bootable on # VBoxManage storageattach ceph-rgw --storagectl "IDE Controller" --type dvddrive --port 0 --device 0 --medium /downloads/CentOS-6.4-x86_64-bin-DVD1.iso # VBoxManage storagectl ceph-rgw --name "SATA Controller" --add sata --controller IntelAHCI --hostiocache on --bootable on # VBoxManage createhd --filename OS-ceph-rgw.vdi --size 10240 # VBoxManage storageattach ceph-rgw --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium OS-ceph-rgw.vdi # VBoxManage startvm ceph-rgw --type gui
ceph-client1
./etc/sysconfig/network-scripts/ifcfg-eth0
file and add:ONBOOT=yes BOOTPROTO=dhcp
/etc/sysconfig/network-scripts/ifcfg-eth1
file and add:ONBOOT=yes BOOTPROTO=static IPADDR=192.168.57.110 NETMASK=255.255.255.0
/etc/hosts
file and add:192.168.57.101 ceph-node1 192.168.57.102 ceph-node2 192.168.57.103 ceph-node3 192.168.57.200 ceph-client1 192.168.57.110 ceph-rgw
The last section was about setting up a virtual machine for RGW. In this section, we will learn to install and configure RGW:
Execute the following commands on the RADOS gateway node ceph-rgw
, unless otherwise specified. Create a ceph-apache repository file, ceph-apache.repo
, for YUM under the /etc/yum.repos.d
directory:
# vim /etc/yum.repos.d/ceph-apache.repo ## replace {distro} with OS distribution type , ex centos6 , rhel6 etc. You can grab this code at publishers website. [apache2-ceph-noarch] name=Apache noarch packages for Ceph baseurl=http://gitbuilder.ceph.com/apache2-rpm-{distro}-x86_64-basic/ref/master enabled=1 priority=2 gpgcheck=1 type=rpm-md gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc [apache2-ceph-source] name=Apache source packages for Ceph baseurl=http://gitbuilder.ceph.com/apache2-rpm-{distro}-x86_64-basic/ref/master enabled=0 priority=2 gpgcheck=1 type=rpm-md gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc
ceph-fastcgi.repo
file under the /etc/yum.repos.d
directory:# vim /etc/yum.repos.d/ceph-fastcgi.repo ## replace {distro}with OS distribution type , ex centos6 , rhel6 etc. You can grab this code at publishers website. [fastcgi-ceph-basearch] name=FastCGI basearch packages for Ceph baseurl=http://gitbuilder.ceph.com/mod_fastcgi-rpm-{distro}-x86_64-basic/ref/master enabled=1 priority=2 gpgcheck=1 type=rpm-md gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc [fastcgi-ceph-noarch] name=FastCGI noarch packages for Ceph baseurl=http://gitbuilder.ceph.com/mod_fastcgi-rpm-{distro}-x86_64-basic/ref/master enabled=1 priority=2 gpgcheck=1 type=rpm-md gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc [fastcgi-ceph-source] name=FastCGI source packages for Ceph baseurl=http://gitbuilder.ceph.com/mod_fastcgi-rpm-{distro}-x86_64-basic/ref/master enabled=0 priority=2 gpgcheck=1 type=rpm-md gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc
ceph.repo
file under the /etc/yum.repos.d
directory:# vim /etc/yum.repos.d/ceph.repo ## You can grab this code at publishers website. [Ceph] name=Ceph packages for $basearch baseurl=http://ceph.com/rpm-firefly/el6/$basearch enabled=1 gpgcheck=1 type=rpm-md gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc [Ceph-noarch] name=Ceph noarch packages baseurl=http://ceph.com/rpm-firefly/el6/noarch enabled=1 gpgcheck=1 type=rpm-md gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc [ceph-source] name=Ceph source packages baseurl=http://ceph.com/rpm-firefly/el6/SRPMS enabled=1 gpgcheck=1 type=rpm-md gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc
# yum install yum-plugin-priorities
# yum install httpd mod_fastcgi ceph-radosgw ceph
The configuration of the RADOS gateway includes Apache and FastCGI configuration and Ceph key generation. Perform the following steps:
/etc/httpd/conf/httpd.conf
:ServerName <FQDN>
LoadModule rewrite_module modules/mod_rewrite.so
/etc/httpd/conf.d/fastcgi.conf
:LoadModule fastcgi_module modules/mod_fastcgi.so
FastCgiWrapper
s3gw.fcgi
file provided with this book:# vim /var/www/html/s3gw.fcgi #!/bin/sh exec /usr/bin/radosgw -c /etc/ceph/ceph.conf -n client.radosgw.gateway # chmod +x /var/www/html/s3gw.fcgi # chown apache:apache /var/www/html/s3gw.fcgi
rgw.conf under /etc/httpd/conf.d
with the following contents. Replace {fqdn}
with servers fqdn (hostname -f
) and {email.address}
with the e-mail address of the server administrator. You can match the changes from the author's version of the rgw.conf
file provided with this book:FastCgiExternalServer /var/www/html/s3gw.fcgi -socket /var/run/ceph/ceph.radosgw.gateway.fastcgi.sock <VirtualHost *:80> ServerName {fqdn} <!--Remove the comment. Add a server alias with *.{fqdn} for S3 subdomains--> <!--ServerAlias *.{fqdn}--> ServerAdmin {email.address} DocumentRoot /var/www/html RewriteEngine On RewriteRule ^/(.*) /s3gw.fcgi?%{QUERY_STRING} [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] <IfModule mod_fastcgi.c> <Directory /var/www/html> Options +ExecCGI AllowOverride All SetHandler fastcgi-script Order allow,deny Allow from all AuthBasicAuthoritative Off </Directory> </IfModule> AllowEncodedSlashes On ErrorLog /var/log/httpd/error.log CustomLog /var/log/httpd/access.log combined ServerSignature Off </VirtualHost> # vim /etc/httpd/conf.d/rgw.conf
# ceph-authtool --create-keyring /etc/ceph/ceph.client.radosgw.keyring # chmod +r /etc/ceph/ceph.client.radosgw.keyring
gateway
:# ceph-authtool /etc/ceph/ceph.client.radosgw.keyring -n client.radosgw.gateway --gen-key
# ceph-authtool -n client.radosgw.gateway --cap osd 'allow rwx' --cap mon 'allow rw' /etc/ceph/ceph.client.radosgw.keyring
# ceph -k /etc/ceph/ceph.client.admin.keyring auth add client.radosgw.gateway -i /etc/ceph/ceph.client.radosgw.keyring
# scp /etc/ceph/ceph.client.radosgw.keyring ceph-rgw:/etc/ceph/ceph.client.radosgw.keyring
# ceph osd pool create .rgw 128 128
# mkdir -p /var/lib/ceph/radosgw/ceph-radosgw.gateway
ceph.conf
file, and move this ceph.conf
file to the RADOS gateway node. Make sure that the hostname is the RADOS gateway hostname, and not FQDN:[client.radosgw.gateway] host = ceph-rgw keyring = /etc/ceph/ceph.client.radosgw.keyring rgw socket path = /var/run/ceph/ceph.radosgw.gateway.fastcgi.sock log file = /var/log/ceph/client.radosgw.gateway.log rgw dns name = ceph-rgw.objectstore.com ## This would be used for S3 API rgw print continue = false # scp /etc/ceph/ceph.conf ceph-rgw:/etc/ceph/ceph.conf
/var/log/httpd
, /var/run/ceph
, and /var/log/ceph
. Set SELinux
to Permissive
:# chown apache:apache /var/log/httpd # chown apache:apache /var/run/ceph # chown apache:apache /var/log/ceph # setenforce 0
# service httpd start
# service ceph-radosgw start
# curl http://ceph-rgw.objectstore.com
<?xml version="1.0" encoding="UTF-8"?> <ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Owner> <ID>anonymous</ID> <DisplayName></DisplayName> </Owner><Buckets></Buckets> </ListAllMyBucketsResult>
To use the Ceph object storage, we need to create users for the RADOS gateway. These user accounts will be identified by access and secret keys, which can be used by clients to perform operations on the Ceph object storage.
Now, let's create a RADOS gateway user and access object storage:
# scp ceph.client.admin.keyring ceph-rgw:/etc/ceph
# ceph -s
access_key
and secret_key
for the user, which will be required to access the Ceph object storage:# radosgw-admin user create --uid=mona --display-name="Monika Singh" [email protected]
The Ceph object storage supports S3- and Swift-compatible APIs; to make use of object storage capabilities of Ceph, we need to configure S3 or Swift interfaces. We will now perform a basic configuration for these interfaces one by one. For advanced configurations, check their respective documentations.
3.144.15.154