Swift创建容器没多久就消失解决办法

昨天添加swift组件时遇到一个诡异的问题,就是使用命令行上传数据到container,一会短则几秒钟,长则几十秒就自动消失了,查阅了谷歌资料,总结的解决思路如下:

1、时间服务器NTP或者存储节点的NTP配置有问题,总之就是时间不同步。我的确实是存储节点忘了配置NTP了。但是我配置了之后还是有问题;

2、删除/etc/swift下面的gz,包括backup文件夹,也就是删除配置重新再来一遍。我删除重配之后,一切正常了。

下面是我搜索到的资料,你们参考一下:

链接自:https://ask.openstack.org/en/question/56642/swift-containers-disappear-in-less-than-1-min/

原来小哥的问题是这样的,和我的一模一样:

Hi,

I had an RDO IceHouse installation of openstack on Fedora 20. It had no swift installed, so I was trying to install it. The installation was done ~6-8 month ago, and since then some additional configs were made, so running packstack again was a bit of risk.

Following mainly that document I succeeded to have swift running.

But the problem is that when I create a container (from a dashboard, for example), in 5-30 seconds it disappears.

    $ swift stat
       Account: AUTH_df715cfea8e240e3be22ba7bd56d148a
    Containers: 1
       Objects: 0
         Bytes: 0
 Accept-Ranges: bytes
   X-Timestamp: 1418907580.14515
    X-Trans-Id: tx811daed7a0d846d8b7ad7-005492cfcb
  Content-Type: text/plain; charset=utf-8

  $ swift stat
       Account: AUTH_df715cfea8e240e3be22ba7bd56d148a
    Containers: 0
       Objects: 0
         Bytes: 0
X-Put-Timestamp: 1418907615.35912
   X-Timestamp: 1418907615.35912
    X-Trans-Id: tx62147245b42340419681f-005492cfdf
  Content-Type: text/plain; charset=utf-8

看上面两个图的对比,第一个图是上传数据一切正常,第二个图是过一会重新检查,containers神奇消失了,变为0

下面是小哥解决的办法:

Ok, seems that it is fixed somehow

Possible reason: in parallel with services (openstack-swift-…), i run swift-init (which run the same processes) and the configuration changes I did were not taken into account.

  1. stop things with swift-init: swift-init kill all (Note: I tried to fix it by doing all the following steps without this one. It did not work, so it was crucial)
  2. stop all services (I run all on one node):for service in openstack-swift-object openstack-swift-object-replicator openstack-swift-object-updater openstack-swift-object-auditor openstack-swift-container openstack-swift-container-replicator openstack-swift-container-updater openstack-swift-container-auditor openstack-swift-account openstack-swift-account-replicator openstack-swift-account-reaper openstack-swift-account-auditor openstack-swift-proxy openstack-swift-account; do service $service stop; done
  3. remove all files from the node (I had it at /srv/node/partition1)
  4. in /etc/swift, removed {account,container,object}{.builder,.ring.gz} (also removed things from /etc/swift/backup)
  5. Recreated rings:cd /etc/swiftswift-ring-builder account.builder create 18 1 1swift-ring-builder container.builder create 18 1 1swift-ring-builder object.builder create 18 1 1swiftstorage=ip-of-your-storage-nodeswift-ring-builder account.builder add z1-$swiftstorage:6202/partition1 100swift-ring-builder container.builder add z1-$swiftstorage:6201/partition1 100swift-ring-builder object.builder add z1-$swiftstorage:6200/partition1 100swift-ring-builder account.builder rebalanceswift-ring-builder container.builder rebalanceswift-ring-builder object.builder rebalancechown -R swift:swift .
  6. restarted services:for service in openstack-swift-object openstack-swift-object-replicator openstack-swift-object-updater openstack-swift-object-auditor openstack-swift-container openstack-swift-container-replicator openstack-swift-container-updater openstack-swift-container-auditor openstack-swift-account openstack-swift-account-replicator openstack-swift-account-reaper openstack-swift-account-auditor openstack-swift-proxy openstack-swift-account; do service $service start; done

Now stuff started working… Hope it can help someone.

我是直接把分区格式化重新再来,注意,如果你重启,重新挂载,记得给/srv对应的权限,也就是 chown -R swift.swift /srv ,否则上传文件报错404

[root@server_2 ~]

# swift upload C1 admin-openrc.sh
Warning: failed to create container ‘C1’: 404 Not Found:

Not Found

The resource could not be found.< Object PUT failed: http://176.204.66.102:8080/v1/AUTH_0341849e239042fba0fce28f32e541b0/C1/admin-openrc.sh 404 Not Found [first 60 chars of response]

Not Found

The resource could not be found.<

给权限,再上传,就OK了
[root@object1 swift]# chown -R swift.swift /srv/

[root@server_2 ~]

# swift upload C1 admin-openrc.sh
admin-openrc.sh


此条目发表在OpenStack分类目录,贴了标签。将固定链接加入收藏夹。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注