next up previous contents
Next: Swift Ring 配置錯誤修正 Up: 物件儲存 Swift Previous: 建立 Swift Storage Node   Contents

設定 Swift Service Ring

  1. 載入 keystone 管理者 admin 環境變數。
    [root@kvm4 ~]# source keystonerc_admin 
    [root@kvm4 ~(keystone_admin)]#
    
  2. 使用 swift-ring-builder 工具建立每個服務的 ring,partitions=2^9=512, replicas=2, min_part_hours=1。執行工具就會出現參數說明。
    [root@kvm4 ~(keystone_admin)]# swift-ring-builder
    swift-ring-builder <builder_file> create <part_power> <replicas> <min_part_hours>
    [root@kvm4 ~(keystone_admin)]# swift-ring-builder /etc/swift/account.builder create 9 2 1
    [root@kvm4 ~(keystone_admin)]# swift-ring-builder /etc/swift/container.builder create 9 2 1
    [root@kvm4 ~(keystone_admin)]# swift-ring-builder /etc/swift/object.builder create 9 2 1
    
  3. 將裝置加入到 account 服務,如果做錯了要修改,可參考下節「Swift Ring 配置錯誤修正」4.5。執行命令就會出現參數說明。
    [root@kvm4 ~(keystone_admin)]# swift-ring-builder
    swift-ring-builder <builder_file> add
        [r<region>]z<zone>-<ip>:<port>/<device_name>_<meta> <weight>
    
        Adds devices to the ring with the given information. No partitions will be
        assigned to the new device until after running 'rebalance'. This is so you
        can make multiple device changes and rebalance them all just once.
    
    [root@kvm4 ~(keystone_admin)]# for i in 1 2; do
    > swift-ring-builder /etc/swift/account.builder add z${i}-192.168.122.4:6002/z${i}d1 100
    > done
    WARNING: No region specified for z1-192.168.122.4:6002/z1d1. Defaulting to region 1.
    Device r1z1-192.168.122.4:6002/z1d1_"" with 100.0 weight got id 0
    WARNING: No region specified for z2-192.168.122.4:6002/z2d1. Defaulting to region 1.
    Device r1z2-192.168.122.4:6002/z2d1_"" with 100.0 weight got id
    
  4. 將裝置加入到 container 服務。
    [root@kvm4 ~(keystone_admin)]# for i in 1 2; do swift-ring-builder /etc/swift/container.builder add z${i}-192.168.122.4:6001/z${i}d1 100; done
    WARNING: No region specified for z1-192.168.122.4:6001/z1d1. Defaulting to region 1.
    Device r1z1-192.168.122.4:6001/z1d1_"" with 100.0 weight got id 0
    WARNING: No region specified for z2-192.168.122.4:6001/z2d1. Defaulting to region 1.
    Device r1z2-192.168.122.4:6001/z2d1_"" with 100.0 weight got id 1
    
  5. 將裝置加入到 object 服務。
    [root@kvm4 ~(keystone_admin)]# for i in 1 2; do swift-ring-builder /etc/swift/object.builder add z${i}-192.168.122.4:6000/z${i}d1 100; done
    WARNING: No region specified for z1-192.168.122.4:6000/z1d1. Defaulting to region 1.
    Device r1z1-192.168.122.4:6000/z1d1_"" with 100.0 weight got id 0
    WARNING: No region specified for z2-192.168.122.4:6000/z2d1. Defaulting to region 1.
    Device r1z2-192.168.122.4:6000/z2d1_"" with 100.0 weight got id 1
    
  6. rebalance 剛剛產生的 rings。
    [root@kvm4 ~(keystone_admin)]# swift-ring-builder /etc/swift/account.builder rebalance
    Reassigned 512 (100.00%) partitions. Balance is now 0.00.
    [root@kvm4 ~(keystone_admin)]# swift-ring-builder /etc/swift/container.builder rebalance
    Reassigned 512 (100.00%) partitions. Balance is now 0.00.
    [root@kvm4 ~(keystone_admin)]# swift-ring-builder /etc/swift/object.builder rebalance
    Reassigned 512 (100.00%) partitions. Balance is now 0.00.
    
  7. 確認 ring files 是否成功產生?
    [root@kvm4 ~(keystone_admin)]# ll /etc/swift/*gz
    -rw-r--r--. 1 root root 445 Jan 25 00:35 /etc/swift/account.ring.gz
    -rw-r--r--. 1 root root 448 Jan 25 00:35 /etc/swift/container.ring.gz
    -rw-r--r--. 1 root root 447 Jan 25 00:35 /etc/swift/object.ring.gz
    
  8. 改變目錄 /etc/swift 的群組為 swift。
    [root@kvm4 ~(keystone_admin)]# chown -R root:swift /etc/swift
    [root@kvm4 ~(keystone_admin)]# ll -d /etc/swift/
    drwxr-xr-x. 7 root swift 4096 Jan 25 00:35 /etc/swift/
    



2015-12-29