----------------------- controller : ---------------------------------
source admin-openrc.sh
keystone user-create --name=swift --pass=000000 --email=swift@localhost
keystone user-role-add --user=swift --tenant=service --role=admin
keystone role-create --name=SwiftOperator
keystone user-role-add --user=swift --tenant=service --role=SwiftOperator
keystone service-create --name=swift --type=object-store --description="OpenStack Object Storage"
keystone endpoint-create --service-id=$(keystone service-list | awk '/ object-store/ {print $2}') \
--publicurl="http://controller:8080/v2/AUTH_%(tenant_id)s" \
--internalurl="http:/controller:8080/v2/AUTH_%(tenant_id)s" \
--adminurl="http://controller:8080/v2/AUTH_%(tenant_id)s"
----------------------- controller & compute : ---------------------------------
mkdir -p /etc/swift
echo "[swift-hash]" >> /etc/swift/swift.conf
echo "swift_hash_path_suffix = fLIbertYgibbitZ" >> /etc/swift/swift.conf
----------------------- compute : ---------------------------------
yum -y install openstack-swift openstack-swift-account openstack-swift-container openstack-swift-object xfsprogs xinetd rsync
cat /pro /part
(这里为sda6,根据自己情况)
mkfs.xfs -i size=1024 -f /dev/sda6
echo "/dev/sda6 /srv/node xfs noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab
mkdir -p /srv/node
mount /dev/sda6 /srv/node
chown -R swift:swift /srv/node
vi /etc/rsyncd.conf
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 127.0.0.1
[account]
max connections = 2
path = /srv/node
read only = false
lock file = /var/lock/account.lock
[container]
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
vi /etc/xinetd.d/rsync
disable = no
flags = IPv4
service xinetd start
chkconfig xinetd on
mkdir -p /var/swift/recon
chown -R swift:swift /var/swift/recon
----------------------- controller : ---------------------------------
yum install openstack-swift-proxy memcached python-swiftclient
openstack-config --set /etc/swift/proxy-server.conf DEFAULT bind_port 8080
openstack-config --set /etc/swift/proxy-server.conf DEFAULT workers 8
openstack-config --set /etc/swift/proxy-server.conf DEFAULT user swift
openstack-config --set /etc/swift/proxy-server.conf DEFAULT log_name proxy
openstack-config --set /etc/swift/proxy-server.conf DEFAULT log_level DEBUG
openstack-config --set /etc/swift/proxy-server.conf DEFAULT log_facility LOG_LOCAL0
openstack-config --set /etc/swift/proxy-server.conf pipeline:main pipeline healthcheck\ cache\ authtoken\ keystone\ proxy-server
openstack-config --set /etc/swift/proxy-server.conf app:proxy-server use egg:swift#proxy
openstack-config --set /etc/swift/proxy-server.conf app:proxy-server allow_account_management true
openstack-config --set /etc/swift/proxy-server.conf app:proxy-server account_autocreate true
openstack-config --set /etc/swift/proxy-server.conf filter:cache use egg:swift#memcache
openstack-config --set /etc/swift/proxy-server.conf filter:cache memcache_servers 127.0.0.1:11211
openstack-config --set /etc/swift/proxy-server.conf filter:catch_errors use egg:swift#catch_errors
openstack-config --set /etc/swift/proxy-server.conf filter:healthcheck use egg:swift#healthcheck
openstack-config --set /etc/swift/proxy-server.conf filter:keystone use egg:swift#keystoneauth
openstack-config --set /etc/swift/proxy-server.conf filter:keystone operator_roles admin,\ SwiftOperator,\ _member_
openstack-config --set /etc/swift/proxy-server.conf filter:keystone is_admin true
openstack-config --set /etc/swift/proxy-server.conf filter:keystone cache swift.cache
openstack-config --set /etc/swift/proxy-server.conf filter:authtoken paste.filter_factory keystoneclient.middleware.auth_token:filter_factory
openstack-config --set /etc/swift/proxy-server.conf filter:authtoken signing_dir /tmp/keystone-signing-swift
openstack-config --set /etc/swift/proxy-server.conf filter:authtoken auth_protocol http
openstack-config --set /etc/swift/proxy-server.conf filter:authtoken auth_host controller
openstack-config --set /etc/swift/proxy-server.conf filter:authtoken auth_port 35357
openstack-config --set /etc/swift/proxy-server.conf filter:authtoken admin_tenant_name service
openstack-config --set /etc/swift/proxy-server.conf filter:authtoken admin_user swift
openstack-config --set /etc/swift/proxy-server.conf filter:authtoken admin_password 000000
cd /etc/swift
swift-ring-builder account.builder create 18 3 1
swift-ring-builder container.builder create 18 3 1
swift-ring-builder object.builder create 18 3 1
swift-ring-builder account.builder add z1-192.168.100.20:6002R192.168.100.20:6005/sda6 100
swift-ring-builder container.builder add z1-192.168.100.20:6001R192.168.100.20:6004/sda6 100
swift-ring-builder object.builder add z1-192.168.100.20:6000R192.168.100.20:6003/sda6 100
swift-ring-builder account.builder
swift-ring-builder container.builder
swift-ring-builder object.builder
swift-ring-builder account.builder rebalance
swift-ring-builder container.builder rebalance
swift-ring-builder object.builder rebalance
拷贝 /etc/swift 中的 account.ring.gz、container.ring.gz 和 object.ring.gz 文件到存储(计算)节点 /etc/swift/ 下:
[root@controller swift]# cp *.gz /var/ftp
compute :
yum install ftp
cd /etc/swift/
ftp controller
Name (controller:root): anonymous
Password:
ftp> ls
ftp> get account.ring.gz
ftp> get container.ring.gz
ftp> get object.ring.gz
ftp> bye
controller :
chown -R swift:swift /etc/swift
service openstack-swift-proxy start
chkconfig openstack-swift-proxy on
----------------------- compute : ---------------------------------
sed -i 's/^bind_ip.*/#bind_ip = /g' /etc/swift/account-server.conf
sed -i 's/^bind_ip.*/#bind_ip = /g' /etc/swift/container-server.conf
sed -i 's/^bind_ip.*/#bind_ip = /g' /etc/swift/object-server.conf
mv /etc/swift/account-server.conf /etc/swift/account-server/1.conf
mv /etc/swift/container-server.conf /etc/swift/container-server/1.conf
mv /etc/swift/object-server.conf /etc/swift/object-server/1.conf
openstack-config --set /etc/swift/account-server/1.conf DEFAULT bind_port 6002
openstack-config --set /etc/swift/account-server/1.conf DEFAULT workers 2
openstack-config --set /etc/swift/account-server/1.conf DEFAULT user swift
openstack-config --set /etc/swift/account-server/1.conf DEFAULT devices /srv/node/
openstack-config --set /etc/swift/account-server/1.conf DEFAULT mount_check false
openstack-config --set /etc/swift/account-server/1.conf DEFAULT log_name swift-account
openstack-config --set /etc/swift/account-server/1.conf DEFAULT log_facility LOG_LOCAL1
openstack-config --set /etc/swift/account-server/1.conf DEFAULT log_level DEBUG
openstack-config --set /etc/swift/account-server/1.conf account-replicator vm_test_mode no
openstack-config --set /etc/swift/container-server/1.conf DEFAULT bind_port 6001
openstack-config --set /etc/swift/container-server/1.conf DEFAULT workers 2
openstack-config --set /etc/swift/container-server/1.conf DEFAULT user swift
openstack-config --set /etc/swift/container-server/1.conf DEFAULT devices /srv/node/
openstack-config --set /etc/swift/container-server/1.conf DEFAULT mount_check false
openstack-config --set /etc/swift/container-server/1.conf DEFAULT log_name swift-container
openstack-config --set /etc/swift/container-server/1.conf DEFAULT log_facility LOG_LOCAL1
openstack-config --set /etc/swift/container-server/1.conf DEFAULT log_level DEBUG
openstack-config --set /etc/swift/container-server/1.conf account-replicator vm_test_mode no
openstack-config --set /etc/swift/object-server/1.conf DEFAULT bind_port 6000
openstack-config --set /etc/swift/object-server/1.conf DEFAULT workers 2
openstack-config --set /etc/swift/object-server/1.conf DEFAULT user swift
openstack-config --set /etc/swift/object-server/1.conf DEFAULT devices /srv/node/
openstack-config --set /etc/swift/object-server/1.conf DEFAULT mount_check false
openstack-config --set /etc/swift/object-server/1.conf DEFAULT log_name swift-object
openstack-config --set /etc/swift/object-server/1.conf account-replicator vm_test_mode no
echo "local1.* /var/log/swift/storage1.log" >> /etc/rsyslog.d/10-swift.conf
mkdir -p /var/log/swift
chown -R swift:swift /var/log/swift
service rsyslog restart
chown -R swift:swift /var/swift
chown -R swift:swift /var/cache/swift
swift-init object-server start
swift-init object-replicator start
swift-init object-updater start
swift-init object-auditor start
swift-init container-server start
swift-init container-replicator start
swift-init container-updater start
swift-init container-auditor start
swift-init account-server start
swift-init account-replicator start
swift-init account-auditor start
vi /etc/rc.local
/usr/bin/swift-init object-server start
/usr/bin/swift-init object-replicator start
/usr/bin/swift-init object-updater start
/usr/bin/swift-init object-auditor start
/usr/bin/swift-init container-server start
/usr/bin/swift-init container-replicator start
/usr/bin/swift-init container-updater start
/usr/bin/swift-init container-auditor start
/usr/bin/swift-init account-server start
/usr/bin/swift-init account-replicator start
/usr/bin/swift-init account-auditor start
这时 web界面刷新后可以看到
多了一个存储。
这个可以提供给javaee 安卓开发做存储用
到这里,openstack的iaas基本就这样了。
如果有朋友有什么多的或者什么技术交流,可以再交流一下。
原文链接:https://www.f2er.com/swift/327030.html