企业空间 采购商城 存储论坛
首页 > Openstack > 正文

OpenStack安装手册 - SWIFT对象存储服务配置

2016-03-09 13:17来源:中国存储网
导读:SWIFT对象存储服务配置,建立SWIFT服务启动用户,格式化硬盘及挂载等动作命令语句,详细的OpenStack安装。

目录   上一篇   下一篇

3.17 SWIFT对象存储服务配置

·         建立SWIFT服务配置文件存放目录

mkdir /etc/swift

·         建立SWIFT服务启动用户

useradd -s /sbin/nologin -m -d /var/log/swift swift

·         格式化硬盘及挂载

yum -y install xfsprogs

mkfs.xfs -f -i size=1024 /dev/sdc

mkfs.xfs -f -i size=1024 /dev/sdd

mkdir -p /swift/drivers/sd{c,d}

mount -t xfs -o noatime,nodiratime,nobarrier,logbufs=8 /dev/sdc /swift/drivers/sdc

mount -t xfs -o noatime,nodiratime,nobarrier,logbufs=8 /dev/sdd /swift/drivers/sdd

echo -e '/dev/sdc\t/swift/drivers/sdc\txfs\tnoatime,nodiratime,nobarrier,logbufs=8\t0 0' >>/etc/fstab

echo -e '/dev/sdd\t/swift/drivers/sdd\txfs\tnoatime,nodiratime,nobarrier,logbufs=8\t0 0' >>/etc/fstab

·         swift同步相关配置

mkdir -p /swift/node/sd{c,d}

ln -sv /swift/drivers/sdc /swift/node/sdc

ln -sv /swift/drivers/sdd /swift/node/sdd

/etc下建立rsyncd.conf文件,内容如下:

uid = swift

gid = swift

log file = /var/log/rsyncd.log

pid file = /var/run/rsyncd.pid

address = 192.168.1.2

 

[account5000]

max connections = 50

path = /swift/node/sdc

read only = false

lock file = /var/lock/account5000.lock

 

[account5001]

max connections = 50

path = /swift/node/sdd

read only = false

lock file = /var/lock/account5001.lock

 

[container4000]

max connections = 50

path = /swift/node/sdc

read only = false

lock file = /var/lock/container4000.lock

 

[container4000]

max connections = 50

path = /swift/node/sdd

read only = false

lock file = /var/lock/container4001.lock

 

[object3000]

max connections = 50

path = /swift/node/sdc

read only = false

lock file = /var/lock/object3000.lock

 

[object3001]

max connections = 50

path = /swift/node/sdd

read only = false

lock file = /var/lock/object3001.lock

yum -y install xinetd

sed -i '/disable/s#yes#no#g' /etc/xinetd.d/rsync

/etc/init.d/xinetd start

mkdir -p /etc/swift/{object,container,account}-server

/etc/swift下建立swift.conf文件,内容如下:

[swift-hash]

swift_hash_path_suffix = changeme

/etc/swift下建立proxy-server.conf文件,内容如下:

[DEFAULT]

bind_port = 8080

user = swift

swift_dir = /etc/swift

workers = 8

log_name = swift

log_facility = LOG_LOCAL1

log_level = DEBUG

 

[pipeline:main]

pipeline = healthcheck cache swift3 s3token authtoken keystone proxy-server

 

[app:proxy-server]

use = egg:swift#proxy

allow_account_management = true

account_autocreate = true

 

[filter:keystone]

paste.filter_factory = keystone.middleware.swift_auth:filter_factory

operator_roles = Member,admin,SwiftOperator

 

# NOTE(chmou): s3token middleware is not updated yet to use only

# username and password.

[filter:s3token]

paste.filter_factory = keystone.middleware.s3_token:filter_factory

service_port = 60.12.206.105

service_host = 5000

auth_host = 60.12.206.105

auth_port = 35357

auth_protocol = http

auth_token = ADMIN

admin_token = ADMIN

 

[filter:authtoken]

paste.filter_factory = keystone.middleware.auth_token:filter_factory

auth_host = 60.12.206.105

auth_port = 35357

auth_protocol = http

auth_uri = http://60.12.206.105:5000/

admin_tenant_name = tenant

admin_user = swift

admin_password = service

 

[filter:swift3]

use = egg:swift#swift3

 

[filter:healthcheck]

use = egg:swift#healthcheck

 

[filter:cache]

use = egg:swift#memcache

/etc/swift/account-server下建立sdc.confsdd.conf文件,内容如下:
–——————sdc.conf——————–
[DEFAULT]
devices = /swift/node/sdc
mount
check = false
bind
port = 5000
user = swift
log
facility = LOGLOCAL0
swift
dir = /etc/swift

[pipeline:main]
pipeline = account-server

[app:account-server]
use = egg:swift#account

[account-replicator]
vm
testmode = yes

[account-auditor]

[account-reaper]

–——————sdd.conf——————–
[DEFAULT]
devices = /swift/node/sdd
mount
check = false
bind
port = 5001
user = swift
log
facility = LOGLOCAL0
swift
dir = /etc/swift

[pipeline:main]
pipeline = account-server

[app:account-server]
use = egg:swift#account

[account-replicator]
vm
testmode = yes

[account-auditor]

[account-reaper]

/etc/swift/container-server下建立sdc.confsdd.conf文件,内容如下:

--------------------sdc.conf--------------------

[DEFAULT]

devices = /swift/node/sdc

mount_check = false

bind_port = 4000

user = swift

log_facility = LOG_LOCAL0

swift_dir = /etc/swift

 

[pipeline:main]

pipeline = container-server

 

[app:container-server]

use = egg:swift#container

 

[container-replicator]

vm_test_mode = yes

 

[container-updater]

 

[container-auditor]

 

[container-sync]

 

--------------------sdd.conf--------------------

[DEFAULT]

devices = /swift/node/sdd

mount_check = false

bind_port = 4001

user = swift

log_facility = LOG_LOCAL0

swift_dir = /etc/swift

 

[pipeline:main]

pipeline = container-server

 

[app:container-server]

use = egg:swift#container

 

[container-replicator]

vm_test_mode = yes

 

[container-updater]

 

[container-auditor]

 

[container-sync]

/etc/swift/object-server下建立sdc.confsdd.conf文件,内容如下:

--------------------sdc.conf--------------------

[DEFAULT]

devices = /swift/node/sdc

mount_check = false

bind_port = 3000

user = swift

log_facility = LOG_LOCAL0

swift_dir = /etc/swift

 

[pipeline:main]

pipeline = object-server

 

[app:object-server]

use = egg:swift#object

 

[object-replicator]

vm_test_mode = yes

 

[object-updater]

 

[object-auditor]

 

[object-expirer]

 

--------------------sdd.conf--------------------

[DEFAULT]

devices = /swift/node/sdd

mount_check = false

bind_port = 3001

user = swift

log_facility = LOG_LOCAL0

swift_dir = /etc/swift

 

[pipeline:main]

pipeline = object-server

 

[app:object-server]

use = egg:swift#object

 

[object-replicator]

vm_test_mode = yes

 

[object-updater]

 

[object-auditor]

 

[object-expirer]

·         建立ring

cd /etc/swift

swift-ring-builder account.builder create 8 2 1

swift-ring-builder account.builder add z1-60.12.206.105:5000/sdc 1

swift-ring-builder account.builder add z2-60.12.206.105:5001/sdd 1

swift-ring-builder account.builder rebalance

 

swift-ring-builder container.builder create 8 2 1

swift-ring-builder container.builder add z1-60.12.206.105:4000/sdc 1

swift-ring-builder container.builder add z2-60.12.206.105:4001/sdd 1

swift-ring-builder container.builder rebalance

 

swift-ring-builder object.builder create 8 2 1

swift-ring-builder object.builder add z1-60.12.206.105:3000/sdc 1

swift-ring-builder object.builder add z2-60.12.206.105:3001/sdd 1

swift-ring-builder object.builder rebalance

·         设置权限

chown -R swift:swift /swift

·         建立各服务启动脚本

/etc/swift下建立functions文件,内容如下:

. /etc/rc.d/init.d/functions

 

swift_action() {

  retval=0

  server="$1"

  call="swift_$2"

 

  if [[ -f "/etc/swift/$server-server.conf" ]]; then

    $call "$server" \

          "/etc/swift/$server-server.conf" \

          "/var/run/swift/$server-server.pid"

    [ $? -ne 0 ] && retval=1

  elif [[ -d "/etc/swift/$server-server/" ]]; then

    declare -i count=0

    for name in $( ls "/etc/swift/$server-server/" ); do

      $call "$server" \

            "/etc/swift/$server-server/$name" \

            "/var/run/swift/$server-server/$count.pid"

      [ $? -ne 0 ] && retval=1

      count=$count+1

    done

  fi

  return $retval

}

 

swift_start() {

  name="$1"

  long_name="$name-server"

  conf_file="$2"

  pid_file="$3"

 

  ulimit -n ${SWIFT_MAX_FILES-32768}

  echo -n "Starting swift-$long_name: "

  daemon --pidfile $pid_file \

    "/usr/bin/swift-$long_name $conf_file &>/var/log/swift-startup.log & echo \$! > $pid_file"

  retval=$?

  echo

  return $retval

}

 

swift_stop() {

  name="$1"

  long_name="$name-server"

  conf_name="$2"

  pid_file="$3"

 

  echo -n "Stopping swift-$long_name: "

  killproc -p $pid_file -d ${SWIFT_STOP_DELAY-15} $long_name

  retval=$?

  echo

  return $retval

}

 

swift_status() {

  name="$1"

  long_name="$name-server"

  conf_name="$2"

  pid_file="$3"

 

  status -p $pid_file $long_name

}

/etc/init.d下建立swift-proxy文件,内容如下:

#!/bin/sh

 

### BEGIN INIT INFO

# Provides:          openstack-swift-proxy

# Required-Start:    $remote_fs

# Required-Stop:     $remote_fs

# Default-Stop:      0 1 6

# Short-Description: Swift proxy server

# Description:       Account server for swift.

### END INIT INFO

 

# openstack-swift-proxy: swift proxy server

#

# chkconfig: - 20 80

# description: Proxy server for swift.

 

. /etc/rc.d/init.d/functions

. /etc/swift/functions

 

name="proxy"

 

[ -e "/etc/sysconfig/openstack-swift-$name" ] && . "/etc/sysconfig/openstack-swift-$name"

 

lockfile="/var/lock/swift/openstack-swift-proxy"

 

start() {

    swift_action "$name" start

    retval=$?

    [ $retval -eq 0 ] && touch $lockfile

    return $retval

}

 

stop() {

    swift_action "$name" stop

    retval=$?

    [ $retval -eq 0 ] && rm -f $lockfile

    return $retval

}

 

restart() {

    stop

    start

}

 

rh_status() {

    swift_action "$name" status

}

 

rh_status_q() {

    rh_status &> /dev/null

}

 

case "$1" in

    start)

        rh_status_q && exit 0

        $1

        ;;

    stop)

        rh_status_q || exit 0

        $1

        ;;

    restart)

        $1

        ;;

    reload)

        ;;

    status)

        rh_status

        ;;

    condrestart|try-restart)

        rh_status_q || exit 0

        restart

        ;;

    *)

        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}"

        exit 2

esac

exit $?

/etc/init.d下建立swift-account文件,内容如下:

#!/bin/sh

 

### BEGIN INIT INFO

# Provides:          openstack-swift-account

# Required-Start:    $remote_fs

# Required-Stop:     $remote_fs

# Default-Stop:      0 1 6

# Short-Description: Swift account server

# Description:       Account server for swift.

### END INIT INFO

 

# openstack-swift-account: swift account server

#

# chkconfig: - 20 80

# description: Account server for swift.

 

. /etc/rc.d/init.d/functions

. /etc/swift/functions

 

name="account"

 

[ -e "/etc/sysconfig/openstack-swift-$name" ] && . "/etc/sysconfig/openstack-swift-$name"

 

lockfile="/var/lock/swift/openstack-swift-account"

 

start() {

    swift_action "$name" start

    retval=$?

    [ $retval -eq 0 ] && touch $lockfile

    return $retval

}

 

stop() {

    swift_action "$name" stop

    retval=$?

    [ $retval -eq 0 ] && rm -f $lockfile

    return $retval

}

 

restart() {

    stop

    start

}

 

rh_status() {

    swift_action "$name" status

}

 

rh_status_q() {

    rh_status &> /dev/null

}

 

case "$1" in

    start)

        rh_status_q && exit 0

        $1

        ;;

    stop)

        rh_status_q || exit 0

        $1

        ;;

    restart)

        $1

        ;;

    reload)

        ;;

    status)

        rh_status

        ;;

    condrestart|try-restart)

        rh_status_q || exit 0

        restart

        ;;

    *)

        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}"

        exit 2

esac

exit $?

·         /etc/init.d下建立swift-container文件,内容如下:

#!/bin/sh

 

### BEGIN INIT INFO

# Provides:          openstack-swift-container

# Required-Start:    $remote_fs

# Required-Stop:     $remote_fs

# Default-Stop:      0 1 6

# Short-Description: Swift container server

# Description:       Container server for swift.

### END INIT INFO

 

# openstack-swift-container: swift container server

#

# chkconfig: - 20 80

# description: Container server for swift.

 

. /etc/rc.d/init.d/functions

. /etc/swift/functions

 

name="container"

 

[ -e "/etc/sysconfig/openstack-swift-$name" ] && . "/etc/sysconfig/openstack-swift-$name"

 

lockfile="/var/lock/swift/openstack-swift-container"

 

start() {

    swift_action "$name" start

    retval=$?

    [ $retval -eq 0 ] && touch $lockfile

    return $retval

}

 

stop() {

    swift_action "$name" stop

    retval=$?

    [ $retval -eq 0 ] && rm -f $lockfile

    return $retval

}

 

restart() {

    stop

    start

}

 

rh_status() {

    swift_action "$name" status

}

 

rh_status_q() {

    rh_status &> /dev/null

}

 

case "$1" in

    start)

        rh_status_q && exit 0

        $1

        ;;

    stop)

        rh_status_q || exit 0

        $1

        ;;

    restart)

        $1

        ;;

    reload)

        ;;

    status)

        rh_status

        ;;

    condrestart|try-restart)

        rh_status_q || exit 0

        restart

        ;;

    *)

        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}"

        exit 2

esac

exit $?

·         /etc/init.d下建立swift-object文件,内容如下:

#!/bin/sh

 

### BEGIN INIT INFO

# Provides:          openstack-swift-object

# Required-Start:    $remote_fs

# Required-Stop:     $remote_fs

# Default-Stop:      0 1 6

# Short-Description: Swift object server

# Description:       Object server for swift.

### END INIT INFO

 

# openstack-swift-object: swift object server

#

# chkconfig: - 20 80

# description: Object server for swift.

 

. /etc/rc.d/init.d/functions

. /etc/swift/functions

 

name="object"

 

[ -e "/etc/sysconfig/openstack-swift-$name" ] && . "/etc/sysconfig/openstack-swift-$name"

 

lockfile="/var/lock/swift/openstack-swift-object"

 

start() {

    swift_action "$name" start

    retval=$?

    [ $retval -eq 0 ] && touch $lockfile

    return $retval

}

 

stop() {

    swift_action "$name" stop

    retval=$?

    [ $retval -eq 0 ] && rm -f $lockfile

    return $retval

}

 

restart() {

    stop

    start

}

 

rh_status() {

    swift_action "$name" status

}

 

rh_status_q() {

    rh_status &> /dev/null

}

 

case "$1" in

    start)

        rh_status_q && exit 0

        $1

        ;;

    stop)

        rh_status_q || exit 0

        $1

        ;;

    restart)

        $1

        ;;

    reload)

        ;;

    status)

        rh_status

        ;;

    condrestart|try-restart)

        rh_status_q || exit 0

        restart

        ;;

    *)

        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}"

        exit 2

esac

exit $?

·         配置启动脚本:

chmod 755 /etc/init.d/swift-proxy

chmod 755 /etc/init.d/swift-account

chmod 755 /etc/init.d/swift-container

chmod 755 /etc/init.d/swift-object

mkdir /var/run/swift

mkdir /var/lock/swift

chown swift:root /var/run/swift

chown swift:root /var/lock/swift

·         启动服务

/etc/init.d/swift-proxy start

/etc/init.d/swift-account start

/etc/init.d/swift-container start

/etc/init.d/swift-object start

继续阅读
关键词 :
OpenStack安装手册
中国存储网声明:此文观点不代表本站立场,如有版权疑问请联系我们。
相关阅读
产品推荐
头条阅读
栏目热点

Copyright @ 2006-2019 chinastor.cn 版权所有 京ICP备14047533号

中国存储网

存储第一站,存储门户,存储在线交流平台