OpenStack安裝流程(juno版)- 添加對象存儲服務(swift)- 安裝和配置

在controller節點上安裝和配置

建立swift的數據庫,服務證書和API端點

  1. 建立服務證書:

    啓動admin證書:
    $ source admin-openrc.sh node

    建立swift用戶:
    <pre>$ keystone user-create --name swift --pass SWIFT_PASSpython

Property Value
email
enabled True
id dcf5d53f027b44d38c205ad06717812c
name swift
username swift

+----------+----------------------------------+</pre>
用合適的密碼代替SWIFT_PASS。git

admin角色賦予給swift用戶:
$ keystone user-role-add --user swift --tenant service --role admin
這條命令不產生輸出顯示。github

建立swift服務實體:
<pre>$ keystone service-create --name swift --type object-store \數據庫

--description "OpenStack Object Storage"
Property Value
description OpenStack Object Storage
enabled True
id 11519978722e4fb4be75f086aca49334
name swift
type object-store

+-------------+----------------------------------+</pre>swift

  1. 建立對象存儲服務的API端點:
    <pre>$ keystone endpoint-create \

--service-id $(keystone service-list | awk '/ object-store / {print$2}') \
--publicurl 'http://controller:8080/v1/AUTH_%(tenant_id)s' \
--internalurl 'http://controller:8080/v1/AUTH_%(tenant_id)s' \
--adminurl http://controller:8080 \網絡

--region regionOne
Property Value
adminurl http://controller:8080
id ec003b88a6144afda3fc2b34acb93ded
internalurl http://controller:8080/v1/AUTH_%(tenant_id)s
publicurl http://controller:8080/v1/AUTH_%(tenant_id)s
region regionOne
service_id 11519978722e4fb4be75f086aca49334

+-------------+----------------------------------------------+</pre>app

安裝和配置組件

  1. 安裝所需包:
    # apt-get install swift swift-proxy python-swiftclient python-keystoneclient python-keystonemiddleware memcached
  2. 建立文件夾/etc/swift
  3. 從對象存儲的源碼倉庫中取得代理服務配置文件(proxy service configuration file)。
    # curl -o /etc/swift/proxy-server.conf https://raw.githubusercontent...
  4. 編輯# vi /etc/swift/proxy-server.conf文件:

    [DEFAULT]部分,設置bind port,用戶和配置文件存放目錄:
    <pre>[DEFAULT]curl

...
bind_port = 8080
user = swift
swift_dir = /etc/swift</pre>ide

[pipeline:main]部分,啓用合適的模塊:
<pre>[pipeline:main]
pipeline = authtoken cache healthcheck keystoneauth proxy-logging proxy-server
</pre>

[app:proxy-server]部分,啓用賬戶管理:
<pre>[app:proxy-server]
...
allow_account_management = true
account_autocreate = true
</pre>

[filter:keystoneauth]部分,設定操做者角色(operator role):
<pre>[filter:keystoneauth]
use = egg:swift#keystoneauth
...
operator_roles = admin,_member_
</pre>

[filter:authtoken]部分,設定認證服務:
<pre>[filter:authtoken]
paste.filter_factory = keystonemiddleware.auth_token:filter_factory
...
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = swift
admin_password = SWIFT_PASS
delay_auth_decision = true
</pre>
SWIFT_PASS爲建立swift用戶時使用的密碼。註釋掉 auth_host,auth_port,和auth_protocol的選項,由於identity_uri選項是直接代替它們的。

[filter:cache]部分,設定memcached location:
<pre>[filter:cache]
...
memcache_servers = 127.0.0.1:11211
</pre>

在object節點上安裝和配置

這裏要求兩個object存儲節點,每個都包含兩個空的本地塊存儲設備(two empty local block storage devices)。每一個設備(/dev/sdb/dev/sdc)都必須包含一個合適的分區表,整個設備就一個分區(Each of the devices, /dev/sdb and /dev/sdc, must contain a suitable partition table with one partition occupying the entire device. )。

配置存儲

爲object節點增添兩塊硬盤:設置->存儲->控制器:SATA->添加虛擬硬盤。

object節點的基礎環境配置

由前文所述的虛擬機模版建立兩個存儲節點,分別爲object1和object2節點,基礎環境配置以下:

配置網絡

object節點虛擬機網絡設置,設置->網絡:

  1. 網卡1,鏈接方式->僅主機(Host-Only)適配器,界面名稱->VirtualBox Host-Only Ethernet Adapter #2,控制芯片->準虛擬化網絡(virtio-net),混雜模式->所有容許,接入網線->勾選;
  2. 網卡2,鏈接方式->網絡地址轉換(NAT),控制芯片->準虛擬化網絡(virtio-net),接入網線->勾選。

啓動虛擬機後,配置其網絡,經過更改# vi /etc/network/interfaces文件,添加以下代碼:
object1:
<pre># The management network interface
auto eth0
iface eth0 inet static

address 10.10.10.14
netmask 255.255.255.0

The NAT network

auto eth1
iface eth1 inet dhcp</pre>
object2:
<pre># The management network interface
auto eth0
iface eth0 inet static

address 10.10.10.15
netmask 255.255.255.0

The NAT network

auto eth1
iface eth1 inet dhcp</pre>

配置命名的解決方案,更改# vi /etc/hostname文件,將主機名改成object1object2,更改# vi /etc/hosts文件,添加如下代碼:
<pre>10.10.10.10 controller
10.10.10.11 compute
10.10.10.12 network
10.10.10.13 block
10.10.10.14 object1
10.10.10.15 object2
</pre>

配置NTP

修改配置文件# vi /etc/ntp.conf,添加以下代碼:

<pre>server controller iburst</pre>
其餘server所有都註釋掉。若是/var/lib/ntp/ntp.conf.dhcp文件存在,則刪除之。

重啓NTP服務:# service ntp restart

配置存儲

  1. 安裝配套的功能包

# apt-get install xfsprogs rsync

  1. 格式化分區/dev/sdb/dev/sdc爲XFS格式:
    <pre># mkfs.xfs /dev/sdb

meta-data=/dev/sdb isize=256 agcount=4, agsize=524288 blks

=                       sectsz=512   attr=2, projid32bit=0

data = bsize=4096 blocks=2097152, imaxpct=25

=                       sunit=0      swidth=0 blks

naming =version 2 bsize=4096 ascii-ci=0
log =internal log bsize=4096 blocks=2560, version=2

=                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none extsz=4096 blocks=0, rtextents=0</pre>
<pre># mkfs.xfs /dev/sdc
meta-data=/dev/sdc isize=256 agcount=4, agsize=524288 blks

=                       sectsz=512   attr=2, projid32bit=0

data = bsize=4096 blocks=2097152, imaxpct=25

=                       sunit=0      swidth=0 blks

naming =version 2 bsize=4096 ascii-ci=0
log =internal log bsize=4096 blocks=2560, version=2

=                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none extsz=4096 blocks=0, rtextents=0></pre>

  1. 建立掛載點的目錄結構

# mkdir -p /srv/node/sdb
# mkdir -p /srv/node/sdc

  1. 編輯# vi /etc/fstab文件,添加以下內容:

    <pre>/dev/sdb /srv/node/sdb xfs noatime,nodiratime,nobarrier,logbufs=8 0 2

/dev/sdc /srv/node/sdc xfs noatime,nodiratime,nobarrier,logbufs=8 0 2</pre>

  1. 掛載設備

# mount /srv/node/sdb
# mount /srv/node/sdc

  1. 新建# vi /etc/rsyncd.conf文件,添加以下內容:
    <pre>uid = swift

gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = MANAGEMENT_INTERFACE_IP_ADDRESS
[account]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/account.lock
[container]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/container.lock
[object]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/object.lock</pre>
MANAGEMENT_INTERFACE_IP_ADDRESS爲object節點在management網絡中的IP地址,object1爲10.10.10.14,object2爲10.10.10.15。

  1. 編輯# vi /etc/default/rsync文件,啓用rsync服務:
    <pre>RSYNC_ENABLE=true</pre>
  2. 重啓rsync服務:

# service rsync start

安裝和配置存儲節點組件

  1. 安裝所需包:

# apt-get install swift swift-account swift-container swift-object

  1. 從對象存儲的源碼倉庫中取得accounting,container和object服務配置文件:

# curl -o /etc/swift/account-server.conf https://raw.githubusercontent...
# curl -o /etc/swift/container-server.conf https://raw.githubusercontent...
# curl -o /etc/swift/object-server.conf https://raw.githubusercontent...

  1. 編輯# vi /etc/swift/account-server.conf文件:
    [DEFAULT]部分,設定bind IP地址,bind port,用戶,配置文件目錄和掛載點目錄:
    <pre>[DEFAULT]

...
bind_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
bind_port = 6002
user = swift
swift_dir = /etc/swift
devices = /srv/node</pre>
MANAGEMENT_INTERFACE_IP_ADDRESS爲object節點在management網絡中的IP地址,object1爲10.10.10.14,object2爲10.10.10.15。

[pipeline:main]部分,啓用合適的模塊:
<pre>[pipeline:main]
pipeline = healthcheck recon account-server
</pre>

[filter:recon]部分,設定recon(metrics)cache目錄:
<pre>[filter:recon]
...
recon_cache_path = /var/cache/swift
</pre>

  1. 編輯# vi /etc/swift/container-server.conf文件:
    [DEFAULT]部分,設定bind IP地址,bind port,用戶,配置文件目錄和掛載點目錄:
    <pre>[DEFAULT]

...
bind_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
bind_port = 6001
user = swift
swift_dir = /etc/swift
devices = /srv/node</pre>
MANAGEMENT_INTERFACE_IP_ADDRESS爲object節點在management網絡中的IP地址,object1爲10.10.10.14,object2爲10.10.10.15。

[pipeline:main]部分,啓用合適的模塊:
<pre>[pipeline:main]
pipeline = healthcheck recon container-server
</pre>

[filter:recon]部分,設定recon(metrics)cache目錄:
<pre>[filter:recon]
...
recon_cache_path = /var/cache/swift
</pre>

  1. 編輯# vi /etc/swift/object-server.conf文件:

    [DEFAULT]部分,設定bind IP地址,bind port,用戶,配置文件目錄和掛載點目錄:
    <pre>[DEFAULT]

...
bind_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
bind_port = 6000
user = swift
swift_dir = /etc/swift
devices = /srv/node</pre>
MANAGEMENT_INTERFACE_IP_ADDRESS爲object節點在management網絡中的IP地址,object1爲10.10.10.14,object2爲10.10.10.15。

[pipeline:main]部分,啓用合適的模塊:
<pre>[pipeline:main]
pipeline = healthcheck recon object-server
</pre>

[filter:recon]部分,設定recon(metrics)cache目錄:
<pre>[filter:recon]
...
recon_cache_path = /var/cache/swift
</pre>

  1. 確保掛載點目錄結構的權限正確:

# chown -R swift:swift /srv/node

  1. 建立recon目錄,並確保權限正確:

# mkdir -p /var/cache/swift
# chown -R swift:swift /var/cache/swift

相關文章
相關標籤/搜索