1.所有Storage节点上的安装 sudo apt-get --option Dpkg::Options::=--force-confold --assume-yes update sudo apt-get install pep8 pylint Python-pip screen unzip wget psmisc git-core lsof vim-nox curl python-MySQLdb cd /home/swift/openstack/ sudo pip install -r ./swift/tools/ pip-requires #安装swift的相关依赖,这里可能需要点时间 #安装swift cd /home/swift/openstack/swift sudo python setup.py install --record file.txt #假如要删除所安装的东西需要用root用户来删除,删除方法: sudo cat file.txt | xargs rm -rf 2.Proxy节点上的安装 sudo apt-get --option Dpkg::Options::=--force-confold --assume-yes update sudo apt-get install pep8 pylint python-pip screen unzip wget psmisc git-core lsof vim-nox curl python-mysqldb cd /home/swift/openstack/ sudo pip install -r ./swift/tools/ pip-requires cd /home/swift/openstack/swift sudo python setup.py install --record file.txt cd /home/swift/openstack/keystone sudo pip install -r ./tools/pip-requires sudo python setup.py install --record file.txt 3.Auth(Keystone)节点的安装 sudo apt-get --option Dpkg::Options::=--force-confold --assume-yes update sudo apt-get install pep8 pylint python-pip screen unzip wget psmisc git-core lsof vim-nox curl python-mysqldb mysql-server mysql-client cd /home/swift/openstack/ sudo pip install -r ./keystone/tools/pip-requires sudo pip install -r ./ python-keystoneclient/tools/pip-requires cd /home/swift/openstack/python-keystoneclient/ sudo python setup.py install --record file.txt cd /home/swift/openstack/keystone sudo python setup.py install --record file.txt
5. Proxy节点的设置(192.168.112.129)1.sudo apt-get install memcached #安装缓存服务器 修改/etc/ memcached.conf文件,将-l 127.0.0.1改为-l 192.168.112.129(这里我是根据我自己的情况设定的,具体原因见第一点中的图) sudo service memcached restart sudo mkdir /etc/swift cd /etc/swift sudo chown -R swift:swift /etc/swift cp /home/swift/openstack/swift/etc/proxy-server.conf /etc/swift/ cp /home/swift/openstack/swift/etc/swift.conf /etc/swift/ 2.修改/etc/swift/proxy-server.conf文件,具体内容如下,原文件中没有的项需要自行增加 [DEFAULT] bind_port = 8080 user = swift swift_dir = /etc/swift workers = 1 [pipeline:main] pipeline = healthcheck cache swift3 authtoken keystone proxy-server [app:proxy-server] use = egg:swift#proxy allow_account_management = true account_autocreate = true [filter:keystone] paste.filter_factory = keystone.middleware.swift_auth:filter_factory operator_roles = Member,admin [filter:authtoken] paste.filter_factory = keystone.middleware.auth_token:filter_factory auth_host =<span style="background-color: rgb(255, 255, 255);"> </span><span style="background-color: rgb(204, 204, 204);">192.168.112.133</span> auth_port = 35357 auth_protocol = http auth_uri = :5000/ admin_tenant_name = service admin_user = swift admin_password = admin [filter:swift3] use = egg:swift#swift3 [filter:healthcheck] use = egg:swift#healthcheck [filter:cache] use = egg:swift#memcache 192.168.112.133部分为Auth(Keystone)节点的IP 3.修改/etc/swift/swift.conf,‘cynric’部分是随意更改的,你可以根据自己的需要更改 [swift-hash] swift_hash_path_suffix = cynric 4.生成相关ring以及builder文件,使用如下命令生成,加粗部分是根据具体情况而更改的,具体原因见摘要说明里的图。每一台机器使用一个域(z1, z2, z3…依次递增) sudo chown -R swift:swift /etc/swift/* cd /etc/swift swift-ring-builder object.builder create 18 3 1 swift-ring-builder container.builder create 18 3 1 swift-ring-builder account.builder create 18 3 1 export HOST_IP=192.168.112.130 swift-ring-builder object.builder add z1-${HOST_IP}:6010/sdb1 100 swift-ring-builder container.builder add z1-${HOST_IP}:6011/sdb1 100 swift-ring-builder account.builder add z1-${HOST_IP}:6012/sdb1 100 export HOST_IP=192.168.112.131 swift-ring-builder object.builder add z2-${HOST_IP}:6010/sdb1 100 swift-ring-builder container.builder add z2-${HOST_IP}:6011/sdb1 100 swift-ring-builder account.builder add z2-${HOST_IP}:6012/sdb1 100 export HOST_IP=192.168.112.132 swift-ring-builder object.builder add z3-${HOST_IP}:6010/sdb1 100 swift-ring-builder container.builder add z3-${HOST_IP}:6011/sdb1 100 swift-ring-builder account.builder add z3-${HOST_IP}:6012/sdb1 100 swift-ring-builder object.builder rebalance swift-ring-builder container.builder rebalance swift-ring-builder account.builder rebalance 5.启动proxy服务 swift-init proxy start
6. 配置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 chown -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 = 127.0.0.1 #这里也可以改为192.168.112.130 [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.存储点的设置 这里有分两种情况来设置存储点 a.假设你的系统里有一个单独分区,使用此分区来做存储点,在这里假设系统中有/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 b.如果系统里没有单独的分区来做存储点,则需要创建一个临时分区来做存储点 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 c.创建相关的目录 sudo mkdir /var/run/swift sudo chown swift:swift /var/run/swift sudo chmod a+w /var/run/swift d.在/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? 这是正常情况