swift分布式文件服務(wù)部署

一递雀、環(huán)境

二路克、部署

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
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市嗅虏,隨后出現(xiàn)的幾起案子洛姑,更是在濱河造成了極大的恐慌,老刑警劉巖皮服,帶你破解...
    沈念sama閱讀 207,113評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件楞艾,死亡現(xiàn)場離奇詭異,居然都是意外死亡龄广,警方通過查閱死者的電腦和手機硫眯,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,644評論 2 381
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來择同,“玉大人两入,你說我怎么就攤上這事∏貌牛” “怎么了裹纳?”我有些...
    開封第一講書人閱讀 153,340評論 0 344
  • 文/不壞的土叔 我叫張陵,是天一觀的道長紧武。 經(jīng)常有香客問我剃氧,道長,這世上最難降的妖魔是什么阻星? 我笑而不...
    開封第一講書人閱讀 55,449評論 1 279
  • 正文 為了忘掉前任朋鞍,我火速辦了婚禮,結(jié)果婚禮上妥箕,老公的妹妹穿的比我還像新娘滥酥。我一直安慰自己,他們只是感情好畦幢,可當(dāng)我...
    茶點故事閱讀 64,445評論 5 374
  • 文/花漫 我一把揭開白布坎吻。 她就那樣靜靜地躺著,像睡著了一般呛讲。 火紅的嫁衣襯著肌膚如雪禾怠。 梳的紋絲不亂的頭發(fā)上返奉,一...
    開封第一講書人閱讀 49,166評論 1 284
  • 那天贝搁,我揣著相機與錄音,去河邊找鬼芽偏。 笑死雷逆,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的污尉。 我是一名探鬼主播膀哲,決...
    沈念sama閱讀 38,442評論 3 401
  • 文/蒼蘭香墨 我猛地睜開眼往产,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了某宪?” 一聲冷哼從身側(cè)響起仿村,我...
    開封第一講書人閱讀 37,105評論 0 261
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎兴喂,沒想到半個月后蔼囊,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 43,601評論 1 300
  • 正文 獨居荒郊野嶺守林人離奇死亡衣迷,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,066評論 2 325
  • 正文 我和宋清朗相戀三年畏鼓,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片壶谒。...
    茶點故事閱讀 38,161評論 1 334
  • 序言:一個原本活蹦亂跳的男人離奇死亡云矫,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出汗菜,到底是詐尸還是另有隱情让禀,我是刑警寧澤,帶...
    沈念sama閱讀 33,792評論 4 323
  • 正文 年R本政府宣布陨界,位于F島的核電站堆缘,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏普碎。R本人自食惡果不足惜吼肥,卻給世界環(huán)境...
    茶點故事閱讀 39,351評論 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望麻车。 院中可真熱鬧缀皱,春花似錦、人聲如沸动猬。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,352評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽赁咙。三九已至钮莲,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間彼水,已是汗流浹背崔拥。 一陣腳步聲響...
    開封第一講書人閱讀 31,584評論 1 261
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留凤覆,地道東北人链瓦。 一個月前我還...
    沈念sama閱讀 45,618評論 2 355
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親慈俯。 傳聞我的和親對象是個殘疾皇子渤刃,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 42,916評論 2 344

推薦閱讀更多精彩內(nèi)容