这几天正在自己搭建一个swift的环境。看了一些资料,结合自己的实践,写下了它:
1.物理环境说明:
Linux系统版本:Ubuntu Server 12.04
Proxy Server IP: 10.214.0.181
Storage Server One: 10.214.0.179
Storage Server Two: 10.214.0.180
Storage Server three: 10.214.0.182
2.重要组件说明:
node:运行一个或多个object storage service
proxy node:运行 proxy services
auth node:运行Auth service
storage:运行account,container,and object services
Ring:是Openstack object storage 到物理设备的映射集合
在所有节点上的准备工作:
安装服务
apt-get install swift openssh-server rsync memcached python-netifaces python-xattr python-memcache
配置路径
mkdir -p /etc/swift
chown -R swift:swift /etc/swift/
新建文件 vim /etc/swift/swift.conf
[swift-hash]
# random unique string that can never change (DO NOT LOSE)
swift_hash_path_suffix = fLIbertYgibbitZ
3.安装和配置storage nodes
安装:Storage node packages,所有storage都要进行操作。
aptitude install swift-account swift-container swift-object xfsprogs
新建xfs系统分区,当然,(这需要一个空分区),如果硬盘的分区已经被使用而数据你又不想要了,那就删除分区后进行下列操作。否则添加一块新硬盘是最方便的选择。所有storage都要进行操作。
fdisk /dev/sdb
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-488281249, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-488281249, default 488281249):
Using default value 488281249
Command (m for help): p
Disk /dev/sdb: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders, total 488281250 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000081
Device Boot Start End Blocks Id System
/dev/sdb1 2048 488281249 244139601 83 Linux
Command (m for help): w
The partition table has been altered!
识别并挂载新的分区:
partprobe#如果不行,就重启一下吧。
mkdir -p /srv/node/sdb1
mkfs.xfs -i size=1024 /dev/sdb1 -f
echo "/dev/sdb1 /srv/node/sdb1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab
mount /srv/node/sdb1
chown -R swift:swift /srv/node
创建并配置 vim /etc/rsyncd.conf
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 10.214.0.179
[account]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/account.lock
[container]
max c