Swift安装

Server1

1.Update
sudo apt-get update
sudo apt-get upgrade

2.
sudo apt-get install bridge-utils

3.IP
3.1
sudo vi /etc/network/interfaces
----------------------------------------------
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.75.110
netmask 255.255.255.0
broadcast 192.168.75.255
gateway 192.168.75.2
dns-nameservers 192.168.75.2

auto eth1
iface eth1 inet static
address 192.168.4.1
netmask 255.255.255.0
network 192.168.4.0
broadcast 192.168.4.255
3.2
sudo /etc/init.d/networking restart

4.NTP Server
4.1
sudo apt-get install ntp

4.2
sudo vi /etc/ntp.conf

--------------------------------
server ntp.ubuntu.com
server 127.127.1.0
fudge 127.127.1.0 stratum 10

4.3
sudo service ntp restart

5.database
5.1
sudo apt-get install mysql-server python-mysqldb

设置密码:gis

5.2
sudo vi /etc/mysql/my.cnf

-------------------------------------
bind-address = 0.0.0.0

5.3
sudo restart mysql

sudo mysql -u root -p
use mysql

select host, user, password from user;
    delete from user where user=‘root‘ and host=‘localhost‘;
    delete from user where user=‘root‘ and host=‘::1‘;
    delete from user where user=‘root‘ and host=‘127.0.0.1‘;
    delete from user where user=‘‘;
    update user set host=‘%‘ where user=‘root‘;
    commit;
sudo restart mysql

5.4
sudo mysql -u root -p -e ‘CREATE DATABASE keystone;‘

5.5
sudo mysql -u root -p -e ‘CREATE USER keystone;‘

5.6
sudo mysql -u root -p -e "GRANT ALL PRIVILEGES ON keystone.* TO ‘keystone‘@‘%‘;"
sudo mysql -u root -p -e "GRANT ALL PRIVILEGES ON keystone.* TO ‘keystone‘@‘localhost‘"

5.7
sudo mysql -u root -p -e "SET PASSWORD FOR ‘keystone‘@‘%‘ = PASSWORD(‘gis‘);"

6.
sudo apt-get install keystone

6.1
sudo rm /var/lib/keystone/keystone.db

6.2
sudo vi /etc/keystone/keystone.conf

bind_host = 0.0.0.0
public_port = 5000
admin_port = 35357
admin_token = 012345SECRET99TOKEN012345
compute_port = 8774
verbose = True
debug = True
log_config = /etc/keystone/logging.conf
use_syslog = False

connection = mysql://keystone:[email protected]/keystone

6.3
sudo keystone-manage pki_setup

sudo chown -R keystone:keystone /etc/keystone/

sudo chmod g+rx,o+rx -R /etc/keystone/

sudo chmod -R g+rwx,o+rwx /var/log/keystone/

6.4
sudo service keystone restart

6.5
sudo keystone-manage db_sync

7 identity
7.1
export OS_SERVICE_TOKEN=012345SECRET99TOKEN012345
export OS_SERVICE_ENDPOINT=http://192.168.75.110:35357/v2.0

keystone tenant-create --name demo --description "Default Tenant"

+-------------+----------------------------------+
|   Property    |              Value                              |
+-------------+----------------------------------+
| description  |          Default Tenant                  |
|   enabled     |               True                               |
|      id            | 3b440084158a42c0917603e066261aaf |
|     name       |               demo                             |
+-------------+----------------------------------+

keystone user-create --tenant-id 3b440084158a42c0917603e066261aaf --name admin --pass secrete

+----------+----------------------------------+
| Property  |              Value                             |
+----------+----------------------------------+
|  email      |                                                     |
| enabled   |               True                              |
|    id          | d99081655e834ded8abea8e6f6e111bb |
|   name     |              admin                            |
| tenantId  | 3b440084158a42c0917603e066261aaf |
+----------+----------------------------------+

keystone role-create --name admin

+----------+----------------------------------+
| Property  |              Value                             |
+----------+----------------------------------+
|    id          | c55516c9bcae400bad38b96e98e35279 |
|   name     |              admin                           |
+----------+----------------------------------+

keystone user-role-add --user-id d99081655e834ded8abea8e6f6e111bb --tenant-id 3b440084158a42c0917603e066261aaf --role-id c55516c9bcae400bad38b96e98e35279

7.2

keystone tenant-create --name service --description "Service Tenant"

+-------------+----------------------------------+
|   Property     |              Value                            |
+-------------+----------------------------------+
| description  |          Service Tenant                  |
|   enabled     |               True                              |
|      id             | d5f00c8160b94fc5acdf2f2a79d790dc |
|     name       |             service                             |
+-------------+----------------------------------+

keystone user-create --tenant-id d5f00c8160b94fc5acdf2f2a79d790dc --name glance --pass glance

+----------+----------------------------------+
| Property  |              Value                             |
+----------+----------------------------------+
|  email      |                                                    |
| enabled  |               True                              |
|    id          | 2d16d19937fd4f3eba46a48d0a5d1c90 |
|   name    |              glance                            |
| tenantId | d5f00c8160b94fc5acdf2f2a79d790dc |
+----------+----------------------------------+

keystone user-role-add --user-id 2d16d19937fd4f3eba46a48d0a5d1c90 --tenant-id d5f00c8160b94fc5acdf2f2a79d790dc --role-id c55516c9bcae400bad38b96e98e35279

keystone user-create --tenant-id d5f00c8160b94fc5acdf2f2a79d790dc --name ec2 --pass ec2

+----------+----------------------------------+
| Property  |              Value                             |
+----------+----------------------------------+
|  email      |                                                    |
| enabled   |               True                             |
|    id          | 2782536bd49a4802a575301ccdb44324 |
|   name     |               ec2                               |
| tenantId  | d5f00c8160b94fc5acdf2f2a79d790dc |
+----------+----------------------------------+

keystone user-role-add --user-id 2782536bd49a4802a575301ccdb44324 --tenant-id d5f00c8160b94fc5acdf2f2a79d790dc --role-id c55516c9bcae400bad38b96e98e35279

keystone user-create --tenant-id d5f00c8160b94fc5acdf2f2a79d790dc --name swift --pass swiftpass

+----------+----------------------------------+
| Property  |              Value                             |
+----------+----------------------------------+
|  email      |                                                     |
| enabled  |               True                               |
|    id          | cdee582c005745808f064ceea1e20953 |
|   name    |              swift                                |
| tenantId | d5f00c8160b94fc5acdf2f2a79d790dc |
+----------+----------------------------------+

keystone user-role-add --user-id cdee582c005745808f064ceea1e20953 --tenant-id d5f00c8160b94fc5acdf2f2a79d790dc --role-id c55516c9bcae400bad38b96e98e35279

7.3

keystone service-create --name=keystone --type=identity --description="Identity Service"

+-------------+----------------------------------+
|   Property    |              Value                             |
+-------------+----------------------------------+
| description  |         Identity Service                  |
|      id             | c697cfd78fa14b8eaf296af2569b711c |
|     name       |             keystone                        |
|     type          |             identity                          |
+-------------+----------------------------------+

keystone endpoint-create --region RegionOne --service-id=c697cfd78fa14b8eaf296af2569b711c --publicurl=http://192.168.75.110:5000/v2.0 \
--internalurl=http://192.168.75.110:5000/v2.0 \
--adminurl=http://192.168.75.110:35357/v2.0

+-------------+----------------------------------+
|   Property    |              Value                              |
+-------------+----------------------------------+
|   adminurl   | http://192.168.75.110:35357/v2.0 |
|      id            | 6a32df6c6c714e30a9830cfe39e8d64f |
| internalurl   | http://192.168.75.110:5000/v2.0  |
|  publicurl     | http://192.168.75.110:5000/v2.0  |
|    region       |            RegionOne             |
|  service_id    | c697cfd78fa14b8eaf296af2569b711c |
+-------------+----------------------------------+

keystone service-create --name=ec2 --type=ec2 --description="EC2 Compatibility Layer"

+-------------+----------------------------------+
|   Property    |              Value                             |
+-------------+----------------------------------+
| description  |     EC2 Compatibility Layer        |
|      id             | 528b19e43cec466192c770c26d3a73a3 |
|     name       |               ec2                                |
|     type         |               ec2                                |
+-------------+----------------------------------+

keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.75.110:35357/v2.0/ \
endpoint-create --region RegionOne --service-id=528b19e43cec466192c770c26d3a73a3 --publicurl=http://192.168.75.110:8773/services/Cloud \
--internalurl=http://192.168.75.110:8773/services/Cloud \
--adminurl=http://192.168.75.110:8773/services/Admin

+-------------+-------------------------------------------+
|   Property    |                   Value                   |
+-------------+-------------------------------------------+
|   adminurl   | http://192.168.75.110:8773/services/Admin |
|      id            |      64007630d09c450a8418985c98dbcd07     |
| internalurl   | http://192.168.75.110:8773/services/Cloud |
|  publicurl     | http://192.168.75.110:8773/services/Cloud |
|    region       |                 RegionOne                 |
|  service_id    |      528b19e43cec466192c770c26d3a73a3     |
+-------------+-------------------------------------------+

keystone service-create --name=swift --type=object-store --description="Object Storage Service"

+-------------+----------------------------------+
|   Property    |              Value               |
+-------------+----------------------------------+
| description  |      Object Storage Service      |
|      id            | b162fbd8a371465bba07b9c0ea3f9c32 |
|     name       |              swift               |
|     type          |           object-store           |
+-------------+----------------------------------+

 keystone endpoint-create --region RegionOne --service-id=b162fbd8a371465bba07b9c0ea3f9c32 --publicurl ‘http://192.168.75.110:8888/v1/AUTH_%(tenant_id)s‘ --adminurl ‘http://192.168.75.110:8888/v1‘ --internalurl ‘http://192.168.75.110:8888/v1/AUTH_%(tenant_id)s‘

+-------------+--------------------------------------------------+
|   Property    |                      Value                       |
+-------------+--------------------------------------------------+
|   adminurl   |          http://192.168.75.110:8888/v1           |
|      id            |         5eb5295ee08d4967838f2b8f3fd44939         |
| internalurl   | http://192.168.75.110:8888/v1/AUTH_%(tenant_id)s |
|  publicurl     | http://192.168.75.110:8888/v1/AUTH_%(tenant_id)s |
|    region       |                    RegionOne                     |
|  service_id    |         b162fbd8a371465bba07b9c0ea3f9c32         |
+-------------+--------------------------------------------------+

8.
unset OS_SERVICE_TOKEN
unset OS_SERVICE_ENDPOINT

9.
keystone --os-auth-url=http://192.168.75.110:35357/v2.0 token-get

keystone --os-username=admin --os-password=secrete --os-auth-url=http://192.168.75.110:35357/v2.0 token-get

keystone --os-username=admin --os-password=secrete --os-tenant-name=demo --os-auth-url=http://192.168.75.110:35357/v2.0 token-get

keystone --os-username=admin --os-password=secrete --os-auth-url=http://192.168.75.110:35357/v2.0 token-get

keystone --os-username=admin --os-password=secrete --os-tenant-name=service  --os-auth-url=http://192.168.75.110:35357/v2.0 token-get

11.
vi keystonerc

export OS_USERNAME=swift
export OS_PASSWORD=swiftpass
export OS_TENANT_NAME=service
export OS_AUTH_URL=http://192.168.75.110:35357/v2.0
export OS_REGION_NAME=RegionOne
export OS_SERVICE_TOKEN=012345SECRET99TOKEN012345
export OS_SERVICE_ENDPOINT=http://192.168.75.110:35357/v2.0

export OS_USERNAME=admin
export OS_PASSWORD=secrete
export OS_TENANT_NAME=demo
export OS_AUTH_URL=http://192.168.75.110:35357/v2.0

source keystonerc

12.
keystone user-list
keystone role-list

-------------------------------------Server1, Server2, Server3, Server4----------------------------------------------------

1.安装SSH和Swift的核心包

sudo apt-get install swift openssh-server rsync memcached python-netifaces python-xattr python-memcache

2.在所有节点上创创建配置文件目录

sudo mkdir -p /etc/swift
sudo chown -R swift:swift /etc/swift/

3. 在所有节点上创创建swift配置文件(/etc/swift/swift.conf)
sudo vi /etc/swift/swift.conf

[swift-hash]
# random unique string that can never change (DO NOT LOSE)
swift_hash_path_suffix = fLIbertYgibbitZ

sudo chown -R swift:swift /etc/swift/

------------------------------------Server 2, Server 3, Server 4-----------------------------------------------------------

1.在所有存贮节点上安装Swift包

sudo apt-get install swift-account swift-container swift-object xfsprogs

2. 建立XFS文件系统存贮

sudo fdisk /dev/sdb        //#然后一次选择 n, p, 1, 默认, 默认, w

sudo mkfs.xfs -f -i size=1024 /dev/sdb1
(   命令格式:   sudo mkfs -t ext3 /dev/sdb1   )

sudo mkdir -p /srv/node/sdb1

sudo echo "/dev/sdb1 /srv/node/sdb1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab

sudo mount /srv/node/sdb1

sudo chown -R swift:swift /srv/node

3. 创建数据同步配置文件(/etc/rsyncd.conf)

sudo vi /etc/rsyncd.conf

uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 192.168.4.2   或   192.168.4.3    或   192.168.4.4

[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

4.启用系统同步
sudo vi /etc/default/rsync

RSYNC_ENABLE = true

sudo service rsync start

5.创建目录
sudo mkdir -p /var/swift/recon

sudo chown -R swift:swift /var/swift/recon

---------------------------------------------------Server 1----------------------------------------------------------

1.安装swift-proxy节点包

sudo apt-get install swift-proxy memcached python-keystoneclient python-swiftclient python-webob

2.生成SSL认证文件

cd /etc/swift
sudo openssl req -new -x509 -nodes -out cert.crt -keyout cert.key

3.修改缓存配置文件

sudo vi /etc/memcached.conf
将
-l 127.0.0.1
改为
-l 192.168.4.1

4.重启缓存服务
sudo service memcached restart

5.修改swift-proxy缓存配置文件
sudo vi /etc/swift/proxy-server.conf

[DEFAULT]
cert_file = /etc/swift/cert.crt
key_file = /etc/swift/cert.key
bind_port = 8888
user = swift

[pipeline:main]
pipeline = healthcheck cache authtoken keystoneauth proxy-server

[app:proxy-server]
use = egg:swift#proxy
allow_account_management = true
account_autocreate = true

[filter:keystoneauth]
use = egg:swift#keystoneauth
operator_roles = Member,admin,swiftoperator

[filter:authtoken]
paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory

# Delaying the auth decision is required to support token-less
# usage for anonymous referrers (‘.r:*‘).
delay_auth_decision = true

# cache directory for signing certificate
signing_dir = /home/swift/keystone-signing

# auth_* settings refer to the Keystone server
auth_protocol = http
auth_host = 192.168.75.110
auth_port = 35357

# the same admin_token as provided in keystone.conf
admin_token = 012345SECRET99TOKEN012345

# the service tenant and swift userid and password created in Keystone
admin_tenant_name = service
admin_user = swift
admin_password = swiftpass

[filter:cache]
use = egg:swift#memcache
memcache_servers = 192.168.75.110:11211

[filter:catch_errors]
use = egg:swift#catch_errors

[filter:healthcheck]
use = egg:swift#healthcheck

6. 创建swift的认证目录

sudo mkdir -p /home/swift/keystone-signing
sudo chown -R swift:swift /home/swift/keystone-signing

7.创建account, container, object的ring

cd /etc/swift
sudo swift-ring-builder account.builder create 18 3 24
sudo swift-ring-builder container.builder create 18 3 24
sudo swift-ring-builder object.builder create 18 3 24

8. 将存贮实体加入到环中

sudo swift-ring-builder account.builder add z1-192.168.4.2:6002/sdb1 100
sudo swift-ring-builder container.builder add z1-192.168.4.2:6001/sdb1 100
sudo swift-ring-builder object.builder add z1-192.168.4.2:6000/sdb1 100

sudo swift-ring-builder account.builder add z2-192.168.4.3:6002/sdb1 100
sudo swift-ring-builder container.builder add z2-192.168.4.3:6001/sdb1 100
sudo swift-ring-builder object.builder add z2-192.168.4.3:6000/sdb1 100

sudo swift-ring-builder account.builder add z3-192.168.4.4:6002/sdb1 100
sudo swift-ring-builder container.builder add z3-192.168.4.4:6001/sdb1 100
sudo swift-ring-builder object.builder add z3-192.168.4.4:6000/sdb1 100

9. 查看各个环
sudo swift-ring-builder account.builder
sudo swift-ring-builder container.builder
sudo swift-ring-builder object.builder

10. 平衡各个环
sudo  swift-ring-builder account.builder rebalance
sudo  swift-ring-builder container.builder rebalance
sudo  swift-ring-builder object.builder rebalance

11. 将生成的环信息复制到Proxy节点与Storage节点的/etc/swift目录下
account.ring.gz
container.ring.gz
object.ring.gz

sudo chown -R swift:swift /etc/swift

sudo chmod g+rw,o+rw -R /etc/swift/

 sudo scp account.ring.gz [email protected]192.168.75.111:/etc/swift
 sudo scp account.ring.gz [email protected]192.168.75.112:/etc/swift
 sudo scp account.ring.gz [email protected]192.168.75.113:/etc/swift

 sudo scp container.ring.gz [email protected]192.168.75.111:/etc/swift
 sudo scp container.ring.gz [email protected]192.168.75.112:/etc/swift
 sudo scp container.ring.gz [email protected]192.168.75.113:/etc/swift

 sudo scp object.ring.gz [email protected]192.168.75.111:/etc/swift
 sudo scp object.ring.gz [email protected]192.168.75.112:/etc/swift
 sudo scp object.ring.gz [email protected]192.168.75.113:/etc/swift

12. 将各个配置文件的用户改为swift

sudo chown -R swift:swift /etc/swift

13. 启动代理服务
sudo service proxy-server start
sudo swift-init proxy start (有效)

------------------------------------------Server 2, Server 3, Server 4-----------------------------------------------------------

14.启动存贮服务

sudo service swift-object start
sudo service swift-object-replicator start
sudo service swift-object-updater start
sudo service swift-object-auditor start
sudo service swift-container start
sudo service swift-container-replicator start
sudo service swift-container-updater start
sudo service swift-container-auditor start
sudo service swift-account start
sudo service swift-account-replicator start
sudo service swift-account-updater start
sudo service swift-account-auditor start

sudo swift-init all start (有效)
或

sudo swift-init object-server start
sudo swift-init object-replicator start
sudo swift-init object-updater start
sudo swift-init object-auditor start
sudo swift-init container-server start
sudo swift-init container-replicator start
sudo swift-init container-updater start
sudo swift-init container-auditor start
sudo swift-init account-server start
sudo swift-init account-replicator start
sudo swift-init account-auditor start

------------------------------------------Verify the Installation-------------------------------------------------------------
15.验证Swift安装
15.1设置变量
export ADMINPASS=swiftpass

export SWIFT_PROXY_CONF="/etc/swift/proxy-server.conf"

15.1验证
swift -V 2.0 -A http://192.168.75.110:5000/v2.0 -U service:swift -K swiftpass stat (有效)

curl -d ‘{"auth":{"tenantName": "service","passwordCredentials":{"username": "swift","password": "swiftpass"}}}‘ -H "Content-type:application/json" http://192.168.75.110:35357/v2.0/tokens  (有效)

{
    "access": {
        "token": {
            "issued_at": "2013-07-20T02:20:19.836225",
            "expires": "2013-07-21T02:20:19Z",
            "id": "MIIHHAYJ.....",
            "tenant": {
                "description": "Service Tenant",
                "enabled": true,
                "id": "5e3af2dac2d1451ba90c4f151a40a463",
                "name": "service"
            }
        },
        "serviceCatalog": [
            {
                "endpoints": [
                    {
                        "adminURL": "http://192.168.75.110:8888/v1",
                        "region": "RegionOne",
                        "internalURL": "http://192.168.75.110:8888/v1/AUTH_5e3af2dac2d1451ba90c4f151a40a463",
                        "id": "944b056c8ea44f4bb2f85f350fc6d749",
                        "publicURL": "http://192.168.75.110:8888/v1/AUTH_5e3af2dac2d1451ba90c4f151a40a463"
                    }
                ],
                "endpoints_links": [],
                "type": "object-store",
                "name": "swift"
            },
            {
                "endpoints": [
                    {
                        "adminURL": "http://192.168.75.110:8773/services/Admin",
                        "region": "RegionOne",
                        "internalURL": "http://192.168.75.110:8773/services/Cloud",
                        "id": "14c95395690d4d5393ad91c4c9ce0191",
                        "publicURL": "http://192.168.75.110:8773/services/Cloud"
                    }
                ],
                "endpoints_links": [],
                "type": "ec2",
                "name": "ec2"
            },
            {
                "endpoints": [
                    {
                        "adminURL": "http://192.168.75.110:35357/v2.0",
                        "region": "RegionOne",
                        "internalURL": "http://192.168.75.110:5000/v2.0",
                        "id": "2c48f04762304a46ae6ae2bacfa0d91a",
                        "publicURL": "http://192.168.75.110:5000/v2.0"
                    }
                ],
                "endpoints_links": [],
                "type": "identity",
                "name": "keystone"
            }
        ],
        "user": {
            "username": "swift",
            "roles_links": [],
            "id": "eef77f25cf8b4563bffbcb4d9a6091bc",
            "roles": [
                {
                    "name": "_member_"
                },
                {
                    "name": "admin"
                }
            ],
            "name": "swift"
        },
        "metadata": {
            "is_admin": 0,
            "roles": [
                "9fe2ff9ee4384b1894a90878d3e92bab",
                "76f281288ce7401bbb5472f17e7197ec"
            ]
        }
    }
}

swift -A http://192.168.75.110:5000/v2.0 -U service:swift -K swiftpass upload myfiles bigfile1.tgz

15.3上传文件
swift upload myfiles bigfile1.tgz  (有效)

swift -V 2.0 -A http://192.168.75.110:5000/v2.0 -U service:swift -K swiftpass stat (有效)

15.4下载文件

swift -A http://192.168.75.110:5000/v2.0 -U service:swift -K swiftpass download myfiles

swift download myfiles  (有效)

http://blog.csdn.net/gjhnorth/article/details/9036869

------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
http://www.openstack.org.cn/ask/?q-24.html
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Swift多节点安装

安装环境:
Proxy Node:192.168.5.152
Storage Node1:192.168.5.155
Storage Node1:192.168.5.156
Storage Node1:192.168.5.157

一、 安装配置存储节点(Storage Node)
在192.168.5.155存储节点上进行操作,其他存储节点操作内容相同

1、 安装需要的软件包

apt-get update

apt-get install swift swift-account swift-container swift-object swift-doc xfsprogs

2、 创建loopback设备(假设为sdb1)分出一个分区然后格式化

fdisk /dev/sdb

mkfs.xfs -i size=1024 /dev/sdb1

上面的方法是官方文档上的方法,也是推荐的方法,我使用的是创建回环设备来存
   dd if=/dev/zero of=/srv/swift-node bs=1024 count=0 seek=1000000
   mkfs.xfs -i size=1024 /srv/swift-node

3、 更新fstab文件

cat >> /etc/fstab <<EOF

/dev/sdb1 /swift/node/sdb1 xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0
/dev/sdc1 /swift/node/sdc1 xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0
/dev/sdd1 /swift/node/sdd1 xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0
/dev/sde1 /swift/node/sde1 xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0
EOF

4、 挂载

mkdir -p /swift/node/sdb1
mkdir -p /swift/node/sdc1
mkdir -p /swift/node/sdd1
mkdir -p /swift/node/sde1

mount /swift/node/sdb1
mount /swift/node/sdc1
mount /swift/node/sdd1
mount /swift/node/sde1

chown -R swift:swift /swift 注意 没有赋权限,会导致创建失败

5、 创建swift的配置文件

cat >/etc/swift/swift.conf <<EOF

[swift-hash]

# random unique string that can never change (DO NOT LOSE)

swift_hash_path_suffix = `od -t x8 -N 8 -A n </dev/random`

EOF

Note: 这个文件所有的存储节点和代理节点共用,可以用scp拷贝到其它节点

6、 安装rsync

apt-get install rsync

7、 创建rsync配置文件

cat > /etc/rsyncd.conf << EOF
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 192.168.5.155

[account]
max connections = 2
path = /swift/node
read only = false
lock file = /var/lock/account.lock

[container]
max connections = 2
path = /swift/node
read only = false
lock file = /var/lock/container.lock

[object]
max connections = 2
path = /swift/node
read only = false
lock file = /var/lock/object.lock

EOF
注意:path 写你实际的(刚才新建的)分区的位置。address修改为当前storage的地址。

8、 启用rsync

perl -pi -e ‘s/RSYNC_ENABLE=false/RSYNC_ENABLE=true/‘ /etc/default/rsync

9、 启动rsync

service rsync start

10、 配置account服务

cat > /etc/swift/account-server.conf << EOF
[DEFAULT]

devices = /swift/node

mount_check = false

bind_ip = 0.0.0.0

bind_port = 6012

workers = 2

log_facility = LOG_LOCAL3

[pipeline:main]

pipeline = account-server

[app:account-server]

use = egg:swift#account

[account-replicator]

[account-auditor]

[account-reaper]

EOF

11、 配置container服务

cat > /etc/swift/container-server.conf << EOF
[DEFAULT]

devices = /swift/node

mount_check = false

bind_ip = 0.0.0.0

bind_port = 6011

workers = 2

log_facility = LOG_LOCAL2

[pipeline:main]

pipeline = container-server

[app:container-server]

use = egg:swift#container

[container-replicator]

[container-updater]

[container-auditor]

[container-sync]

EOF

12、 配置object服务

cat > /etc/swift/object-server.conf << EOF
[DEFAULT]

devices = /swift/node/

mount_check = false

bind_ip = 0.0.0.0

bind_port = 6010

workers = 2

log_facility = LOG_LOCAL1

[pipeline:main]

pipeline = object-server

[app:object-server]

use = egg:swift#object

[object-replicator]

[object-updater]

[object-auditor]

[object-expirer]

EOF

13、 创建swift日志配置文件

cat > /etc/rsyslog.d/10-swift.conf << EOF

local1,local2,local3.*   /var/log/swift/all.log

local1.*   /var/log/swift/object.log

local2.*   /var/log/swift/container.log

local3.*   /var/log/swift/account.log

EOF

14、 创建日志目录

mkdir -p /var/log/swift

chown -R syslog.adm /var/log/swift

15、 重启日志服务进程

service rsyslog restart

二、 安装配置代理节点(Proxy Node)

1、 安装需要的软件包

apt-get update

apt-get install swift swift-proxy swift-doc memcached

2、 修改memcached配置文件

perl -pi -e "s/-l 127.0.0.1/-l 192.168.5.152/" /etc/memcached.conf

3、 重启memcached服务

service memcached restart

4、 从存储节点拷贝swift配置文件

mkdir /etc/swift

scp [email protected]192.168.5.155:/etc/swift/swift.conf /etc/swift

5、 创建proxy-server配置文件
--------------------------tempauth认证------------------------------------------------
cat > /etc/swift/proxy-server.conf << EOF
[DEFAULT]
bind_port =8080
bind_ip = 192.168.5.152
user = swift

[pipeline:main]
pipeline = healthcheck cache tempauth proxy-server

[app:proxy-server]
use = egg:swift#proxy
allow_account_management = true
account_autocreate = true

[filter:tempauth]
use = egg:swift#tempauth
user_admin_admin = admin .admin .reseller_admin
user_test_tester = testing .admin
user_test2_tester2 = testing2 .admin
user_test_tester3 = testing3

[filter:healthcheck]
use = egg:swift#healthcheck

[filter:cache]
use = egg:swift#memcache
memcache_servers = 192.168.5.152:11211
EOF

-----------------------------keystone认证----------------------------------------------------------
cat > /etc/swift/proxy-server.conf << EOF
[DEFAULT]
bind_port = 8080
bind_ip = 192.168.5.152
user = swift
log_level = DEBUG
log_facility = LOG_LOCAL1

[pipeline:main]
pipeline = healthcheck cache authtoken keystone proxy-server

[app:proxy-server]
use = egg:swift#proxy
allow_account_management = true
account_autocreate = true

[filter:keystone]
paste.filter_factory = keystone.middleware.swift_auth:filter_factory
operator_roles = admin, swiftoperator

[filter:authtoken]
paste.filter_factory = keystone.middleware.auth_token:filter_factory
delay_auth_decision = 1
auth_port = 35357
auth_host = 192.168.5.152
auth_protocol = http
service_protocol = http
service_host = 192.168.5.152
service_port = 5000
admin_tenant_name = service
admin_user = swift
admin_password = 12345678

[filter:healthcheck]
use = egg:swift#healthcheck

[filter:cache]
use = egg:swift#memcache
memcache_servers = 192.168.5.152:11211
EOF

6、 创建swift日志配置文件

cat > /etc/rsyslog.d/10-swift.conf << EOF

local1.*   /var/log/swift/proxy.log

EOF

7、 创建日志目录

mkdir -p /var/log/swift

chown -R syslo.adm /var/log/swift

8、 重启日志服务进程

service rsyslog restart

9、 首先创建环

cd /etc/swift

swift-ring-builder account.builder create 18 3 1

swift-ring-builder container.builder create 18 3 1

swift-ring-builder object.builder create 18 3 1

Note: 后面的数字第一个为存储分区数,第二个为备份次数,备份次数不能小于ZONE数目,第三个为延迟删除的时间,以小时为单位

10、向环里添加存储设备我前面配置了三台存储节点:

|---------+------+-----------+-----------+------+--------|

| Storage | Zone |        IP | Server    | Port | Device |

|---------+------+-----------+-----------+------+--------|

|       1 |    1 |192.168.5.155| account   | 6012 | sdb1 |

|         |      |           | container | 6011 | sdb1   |

|         |      |           | object    | 6010 | sdb1   |

|---------+------+-----------+-----------+------+--------|

|       2 |    2 |192.168.5.156 | account   | 6012 | sdb1 |

|         |      |           | container | 6011 | sdb1   |

|         |      |           | object    | 6010 | sdb1   |

|---------+------+-----------+-----------+------+--------|

|       3 |    3 |192.168.5.157 | account   | 6012 | sdb1  |

|         |      |           | container | 6011 | sdb1   |

|         |      |           | object    | 6010 | sdb1   |
|---------+------+-----------+-----------+------+--------|

cd /etc/swift

swift-ring-builder account.builder add z1-192.168.5.155:6012/sdb1 100

swift-ring-builder container.builder add z1-192.168.5.155:6011/sdb1 100

swift-ring-builder object.builder add z1-192.168.5.155:6010/sdb1 100

swift-ring-builder account.builder add z2-192.168.5.156:6012/sdb1 100

swift-ring-builder container.builder add z2-192.168.5.156:6011/sdb1 100

swift-ring-builder object.builder add z2-192.168.5.156:6010/sdb1 100

swift-ring-builder account.builder add z3-192.168.5.157:6012/sdb1 100

swift-ring-builder container.builder add z3-192.168.5.157:6011/sdb1 100

swift-ring-builder object.builder add z3-192.168.5.157:6010/sdb1 100

Note: IP,端口,设备和前面的配置对应

11、 检验每个环里的条目

cd /etc/swift

swift-ring-builder account.builder

swift-ring-builder container.builder

swift-ring-builder object.builder

应该得到类似这样的输出

account.builder, build version 3
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
The minimum number of hours before a partition can be reassigned is 1
Devices:    id  zone      ip address  port      name weight partitions balance meta
            0     1   192.168.5.155  6012      sdb1 100.00     262144    0.00
            1     2   192.168.5.156  6012      sdb1 100.00     262144    0.00
            2     3   192.168.5.157  6012      sdb1 100.00     262144    0.00

14、 平衡环

cd /etc/swift

swift-ring-builder account.builder rebalance

swift-ring-builder container.builder rebalance

swift-ring-builder object.builder rebalance

Note: 这个过程可能需要一些时间

Note: 这三条命令会产生以gz结尾的文件,这些文件就是所有节点要用到的环文件,可以用scp拷贝到其它各节点

Note: 如果创建环的时候指定的副本数大于环的数量,平衡环的时候可能会报类似下面的错误

... in _initial_balance

   while available_devs[index][‘zone‘] in other_zones:

IndexError: list index out of range

15、 分发新生成的环文件

scp /etc/swift/*.gz [email protected]:/etc/swift/

scp /etc/swift/*.gz [email protected]:/etc/swift/

scp /etc/swift/*.gz [email protected]:/etc/swift/

16、 启动各节点相关的服务

# 代理节点

swift-init proxy start

# 存储节点

swift-init all start

三、测试swift

1、得到an X-Storage-Url 和X-Auth-Token
[email protected]:/etc/swift# curl -v -H ‘X-Storage-User: test:tester‘ -H ‘X-Storage-Pass: testing‘ http://192.168.5.152:8080/auth/v1.0
* About to connect() to 192.168.5.152 port 8080 (#0)
*   Trying 192.168.5.152... connected
> GET /auth/v1.0 HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: 192.168.5.152:8080
> Accept: */*
> X-Storage-User: test:tester
> X-Storage-Pass: testing
>
< HTTP/1.1 200 OK
< X-Storage-Url: http://192.168.5.152:8080/v1/AUTH_test
< X-Storage-Token: AUTH_tk51644b8e782040f6ab788caa23ad6a1b
< X-Auth-Token: AUTH_tk51644b8e782040f6ab788caa23ad6a1b
< Content-Length: 0
< Date: Thu, 11 Oct 2012 07:47:53 GMT
<
* Connection #0 to host 192.168.5.152 left intact
* Closing connection #0

[email protected]:/etc/swift# curl -v -H ‘X-Auth-Token: AUTH_tk51644b8e782040f6ab788caa23ad6a1b‘ http://192.168.5.152:8080/v1/AUTH_test
* About to connect() to 192.168.5.152 port 8080 (#0)
*   Trying 192.168.5.152... connected
> GET /v1/AUTH_test HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: 192.168.5.152:8080
> Accept: */*
> X-Auth-Token: AUTH_tk51644b8e782040f6ab788caa23ad6a1b
>
< HTTP/1.1 204 No Content
< X-Account-Object-Count: 0
< X-Account-Bytes-Used: 0
< X-Account-Container-Count: 0
< Accept-Ranges: bytes
< Content-Length: 0
< Date: Thu, 11 Oct 2012 07:48:24 GMT
<
* Connection #0 to host 192.168.5.152 left intact
* Closing connection #0

测试swift目前工作状态
swift -A http://192.168.5.152:8080/auth/v1.0 -U test:tester -K testing stat

将当前目录下test.txt文件上传到myfiles目录
swift -A http://192.168.5.152:8080/auth/v1.0 -U test:tester -K testing upload myfiles test.txt
时间: 2024-11-08 08:47:21

Swift安装的相关文章

OpenStack swift安装

由于实验室项目需要云存储系统,因此在实验室服务器上搭建一个基于OpenStack swift的云存储系统. 最开始按照官方网站上介绍的方法,使用SAIO方式安装http://docs.openstack.org/developer/swift/development_saio.html,但是中间经常安装到最后,测试的时候,认证不成功,而且安装的过程比较繁琐,于是采用了git的安装方式git clone https://github.com/NewpTone/SAIO.git,将SAIO下载来之后

openstack学习笔记七 swift安装

项目--对象存储--容器            在容器里你创建的即使是一个文件夹,那么体现在硬盘里,也是一个文件,也就是对象object [[email protected] ~(keystone_admin)]# openstack service list +----------------------------------+------------+--------------+ | ID                               | Name       | Type

OpenStack之swift安装笔记

在顺利的安装部署了KeyStone之后,原以为swift的安装调试也会如KeyStone一般,但过程却充满了坎坷,在结合源代码中的一些函数之后,终于成功的完成了swift的安装,并实验了上传下载文件等功能,下面整理了swift的安装过程,并对遇到的问题进行了总结,希望对遇到同样问题的人有些启示或帮助.安装过程依然参考的是OpenStack的官方安装手册,但补充了一些细节.在安装之前,先简单的介绍一下Swift是什么.主要功能是什么.OpenStack的对象存储(Swift)是一个多租户的.高可扩

(九)OpenStack---M版---双节点搭建---Swift安装和配置

↓↓↓↓↓↓↓↓视频已上线B站↓↓↓↓↓↓↓↓ >>>>>>传送门 本次搭建仅采用Compute单节点做swift组件 1.Controller安装并配置控制节点 2.Compute安装和配置存储节点 3.Compute节点安装并配置组件 4.Controller节点创建,分发并初始化rings 5.启动服务 6.Controller执行验证操作 1.Controller安装并配置控制节点 1.获得凭证并创建身份认证服务的凭证 # . /root/admin-openr

openstack成长之旅 - 5 Swift介绍安装及作者的反思

这么长时间没有更新博客了,哎,之前都是用Ubuntu物理机搭建的openstack,但是最近用自己的centos虚拟机搭建的时候总是报错,一些基本的东西,频频出错,对此很是无奈啊,看来我的能力还是有待提升了,虽说虚拟机搭建openstack会有一些问题,但是也没有我的这么夸张吧,所以我决定,最近一段时间内要闭关修炼了,一定要能在任何环境中熟练操作openstack,希望大家能持续关注我哦. 下面简单讲解下Swift这个在openstack中起到非常重要的存储组件吧. Swift是openstac

OpenStack Swift集群部署流程与简单使用

转载:http://www.cnblogs.com/fczjuever/p/3224022.html 之前介绍了<OpenStack Swift All In One安装部署流程与简单使用>,那么接下来就说一说Swift集群部署吧. 1. 简介 本文档详细描述了使用两台PC部署一个小型Swift集群的过程,并给出一些简单的使用实例.本文档假定如下前提条件: 使用Ubuntu操作系统. 每台机器都运行Swift的所有服务,既是Proxy Server,又是Storage Server,用户可以向

Swift 开源 Linux Ubuntu Install

Swift 开源了,它现在变成跨平台的了,开源后的 Swift 不止能运行在 MAC 和 iOS 平台,现在也可以运行在 Linux 平台了.swift.org 网站上面提供了在 Linux 上面安装 Swift 环境的完整指引.当前 Swift 支持 Ubuntu 15.10 和 Ubuntu 14.04 两个版本. 这里我使用Ubuntu 14.04,带领大家体验Linux 平台上的 Swift使用,感兴趣的同学感觉看过来:如果确实帮助到了你,记得投票点赞,让更多的的人看到,非常感谢: 工具

OpenStack安装与配置2

第二部分 OpenStack安装与配置 一.引言 本章内容讲解如何在3台物理机上搭建最小化云平台,这3台机器分为称为Server1.Server2和Client1,之后的各章也是如此.Server1承载着Nova.Glance.Swift.Keystone及Horizon(OpenStack的Web UI)服务.Server2只用来运行实例管理的nova运算工作站.由于OpenStack组件采用分布式结构,其中的任何一部分或几个部分都可以安装在任意服务器上. Client1并不是安装所必须的,在

openstack学习(七):swift配置以及使用

记录,方便查阅. 只做部分解释 Install and configure the controller node keystone user-create --name swift --pass swift keystone user-role-add --user swift --tenant service --role admin keystone service-create --name swift --type object-store --description "OpenSta