標籤:-o 安裝 wing over seq 發包 containe ret test
在已經搭建好的GlusterFS伺服器上(如不知道如何搭建GlusteFS請參考上一篇):
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 (注意安裝版本要與openstack swift版本一致)# 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=0180ddb97c96cbb2d4f25d2ae11c64ac)#yum install python-prettytable (安裝python相關包過程中如果遇到gcc相關編譯報錯,請執行yum install python-devel 安裝python開發包)#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...](命令格式)# gluster-swift-gen-builders swift-test-vol-01 (命令執行個體)
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-01/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 如果不是GlusterFS伺服器,需要先安裝以下包:
Installing and starting GlusterFS
# yum install centos-release-gluster# yum install glusterfs glusterfs-server glusterfs-cli glusterfs-libs glusterfs-client glusterfs-fuse glusterfs-api
用GlusterFS+Swift搭建Object Storage Service