swift云存储部署

2019-07-20 作者:yzc216亚洲城   |   浏览(195)

0.环境

接上篇,swift-proxy和swift-store的安装

1.安装依赖库

先说一下服务器分配

2.准备磁盘

    swift-proxy和keystone部署在192.168.25.11

3.构建ring

    swift-store是两台  分别是192.168.25.12和192.168.25.13  (这是测试IP)

4.安装swift

先安装代理节点swift-proxy:

  • 4.1 apt-get install安装
  • 4.2源代码安装

    wget -c

5.更改配置文件

    rpm -ivh epel-release-6-8.noarch.rpm

6.启动服务  

    不要问我以上那个干吗用的  本来它是openstack的有关的包下载的地方,相当于一个镜像地址,但事实是它里面什么也没有但是这个环境还必须得安装,就这么简单粗暴,安装完成后在/etc/yum.repos.d/下会生成两个文件 epel.repo和epel-    testing.repo 但实际上epel-testing.repo这个文件并没有什么卵用。vim 到epel.repo文件里注销掉[epel]下的以mirror开头的那一行(#mirror。。。),打开http开头的那一行。然后在命令行执行yum  makecache就ok了。

0.环境

 

    操作系统:Ubuntu 12.04 LTS,swift版本:1.4.8。四台机器,IP地址分别为:

    192.168.1.11,

    192.168.1.12,

    192.168.1.13,

    192.168.1.14.

由于swift的全分布式特点,故每个节点都作为存储节点,并选用192.168.1.11作为proxy server。

磁盘分区如下:

图片 1

 

 

    yum install openstack-swift openstack-swift-proxy  openstack-swift-account openstack-swift-container   openstack-swift-object memcached 

1.安装依赖库

    所有节点都需要安装的:

 

 

python-netifaces

python-setuptools

python-eventlet

python-pastedeploy

python-xattr

xfsprogs

 

        以上软件包可以直接使用apt-get install来安装。一个比较特殊的包:python-webob。该包在ubuntu软件源中的版本是1.1.1(ubuntu12.04).而这个版本有个bug,会导致swift client使用HEAD无法正常的获取content-length。比如,获取文件尺寸,得到的结果永远是 13。解决方法是在ubuntu软件包网站下载1.0.8版本的deb安装包,然后手工安装。安装包我已经下载,见附件。

 

  安装以上包时会有N 多的依赖性,根据要求一一安装,但是坑爹的是好多需要的依赖性centos6.4里、没、有、然后找了N久找到一个下载地址  在这个地址里随便下载你需要的包吧!不收费!

2.准备磁盘

    选取某一个磁盘分区做存储,本例使用sda5.

   

 

 

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

在/etc/fstab中添加

    

 

 /dev/sda5 /srv/node/sda5 xfs noatime,nodiratime,nobarrier,logbufs=8   0   0

挂载磁盘分区

  

 

 

sudo mount /srv/node/sda5

 

    以上安装完成后,修改配置文件:/etc/swift/swift.conf

3.构建ring

    

 

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

        18: 用于指定分区数。分区数目为2的幂次,如18,则分区数是2的18次方。

        3:文件副本数目

        1:分区移动的最小时间间隔,单位是小时。

 

swift-ring-builder account.builder add z1-192.168.1.11:6002/sda5  100

swift-ring-builder account.builder add z2-192.168.1.12:6002/sda5  100

swift-ring-builder account.builder add z3-192.168.1.13:6002/sda5  100

swift-ring-builder account.builder add z4-192.168.1.14:6002/sda5  100

        100 代表设备的权重。可以根据磁盘的容量设定对应值,比如2T的100,则1T的可以是50。

 

    swift-ring-builder account.builder可以检测配置,确认无误后,使用swift-ring-builder account.builder rebalance重新平衡。成功之后会在当前目录生成 account.ring.gz 文件。

 

    使用同样的方式构建 container和object的ring。container服务端口是6001,object的服务端口是6000。特别需要注意的是:一旦ring投入使用,更改配置的时候要针对该ring,不能重新构建,否则,很多数据可能会404.

    最后将生成的account.ring.gz,container.ring.gz,object.ring.gz分发至各个节点的/etc/swift目录。 

图片 2

      [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`

    创建自签名证书

      cd /etc/swift

      openssl req -new -x509 -nodes -out cert.crt -keyout cert.key

    配置proxy-server:/etc/swift/proxy-server.conf  

      [DEFAULT]
      bind_port = 8080
      workers = 8
      user = swift

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

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

      [filter:cache]
      use = egg:swift#memcache
      memcache_servers = 192.168.25.12:11211
      set log_name = cache

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

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

      [filter:keystone]
      paste.filter_factory = keystone.middleware.swift_auth:filter_factory
      use = egg:swift#keystoneauth
      operator_roles = Menber,admin, SwiftOperator
      is_admin = true
      cache = swift.cache

      [filter:authtoken]
      paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory
      delay_auth_decision = 10
      service_port = 5000
      service_host = 127.0.0.1
      admin_tenant_name = service
      admin_user = swift
      admin_password = swift
      auth_host = 127.0.0.1
      auth_port = 35357
      auth_protocol = http
      auth_uri =
      auth_token = 89bbecb48e973be18dd7
      admin_token = 89bbecb48e973be18dd7
      signing_dir = /tmp/keystone-signing-swift

  创建 account, container, object rings   第二个参数为每个对象复制的个数

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

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

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

*
*  添加每个节点上的存储设备:

    swift-ring-builder account.builder add z1-192.168.25.12:6002/sdb1 100 (swift-ring-builder account.builder add z2-192.168.25.13:6002/sdb1 100)

    swift-ring-builder container.builder add z1-192.168.25.12:6001/sdb1 100

    swift-ring-builder object.builder add z1-192.168.25.12:6000/sdb1 100

*
*  检查每个ring中的内容

    swift-ring-builder account.builder

    swift-ring-builder container.builder

    swift-ring-builder object.builder

  重新平衡ring

    swift-ring-builder account.builder rebalance

    swift-ring-builder container.builder rebalance

    swift-ring-builder object.builder rebalance

  复制所有配置文件为swift用户所有

    chown -R swift:swift /etc/swift

  启动proxy服务(在存储节点服务启动之后再启动)

    swift-init  proxy start

下面安装存储节点,因为两台存储节点配置一样,所以只以192.168.25.12为例:

  同样没有包但是需要环境的epel的配置,雷同swift-proxy的配置

  yum install openstack-swift-account openstack-swift-container  openstack-swift-object xfsprogs(没有的包自己去

  创建虚拟磁盘:

    fdisk /dev/sdb=》创建虚拟磁盘sdb1

    mkfs.xfs  -i size=1024  /dev/sdb1  创建文件系统

    echo "/dev/sdb1  /srv/node/sdb1  xfs  noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab 添加到启动时自动挂载分区

    mkdir -p /srv/node/sdb1

    mount /dev/sdb1  /srv/node/sdb1  当然也可以执行mount -a  是/etc/fstab 生效

    chown -R swift:swift  /srv/node

  创建/etc/rsyncd.conf (rsync需要yum)

    uid = swift

    gid = swift

    log file = /var/log/rsyncd.log
    pid file = /var/run/rsyncd.pid
    address = 192.168.25.12
    [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

  在开启rsync服务之前需要拷贝swift-proxy中/etc/swift/下的swift.conf object.ring.gz container.ring.gz account.ring.gz 到存储节点的/etc/swift目录下。

  rsync --daemon --config=/etc/rsyncd.conf  开启rsync服务 

  创建三个配置文件:

    /etc/swift/account-server.conf

      [DEFAULT]
      bind_ip = 192.168.25.12
      bind_port = 6002
      workers = 2

      [pipeline:main]
      pipeline = account-server

      [app:account-server]
      use = egg:swift#account

      [account-replicator]

      [account-auditor]

      [account-reaper]

    /etc/swift/container-server.conf

      [DEFAULT]

      bind_ip = 192.168.25.12
      bind_port = 6001
      workers = 2

      [pipeline:main]
      pipeline = container-server

      [app:container-server]
      use = egg:swift#container

      [container-replicator]

      [container-updater]

      [container-auditor]

      [container-sync]

    /etc/swift/object-server.conf

      [DEFAULT]

      bind_ip = 192.168.25.12
      bind_port = 6000
      workers = 3

      [pipeline:main]
      pipeline = object-server

      [app:object-server]
      use = egg:swift#object

      [object-replicator]

      [object-updater]

      [object-auditor]

  开启storage服务

    swift-init object-server start

    swift-init object-replicator start

    swift-init object-updater start  

    swift-init object-auditor start

    swift-init container-server start    

    swift-init container-replicator start

    swift-init container-updater start

    swift-init container-auditor start

    swift-init account-server start  

     swift-init account-replicator start

    swift-init account-auditor start

以上是主节点和存储节点的配置

192.168.25.13的配置与12的配置相同  只是需要把account-server.conf container-server.conf object-server.conf 的ip改为本机ip即可

 

下面进行测试:

  在主节点上:swift -V 2.0 -A -U admin:admin -K 123456 stat

        swift -V 2.0 -A -U admin:admin -K 123456 upload myfile token 上传文件到存储节点,在/srv/node/sdb1/objects目录下

        swift -V 2.0 -A -U admin:admin -K 123456 download myfile token  可从存储节点下载文件

以上整个openstack  swift 云存储就部署完成了!

 

本文由yzc216亚洲城发布于yzc216亚洲城,转载请注明出处:swift云存储部署

关键词: yzc216亚洲城