SlideShare ist ein Scribd-Unternehmen logo
1 von 51
Downloaden Sie, um offline zu lesen
Openstack swift
果凍
簡介
● 任職於迎棧科技
○ 過去的迎廣科技雲端應用研發中
心
● python, django, linux,
openstack, docker
● 業餘玩玩 scala
● http://about.me/ya790206
swift
1. Swift is a highly available, distributed,
eventually consistent object/blob store.
2. Organizations can use Swift to store lots of
data efficiently, safely, and cheaply.
3. written by python.
4. microservice 架構
hdfs 和 swift 比較
● Swift is designed with multi-tenancy in mind,
where HDFS has no notion of multi-tenancy
● HDFS uses a central system to maintain file
metadata (Namenode), where as in Swift the
metadata is distributed and replicated across
the cluster.
ceph 和 swift 比較
Ceph
○ Started in 2006
○ Written in C++.
○ Strongly consistent.
○ Block storage.
○ Object storage.
Swift
○ Started in 2008
○ Written in Python.
○ Eventually consistent.
○ Object storage.
○ In production on really
large public clouds.
Strongly consistent vs Eventually
consistent
● Eventually consistent
○ if no new updates are made to a given data item,
eventually all accesses to that item will return the
last updated value.
● Strongly consistent
○ If you successfully write a value to a key in a
strongly consistent system, the next successful read
of that key is guaranteed to show that write.
Openstack swift, how does it work?
swift data hierarchy
● account
○ In the OpenStack environment, account is
synonymous with a project or tenant.
● container
○ namespace for objects.
○ access control list
● object
swift service 常見程序名稱
● proxy:負責接受 client 端的 request,並根據
request 來決定哪個 server 發 request。
● server:負責接受 proxy 的請求,處理 CRUD。
部份程序會處理 replicator 的 request。
● updater:處理非同步更新 database 的請求
swift service 常見程序名稱
● auditor:當發現現在的資料 hash 和之前紀錄
的 hash 不同時,則將資料移動到隔離區
(quarantined)。
● replicator:當發現本機和遠端的資料 hash 不
同時,則將本地資料推向遠端主機(不會覆寫
已存在的檔案)
● reaper:for deleting something
Ring 概念
● 將 account, container,
object 做 hash,產生一
個值
● 若值介在 0~33,則放在
A 主機。
A: 0~33
B: 33~66
C: 66~99
根據 hash 演算法決
定資料要存在哪個
node
data1 data2 data3
node1
data4
node2 node3
如果有新主機加入 ring
● 很多資料必須移動,讓
他們到正確的 node
去。
A: 0~25
B: 25~50
C: 50~75
C: 75~50
如何解決加入主機後,有需多資料要移
動的問題
● All problems in computer science can be
solved by another level of indirection, except
of course for the problem of too many
indirections.
swift ring 的概念
Q:data 如何決定放在哪些
partition?
A: 根據 hash 演算法
Q:partition如何決定放在哪
些node ?
A: ring 紀錄哪些 partition
放在 node 裡
data1 data2 data3
node1
data4
node2 node3
Virtual
partitio
n1
Virtual
partitio
n2
Virtual
partitio
n3
Virtual
partitio
n4
data5
ceph
● 和 swift 一
樣,不直接由
hash 值決定
放哪。而是先
放進 pg ,在
由 pg 決定放
哪個 node
ceph
● Each pool has a number of placement
groups. CRUSH maps PGs to OSDs
dynamically. When a Ceph Client stores
objects, CRUSH will map each object to a
placement group.
ceph
● Mapping objects to placement groups creates a layer of indirection
between the Ceph OSD Daemon and the Ceph Client. The Ceph Storage
Cluster must be able to grow (or shrink) and rebalance where it stores
objects dynamically. If the Ceph Client “knew” which Ceph OSD Daemon
had which object, that would create a tight coupling between the Ceph
Client and the Ceph OSD Daemon. Instead, the CRUSH algorithm maps
each object to a placement group and then maps each placement group to
one or more Ceph OSD Daemons. This layer of indirection allows Ceph to
rebalance dynamically when new Ceph OSD Daemons and the underlying
OSD devices come online. The following diagram depicts how CRUSH
maps objects to placement groups, and placement groups to OSDs.
建立一個 ring 檔案
swift-ring-builder object.builder create 10 3 1
swift-ring-builder container.builder create 10 3 1
swift-ring-builder account.builder create 10 3 1
2^10 個 virtual
parition
資料備份三份 這個檔案要間
隔一小時後才
能在
rebanlance
● 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
建立一個 node
(真的存放資料的
機器)
swift ring 功能
● 決定 partition 的數量
● 紀錄哪些 partition 放在哪些 node 裡
第一個副
本
第二個副
本
column 為 partition。0與
1 為 device 的 id
column 數目為 8。因為
2^3 是8
2^3=3
How to get partition from ring?
self._part_shift = 32 - part_power
至多 42 億
個 partition
Ring 的旅程暫時告一段落
Proxy server
● 當 proxy.server 收到請求
後,根據 req.path 來來決
定 controller (proxy.
controller.obj or proxy.
controller.account or
proxy.controller.
container)
container-server
object-server
proxy-server
object-server
account-server
account-server
proxy-server
proxy-server
proxy.server -> proxy.controller
Proxy server
● proxy.server 也會決定要
呼叫 controller 哪個
method
● controller 則會向 object-
server or container-
server or account-server
發請求 。
container-server
object-server
proxy-server
object-server
account-server
account-server
proxy-server
Proxy server
● How to select object-
server for get?
○ 找出所有可能主機
○ 剔除已經在使用的主機
○ 第一台能在 0.5 秒內回應
的主機
Proxy server
● How to select object-
server for put?
○ 從 ring 找出主機列表
○ 將資料寫入到主機列表
中所有主機 找出主機並建
立連線
上傳資料到
object-server
= (n // 2) + 1
object-server
● 和 object 相關的動作由 object-server 負責。
○ CRUD for object and object meta.
○ 存放 object meta 在 file system xattr。
● 根據 account name, container name, object
name 決定物件存放位置。
sdb1/objects/18/a97/90286a5e5b4aeb7370b1091f23151a97/1426663507.97553.data
sdb1/
objects/
18/
a97/90286a5e5b4aeb7370b1091f23151a97/1426663507
hash_path,由 account,
container, object 三個名稱決定。
hash_path
的後三碼
partition,由 account, container, object, ring 所決定。在 proxy-server 時就已經決定。
accounts, containers, objects 三選一
device name,由 account, container, object, ring 所
決定。在 proxy-server 時就已經決定。
副檔名決定檔案是
存在或是被刪除
object-auditor
● 檢查 object 完整性
○ 計算物件的 hash ,比較是否和紀錄相同(紀錄放在
xattr 裡)
○ 當發現 hash 不同時,則會將物件放到 Quarantined
目錄。
● 如何找出該主機所存放的物件?
○ 列舉特定目錄下滿足特定路徑規則的所有檔案
Object-autitor how to find all object?
第一個 listdir
第二個 listdir
第三個 listdir
Object-replicator
● 知錯能改,善莫大焉:
○ 知錯:object-auditor
○ 能改:object-replicator
● Object-replicator 會比對本地和遠端機器的副
本 hash 是否相同,如果不同則執行 rsync 指
令,將資料 push 到遠端。
Object-replicator
● 萬一是自己的資料錯了,Object-replicator
push 資料到遠端,不是會讓錯誤擴散?
○ 當自己的資料有誤時,Object-replicator 會嘗試透過
rysnc push 資料到其他台,但因為 --ignore-existing
參數的關係,實際上不會 push 任何資料。
○ Object-replicator 不會主動 pull 其他主機資料到本地。
只能等待其他主機 push。
○ object-auditor 察覺到本地資料有誤,則將本地資料放
到隔離區。遠端 Object-replicator 比對 hash 時,發現
ObjectReplicator.update
不要覆蓋遠端
的檔案
同步檔案的
meta
只有一個 os.listdir
rsync 是以 partition 為單位
/srv/a/objects/30
資料復原 - 情境分析
● 修改副本内容:
○ (A 電腦的)object-auditor 比對檔案和檔案 xattr 的屬
性(檔案長度與 hash),發現內容有誤,則將資料放進
隔離區。並修改 hahses.pkl
○ 遠端的 object-replicator 發現 A 電腦的資料 hashes.
pkl 和自己的不同,則會試圖 push 自己的電腦資料到
A 電腦
資料復原 - 情境分析
● 刪除副本與 hashes.pkl:
○ 因為 object-auditor 是根據檔案來找出該電腦有哪些
物件。但是檔案被刪除,因此 object-auditor 不知道有
這個物件的存在。
○ 遠端的 object-replicator 要比對 hashes.pkl 的 hash,
但是 hashes.pkl 被刪除。遠端的 object-replicator 要
重新計算 hash,但是檔案已經被刪除,無法重新計算
hash。遠端的 object-replicator 因此執行 rsync 動作
資料復原 - 情境分析
● 刪除副本:
○ 因為 object-auditor 是根據檔案來找出該電腦有哪些
物件。但是檔案被刪除,因此 object-auditor 不知道有
這個物件的存在。而該物件的 hash 也不會被修改。
○ 因為該物件的 hashes.pkl 沒被修改,因此遠端的
object-replicator 不會發現該物件已被刪除。
○ 但是遠端的 object-replicator 還是有可能會還原該副
本,因為 rsync 是以 partition 為單位,而非物件。
資料復原 - 情境分析
● 刪除hashes.pkl:
○ 因為 hashes.pkl 被刪除,因此遠端的 object-replicator
在比對 hash 時會出錯,因此會同步目錄。
container-server
● 和 object-server 運作方式相似,除了是存放
sqlite 檔案
○ 每次對 db 更動都是一筆新紀錄
○ 最新的資料一定是 primary key 最大的
○ 合併時,保留 primary key 最大的
● 也會負責處理 ReplicatorRpc
○ merge_syncs
○ merge_items
○ complete_rsync
container-auditor
● 只檢查檔案
是否能夠被
開啟。
● 檔案不能被
開啟,則會
被隔離。
● 負責 db 的同步與合併
● 同步方法:
○ 傳送差異:db_replicator.Replicator._usync_db
○ rsync:db_replicator.Replicator._rsync_db
● db 合併,保留 primary key 最大的
○ 每次對 db 更動都是一筆新紀錄
○ 最新的資料一定是 primary key 最大的
container-replicator
container-replicator
● 當 db 被刪除時:
○ 遠端主機的 container-replicator 透過 http request 向
本機的 container-server 要求資料
○ 因為 db 被刪除,所以 container-server 回傳找不到檔
案
○ 遠端主機透過 rsync 來 push 被刪除的 db。
● 當發現檔案不能被開啟,則會隔離檔案。(與 container-
auditor 重複)
總結
● swift 架構
● swift ring 介紹
○ a layer of indirection
● proxy-server 如何存取 object
● object-server 與修復情境分析
● container-server 簡易分析
總結
洞悉事物的本質,就不會被表象所迷惑
參考資料
http://blog.csdn.
net/cywosp/article/details/12850645
參考資料
http://www.quora.com/What-
features-differentiate-HDFS-and-
OpenStack-Object-Storage
https://www.mirantis.
com/blog/object-storage-openstack-
cloud-swift-ceph/

Weitere ähnliche Inhalte

Was ist angesagt?

開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018Will Huang
 
Sheepdog内部实现机制
Sheepdog内部实现机制Sheepdog内部实现机制
Sheepdog内部实现机制Liu Yuan
 
Network and Multitasking
Network and MultitaskingNetwork and Multitasking
Network and Multitaskingyarshure Kong
 
Large-Scale Cluster Mangement & Kubernetes Under The Hood
Large-Scale Cluster Mangement & Kubernetes Under The HoodLarge-Scale Cluster Mangement & Kubernetes Under The Hood
Large-Scale Cluster Mangement & Kubernetes Under The HoodLei (Harry) Zhang
 
Golang 高性能实战
Golang 高性能实战Golang 高性能实战
Golang 高性能实战rfyiamcool
 
Linux基础
Linux基础Linux基础
Linux基础zhuqling
 
Sheepdog介绍
Sheepdog介绍Sheepdog介绍
Sheepdog介绍Liu Yuan
 
Mac os Terminal 常用指令與小技巧
Mac os Terminal 常用指令與小技巧Mac os Terminal 常用指令與小技巧
Mac os Terminal 常用指令與小技巧Chen Liwei
 
Mininet Learning Guide(Mininet 学习指南)
Mininet Learning Guide(Mininet 学习指南)Mininet Learning Guide(Mininet 学习指南)
Mininet Learning Guide(Mininet 学习指南)呈 李
 
Monitor is all for ops
Monitor is all for opsMonitor is all for ops
Monitor is all for ops琛琳 饶
 
OpenResty/Lua Practical Experience
OpenResty/Lua Practical ExperienceOpenResty/Lua Practical Experience
OpenResty/Lua Practical ExperienceHo Kim
 
lua & ngx_lua 的介绍与应用
lua & ngx_lua 的介绍与应用lua & ngx_lua 的介绍与应用
lua & ngx_lua 的介绍与应用hugo
 
Docker一期培训
Docker一期培训Docker一期培训
Docker一期培训青帅 常
 
Heartbeat+my sql+drbd构建高可用mysql方案
Heartbeat+my sql+drbd构建高可用mysql方案Heartbeat+my sql+drbd构建高可用mysql方案
Heartbeat+my sql+drbd构建高可用mysql方案cao jincheng
 
20150604 docker 新手入門
20150604 docker 新手入門20150604 docker 新手入門
20150604 docker 新手入門azole Lai
 
常用Mac/Linux命令分享
常用Mac/Linux命令分享常用Mac/Linux命令分享
常用Mac/Linux命令分享Yihua Huang
 
Effective linux.2.(tools)
Effective linux.2.(tools)Effective linux.2.(tools)
Effective linux.2.(tools)wang hongjiang
 
DNS协议与应用简介
DNS协议与应用简介DNS协议与应用简介
DNS协议与应用简介琛琳 饶
 

Was ist angesagt? (20)

Docker實務
Docker實務Docker實務
Docker實務
 
Windbg入门
Windbg入门Windbg入门
Windbg入门
 
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
 
Sheepdog内部实现机制
Sheepdog内部实现机制Sheepdog内部实现机制
Sheepdog内部实现机制
 
Network and Multitasking
Network and MultitaskingNetwork and Multitasking
Network and Multitasking
 
Large-Scale Cluster Mangement & Kubernetes Under The Hood
Large-Scale Cluster Mangement & Kubernetes Under The HoodLarge-Scale Cluster Mangement & Kubernetes Under The Hood
Large-Scale Cluster Mangement & Kubernetes Under The Hood
 
Golang 高性能实战
Golang 高性能实战Golang 高性能实战
Golang 高性能实战
 
Linux基础
Linux基础Linux基础
Linux基础
 
Sheepdog介绍
Sheepdog介绍Sheepdog介绍
Sheepdog介绍
 
Mac os Terminal 常用指令與小技巧
Mac os Terminal 常用指令與小技巧Mac os Terminal 常用指令與小技巧
Mac os Terminal 常用指令與小技巧
 
Mininet Learning Guide(Mininet 学习指南)
Mininet Learning Guide(Mininet 学习指南)Mininet Learning Guide(Mininet 学习指南)
Mininet Learning Guide(Mininet 学习指南)
 
Monitor is all for ops
Monitor is all for opsMonitor is all for ops
Monitor is all for ops
 
OpenResty/Lua Practical Experience
OpenResty/Lua Practical ExperienceOpenResty/Lua Practical Experience
OpenResty/Lua Practical Experience
 
lua & ngx_lua 的介绍与应用
lua & ngx_lua 的介绍与应用lua & ngx_lua 的介绍与应用
lua & ngx_lua 的介绍与应用
 
Docker一期培训
Docker一期培训Docker一期培训
Docker一期培训
 
Heartbeat+my sql+drbd构建高可用mysql方案
Heartbeat+my sql+drbd构建高可用mysql方案Heartbeat+my sql+drbd构建高可用mysql方案
Heartbeat+my sql+drbd构建高可用mysql方案
 
20150604 docker 新手入門
20150604 docker 新手入門20150604 docker 新手入門
20150604 docker 新手入門
 
常用Mac/Linux命令分享
常用Mac/Linux命令分享常用Mac/Linux命令分享
常用Mac/Linux命令分享
 
Effective linux.2.(tools)
Effective linux.2.(tools)Effective linux.2.(tools)
Effective linux.2.(tools)
 
DNS协议与应用简介
DNS协议与应用简介DNS协议与应用简介
DNS协议与应用简介
 

Andere mochten auch

Agile x API x Documentation @ NGO [[MOPCON2015]]
Agile x API x Documentation @ NGO [[MOPCON2015]]Agile x API x Documentation @ NGO [[MOPCON2015]]
Agile x API x Documentation @ NGO [[MOPCON2015]]Chun-Yu Tseng
 
從蟒蛇到神龍 - 從 1 接關繼續打造爬蟲程式
從蟒蛇到神龍 - 從 1 接關繼續打造爬蟲程式從蟒蛇到神龍 - 從 1 接關繼續打造爬蟲程式
從蟒蛇到神龍 - 從 1 接關繼續打造爬蟲程式Chun-Yu Tseng
 
Essential TDD @ pycontw2016
Essential TDD @ pycontw2016Essential TDD @ pycontw2016
Essential TDD @ pycontw2016Chun-Yu Tseng
 
快快樂樂成為 Coding Ninja (by pytest) @ PyConAPAC2015
快快樂樂成為 Coding Ninja (by pytest) @ PyConAPAC2015快快樂樂成為 Coding Ninja (by pytest) @ PyConAPAC2015
快快樂樂成為 Coding Ninja (by pytest) @ PyConAPAC2015Chun-Yu Tseng
 
故事:自由軟體和 Richard Stallman
故事:自由軟體和 Richard Stallman故事:自由軟體和 Richard Stallman
故事:自由軟體和 Richard StallmanWen Liao
 
HPX79 以網路科技幫助青少年達成「個人化教育」/ 呂冠緯 + 黃俊諺
HPX79  以網路科技幫助青少年達成「個人化教育」/ 呂冠緯 + 黃俊諺HPX79  以網路科技幫助青少年達成「個人化教育」/ 呂冠緯 + 黃俊諺
HPX79 以網路科技幫助青少年達成「個人化教育」/ 呂冠緯 + 黃俊諺悠識學院
 
Onos sdn ip 建置之路 20160522
Onos sdn ip 建置之路 20160522Onos sdn ip 建置之路 20160522
Onos sdn ip 建置之路 20160522Fei Ji Siao
 
Immutable infrastructure 介紹與實做:以 kolla 為例
Immutable infrastructure 介紹與實做:以 kolla 為例Immutable infrastructure 介紹與實做:以 kolla 為例
Immutable infrastructure 介紹與實做:以 kolla 為例kao kuo-tung
 
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明National Cheng Kung University
 

Andere mochten auch (11)

Agile x API x Documentation @ NGO [[MOPCON2015]]
Agile x API x Documentation @ NGO [[MOPCON2015]]Agile x API x Documentation @ NGO [[MOPCON2015]]
Agile x API x Documentation @ NGO [[MOPCON2015]]
 
從蟒蛇到神龍 - 從 1 接關繼續打造爬蟲程式
從蟒蛇到神龍 - 從 1 接關繼續打造爬蟲程式從蟒蛇到神龍 - 從 1 接關繼續打造爬蟲程式
從蟒蛇到神龍 - 從 1 接關繼續打造爬蟲程式
 
Essential TDD @ pycontw2016
Essential TDD @ pycontw2016Essential TDD @ pycontw2016
Essential TDD @ pycontw2016
 
快快樂樂成為 Coding Ninja (by pytest) @ PyConAPAC2015
快快樂樂成為 Coding Ninja (by pytest) @ PyConAPAC2015快快樂樂成為 Coding Ninja (by pytest) @ PyConAPAC2015
快快樂樂成為 Coding Ninja (by pytest) @ PyConAPAC2015
 
故事:自由軟體和 Richard Stallman
故事:自由軟體和 Richard Stallman故事:自由軟體和 Richard Stallman
故事:自由軟體和 Richard Stallman
 
HPX79 以網路科技幫助青少年達成「個人化教育」/ 呂冠緯 + 黃俊諺
HPX79  以網路科技幫助青少年達成「個人化教育」/ 呂冠緯 + 黃俊諺HPX79  以網路科技幫助青少年達成「個人化教育」/ 呂冠緯 + 黃俊諺
HPX79 以網路科技幫助青少年達成「個人化教育」/ 呂冠緯 + 黃俊諺
 
Onos sdn ip 建置之路 20160522
Onos sdn ip 建置之路 20160522Onos sdn ip 建置之路 20160522
Onos sdn ip 建置之路 20160522
 
Immutable infrastructure 介紹與實做:以 kolla 為例
Immutable infrastructure 介紹與實做:以 kolla 為例Immutable infrastructure 介紹與實做:以 kolla 為例
Immutable infrastructure 介紹與實做:以 kolla 為例
 
Intorduce to Ceph
Intorduce to CephIntorduce to Ceph
Intorduce to Ceph
 
Python to scala
Python to scalaPython to scala
Python to scala
 
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
 

Ähnlich wie Openstack swift, how does it work?

ElasticSearch Training#2 (advanced concepts)-ESCC#1
ElasticSearch Training#2 (advanced concepts)-ESCC#1ElasticSearch Training#2 (advanced concepts)-ESCC#1
ElasticSearch Training#2 (advanced concepts)-ESCC#1medcl
 
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUGYingSiang Geng
 
Artifacts management with CI and CD
Artifacts management with CI and CDArtifacts management with CI and CD
Artifacts management with CI and CDChen-Tien Tsai
 
HDFS與MapReduce架構研討
HDFS與MapReduce架構研討HDFS與MapReduce架構研討
HDFS與MapReduce架構研討Billy Yang
 
丁原:海量数据迁移方案
丁原:海量数据迁移方案丁原:海量数据迁移方案
丁原:海量数据迁移方案YANGL *
 
RxJS 6 新手入門
RxJS 6 新手入門RxJS 6 新手入門
RxJS 6 新手入門Will Huang
 
賽門鐵克 Storage Foundation 6.0 簡報
賽門鐵克 Storage Foundation 6.0 簡報賽門鐵克 Storage Foundation 6.0 簡報
賽門鐵克 Storage Foundation 6.0 簡報Wales Chen
 
20201006 meta_coin 六角學院
20201006 meta_coin 六角學院20201006 meta_coin 六角學院
20201006 meta_coin 六角學院Hu Kenneth
 
線上埋碼資料收集實作
線上埋碼資料收集實作線上埋碼資料收集實作
線上埋碼資料收集實作FEG
 
喬叔 Elasticsearch Index 管理技巧與效能優化
喬叔 Elasticsearch Index 管理技巧與效能優化喬叔 Elasticsearch Index 管理技巧與效能優化
喬叔 Elasticsearch Index 管理技巧與效能優化Joe Wu
 
Erlang游戏开发
Erlang游戏开发Erlang游戏开发
Erlang游戏开发litaocheng
 
Couchbase introduction - Chinese
Couchbase introduction - Chinese Couchbase introduction - Chinese
Couchbase introduction - Chinese Vickie Zeng
 
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2Yang FaFa
 
淘宝分布式数据处理实践
淘宝分布式数据处理实践淘宝分布式数据处理实践
淘宝分布式数据处理实践isnull
 
realtime-twitter-search
realtime-twitter-searchrealtime-twitter-search
realtime-twitter-search亚军 汪
 
D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版Jackson Tian
 
Programming python - part 1
Programming python - part 1Programming python - part 1
Programming python - part 1Che-Cheng Hsu
 

Ähnlich wie Openstack swift, how does it work? (20)

ElasticSearch Training#2 (advanced concepts)-ESCC#1
ElasticSearch Training#2 (advanced concepts)-ESCC#1ElasticSearch Training#2 (advanced concepts)-ESCC#1
ElasticSearch Training#2 (advanced concepts)-ESCC#1
 
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
 
Artifacts management with CI and CD
Artifacts management with CI and CDArtifacts management with CI and CD
Artifacts management with CI and CD
 
HDFS與MapReduce架構研討
HDFS與MapReduce架構研討HDFS與MapReduce架構研討
HDFS與MapReduce架構研討
 
丁原:海量数据迁移方案
丁原:海量数据迁移方案丁原:海量数据迁移方案
丁原:海量数据迁移方案
 
Why use MySQL
Why use MySQLWhy use MySQL
Why use MySQL
 
Rsync服务器架设方法.v0.1b
Rsync服务器架设方法.v0.1bRsync服务器架设方法.v0.1b
Rsync服务器架设方法.v0.1b
 
RxJS 6 新手入門
RxJS 6 新手入門RxJS 6 新手入門
RxJS 6 新手入門
 
Hadoop ecosystem
Hadoop ecosystemHadoop ecosystem
Hadoop ecosystem
 
賽門鐵克 Storage Foundation 6.0 簡報
賽門鐵克 Storage Foundation 6.0 簡報賽門鐵克 Storage Foundation 6.0 簡報
賽門鐵克 Storage Foundation 6.0 簡報
 
20201006 meta_coin 六角學院
20201006 meta_coin 六角學院20201006 meta_coin 六角學院
20201006 meta_coin 六角學院
 
線上埋碼資料收集實作
線上埋碼資料收集實作線上埋碼資料收集實作
線上埋碼資料收集實作
 
喬叔 Elasticsearch Index 管理技巧與效能優化
喬叔 Elasticsearch Index 管理技巧與效能優化喬叔 Elasticsearch Index 管理技巧與效能優化
喬叔 Elasticsearch Index 管理技巧與效能優化
 
Erlang游戏开发
Erlang游戏开发Erlang游戏开发
Erlang游戏开发
 
Couchbase introduction - Chinese
Couchbase introduction - Chinese Couchbase introduction - Chinese
Couchbase introduction - Chinese
 
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
 
淘宝分布式数据处理实践
淘宝分布式数据处理实践淘宝分布式数据处理实践
淘宝分布式数据处理实践
 
realtime-twitter-search
realtime-twitter-searchrealtime-twitter-search
realtime-twitter-search
 
D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版
 
Programming python - part 1
Programming python - part 1Programming python - part 1
Programming python - part 1
 

Mehr von kao kuo-tung

用 Open source 改造鍵盤
用 Open source 改造鍵盤用 Open source 改造鍵盤
用 Open source 改造鍵盤kao kuo-tung
 
Why is a[1] fast than a.get(1)
Why is a[1]  fast than a.get(1)Why is a[1]  fast than a.get(1)
Why is a[1] fast than a.get(1)kao kuo-tung
 
減少重複的測試程式碼的一些方法
減少重複的測試程式碼的一些方法減少重複的測試程式碼的一些方法
減少重複的測試程式碼的一些方法kao kuo-tung
 
Openstack taskflow 簡介
Openstack taskflow 簡介Openstack taskflow 簡介
Openstack taskflow 簡介kao kuo-tung
 
Async: ways to store state
Async:  ways to store stateAsync:  ways to store state
Async: ways to store statekao kuo-tung
 
Docker 原理與實作
Docker 原理與實作Docker 原理與實作
Docker 原理與實作kao kuo-tung
 
那些年,我們一起看的例外
那些年,我們一起看的例外那些年,我們一起看的例外
那些年,我們一起看的例外kao kuo-tung
 
Python 中 += 與 join比較
Python 中 += 與 join比較Python 中 += 與 join比較
Python 中 += 與 join比較kao kuo-tung
 
Garbage collection 介紹
Garbage collection 介紹Garbage collection 介紹
Garbage collection 介紹kao kuo-tung
 
Python 如何執行
Python 如何執行Python 如何執行
Python 如何執行kao kuo-tung
 
C python 原始碼解析 投影片
C python 原始碼解析 投影片C python 原始碼解析 投影片
C python 原始碼解析 投影片kao kuo-tung
 
recover_pdb 原理與介紹
recover_pdb 原理與介紹recover_pdb 原理與介紹
recover_pdb 原理與介紹kao kuo-tung
 

Mehr von kao kuo-tung (13)

用 Open source 改造鍵盤
用 Open source 改造鍵盤用 Open source 改造鍵盤
用 Open source 改造鍵盤
 
Why is a[1] fast than a.get(1)
Why is a[1]  fast than a.get(1)Why is a[1]  fast than a.get(1)
Why is a[1] fast than a.get(1)
 
減少重複的測試程式碼的一些方法
減少重複的測試程式碼的一些方法減少重複的測試程式碼的一些方法
減少重複的測試程式碼的一些方法
 
Openstack taskflow 簡介
Openstack taskflow 簡介Openstack taskflow 簡介
Openstack taskflow 簡介
 
Async: ways to store state
Async:  ways to store stateAsync:  ways to store state
Async: ways to store state
 
Openstack 簡介
Openstack 簡介Openstack 簡介
Openstack 簡介
 
Docker 原理與實作
Docker 原理與實作Docker 原理與實作
Docker 原理與實作
 
那些年,我們一起看的例外
那些年,我們一起看的例外那些年,我們一起看的例外
那些年,我們一起看的例外
 
Python 中 += 與 join比較
Python 中 += 與 join比較Python 中 += 與 join比較
Python 中 += 與 join比較
 
Garbage collection 介紹
Garbage collection 介紹Garbage collection 介紹
Garbage collection 介紹
 
Python 如何執行
Python 如何執行Python 如何執行
Python 如何執行
 
C python 原始碼解析 投影片
C python 原始碼解析 投影片C python 原始碼解析 投影片
C python 原始碼解析 投影片
 
recover_pdb 原理與介紹
recover_pdb 原理與介紹recover_pdb 原理與介紹
recover_pdb 原理與介紹
 

Kürzlich hochgeladen

买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】
买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】
买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】黑客 接单【TG/微信qoqoqdqd】
 
20211119 - demystified artificial intelligence with NLP
20211119 - demystified artificial intelligence with NLP20211119 - demystified artificial intelligence with NLP
20211119 - demystified artificial intelligence with NLPJamie (Taka) Wang
 
20161220 - domain-driven design
20161220 - domain-driven design20161220 - domain-driven design
20161220 - domain-driven designJamie (Taka) Wang
 
函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptx
函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptx函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptx
函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptxNCU MCL
 
SymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptx
SymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptxSymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptx
SymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptxNCU MCL
 
20170104 - transaction_pattern
20170104 - transaction_pattern20170104 - transaction_pattern
20170104 - transaction_patternJamie (Taka) Wang
 
SymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptx
SymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptxSymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptx
SymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptxNCU MCL
 
函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptx
函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptx函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptx
函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptxNCU MCL
 
函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptx
函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptx函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptx
函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptxNCU MCL
 
函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptx
函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptx函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptx
函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptxNCU MCL
 

Kürzlich hochgeladen (15)

20200323 - AI Intro
20200323 - AI Intro20200323 - AI Intro
20200323 - AI Intro
 
买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】
买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】
买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】
 
20211119 - demystified artificial intelligence with NLP
20211119 - demystified artificial intelligence with NLP20211119 - demystified artificial intelligence with NLP
20211119 - demystified artificial intelligence with NLP
 
Entities in DCPS (DDS)
Entities in DCPS (DDS)Entities in DCPS (DDS)
Entities in DCPS (DDS)
 
20161220 - domain-driven design
20161220 - domain-driven design20161220 - domain-driven design
20161220 - domain-driven design
 
函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptx
函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptx函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptx
函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptx
 
SymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptx
SymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptxSymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptx
SymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptx
 
20170104 - transaction_pattern
20170104 - transaction_pattern20170104 - transaction_pattern
20170104 - transaction_pattern
 
20151111 - IoT Sync Up
20151111 - IoT Sync Up20151111 - IoT Sync Up
20151111 - IoT Sync Up
 
20200226 - AI Overview
20200226 - AI Overview20200226 - AI Overview
20200226 - AI Overview
 
SymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptx
SymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptxSymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptx
SymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptx
 
函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptx
函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptx函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptx
函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptx
 
20161027 - edge part2
20161027 - edge part220161027 - edge part2
20161027 - edge part2
 
函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptx
函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptx函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptx
函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptx
 
函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptx
函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptx函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptx
函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptx
 

Openstack swift, how does it work?

  • 2. 簡介 ● 任職於迎棧科技 ○ 過去的迎廣科技雲端應用研發中 心 ● python, django, linux, openstack, docker ● 業餘玩玩 scala ● http://about.me/ya790206
  • 3. swift 1. Swift is a highly available, distributed, eventually consistent object/blob store. 2. Organizations can use Swift to store lots of data efficiently, safely, and cheaply. 3. written by python. 4. microservice 架構
  • 4. hdfs 和 swift 比較 ● Swift is designed with multi-tenancy in mind, where HDFS has no notion of multi-tenancy ● HDFS uses a central system to maintain file metadata (Namenode), where as in Swift the metadata is distributed and replicated across the cluster.
  • 5. ceph 和 swift 比較 Ceph ○ Started in 2006 ○ Written in C++. ○ Strongly consistent. ○ Block storage. ○ Object storage. Swift ○ Started in 2008 ○ Written in Python. ○ Eventually consistent. ○ Object storage. ○ In production on really large public clouds.
  • 6. Strongly consistent vs Eventually consistent ● Eventually consistent ○ if no new updates are made to a given data item, eventually all accesses to that item will return the last updated value. ● Strongly consistent ○ If you successfully write a value to a key in a strongly consistent system, the next successful read of that key is guaranteed to show that write.
  • 8. swift data hierarchy ● account ○ In the OpenStack environment, account is synonymous with a project or tenant. ● container ○ namespace for objects. ○ access control list ● object
  • 9. swift service 常見程序名稱 ● proxy:負責接受 client 端的 request,並根據 request 來決定哪個 server 發 request。 ● server:負責接受 proxy 的請求,處理 CRUD。 部份程序會處理 replicator 的 request。 ● updater:處理非同步更新 database 的請求
  • 10. swift service 常見程序名稱 ● auditor:當發現現在的資料 hash 和之前紀錄 的 hash 不同時,則將資料移動到隔離區 (quarantined)。 ● replicator:當發現本機和遠端的資料 hash 不 同時,則將本地資料推向遠端主機(不會覆寫 已存在的檔案) ● reaper:for deleting something
  • 11. Ring 概念 ● 將 account, container, object 做 hash,產生一 個值 ● 若值介在 0~33,則放在 A 主機。 A: 0~33 B: 33~66 C: 66~99
  • 14. 如何解決加入主機後,有需多資料要移 動的問題 ● All problems in computer science can be solved by another level of indirection, except of course for the problem of too many indirections.
  • 15. swift ring 的概念 Q:data 如何決定放在哪些 partition? A: 根據 hash 演算法 Q:partition如何決定放在哪 些node ? A: ring 紀錄哪些 partition 放在 node 裡 data1 data2 data3 node1 data4 node2 node3 Virtual partitio n1 Virtual partitio n2 Virtual partitio n3 Virtual partitio n4 data5
  • 16. ceph ● 和 swift 一 樣,不直接由 hash 值決定 放哪。而是先 放進 pg ,在 由 pg 決定放 哪個 node
  • 17. ceph ● Each pool has a number of placement groups. CRUSH maps PGs to OSDs dynamically. When a Ceph Client stores objects, CRUSH will map each object to a placement group.
  • 18. ceph ● Mapping objects to placement groups creates a layer of indirection between the Ceph OSD Daemon and the Ceph Client. The Ceph Storage Cluster must be able to grow (or shrink) and rebalance where it stores objects dynamically. If the Ceph Client “knew” which Ceph OSD Daemon had which object, that would create a tight coupling between the Ceph Client and the Ceph OSD Daemon. Instead, the CRUSH algorithm maps each object to a placement group and then maps each placement group to one or more Ceph OSD Daemons. This layer of indirection allows Ceph to rebalance dynamically when new Ceph OSD Daemons and the underlying OSD devices come online. The following diagram depicts how CRUSH maps objects to placement groups, and placement groups to OSDs.
  • 19. 建立一個 ring 檔案 swift-ring-builder object.builder create 10 3 1 swift-ring-builder container.builder create 10 3 1 swift-ring-builder account.builder create 10 3 1 2^10 個 virtual parition 資料備份三份 這個檔案要間 隔一小時後才 能在 rebanlance
  • 20. ● 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 建立一個 node (真的存放資料的 機器)
  • 21. swift ring 功能 ● 決定 partition 的數量 ● 紀錄哪些 partition 放在哪些 node 裡
  • 22. 第一個副 本 第二個副 本 column 為 partition。0與 1 為 device 的 id column 數目為 8。因為 2^3 是8
  • 23. 2^3=3
  • 24. How to get partition from ring? self._part_shift = 32 - part_power 至多 42 億 個 partition
  • 26. Proxy server ● 當 proxy.server 收到請求 後,根據 req.path 來來決 定 controller (proxy. controller.obj or proxy. controller.account or proxy.controller. container) container-server object-server proxy-server object-server account-server account-server proxy-server proxy-server proxy.server -> proxy.controller
  • 27. Proxy server ● proxy.server 也會決定要 呼叫 controller 哪個 method ● controller 則會向 object- server or container- server or account-server 發請求 。 container-server object-server proxy-server object-server account-server account-server proxy-server
  • 28. Proxy server ● How to select object- server for get? ○ 找出所有可能主機 ○ 剔除已經在使用的主機 ○ 第一台能在 0.5 秒內回應 的主機
  • 29. Proxy server ● How to select object- server for put? ○ 從 ring 找出主機列表 ○ 將資料寫入到主機列表 中所有主機 找出主機並建 立連線 上傳資料到 object-server = (n // 2) + 1
  • 30. object-server ● 和 object 相關的動作由 object-server 負責。 ○ CRUD for object and object meta. ○ 存放 object meta 在 file system xattr。 ● 根據 account name, container name, object name 決定物件存放位置。
  • 31. sdb1/objects/18/a97/90286a5e5b4aeb7370b1091f23151a97/1426663507.97553.data sdb1/ objects/ 18/ a97/90286a5e5b4aeb7370b1091f23151a97/1426663507 hash_path,由 account, container, object 三個名稱決定。 hash_path 的後三碼 partition,由 account, container, object, ring 所決定。在 proxy-server 時就已經決定。 accounts, containers, objects 三選一 device name,由 account, container, object, ring 所 決定。在 proxy-server 時就已經決定。 副檔名決定檔案是 存在或是被刪除
  • 32. object-auditor ● 檢查 object 完整性 ○ 計算物件的 hash ,比較是否和紀錄相同(紀錄放在 xattr 裡) ○ 當發現 hash 不同時,則會將物件放到 Quarantined 目錄。 ● 如何找出該主機所存放的物件? ○ 列舉特定目錄下滿足特定路徑規則的所有檔案
  • 33. Object-autitor how to find all object?
  • 35. Object-replicator ● 知錯能改,善莫大焉: ○ 知錯:object-auditor ○ 能改:object-replicator ● Object-replicator 會比對本地和遠端機器的副 本 hash 是否相同,如果不同則執行 rsync 指 令,將資料 push 到遠端。
  • 36. Object-replicator ● 萬一是自己的資料錯了,Object-replicator push 資料到遠端,不是會讓錯誤擴散? ○ 當自己的資料有誤時,Object-replicator 會嘗試透過 rysnc push 資料到其他台,但因為 --ignore-existing 參數的關係,實際上不會 push 任何資料。 ○ Object-replicator 不會主動 pull 其他主機資料到本地。 只能等待其他主機 push。 ○ object-auditor 察覺到本地資料有誤,則將本地資料放 到隔離區。遠端 Object-replicator 比對 hash 時,發現
  • 39. 只有一個 os.listdir rsync 是以 partition 為單位 /srv/a/objects/30
  • 40. 資料復原 - 情境分析 ● 修改副本内容: ○ (A 電腦的)object-auditor 比對檔案和檔案 xattr 的屬 性(檔案長度與 hash),發現內容有誤,則將資料放進 隔離區。並修改 hahses.pkl ○ 遠端的 object-replicator 發現 A 電腦的資料 hashes. pkl 和自己的不同,則會試圖 push 自己的電腦資料到 A 電腦
  • 41. 資料復原 - 情境分析 ● 刪除副本與 hashes.pkl: ○ 因為 object-auditor 是根據檔案來找出該電腦有哪些 物件。但是檔案被刪除,因此 object-auditor 不知道有 這個物件的存在。 ○ 遠端的 object-replicator 要比對 hashes.pkl 的 hash, 但是 hashes.pkl 被刪除。遠端的 object-replicator 要 重新計算 hash,但是檔案已經被刪除,無法重新計算 hash。遠端的 object-replicator 因此執行 rsync 動作
  • 42. 資料復原 - 情境分析 ● 刪除副本: ○ 因為 object-auditor 是根據檔案來找出該電腦有哪些 物件。但是檔案被刪除,因此 object-auditor 不知道有 這個物件的存在。而該物件的 hash 也不會被修改。 ○ 因為該物件的 hashes.pkl 沒被修改,因此遠端的 object-replicator 不會發現該物件已被刪除。 ○ 但是遠端的 object-replicator 還是有可能會還原該副 本,因為 rsync 是以 partition 為單位,而非物件。
  • 43. 資料復原 - 情境分析 ● 刪除hashes.pkl: ○ 因為 hashes.pkl 被刪除,因此遠端的 object-replicator 在比對 hash 時會出錯,因此會同步目錄。
  • 44. container-server ● 和 object-server 運作方式相似,除了是存放 sqlite 檔案 ○ 每次對 db 更動都是一筆新紀錄 ○ 最新的資料一定是 primary key 最大的 ○ 合併時,保留 primary key 最大的 ● 也會負責處理 ReplicatorRpc ○ merge_syncs ○ merge_items ○ complete_rsync
  • 46. ● 負責 db 的同步與合併 ● 同步方法: ○ 傳送差異:db_replicator.Replicator._usync_db ○ rsync:db_replicator.Replicator._rsync_db ● db 合併,保留 primary key 最大的 ○ 每次對 db 更動都是一筆新紀錄 ○ 最新的資料一定是 primary key 最大的 container-replicator
  • 47. container-replicator ● 當 db 被刪除時: ○ 遠端主機的 container-replicator 透過 http request 向 本機的 container-server 要求資料 ○ 因為 db 被刪除,所以 container-server 回傳找不到檔 案 ○ 遠端主機透過 rsync 來 push 被刪除的 db。 ● 當發現檔案不能被開啟,則會隔離檔案。(與 container- auditor 重複)
  • 48. 總結 ● swift 架構 ● swift ring 介紹 ○ a layer of indirection ● proxy-server 如何存取 object ● object-server 與修復情境分析 ● container-server 簡易分析