部署 Openstack Havana – 3 Swift All In One
加入 HDD 2
把之前我们新建的虚拟盘 HDD2 挂载到 VM 上。都是 VMware 的操作,不会的就放狗搜吧。准备 Swift All In One 的存储盘
我的这个 HDD2 的设备名是 sdb,你的兴许不一样。fdisk 查看一下。
$ sudo fdisk -l |grep Disk Disk /dev/sdb doesn't contain a valid partition table Disk /dev/sda: 17.2 GB, 17179869184 bytes Disk identifier: 0x000ba1f7 Disk /dev/sdb: 21.5 GB, 21474836480 bytes Disk identifier: 0x00000000
分区
$ sudo fdisk /dev/sdb Command (m for help): n
一路默认
Command (m for help): w
写入&退出
分区完毕,瞅一眼
$ sudo fdisk /dev/sdb -l Disk /dev/sdb: 21.5 GB, 21474836480 bytes 213 heads, 34 sectors/track, 5791 cylinders, total 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x8a9eb7e4 Device Boot Start End Blocks Id System /dev/sdb1 2048 41943039 20970496 83 Linux
格式化
安装 XFSprogs 工具
$ sudo apt-get install xfsprogs
格式化 sdb1
$ sudo mkfs.xfs /dev/sdb1
编辑 /etc/fstab
加入:/dev/sdb1 /mnt/sdb1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 0
挂载 HDD 2 & 创建存储区目录结构
$ sudo mkdir /mnt/sdb1 $ sudo mount /mnt/sdb1/ $ sudo chown : /mnt/sdb1 $ mkdir /mnt/sdb1/1 /mnt/sdb1/2 /mnt/sdb1/3 /mnt/sdb1/4 $ mkdir /srv
注:如果系统已经有 /srv 了,并且是 root:root 的话,需要修改一下 owner
sudo chown [YOUR-USER-NAME]:[YOUR-GROUP-NAME] /srv
继续
$ for x in {1..4}; do ln -s /mnt/sdb1/$x /srv/$x; done $ sudo 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 $ sudo chown -R : /etc/swift /srv/[1-4]/ /var/run/swift # Make sure to include the trailing slash after /srv/[1-4]/
编辑 /etc/rc.local
在 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
设置 rsync
新建 /etc/rsyncd.confuid = [YOUR-USER-NAME] gid = [YOUR-GROUP-NAME] log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid address = [YOUR_IP_ADDRESS] [account6012] max connections = 25 path = /srv/1/node/ read only = false lock file = /var/lock/account6012.lock [account6022] max connections = 25 path = /srv/2/node/ read only = false lock file = /var/lock/account6022.lock [account6032] max connections = 25 path = /srv/3/node/ read only = false lock file = /var/lock/account6032.lock [account6042] max connections = 25 path = /srv/4/node/ read only = false lock file = /var/lock/account6042.lock [container6011] max connections = 25 path = /srv/1/node/ read only = false lock file = /var/lock/container6011.lock [container6021] max connections = 25 path = /srv/2/node/ read only = false lock file = /var/lock/container6021.lock [container6031] max connections = 25 path = /srv/3/node/ read only = false lock file = /var/lock/container6031.lock [container6041] max connections = 25 path = /srv/4/node/ read only = false lock file = /var/lock/container6041.lock [object6010] max connections = 25 path = /srv/1/node/ read only = false lock file = /var/lock/object6010.lock [object6020] max connections = 25 path = /srv/2/node/ read only = false lock file = /var/lock/object6020.lock [object6030] max connections = 25 path = /srv/3/node/ read only = false lock file = /var/lock/object6030.lock [object6040] max connections = 25 path = /srv/4/node/ read only = false lock file = /var/lock/object6040.lock
修改 /etc/default/rsync
RSYNC_ENABLE=true
重启 rsync 服务
$ sudo service rsync restart
$ sudo rsync rsync://pub@[YOUR_IP_ADDRESS]/ account6012 account6022 account6032 account6042 container6011 container6021 container6031 container6041 object6010 object6020 object6030 object6040
开启 memcached
Swift proxy server 需要用到 memcache 来作为 token 的临时存储,所以需要安装和配置一下 memcached.$ sudo apt-get install memcached $ sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/memcached.conf $ sudo service memcached restart
安装 Swift 组件
$ sudo apt-get install swift swift-account swift-container swift-proxy swift-object
配置各节点
新建 /etc/swift/proxy-server.conf[DEFAULT] bind_port = 8080 workers = 1 user = [YOUR-USER-NAME] log_facility = LOG_LOCAL1 eventlet_debug = true [pipeline:main] pipeline = healthcheck proxy-logging cache authtoken keystoneauth proxy-logging proxy-server [app:proxy-server] use = egg:swift#proxy allow_account_management = true account_autocreate = true [filter:authtoken] paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory auth_host = [YOUR_IP_ADDRESS] auth_port = 35357 auth_protocol=http service_host = [YOUR_IP_ADDRESS] service_port = 5000 admin_token = ADMIN admin_user = admin admin_password = admin admin_tenant_name = admin [filter:keystoneauth] use = egg:swift#keystoneauth operator_roles = admin, swiftoperator is_admin = true reseller_prefix=AUTH [filter:healthcheck] use = egg:swift#healthcheck [filter:cache] use = egg:swift#memcache memcache_servers = 127.0.0.1:11211 [filter:proxy-logging] use = egg:swift#proxy_logging
新建 /etc/swift/swift.conf
[swift-hash] # random unique strings that can never change (DO NOT LOSE) swift_hash_path_prefix = zmanda swift_hash_path_suffix = zmanda
新建 /etc/swift/account-server/1.conf
[DEFAULT] devices = /srv/1/node mount_check = false disable_fallocate = true bind_port = 6012 workers = 1 user = [YOUR-USER-NAME] log_facility = LOG_LOCAL2 recon_cache_path = /var/cache/swift eventlet_debug = true [pipeline:main] pipeline = recon account-server [app:account-server] use = egg:swift#account [filter:recon] use = egg:swift#recon [account-replicator] vm_test_mode = yes [account-auditor] [account-reaper]
新建 /etc/swift/account-server/2.conf
[DEFAULT] devices = /srv/2/node mount_check = false disable_fallocate = true bind_port = 6022 workers = 1 user = [YOUR-USER-NAME] log_facility = LOG_LOCAL3 recon_cache_path = /var/cache/swift2 eventlet_debug = true [pipeline:main] pipeline = recon account-server [app:account-server] use = egg:swift#account [filter:recon] use = egg:swift#recon [account-replicator] vm_test_mode = yes [account-auditor] [account-reaper]
新建 /etc/swift/account-server/3.conf
[DEFAULT] devices = /srv/3/node mount_check = false disable_fallocate = true bind_port = 6032 workers = 1 user = [YOUR-USER-NAME] log_facility = LOG_LOCAL4 recon_cache_path = /var/cache/swift3 eventlet_debug = true [pipeline:main] pipeline = recon account-server [app:account-server] use = egg:swift#account [filter:recon] use = egg:swift#recon [account-replicator] vm_test_mode = yes [account-auditor] [account-reaper]
新建 /etc/swift/account-server/4.conf
[DEFAULT] devices = /srv/4/node mount_check = false disable_fallocate = true bind_port = 6042 workers = 1 user = [YOUR-USER-NAME] log_facility = LOG_LOCAL5 recon_cache_path = /var/cache/swift4 eventlet_debug = true [pipeline:main] pipeline = recon account-server [app:account-server] use = egg:swift#account [filter:recon] use = egg:swift#recon [account-replicator] vm_test_mode = yes [account-auditor] [account-reaper]
新建 /etc/swift/container-server/1.conf
[DEFAULT] devices = /srv/1/node mount_check = false disable_fallocate = true bind_port = 6011 workers = 1 user = [YOUR-USER-NAME] log_facility = LOG_LOCAL2 recon_cache_path = /var/cache/swift eventlet_debug = true [pipeline:main] pipeline = recon container-server [app:container-server] use = egg:swift#container [filter:recon] use = egg:swift#recon [container-replicator] vm_test_mode = yes [container-updater] [container-auditor] [container-sync]
新建 /etc/swift/container-server/2.conf
[DEFAULT] devices = /srv/2/node mount_check = false disable_fallocate = true bind_port = 6021 workers = 1 user = [YOUR-USER-NAME] log_facility = LOG_LOCAL3 recon_cache_path = /var/cache/swift2 eventlet_debug = true [pipeline:main] pipeline = recon container-server [app:container-server] use = egg:swift#container [filter:recon] use = egg:swift#recon [container-replicator] vm_test_mode = yes [container-updater] [container-auditor] [container-sync]
新建 /etc/swift/container-server/3.conf
[DEFAULT] devices = /srv/3/node mount_check = false disable_fallocate = true bind_port = 6031 workers = 1 user = [YOUR-USER-NAME] log_facility = LOG_LOCAL4 recon_cache_path = /var/cache/swift3 eventlet_debug = true [pipeline:main] pipeline = recon container-server [app:container-server] use = egg:swift#container [filter:recon] use = egg:swift#recon [container-replicator] vm_test_mode = yes [container-updater] [container-auditor] [container-sync]
新建 /etc/swift/container-server/4.conf
[DEFAULT] devices = /srv/4/node mount_check = false disable_fallocate = true bind_port = 6041 workers = 1 user = [YOUR-USER-NAME] log_facility = LOG_LOCAL5 recon_cache_path = /var/cache/swift4 eventlet_debug = true [pipeline:main] pipeline = recon container-server [app:container-server] use = egg:swift#container [filter:recon] use = egg:swift#recon [container-replicator] vm_test_mode = yes [container-updater] [container-auditor] [container-sync]
新建 /etc/swift/object-server/1.conf
[DEFAULT] devices = /srv/1/node mount_check = false disable_fallocate = true bind_port = 6010 workers = 1 user = [YOUR-USER-NAME] log_facility = LOG_LOCAL2 recon_cache_path = /var/cache/swift eventlet_debug = true [pipeline:main] pipeline = recon object-server [app:object-server] use = egg:swift#object [filter:recon] use = egg:swift#recon [object-replicator] vm_test_mode = yes [object-updater] [object-auditor] [object-expirer]
新建 /etc/swift/object-server/2.conf
[DEFAULT] devices = /srv/2/node mount_check = false disable_fallocate = true bind_port = 6020 workers = 1 user = [YOUR-USER-NAME] log_facility = LOG_LOCAL3 recon_cache_path = /var/cache/swift2 eventlet_debug = true [pipeline:main] pipeline = recon object-server [app:object-server] use = egg:swift#object [filter:recon] use = egg:swift#recon [object-replicator] vm_test_mode = yes [object-updater] [object-auditor] [object-expirer]
新建 /etc/swift/object-server/3.conf
[DEFAULT] devices = /srv/3/node mount_check = false disable_fallocate = true bind_port = 6030 workers = 1 user = [YOUR-USER-NAME] log_facility = LOG_LOCAL4 recon_cache_path = /var/cache/swift3 eventlet_debug = true [pipeline:main] pipeline = recon object-server [app:object-server] use = egg:swift#object [filter:recon] use = egg:swift#recon [object-replicator] vm_test_mode = yes [object-updater] [object-auditor] [object-expirer]
新建 /etc/swift/object-server/4.conf
[DEFAULT] devices = /srv/4/node mount_check = false disable_fallocate = true bind_port = 6040 workers = 1 user = [YOUR-USER-NAME] log_facility = LOG_LOCAL5 recon_cache_path = /var/cache/swift4 eventlet_debug = true [pipeline:main] pipeline = recon object-server [app:object-server] use = egg:swift#object [filter:recon] use = egg:swift#recon [object-replicator] vm_test_mode = yes [object-updater] [object-auditor] [object-expirer]
几个启动 Swift 会用到的脚本
弄个 bin 文件夹放脚本
$ mkdir ~/bin
新建 ~/bin/remakerings:
#!/bin/bash cd /etc/swift rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz swift-ring-builder object.builder create 10 3 1 swift-ring-builder object.builder add r1z1-127.0.0.1:6010/sdb1 1 swift-ring-builder object.builder add r1z2-127.0.0.1:6020/sdb2 1 swift-ring-builder object.builder add r1z3-127.0.0.1:6030/sdb3 1 swift-ring-builder object.builder add r1z4-127.0.0.1:6040/sdb4 1 swift-ring-builder object.builder rebalance swift-ring-builder container.builder create 10 3 1 swift-ring-builder container.builder add r1z1-127.0.0.1:6011/sdb1 1 swift-ring-builder container.builder add r1z2-127.0.0.1:6021/sdb2 1 swift-ring-builder container.builder add r1z3-127.0.0.1:6031/sdb3 1 swift-ring-builder container.builder add r1z4-127.0.0.1:6041/sdb4 1 swift-ring-builder container.builder rebalance swift-ring-builder account.builder create 10 3 1 swift-ring-builder account.builder add r1z1-127.0.0.1:6012/sdb1 1 swift-ring-builder account.builder add r1z2-127.0.0.1:6022/sdb2 1 swift-ring-builder account.builder add r1z3-127.0.0.1:6032/sdb3 1 swift-ring-builder account.builder add r1z4-127.0.0.1:6042/sdb4 1 swift-ring-builder account.builder rebalance
新建 ~/bin/startmain:
#!/bin/bash swift-init main start
新建 ~/bin/startrest:
#!/bin/bash swift-init rest start
$ chmod +x ~/bin/*
在 ~/.bashrc 里加上:
export PATH=${PATH}:~/bin
重新加载 bashrc
$ . ~/.bashrc
创建环
$ remakerings
启动 Swift
$ startmainUnable to increase file descriptor limit. Running as non-root? 这个提示可以忽略
$ startrestUnable to find container-sync config section in /etc/swift/container-server.conf 如果遇到这个提示,需要把下面这行加入到 /etc/swfit/container-server.conf 末尾。
[container-sync]
没有评论:
发表评论