openstack swift All In One安装

操作系统:Ubuntu 14.04.3 LTS

  1. 安装依赖
sudo apt-get update
sudo apt-get install curl gcc memcached rsync sqlite3 xfsprogs \
                     git-core libffi-dev python-setuptools \
                     liberasurecode-dev
sudo apt-get install python-coverage python-dev python-nose \
                     python-xattr python-eventlet \
                     python-greenlet python-pastedeploy \
                     python-netifaces python-pip python-dnspython \
                     python-mock
  1. 为存储创建分区
    使用loopback设备作为存储
sudo mkdir /srv
sudo truncate -s 1GB /srv/swift-disk
sudo mkfs.xfs /srv/swift-disk

编辑分区表/etc/fstab,添加如下一行

/srv/swift-disk /mnt/sdb1 xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0
  1. 创建挂在点和独立的连接
sudo mkdir /mnt/sdb1
sudo mount /mnt/sdb1
sudo mkdir /mnt/sdb1/1 /mnt/sdb1/2 /mnt/sdb1/3 /mnt/sdb1/4
sudo chown ${USER}:${USER} /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 ${USER}:${USER} /var/run/swift
# **Make sure to include the trailing slash after /srv/$x/**
for x in {1..4}; do sudo chown -R ${USER}:${USER} /srv/$x/; done
  1. 添加一下几行到/etc/rc.local中去
mkdir -p /var/cache/swift /var/cache/swift2 /var/cache/swift3 /var/cache/swift4
chown : /var/cache/swift*
mkdir -p /var/run/swift
chown : /var/run/swift
  1. 获取代码

    1. 下载python-swiftclient 代码
    cd $HOME; git clone https://github.com/openstack/python-swiftclient.git
    
    1. 编译并安装python-swiftclient
    cd $HOME/python-swiftclient; sudo python setup.py develop; cd -
    
    1. 下载swift的代码
    git clone https://github.com/openstack/swift.git
    
    1. 编译并安装swift
    cd $HOME/swift; sudo pip install -r requirements.txt; sudo python setup.py develop; cd -
    
    1. 安装swift测试相关的依赖
    cd $HOME/swift; sudo pip install -r test-requirements.txt
    
  2. 安装rsync

    1. 创建/etc/rsyncd.conf
    sudo cp $HOME/swift/doc/saio/rsyncd.conf /etc/
    sudo sed -i "s//${USER}/" /etc/rsyncd.conf
    
    1. 修改/etc/default/rsync中的下面一行
    RSYNC_ENABLE=true
    
    1. 在系统的SELinuxEnforcing模式下执行下面两个命令中的一个
    sudo setenforce Permissive
    

    仅仅允许rsyncfull权限

    sudo setsebool -P rsync_full_access 1
    
    1. 启动rsync
    sudo service rsync restart
    
    1. 验证rsync是不是接受了所有的连接
    rsync rsync://pub@localhost/
    

    执行上述命令,应该会看到

    account6012
    account6022
    account6032
    account6042
    container6011
    container6021
    container6031
    container6041
    object6010
    object6020
    object6030
    object6040
    
  3. 启动memcached

sudo service memcached start
sudo chkconfig memcached on

8.(可选)为独立的日志,启动rsyslog
a. 安装swift rsyslogd的配置
shell sudo cp $HOME/swift/doc/saio/rsyslog.d/10-swift.conf /etc/rsyslog.d/
b. 编辑/etc/rsyslog.conf中的下述配置

```shell
$PrivDropToGroup adm
```

c. 如果使用的是hourly logs,则执行下面的

```shell
sudo mkdir -p /var/log/swift/hourly
```
    否则执行

```shell
sudo mkdir -p /var/log/swift
```

d. 创建日志目录,启动syslog
shell sudo chown -R syslog.adm /var/log/swift sudo chmod -R g+w /var/log/swift sudo service rsyslog restart

  • 配置每一个节点

    a. (可选)删除已经存在的swift目录

    sudo rm -rf /etc/swift
    

    b. 往/etc/swift中加配置文件

    cd $HOME/swift/doc; sudo cp -r saio/swift /etc/swift; cd -
    sudo chown -R ${USER}:${USER} /etc/swift
    

    c. 在Swift config中更新引用

    find /etc/swift/ -name \*.conf | xargs sudo sed -i "s//${USER}/"
    
  1. 创建运行Swift的脚本
    a. 复制SAIO脚本,重新设置环境

    mkdir -p $HOME/bin
    cd $HOME/swift/doc; cp saio/bin/* $HOME/bin; cd -
    chmod +x $HOME/bin/*
    

    b. 编辑$HOME/bin/resetswift脚本

    echo "export SAIO_BLOCK_DEVICE=/srv/swift-disk" >> $HOME/.bashrc
    c. 安装测试用的简单配置文件
    
    ```shell
    cp $HOME/swift/test/sample.conf /etc/swift/test.conf
    

    d 添加运行测试用的环境变量

    echo "export SWIFT_TEST_CONFIG_FILE=/etc/swift/test.conf" >> $HOME/.bashrc
    

    e 确保把bin目录设置到环境变了中去

    echo "export PATH=${PATH}:$HOME/bin" >> $HOME/.bashrc
    

    f. source 一下刚刚设置环境变量,使其生效

    . $HOME/.bashrc
    

    g. 创建初始化rings

    remakerings
    

    h. xx
    i. 运行单元测试

    $HOME/swift/.unittests
    

    j. 启动Swift的主线程,分别包括(proxy, account, container, and object)这几个进程

    startmain
    

    k. 获取X-Storage-UrlX-Auth-Token

    curl -v -H 'X-Storage-User: test:tester' -H 'X-Storage-Pass: testing' http://127.0.0.1:8080/auth/v1.0
    

    l. 检查能否获得account

    curl -v -H 'X-Auth-Token: ' 
    

    m. 检查python-swiftclient提供的swift命令是否可以用

    swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat
    

    n. 验证unctional tests的运行

    $HOME/swift/.functests
    

    o. 验证probe tests的运行

    $HOME/swift/.probetests
    

你可能感兴趣的:(openstack swift All In One安装)