OpenStack安裝流程(juno版)- 添加對象存儲服務(swift)- 建立初始環

在開始對象存儲服務前,必須先建立初始的account,container和object環(ring)。html

Account ring

account服務器使用account ring來保存container列表。git

建立環

在controller節點上進行如下操做。github

  1. 進入/etc/swift目錄。
  2. 建立基礎account.builder文件:

# swift-ring-builder account.builder create 10 3 1
各個數字的含義:
10 - 每塊區域最大擁有2^10 2^10 (1024)個分區(ode uses to determine and deploy the storage architecture. For simplicity, this guide uses one region and zone with 2^10 (1024) maximum partitions)
3 - 3個副本
1 - 移動一個分區超過一次時,每次操做間的最小間隔(1 hour minimum time between moving a partition more than once)swift

  1. 把各個存儲節點添加進環

# swift-ring-builder account.builder add r1z1-STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS:6002/DEVICE_NAME DEVICE_WEIGHT
把STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS替換爲object節點在management網絡中的IP地址。把DEVICE_NAME替換爲相應存儲節點上存儲設備的名字。對應每一個存儲節點上的存儲設備,都重複執行此命令。服務器

在本文的方案下,執行命令以下:
<pre># swift-ring-builder account.builder add r1z1-10.10.10.14:6002/sdb 100
Device d0r1z1-10.10.10.14:6002R10.10.10.14:6002/sdb_"" with 100.0 weight got id 0
</pre>
<pre># swift-ring-builder account.builder add r1z1-10.10.10.14:6002/sdc 100
Device d1r1z1-10.10.10.14:6002R10.10.10.14:6002/sdc_"" with 100.0 weight got id 1
</pre>
<pre># swift-ring-builder account.builder add r1z1-10.10.10.15:6002/sdb 100
Device d2r1z1-10.10.10.15:6002R10.10.10.15:6002/sdb_"" with 100.0 weight got id 2
</pre>
<pre># swift-ring-builder account.builder add r1z1-10.10.10.15:6002/sdc 100
Device d3r1z1-10.10.10.15:6002R10.10.10.15:6002/sdc_"" with 100.0 weight got id 3
</pre>網絡

  1. 驗證環的內容:
    <pre># swift-ring-builder account.builder

account.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 1 zones, 4 devices, 100.00 balance
The minimum number of hours before a partition can be reassigned is 1
Devices: id region zone ip address port replication ip replication port name weight partitions balance metassh

0       1     1     10.10.10.14  6002     10.10.10.14              6002       sdb 100.00          0 -100.00 
         1       1     1     10.10.10.14  6002     10.10.10.14              6002       sdc 100.00          0 -100.00 
         2       1     1     10.10.10.15  6002     10.10.10.15              6002       sdb 100.00          0 -100.00 
         3       1     1     10.10.10.15  6002     10.10.10.15              6002       sdc 100.00          0 -100.00 </code></pre>
  1. 從新平衡環:
    <pre># swift-ring-builder account.builder rebalance

Reassigned 1024 (100.00%) partitions. Balance is now 0.00.</pre>
<pre># swift-ring-builder account.builder
account.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 1 zones, 4 devices, 0.00 balance
The minimum number of hours before a partition can be reassigned is 1
Devices: id region zone ip address port replication ip replication port name weight partitions balance meta
curl

0       1     1     10.10.10.14  6002     10.10.10.14              6002       sdb 100.00        768    0.00 
         1       1     1     10.10.10.14  6002     10.10.10.14              6002       sdc 100.00        768    0.00 
         2       1     1     10.10.10.15  6002     10.10.10.15              6002       sdb 100.00        768    0.00 
         3       1     1     10.10.10.15  6002     10.10.10.15              6002       sdc 100.00        768    0.00 </code></pre>

Container Ring

container服務器使用container ring來保存object列表,但並不追蹤object的位置。ide

建立環

在controller節點上進行如下操做。memcached

  1. 進入/etc/swift目錄。
  2. 建立基礎container.builder文件:

# swift-ring-builder container.builder create 10 3 1

  1. 把各個存儲節點添加進環
    # swift-ring-builder container.builder add r1z1-STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS:6001/DEVICE_NAME DEVICE_WEIGHT

    在本文的方案下,執行命令以下:
    <pre># swift-ring-builder container.builder add r1z1-10.10.10.14:6001/sdb 100

Device d0r1z1-10.10.10.14:6001R10.10.10.14:6001/sdb_"" with 100.0 weight got id 0</pre>
<pre># swift-ring-builder container.builder add r1z1-10.10.10.14:6001/sdc 100
Device d1r1z1-10.10.10.14:6001R10.10.10.14:6001/sdc_"" with 100.0 weight got id 1
</pre>
<pre># swift-ring-builder container.builder add r1z1-10.10.10.15:6001/sdb 100
Device d2r1z1-10.10.10.15:6001R10.10.10.15:6001/sdb_"" with 100.0 weight got id 2
</pre>
<pre># swift-ring-builder container.builder add r1z1-10.10.10.15:6001/sdc 100
Device d3r1z1-10.10.10.15:6001R10.10.10.15:6001/sdc_"" with 100.0 weight got id 3
</pre>

  1. 驗證環的內容:
    <pre># swift-ring-builder container.builder

container.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 1 zones, 4 devices, 100.00 balance
The minimum number of hours before a partition can be reassigned is 1
Devices: id region zone ip address port replication ip replication port name weight partitions balance meta

0       1     1     10.10.10.14  6001     10.10.10.14              6001       sdb 100.00          0 -100.00 
         1       1     1     10.10.10.14  6001     10.10.10.14              6001       sdc 100.00          0 -100.00 
         2       1     1     10.10.10.15  6001     10.10.10.15              6001       sdb 100.00          0 -100.00 
         3       1     1     10.10.10.15  6001     10.10.10.15              6001       sdc 100.00          0 -100.00 </code></pre>
  1. 從新平衡環:
    <pre># swift-ring-builder container.builder rebalance

Reassigned 1024 (100.00%) partitions. Balance is now 0.00.</pre>
<pre># swift-ring-builder container.builder
container.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 1 zones, 4 devices, 0.00 balance
The minimum number of hours before a partition can be reassigned is 1
Devices: id region zone ip address port replication ip replication port name weight partitions balance meta

0       1     1     10.10.10.14  6001     10.10.10.14              6001       sdb 100.00        768    0.00 
         1       1     1     10.10.10.14  6001     10.10.10.14              6001       sdc 100.00        768    0.00 
         2       1     1     10.10.10.15  6001     10.10.10.15              6001       sdb 100.00        768    0.00 
         3       1     1     10.10.10.15  6001     10.10.10.15              6001       sdc 100.00        768    0.00 </code></pre>

Object ring

object服務器使用object ring來保存當地設備上的object位置列表。

建立環

在controller節點上進行如下操做。

  1. 進入/etc/swift目錄。
  2. 建立基礎object.builder文件:

# swift-ring-builder object.builder create 10 3 1

  1. 把各個存儲節點添加進環
    # swift-ring-builder object.builder add r1z1-STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS:6000/DEVICE_NAME DEVICE_WEIGHT

    在本文的方案下,執行命令以下:
    <pre># swift-ring-builder object.builder add r1z1-10.10.10.14:6000/sdb 100

Device d0r1z1-10.10.10.14:6000R10.10.10.14:6000/sdb_"" with 100.0 weight got id 0</pre>
<pre># swift-ring-builder object.builder add r1z1-10.10.10.14:6000/sdc 100
Device d1r1z1-10.10.10.14:6000R10.10.10.14:6000/sdc_"" with 100.0 weight got id 1
</pre>
<pre># swift-ring-builder object.builder add r1z1-10.10.10.15:6000/sdb 100
Device d2r1z1-10.10.10.15:6000R10.10.10.15:6000/sdb_"" with 100.0 weight got id 2
</pre>
<pre># swift-ring-builder object.builder add r1z1-10.10.10.15:6000/sdc 100
Device d3r1z1-10.10.10.15:6000R10.10.10.15:6000/sdc_"" with 100.0 weight got id 3
</pre>

  1. 驗證環的內容:
    <pre># swift-ring-builder object.builder

object.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 1 zones, 4 devices, 100.00 balance
The minimum number of hours before a partition can be reassigned is 1
Devices: id region zone ip address port replication ip replication port name weight partitions balance meta

0       1     1     10.10.10.14  6000     10.10.10.14              6000       sdb 100.00          0 -100.00 
         1       1     1     10.10.10.14  6000     10.10.10.14              6000       sdc 100.00          0 -100.00 
         2       1     1     10.10.10.15  6000     10.10.10.15              6000       sdb 100.00          0 -100.00 
         3       1     1     10.10.10.15  6000     10.10.10.15              6000       sdc 100.00          0 -100.00</code></pre>
  1. 從新平衡環:
    <pre># swift-ring-builder object.builder rebalance

Reassigned 1024 (100.00%) partitions. Balance is now 0.00.</pre>
<pre># swift-ring-builder object.builder
object.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 1 zones, 4 devices, 0.00 balance
The minimum number of hours before a partition can be reassigned is 1
Devices: id region zone ip address port replication ip replication port name weight partitions balance meta

0       1     1     10.10.10.14  6000     10.10.10.14              6000       sdb 100.00        768    0.00 
         1       1     1     10.10.10.14  6000     10.10.10.14              6000       sdc 100.00        768    0.00 
         2       1     1     10.10.10.15  6000     10.10.10.15              6000       sdb 100.00        768    0.00 
         3       1     1     10.10.10.15  6000     10.10.10.15              6000       sdc 100.00        768    0.00 </code></pre>

分配環配置文件

account.ring.gzcontainer.ring.gzobject.ring.gz拷貝到各個存儲節點和運行代理服務的節點下/etc/swift目錄裏。

在controller節點,object1和object2上分別執行:
# apt-get install openssh-server

在controller節點上,進入/etc/swift目錄執行:
# scp account.ring.gz container.ring.gz object.ring.gz controller@object1:~/
# scp account.ring.gz container.ring.gz object.ring.gz controller@object2:~/
在object節點上:
# mv account.ring.gz object.ring.gz container.ring.gz /etc/swift/

完成安裝

設定hashes和默認的存儲策略

  1. 從對象存儲的源碼倉庫中取得/etc/swift/swift.conf文件:
    # curl -o /etc/swift/swift.conf https://raw.githubusercontent...
  2. 編輯# vi /etc/swift/swift.conf文件:

    [swift-hash]部分,爲環境設定hash path prefix和suffix:
    <pre>[swift-hash]

...
swift_hash_path_suffix = HASH_PATH_PREFIX
swift_hash_path_prefix = HASH_PATH_SUFFIX</pre>
把 HASH_PATH_PREFIX和HASH_PATH_SUFFIX替換爲合適的特定值。

[storage-policy:0]部分,設定默認的存儲策略:
<pre>[storage-policy:0]
...
name = Policy-0
default = yes
</pre>

  1. swift.conf拷貝到各個存儲節點和運行代理服務的節點下/etc/swift目錄裏。
  2. 在全部相關節點上,確保配置文件目錄權限正確:

# chown -R swift:swift /etc/swift

  1. 在控制節點和其餘運行代理服務的節點,重啓對象存儲代理服務和它的依賴服務:

# service memcached restart
# service swift-proxy restart

  1. 在存儲節點,啓動對象存儲服務:

# swift-init all start
因爲此命令只是用來簡化重啓服務的命令,因此會有些沒有運行在存儲節點上的服務會報錯,能夠忽略。

驗證操做

如下操做在controller節點上執行。

  1. 啓動demo證書:

$ source demo-openrc.sh

  1. 查看服務狀態:
    <pre>$ swift stat

    Account: AUTH_d1f7caccc65840b68258997a759da07f

    Containers: 0

    Objects: 0
        Bytes: 0

    Content-Type: text/plain; charset=utf-8
    X-Timestamp: 1449023734.57049
    X-Trans-Id: tx9df6cf30763b4abaa05cd-00565e58f5

X-Put-Timestamp: 1449023734.57049</pre>

  1. 上傳一個測試文件:

$ swift upload demo-container1 FILE
把FILE替換爲測試文件的文件名,此文件將被上傳至命名爲demo-container1的container中。
<pre>$ swift upload demo-container1 test_file_for_swift.text
test_file_for_swift.text
</pre>

  1. 列出container:
    <pre>$ swift list

demo-container1</pre>

  1. 下載測試文件:

$ swift download demo-container1 FILE
把FILE替換爲測試文件的文件名。
<pre>$ swift download demo-container1 test_file_for_swift.text
test_file_for_swift.text [auth 0.105s, headers 0.131s, total 0.132s, 0.000 MB/s]
</pre>

安裝時出現的問題及解決方法

在安裝完成執行重啓服務操做時,出現以下錯誤提示:
<pre># service swift-proxy restart
stop: Unknown instance:
start: Job failed to start
</pre>
說明/etc/swift/proxy-server.conf文件配置有問題,經查找後發現是在配置時沒有注意[filter:authtoken][filter:keystoneauth]默認狀態是註釋掉的,將其取消註釋後重啓服務便可成功。在openstack【juno】入門 【swift篇】二十四:建立初始rings此文章中,做者用$ swift-init all start命令查看錯誤更加明晰,也說明配置文件中全部參數都最好頂格寫,不要預留空格。

相關文章
相關標籤/搜索