首页 > 代码库 > OpenStack swift安装

OpenStack swift安装

由于实验项目需要云存储系统,因此在实验室服务器上搭建一个基于OpenStack swift的云存储系统

最开始按照官方网站上介绍的方法,使用SAIO方式安装http://docs.openstack.org/developer/swift/development_saio.html,但是中间经常安装到最后,测试的时候,认证不成功,而且安装的过程比较繁琐,于是采用了git的安装方式git clone https://github.com/NewpTone/SAIO.git,将SAIO下载来之后,运行里面的脚本就自动安装,但是中间也出现了最后认证的问题,swift使用的是tempauth认证,于是按照http://blog.sina.com.cn/s/blog_4b8481f70100x9kk.html,将认证换成了swauth,最后才终于测试成功

然后把SAIO里面的脚本研究了下,其实它就是把安装过程都写在了一个脚本里面,实现自动化,我就把swauth安装的过程加进去,再对swauth的部分进行配置,就完成了可以测试成功的安装脚本。

以下是安装脚本的内容:

#!/bin/bash

sudo apt-get install python-software-properties

sudo apt-get update

sudo apt-get install curl gcc git-core memcached python-coverage python-dev python-nose python-setuptools python-simplejson python-xattr sqlite3 xfsprogs python-eventlet python-greenlet python-pastedeploy python-netifaces python-pip

sudo pip install mock

if ! [ -e /srv ]
then
    sudo mkdir /srv
fi

sudo mkfs.xfs -i size=1024 /srv/swift-disk

#the following has something wrong
sudo echo "/srv/swift-disk /mnt/sdb1 xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab

sudo mkdir -p /mnt/sdb1

sudo mount /mnt/sdb1

sudo mkdir -p /mnt/sdb1/1 /mnt/sdb1/2 /mnt/sdb1/3 /mnt/sdb1/4

sudo chown swift:swift /mnt/sdb1/*

for x in 1 2 3 4
do
  ln -f -s /mnt/sdb1/$x /srv/$X
done

mkdir -p /etc/swift/object-server /etc/swift/container-server /etc/swift/account-server /srv/1/node/sdb1 /srv/2/node/sdb2 /srv/3/node/sdb3 /srv/4/node/sdb4 /var/run/swift

chown -R swift:swift /etc/swift /srv/1/ /srv/2/ /srv/3/ /srv/4/ /var/run/swift

#Add to /etc/rc.local (before the exit 0):

#mkdir -p /var/cache/swift /var/cache/swift2 /var/cache/swift3 /var/cache/swift4
#chown <your-user-name>:<your-group-name> /var/cache/swift*
#mkdir -p /var/run/swift
#chown <your-user-name>:<your-group-name> /var/run/swift

#settting up rsync
sudo cp rsyncd.conf /etc/

echo "RSYNC_ENABLE=true" >> /etc/default/rsync
service rsync restart

sudo mkdir -p ~/bin

sudo git clone https://github.com/openstack/swift.git
cd swift
sudo python setup.py develop
cd ..

sudo git clone https://github.com/openstack/python-swiftclient.git
cd python-swiftclient
sudo python setup.py develop
cd ..

sudo git clone https://github.com/gholt/swauth.git
cd swauth
sudo python setup.py develop
cd ..

if [ -e /home/swift/.bashrc ]
then
   sudo echo -e "export SWIFT_TEST_CONFIG_FILE=/etc/swift/test.conf  \\n export PATH=${PATH}:~/bin" >> /home/swift/.bashrc
   sudo source ~/.bashrc
fi

#configure swift and related conf
if ! [ -e /etc/swift ]
then
    sudo mkdir /etc/swift
fi
sudo chown swift:swift /etc/swift
sudo cp --recursive conf/* /etc/swift/
#cp rsyncd.conf /etc
#sudo service rsync restart

#sudo cp --recursive bin/* ~/bin
sudo chmod +x bin/*

cd bin
sudo ./remakerings
cd ..

sudo cp ~/saio-setup/swift/test/sample.conf /etc/swift/test.conf

cd swift
sudo ./.unittests
cd ..

cd bin

sudo ./startmain
cd ..

swift-init proxy reload
swauth-prep -K swauth -A http://127.0.0.1/auth/
echo "swauth-prep finished"

echo "SAIO setup finished!"

其它的诸如rsyncd.conf,container-server等,按照官方SAIO安装方式进行配置即可。

然后就可以进行测试了


 

在安装过程中会出现下面这种问题:

 


 

请忽略它,它并不会影响后面的操作。