On the already built GlusterFS server (if you don't know how to build GlusteFS, please refer to the previous article):
Create bricks:
# truncate -s 1GB /srv/disk{1..4}# for i in `seq 1 4`; do mkfs.xfs -i size = 512 / srv / disk $ i; done # mkdir -p / export / brick {1..4}
Add the following lines to / etc / fstab to auto-mount the the bricks on system startup:
/ srv / disk1 / export / brick1 xfs loop, inode64, noatime, nodiratime 0 0
/ srv / disk2 / export / brick2 xfs loop, inode64, noatime, nodiratime 0 0
/ srv / disk3 / export / brick3 xfs loop, inode64, noatime, nodiratime 0 0
/ srv / disk4 / export / brick4 xfs loop, inode64, noatime, nodiratime 0 0
Mount the bricks:
# mount -a
You can now create and start the GlusterFS volume. Make sure your hostname is in / etc / hosts or is DNS-resolvable.
# gluster volume create swift-test-vol-01 replica 2 transport tcp cnsz22VLK5966.ossit.sfdc.com.cn:/export/brick{1..4}/data force Mount the GlusterFS volume: # mkdir -p / mnt / gluster-object / test-vol-01 # mount -t glusterfs cnsz22VLK5966.ossit.sfdc.com.cn: swift-test-vol-01 / mnt / gluster-object / test-vol-01 Installing Openstack Swift # yum install centos -release-openstack-newton (http://mirrors.aliyun.com/centos/7/extras/x86_64/Packages/) # yum install openstack-swift- * (http://mirrors.aliyun.com/centos/7 / cloud / x86_64 / openstack-newton /) Installing gluster-swift (Note that the installation version must be consistent with the openstack swift version) # yum install epel-release (http://mirrors.aliyun.com/centos/7/extras/x86_64/ Packages /) # yum install python-scandir (https://pypi.python.org/packages/77/3f/916f524f50ee65e3f465a280d2851bd63685250fddb3020c212b3977664d/scandir-1.6.tar.gz#md5=0180ddb97c96cbb2d4f25d2y11install-acpython-install Packaged If you encounter a gcc-related compilation error during installation, please execute yum install python-devel to install the python development package) #yum install git # git clone https://github.com/gluster/gluster-swift; cd gluster-swift # python setup. py install gluster-swift configuration files # mkdir -p / etc / swift / # cp etc / * / etc / swift / # cd / etc / swift # for tmpl in * .conf-gluster; do cp $ {tmpl} $ { tmpl%. *}. conf; done Export GlusterFS volumes over gluster-swift # gluster-swift-gen-builders [VOLUME] [VOLUME ...] (command format) # gluster-swift-gen-builders swift-test-vol -01 (command example) Start gluster-swift # swift-init main start Using gluster-swift Create a container # curl -i -X PUT http: // localhost: 8080 / v1 / AUTH_swift-test-vol-01 / test- container-01 # ls / mnt / gluster-object / swift-test-vol-01 / Create an object # echo "Hello Swift"> test.txt #curl -i -X PUT -T test.txt http: // localhost : 8080 / v1 / AUTH_swift-test-vol-01 / test-container-01 / test.txt # cat / mnt / gluster-object / swift-test-vol-01 / test-container-0 1 / test.txt Request the object # curl -i -X GET -o newTest.txt http: // localhost: 8080 / v1 / AUTH_swift-test-vol-01 / test-container-01 / test.txt #cat newTest .txt Delete the object #curl -i -X DELETE http: // localhost: 8080 / v1 / AUTH_swift-test-vol-01 / test-container-01 / test.txt If it is not a GlusterFS server, you need to install the following packages first: Installing and starting GlusterFS # yum install centos-release-gluster # yum install glusterfs glusterfs-server glusterfs-cli glusterfs-libs glusterfs-client glusterfs-fuse glusterfs-api
Build object storage with GlusterFS + Swift