在安装好Ubuntu14.04 LTS之后,开始进行SAIO - Swift All In One,官方文档链接http://docs.openstack.org/developer/swift/development_saio.html
创建swift用户
sudo useradd swift -m -s /bin/bash
sudo passwd swift
编辑 /etc/sudoers 在root用户之后加入
swift ALL=(ALL:ALL) ALL
切换到swift用户操作
su - swift
运行脚本sudo ./ubuntu_saio.sh, ubuntu_saio.sh如下:
# /bin/bash
#install indepency
sudo apt-get update
sudo apt-get install -y curl gcc memcached rsync sqlite3 xfsprogs \
git-core libffi-dev python-setuptools
sudo apt-get install -y python-coverage python-dev python-nose \
python-simplejson python-xattr python-eventlet \
python-greenlet python-pastedeploy \
python-netifaces python-pip python-dnspython \
python-mock
#Create the file for the loopback device:
sudo mkdir /srv
sudo truncate -s 1GB /srv/swift-disk
sudo mkfs.xfs /srv/swift-disk
#Edit /etc/fstab and add
sudo echo "/srv/swift-disk /mnt/sdb1 xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab
#Create the mount point and the individualized links:
sudo mkdir /mnt/sdb1
sudo mount /mnt/sdb1
sudo mkdir /mnt/sdb1/1 /mnt/sdb1/2 /mnt/sdb1/3 /mnt/sdb1/4
sudo chown swift:swift /mnt/sdb1/*
for x in {1..4}; do sudo ln -s /mnt/sdb1/$x /srv/$x; done
sudo mkdir -p /srv/1/node/sdb1 /srv/1/node/sdb5 \
/srv/2/node/sdb2 /srv/2/node/sdb6 \
/srv/3/node/sdb3 /srv/3/node/sdb7 \
/srv/4/node/sdb4 /srv/4/node/sdb8 \
/var/run/swift
sudo chown -R swift:swift /var/run/swift
# **Make sure to include the trailing slash after /srv/$x/**
for x in {1..4}; do sudo chown -R swift:swift /srv/$x/; done
#Common Post-Device Setup
sudo echo "sudo mkdir -p /var/cache/swift /var/cache/swift2 /var/cache/swift3 /var/cache/swift4" >> /home/swift/.bashrc
sudo echo "sudo chown swift:swift /var/cache/swift*" >> /home/swift/.bashrc
sudo echo "sudo mkdir -p /var/run/swift" >> /home/swift/.bashrc
sudo echo "sudo chown swift:swift /var/run/swift" >> /home/swift/.bashrc
#Check out the python-swiftclient repo:
cd $HOME; git clone https://github.com/openstack/python-swiftclient.git
#Build a development installation of python-swiftclient:
cd $HOME/python-swiftclient; sudo python setup.py develop; cd -
#Check out the swift repo:
git clone https://github.com/openstack/swift.git
#Build a development installation of swift:
cd $HOME/swift; sudo pip install -r requirements.txt; sudo python setup.py develop; cd -
#Install swift’s test dependencies:
sudo pip install -r swift/test-requirements.txt
#Create /etc/rsyncd.conf:
sudo cp $HOME/swift/doc/saio/rsyncd.conf /etc/
sudo sed -i "s/<your-user-name>/swift/" /etc/rsyncd.conf
sudo sed -i "s/RSYNC_ENABLE=false/RSYNC_ENABLE=true/" /etc/default/rsync
#Start the rsync daemon
sudo service rsync restart
#Verify rsync is accepting connections for all servers:
rsync rsync://pub@localhost/
#Starting memcached
sudo service memcached start
#Setting up rsyslog for individual logging
sudo cp $HOME/swift/doc/saio/rsyslog.d/10-swift.conf /etc/rsyslog.d/
sudo echo "$PrivDropToGroup adm" >>/etc/rsyslog.conf
sudo mkdir -p /var/log/swift/hourly
sudo chown -R syslog.adm /var/log/swift
sudo chmod -R g+w /var/log/swift
sudo service rsyslog restart
#
sudo rm -rf /etc/swift
cd $HOME/swift/doc; sudo cp -r saio/swift /etc/swift; cd -
sudo chown -R swift:swift /etc/swift
find /etc/swift/ -name \*.conf | xargs sudo sed -i "s/<your-user-name>/swift/"
#Setting up scripts for running Swift
#Copy the SAIO scripts for resetting the environment:
mkdir -p $HOME/bin
cd $HOME/swift/doc; cp saio/bin/* $HOME/bin; cd -
chmod +x $HOME/bin/*
echo "export SAIO_BLOCK_DEVICE=/srv/swift-disk" >> $HOME/.bashrc
#Install the sample configuration file for running tests:
cp $HOME/swift/test/sample.conf /etc/swift/test.conf
#Add an environment variable for running tests below:
echo "export SWIFT_TEST_CONFIG_FILE=/etc/swift/test.conf" >> $HOME/.bashrc
echo "export PATH=${PATH}:$HOME/bin" >> $HOME/.bashrc
. $HOME/.bashrc
./bin/remakerings
$HOME/swift/.unittests
./bin/startmain
echo "Hi, SAIO is Finished......."
最后脚本运行startmain, 会报一些异常
Starting proxy-server...(/etc/swift/proxy-server.conf)
Starting container-server...(/etc/swift/container-server/1.conf)
Starting container-server...(/etc/swift/container-server/2.conf)
Starting container-server...(/etc/swift/container-server/3.conf)
Starting container-server...(/etc/swift/container-server/4.conf)
Starting account-server...(/etc/swift/account-server/1.conf)
Starting account-server...(/etc/swift/account-server/2.conf)
Starting account-server...(/etc/swift/account-server/3.conf)
Starting account-server...(/etc/swift/account-server/4.conf)
Starting object-server...(/etc/swift/object-server/1.conf)
Starting object-server...(/etc/swift/object-server/2.conf)
Starting object-server...(/etc/swift/object-server/3.conf)
Starting object-server...(/etc/swift/object-server/4.conf)
Traceback (most recent call last):
File "/usr/local/bin/swift-container-server", line 10, in <module>
execfile(__file__)
File "/home/swift/swift/bin/swift-container-server", line 23, in <module>
sys.exit(run_wsgi(conf_file, 'container-server', **options))
File "/home/swift/swift/swift/common/wsgi.py", line 459, in run_wsgi
sock = get_socket(conf)
File "/home/swift/swift/swift/common/wsgi.py", line 199, in get_socket
bind_addr[0], bind_addr[1], bind_timeout))
Exception: Could not bind to 127.0.0.1:6011 after trying for 30 seconds
Traceback (most recent call last):
File "/usr/local/bin/swift-object-server", line 10, in <module>
execfile(__file__)
File "/home/swift/swift/bin/swift-object-server", line 27, in <module>
**options))
File "/home/swift/swift/swift/common/wsgi.py", line 459, in run_wsgi
sock = get_socket(conf)
File "/home/swift/swift/swift/common/wsgi.py", line 199, in get_socket
bind_addr[0], bind_addr[1], bind_timeout))
Exception: Could not bind to 127.0.0.1:6010 after trying for 30 seconds
查看进程正常
swift@ubuntu:~$ ps aux|grep swift
root 5434 0.0 0.3 109792 3428 ? Ss 21:47 0:00 sshd: swift [priv]
swift 5472 0.0 0.2 109792 2448 ? S 21:47 0:04 sshd: swift@pts/0
swift 5473 0.0 0.4 26888 4752 pts/0 Ss 21:47 0:00 -bash
root 5541 0.0 0.3 109792 3420 ? Ss 21:47 0:00 sshd: swift [priv]
swift 5577 0.0 0.2 109792 2956 ? S 21:47 0:00 sshd: swift@notty
swift 5578 0.0 0.1 12832 1856 ? Ss 21:47 0:00 /usr/lib/openssh/sftp-server
swift 5580 0.0 0.1 12832 1868 ? Ss 21:48 0:00 /usr/lib/openssh/sftp-server
swift 24851 0.0 2.3 96596 23728 ? Ss 22:27 0:00 /usr/bin/python /usr/local/bin/swift-proxy-server /etc/swift/proxy-server.conf
swift 24853 0.0 2.3 111556 23640 ? Ss 22:27 0:00 /usr/bin/python /usr/local/bin/swift-container-server /etc/swift/container-server/2.conf
swift 24854 0.0 2.3 111556 23612 ? Ss 22:27 0:00 /usr/bin/python /usr/local/bin/swift-container-server /etc/swift/container-server/3.conf
swift 24855 0.0 2.3 111556 23712 ? Ss 22:27 0:00 /usr/bin/python /usr/local/bin/swift-container-server /etc/swift/container-server/4.conf
swift 24856 0.0 2.2 102284 22544 ? Ss 22:27 0:00 /usr/bin/python /usr/local/bin/swift-account-server /etc/swift/account-server/1.conf
swift 24857 0.0 2.2 102288 22484 ? Ss 22:27 0:00 /usr/bin/python /usr/local/bin/swift-account-server /etc/swift/account-server/2.conf
swift 24858 0.0 2.2 102284 22544 ? Ss 22:27 0:00 /usr/bin/python /usr/local/bin/swift-account-server /etc/swift/account-server/3.conf
swift 24859 0.0 2.2 102288 22456 ? Ss 22:27 0:00 /usr/bin/python /usr/local/bin/swift-account-server /etc/swift/account-server/4.conf
swift 24862 0.0 2.2 101312 22240 ? Ss 22:27 0:00 /usr/bin/python /usr/local/bin/swift-object-server /etc/swift/object-server/2.conf
swift 24863 0.0 2.2 101312 22156 ? Ss 22:27 0:00 /usr/bin/python /usr/local/bin/swift-object-server /etc/swift/object-server/3.conf
swift 24865 0.0 2.2 101312 22188 ? Ss 22:27 0:00 /usr/bin/python /usr/local/bin/swift-object-server /etc/swift/object-server/4.conf
swift 24932 0.0 1.8 102288 19016 ? S 22:27 0:00 /usr/bin/python /usr/local/bin/swift-account-server /etc/swift/account-server/4.conf
swift 24933 0.0 1.8 102284 18912 ? S 22:27 0:00 /usr/bin/python /usr/local/bin/swift-account-server /etc/swift/account-server/3.conf
swift 24934 0.0 1.9 111556 19712 ? S 22:27 0:00 /usr/bin/python /usr/local/bin/swift-container-server /etc/swift/container-server/3.conf
swift 24935 0.0 1.9 111556 19716 ? S 22:27 0:00 /usr/bin/python /usr/local/bin/swift-container-server /etc/swift/container-server/4.conf
swift 24936 0.0 1.8 102288 18844 ? S 22:27 0:00 /usr/bin/python /usr/local/bin/swift-account-server /etc/swift/account-server/2.conf
swift 24937 0.0 1.9 111556 19772 ? S 22:27 0:00 /usr/bin/python /usr/local/bin/swift-container-server /etc/swift/container-server/2.conf
swift 24938 0.0 1.8 102284 18912 ? S 22:27 0:00 /usr/bin/python /usr/local/bin/swift-account-server /etc/swift/account-server/1.conf
swift 24939 0.0 1.8 101568 18752 ? S 22:27 0:00 /usr/bin/python /usr/local/bin/swift-object-server /etc/swift/object-server/3.conf
swift 24940 0.0 1.8 101568 18884 ? S 22:27 0:00 /usr/bin/python /usr/local/bin/swift-object-server /etc/swift/object-server/2.conf
swift 24941 0.0 1.8 101568 18796 ? S 22:27 0:00 /usr/bin/python /usr/local/bin/swift-object-server /etc/swift/object-server/4.conf
swift 24942 0.0 2.0 97024 20808 ? S 22:28 0:00 /usr/bin/python /usr/local/bin/swift-proxy-server /etc/swift/proxy-server.conf
swift 25120 0.0 0.2 22652 2460 pts/0 R+ 23:05 0:00 ps aux
swift 25121 0.0 0.2 15952 2108 pts/0 S+ 23:05 0:00 grep --color=auto swift
基本测试
swift@ubuntu:~$ curl -v -H 'X-Storage-User: test:tester' -H 'X-Storage-Pass: testing' http://127.0.0.1:8080/auth/v1.0
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /auth/v1.0 HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 127.0.0.1:8080
> Accept: */*
> X-Storage-User: test:tester
> X-Storage-Pass: testing
>
< HTTP/1.1 200 OK
< X-Storage-Url: http://127.0.0.1:8080/v1/AUTH_test
< X-Auth-Token: AUTH_tkb47d5ded6d164c18a8bb911e03e0fa82
< Content-Type: text/html; charset=UTF-8
< X-Storage-Token: AUTH_tkb47d5ded6d164c18a8bb911e03e0fa82
< Content-Length: 0
< X-Trans-Id: tx39cbf5c9e415484390f23-005566b6d7
< Date: Thu, 28 May 2015 06:33:59 GMT
<
* Connection #0 to host 127.0.0.1 left intact
swift@ubuntu:~$ curl -v -H 'X-Storage-User: test:tester' -H 'X-Storage-Pass: testing' http://127.0.0.1:8080/auth/v1.0
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /auth/v1.0 HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 127.0.0.1:8080
> Accept: */*
> X-Storage-User: test:tester
> X-Storage-Pass: testing
>
< HTTP/1.1 200 OK
< X-Storage-Url: http://127.0.0.1:8080/v1/AUTH_test
< X-Auth-Token: AUTH_tkb47d5ded6d164c18a8bb911e03e0fa82
< Content-Type: text/html; charset=UTF-8
< X-Storage-Token: AUTH_tkb47d5ded6d164c18a8bb911e03e0fa82
< Content-Length: 0
< X-Trans-Id: txdaa92b36da8d42b08c1f9-005566b6dd
< Date: Thu, 28 May 2015 06:34:05 GMT
<
* Connection #0 to host 127.0.0.1 left intact