其中,18代表partition的数目为2的18次幂,这个数字取决于你希望一个ring中会有多少个partition。3代表每个object的副本数。最后一个参数1,代表一个partition至少在1小时之后才能被移动。
3.6 让ring记录每个Storage Node的存储设备
export ZONE=1
export STORAGE_LOCAL_NET_IP=172.17.10.10
export WEIGHT=100
export DEVICE=sdb1
sudo swift-ring-builder account.builder addz$ZONE-$STORAGE_LOCAL_NET_IP:6002/$DEVICE $WEIGHT
sudo swift-ring-builder container.builderadd z$ZONE-$STORAGE_LOCAL_NET_IP:6001/$DEVICE $WEIGHT
sudo swift-ring-builder object.builder addz$ZONE-$STORAGE_LOCAL_NET_IP:6000/$DEVICE $WEIGHT
export ZONE=1
export STORAGE_LOCAL_NET_IP=172.17.10.10
export WEIGHT=100
export DEVICE=sdc1
sudo swift-ring-builder account.builder addz$ZONE-$STORAGE_LOCAL_NET_IP:6020/$DEVICE $WEIGHT
sudo swift-ring-builder container.builderadd z$ZONE-$STORAGE_LOCAL_NET_IP:6010/$DEVICE $WEIGHT
sudo swift-ring-builder object.builder add z$ZONE-$STORAGE_LOCAL_NET_IP:6030/$DEVICE$WEIGHT
export ZONE=2
export STORAGE_LOCAL_NET_IP=172.17.10.11
export WEIGHT=100
export DEVICE=sdb1
sudo swift-ring-builder account.builder addz$ZONE-$STORAGE_LOCAL_NET_IP:6002/$DEVICE $WEIGHT
sudo swift-ring-builder container.builderadd z$ZONE-$STORAGE_LOCAL_NET_IP:6001/$DEVICE $WEIGHT
sudo swift-ring-builder object.builder addz$ZONE-$STORAGE_LOCAL_NET_IP:6000/$DEVICE $WEIGHT
export ZONE=3
export STORAGE_LOCAL_NET_IP=172.17.10.13
export WEIGHT=100
export DEVICE=sdb1
sudo swift-ring-builder account.builder addz$ZONE-$STORAGE_LOCAL_NET_IP:6002/$DEVICE $WEIGHT
sudo swift-ring-builder container.builderadd z$ZONE-$STORAGE_LOCAL_NET_IP:6001/$DEVICE $WEIGHT
sudo swift-ring-builder object.builder addz$ZONE-$STORAGE_LOCAL_NET_IP:6000/$DEVICE $WEIGHT
注意,这里需要根据Storage Node的存储设备实际情况来设定:
① DEVICE需要根据Storage Node上的/etc/rsyncd.conf中的path来设置,例如path为/srv/node/,查看/srv/node/下存在目录sdb1上的话,则DEVICE值为sdb1;
② ZONE从1开始计数,逐次加1;当一个Storage Node存在多个DEVICE时,可以设为同一个ZONE(推荐),也可以设为多个ZONE;
③ 如果每个挂载分区的大小都一样,WEIGHT(权重)不妨均设置成100。
3.7 确认ring 的内容是否正确并平衡(Rebalance)ring
swift-ring-builder account.builder
swift-ring-builder container.builder
swift-ring-builder object.builder
sudo swift-ring-builder account.builderrebalance
sudo swift-ring-builder container.builderrebalance
sudo swift-ring-builder object.builderrebalance
3.8 拷贝ring到其它所有节点
swift@ubuntu:~$ scp /etc/swift/*.ring.gz 172.17.10.10:/etc/swift/
这里需要把account.ring.gz、container.ring.gz和object.ring.gz拷贝到其它所有Proxynode和Storage node的/etc/swift目录下。
并需要确保所有节点的配置文件都属于swift用户:
swift@ubuntu:~$ sudo chown -R swift:swift/etc/swift
3.9 开启Proxy 服务
swift@ubuntu:~$ sudo swift-init proxy start
Ubuntu Server 11.10下使用Swauth认证多节点安装Swift