7. 配置Storage节点
因为每个Storage节点的设置基本上是相似的,所以在这里只拿其中一个节点做示例(192.168.112.130),其他节点只需要重复一下几步操作就可以了
1.创建/etc/swift目录 sudo mkdir /etc/swift sudo chown -R swift:swift /etc/swift/*
2.将Proxy节点上/etc/swift/中的account.ring.gz container.ring.gz object.ring.gz swift.conf拷贝到当前存储节点(192.168.112.130)/etc/swift目录中,可使用如下命令 scp swift@192.168.112.129:/etc/swift/*.ring.gz /etc/swift/ scp swift@192.168.112.129:/etc/swift/swift.conf /etc/swift/ sudo shown -R swift:swift /etc/swift/*
3.更改/etc/rsyncd.conf文件,如果该文件不存在则需要自行创建,内容如下 uid = swift gid = swift log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid address = 192.168.112.130 #这里也可以改为127.0.0.1 [account] max connections = 2 path = /srv/node/ read only = false lock file = /var/lock/account.lock [conainer] 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 编辑/etc/default/rsync: 将RSYNC_ENABLE设置为true 更改好之后,重启该服务 sudo service rsync restart
4.存储点的设置 这里有分两种情况来设置存储点 1.假设你的系统里有一个单独分区,使用此分区来做存储点,在这里假设系统中有/dev/sdb1(注:这里根据你自己系统的情况而定)这个分区未被使用,我们用它来做存储点。 sudo mkdir -p /srv/node/sdb1 sudo mkfs.xfs -i size=1024 /dev/sdb1 #以xfs方式格式化分区 sudo chmod a+w /etc/fstab sudo echo “/dev/sdb1 /srv/node/sdb1 xfs noatime,nodiratime nobarrier,logbufs=8 0 0” >> /etc/fstab #系统启动时自动挂载,这里的sdb1是一定不能改的,因为在做Proxy节点生成相应的ring文件时使用了sdb1 (swift-ring-builder object.builder add z1-${HOST_IP}:6010/sdb1 100)的时候,加入需要更改则两个地方都需要改 sudo mount /srv/node/sdb1 sudo chown -R swift:swift /srv/node/sdb1 sudo chmod a+w -R /srv/node/sdb1 2.如果系统里没有单独的分区来做存储点,则需要创建一个临时分区来做存储点 sudo mkdir -p /srv/node/sdb1 sudo dd if=/dev/zero of=/srv/swift-disk bs=1024 count=0 seek=1000000 #这个命令是在/srv/下创建一个名为swift-disk的存储区,你可以改变seek的大小来改变swift-disk的大小 sudo mkfs.xfs -i size=1024 /srv/swift-disk sudo chmod a+w /etc/fstab sudo echo “/srv/swift-disk /srv/node/sdb1 xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0” >> /etc/fstab #系统启动时自动挂载 sudo mount /srv/node/sdb1 sudo chown -R swift:swift /srv/node/sdb1 sudo chmod a+w -R /srv/node/sdb1 sudo chmod a+w /srv/swift-disk 创建相关的目录 sudo mkdir /var/run/swift sudo chown swift:swift /var/run/swift sudo chmod a+w /var/run/swift 在/etc/rc.local的exit 0之前加入下列三行 mkdir /var/run/swift chown swift:swift /var/run/swift chmod a+w /var/run/swift
5.Swift文件配置 创建/etc/swift/account-server.conf文件,并加入如下配置 [DEFAULT] devices = /srv/node mount_check = false bind_port = 6012 user = swift bind_ip = 0.0.0.0 workers = 2 [pipeline:main] pipeline = account-server [app:account-server] use = egg:swift#account [account-replicator] [account-auditor] [account-reaper] 创建/etc/swift/object-server.conf文件 [DEFAULT] devices = /srv/node mount_check = false bind_port = 6010 user = swift bind_ip = 0.0.0.0 workers = 2 [pipeline:main] pipeline = object-server [app:object-server] use = egg:swift#object [object-replicator] [object-updater] [object-auditor] 创建/etc/swift/ container-server.conf文件 [DEFAULT] devices = /srv/node mount_check = false bind_port = 6011 user = swift bind_ip = 0.0.0.0 workers = 2 [pipeline:main] pipeline = container-server [app:container-server] use = egg:swift#container [container-replicator] [container-updater] [container-auditor] [container-sync]
6.启动swift服务 sudo chown -R swift:swift /etc/swift/* swift-init all start #当启动的时候可能会报WARNING: Unable to increase file descriptor limit. Running as non-root? 这是正常情况