一递雀、環(huán)境
python-2.7.5
-
centos-7.5
項目地址:https://github.com/iqiyi/auklet/blob/master/doc/tiny-swift/README.md
二路克、部署
1齐苛、創(chuàng)建用戶
# useradd swift
# setenforce 0
2、依賴安裝
# yum group install "Development Tools" -y
# yum install python-virtualenv memcached rsync libffi-devel openssl-devel python-devel libxslt-devel -y
3毁菱、虛擬環(huán)境
# 創(chuàng)建虛擬環(huán)境
# virtualenv /opt/openstack/swift-kilo
# 進(jìn)入虛擬環(huán)境
# source /opt/openstack/swift-kilo/bin/activate
4、安裝swift依賴
# yum -y install https://buildlogs.centos.org/centos/7/cloud/x86_64/openstack-rocky/liberasurecode-1.5.0-1.el7.x86_64.rpm
# yum -y install https://buildlogs.centos.org/centos/7/cloud/x86_64/openstack-rocky/liberasurecode-devel-1.5.0-1.el7.x86_64.rpm
5、安裝swift
# pip install -i https://mirrors.aliyun.com/pypi/simple swift 內(nèi)網(wǎng)環(huán)境建議
# pip install swift 外網(wǎng)建議
6酵镜、初始化存儲空間
官方引入了兩種類型存儲設(shè)置
使用分區(qū)進(jìn)行存儲
-
使用環(huán)回設(shè)備進(jìn)行存儲
本次單機,顧采用第二種方法柴钻。
# mkdir -p /srv/node/{sdb,sdc,sdd,sde}
# mkdir -p /var/cache/swift
# mkdir -p /var/run/swift
# mkdir /srv/vdisks/
# truncate -s 10G /srv/vdisks/{sdb,sdc,sdd,sde}
# 格式化
# mkfs.xfs /srv/vdisks/{sdb,sdc,sdd,sde}
# mount /srv/vdisks/sdb /srv/node/sdb
相繼掛載
# chown swift.swift -R /srv/node/sdb 類推
腳本
#!/bin/bash
mkdir -p /srv/vdisks
mkdir -p /var/cache/swift
mkdir -p /var/run/swift
chown swift.swift -R /var/cache/swift
chown swift.swift -R /var/run/swift
for disk in sdb sdc sdd sde
do
# Create disk images
truncate -s 10G /srv/vdisks/$disk
# Create file systems
mkfs.xfs /srv/vdisks/$disk
# Create mount points
mkdir -p /srv/node/$disk
echo "/srv/vdisks/$disk /srv/node/$disk xfs defaults 0 0" >> /etc/fstab
mount /srv/vdisks/$disk /srv/node/$disk
chown swift:swift -R /srv/node/$disk
done
7淮韭、配置文件
7.1、新建配置目錄
# mkdir /etc/swift
7.2贴届、swift.conf
[swift-hash]
swift_hash_path_prefix = changeme
swift_hash_path_suffix = emegnahc
[storage-policy:0]
default = yes
name = gold
policy_type = replication
[swift-constraints]
# Limit maximum object size to 5G
max_file_size = 5368709120
7.3靠粪、proxy-server.conf
[DEFAULT]
bind_port = 8080
bind_ip = 0.0.0.0
workers = 1
user = swift
[pipeline:main]
pipeline = catch_errors gatekeeper healthcheck proxy-logging cache tempurl slo dlo proxy-logging proxy-server
[app:proxy-server]
use = egg:swift#proxy
allow_account_management = no
account_autocreate = yes
object_post_as_copy = no
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:cache]
use = egg:swift#memcache
memcache_servers = 127.0.0.1:11211
[filter:catch_errors]
use = egg:swift#catch_errors
[filter:proxy-logging]
use = egg:swift#proxy_logging
[filter:tempurl]
use = egg:swift#tempurl
[filter:slo]
use = egg:swift#slo
[filter:dlo]
use = egg:swift#dlo
[filter:gatekeeper]
use = egg:swift#gatekeeper
7.4、account-server.conf
[DEFAULT]
bind_ip = 0.0.0.0
bind_port = 6002
workers = 1
user = swift
[pipeline:main]
pipeline = account-server
[app:account-server]
use = egg:swift#account
[account-replicator]
[account-auditor]
[account-reaper]
7.5毫蚓、container-server.conf
[DEFAULT]
bind_ip = 0.0.0.0
bind_port = 6001
workers = 1
mount_check = false
allow_versions = True
user = swift
[pipeline:main]
pipeline = container-server
[app:container-server]
use = egg:swift#container
[container-replicator]
[container-updater]
interval = 10
[container-auditor]
[container-sync]
[container-sharder]
7.6占键、container-reconciler.conf
[DEFAULT]
user = swift
[container-reconciler]
[pipeline:main]
pipeline = catch_errors proxy-logging cache proxy-server
[app:proxy-server]
use = egg:swift#proxy
[filter:cache]
use = egg:swift#memcache
[filter:proxy-logging]
use = egg:swift#proxy_logging
[filter:catch_errors]
use = egg:swift#catch_errors
7.7、object-server.conf
[DEFAULT]
bind_ip = 0.0.0.0
bind_port = 6000
workers = 1
user = swift
[pipeline:main]
pipeline = object-server
[app:object-server]
use = egg:swift#object
[object-replicator]
sync_method = ssync
[object-auditor]
log_level = DEBUG
concurrency = 4
interval = 30
files_per_second = 0
bytes_per_second = 0
[object-updater]
interval = 10
[object-auditor]
[object-reconstructor]
[object-expirer]
7.8元潘、object-expirer.conf
[DEFAULT]
user = swift
[object-expirer]
# auto_create_account_prefix = .
[pipeline:main]
pipeline = catch_errors cache proxy-server
[app:proxy-server]
use = egg:swift#proxy
[filter:cache]
use = egg:swift#memcache
memcache_servers = 127.0.0.1:11211
[filter:catch_errors]
use = egg:swift#catch_errors
7.9畔乙、internal-client.conf
[DEFAULT]
[pipeline:main]
pipeline = catch_errors proxy-logging cache symlink proxy-server
[app:proxy-server]
use = egg:swift#proxy
account_autocreate = true
# See proxy-server.conf-sample for options
[filter:symlink]
use = egg:swift#symlink
# See proxy-server.conf-sample for options
[filter:cache]
use = egg:swift#memcache
# See proxy-server.conf-sample for options
[filter:proxy-logging]
use = egg:swift#proxy_logging
[filter:catch_errors]
use = egg:swift#catch_errors
# See proxy-server.conf-sample for options
8、配置rsync
# egrep -v "^$|*#" /etc/rsyncd.conf
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
[account]
max connections = 2
path = /srv/node
read only = false
lock file = /var/lock/account.lock
[container]
max connections = 4
path = /srv/node
read only = false
lock file = /var/lock/container.lock
[object]
max connections = 8
path = /srv/node
read only = false
lock file = /var/lock/object.lock
# 啟動
# systemctl restart rsyncd
9翩概、創(chuàng)建rings
#!/bin/bash
cd /etc/swift
rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
swift-ring-builder object.builder create 8 3 1
swift-ring-builder object.builder add r1z1-127.0.0.1:6000/sdb 1
swift-ring-builder object.builder add r1z2-127.0.0.1:6000/sdc 1
swift-ring-builder object.builder add r1z3-127.0.0.1:6000/sdd 1
swift-ring-builder object.builder add r1z4-127.0.0.1:6000/sde 1
swift-ring-builder object.builder rebalance
swift-ring-builder container.builder create 8 3 1
swift-ring-builder container.builder add r1z1-127.0.0.1:6001/sdb 1
swift-ring-builder container.builder add r1z2-127.0.0.1:6001/sdc 1
swift-ring-builder container.builder add r1z3-127.0.0.1:6001/sdd 1
swift-ring-builder container.builder add r1z4-127.0.0.1:6001/sde 1
swift-ring-builder container.builder rebalance
swift-ring-builder account.builder create 8 3 1
swift-ring-builder account.builder add r1z1-127.0.0.1:6002/sdb 1
swift-ring-builder account.builder add r1z2-127.0.0.1:6002/sdc 1
swift-ring-builder account.builder add r1z3-127.0.0.1:6002/sdd 1
swift-ring-builder account.builder add r1z4-127.0.0.1:6002/sde 1
swift-ring-builder account.builder rebalance
10牲距、啟動
# swift-init start all
# swift-init status all
# 默認(rèn)情況下所有日志都寫入/var/log/messages
11袖订、測試
# 創(chuàng)建 contaien
curl -v -X PUT http://127.0.0.1:8080/v1/iqiyi/auklet
#上傳對象
curl -v -X PUT -H "Content-Type: text/plain" -d "Hello World" http://127.0.0.1:8080/v1/iqiyi/auklet/hi