一、 环境配置
Controller节点
1.创建服务认证
# . admin-openrc
# openstack user create --domain default --password-prompt swift
# openstack role add --project service --user swift admin
# openstack service create --name swift --description "OpenStack Object Storage" object-store
2.创建服务端点
# openstack endpoint create --region RegionOne object-store public http://controller:8080/v1/AUTH_%\(tenant_id\)s
# openstack endpoint create --region RegionOne object-store admin http://controller:8080/v1/AUTH_%\(tenant_id\)s
# openstack endpoint create --region RegionOne object-store internal http://controller:8080/v1/AUTH_%\(tenant_id\)s
二、控制节点安装并配置Swift
Controller节点
1.安装Swift软件包
# yum install -y openstack-swift-proxy python-swiftclient python-keystoneclient python-keystonemiddleware memcached
2.获取代理服务配置文件
注:Mitaka.iso镜像里面有该文件,你也可以通过命令下载到/etc/swift/目录下
(
# curl -o /etc/swift/proxy-server.conf \
https://git.openstack.org/cgit/openstack/swift/plain/etc/proxy-server.conf-sample?h=mitaka-eol
)
或者通过https://git.openstack.org/cgit/openstack/swift/plain/etc/proxy-server.conf-sample?h=mitaka-eol链接下载至物理机,再上传至controller节点
# find / -name proxy-server.conf
/etc/swift/proxy-server.conf
/opt/mitaka/swift/proxy-server.conf
# cp -rvf /opt/mitaka/swift/proxy-server.conf /etc/swift/
cp: overwrite ‘/etc/swift/proxy-server.conf’? y
‘/opt/mitaka/swift/proxy-server.conf’ -> ‘/etc/swift/proxy-server.conf’
3.编辑并配置Swift
# vi /etc/swift/proxy-server
[DEFAULT]
bind_port = 8080
swift_dir = /etc/swift
user = swift
[pipeline:main]部分,删除’tempurl’和’tempauth’模块,并增加’authtoken’和’keystoneauth’模块
[pipeline:main]
pipeline = catch_errors gatekeeper healthcheck proxy-logging cache container_sync bulk ratelimit authtoken keystoneauth container-quotas account-quotas slo dlo versioned_writes proxy-logging proxy-server
[app:proxy-server]
use = egg:swift#proxy
account_autocreate = True
[filter:keystoneauth]
use = egg:swift#keystoneauth
operator_roles = admin, user
[filter:authtoken]
paste.filter_factory = keystonemiddleware.auth_token:filter_factory
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = swift
password = 123456
delay_auth_decision = True
[filter:cache]
use = egg:swift#memcache
memcache_servers = controller:11211
三、存储节点安装并配置Swift
注:
1)先添加两块虚拟硬盘(不会添加点这,第四小部分有讲解) https://blog.csdn.net/qq_40791253/article/details/83660338
2) 由于swift需要两个存储节点,而我们只有两台虚拟机,所以把Controller和Compute节点当作存储节点进行配置
Controller节点
1.环境配置
# yum install -y xfsprogs rsync
# ls /dev/sd* (查看添加的磁盘)
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdc
# mkfs.xfs /dev/sdb
# mkfs.xfs /dev/sdc
# mkdir -p /srv/node/sdb
# mkdir -p /srv/node/sdc
2.编辑/etc/fstab配置文件,在末尾添加如下内容,设置开机自动挂载
# vi /etc/fstab
/dev/sdb /srv/node/sdb xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
/dev/sdc /srv/node/sdc xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
# mount /srv/node/sdb
# mount /srv/node/sdc
# df -hT
3.编辑/etc/rsyncd.conf文件
# vi /etc/rsyncd.conf
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 192.168.100.10
[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
# systemctl enable rsyncd.service
# systemctl start rsyncd.service (若启动失败,重启一下就OK了)
Compute节点
1.环境配置
# yum install -y xfsprogs rsync
# ls /dev/sd* (查看添加的磁盘)
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdc
# mkfs.xfs /dev/sdb
# mkfs.xfs /dev/sdc
# mkdir -p /srv/node/sdb
# mkdir -p /srv/node/sdc
2.编辑/etc/fstab配置文件,在末尾添加如下内容,设置开机自动挂载
# vi /etc/fstab
/dev/sdc /srv/node/sdb xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
/dev/sdd /srv/node/sdc xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
# mount /srv/node/sdc
# mount /srv/node/sdd
# df -hT
3.编辑/etc/rsyncd.conf文件
# vi /etc/rsyncd.conf
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 192.168.100.20 (存储节点管理IP)
[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
# systemctl enable rsyncd.service
# systemctl start rsyncd.service
1.安装并配置
Controller节点
1)安装软件包
# yum install -y openstack-swift-account openstack-swift-container openstack-swift-object
2)获取accounting、container、object服务配置文件
注:Mitaka.iso文件自带配置文件,也可通过命令的方式联网下载
# curl -o /etc/swift/account-server.conf \
https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample?h=mitaka-eol
# curl -o /etc/swift/container-server.conf \
https://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample?h=mitaka-eol
# curl -o /etc/swift/object-server.conf \
https://git.openstack.org/cgit/openstack/swift/plain/etc/object-server.conf-sample?h=mitaka-eol
3) 编辑accounting、container、object服务配置文件
编辑/etc/swift/account-server.conf文件
# vi /etc/swift/account-server.conf
[DEFAULT]
bind_ip = 192.168.100.10 (存储节点管理IP:192.168.100.10、192.168.100.20)
bind_port = 6002
# bind_timeout = 30
# backlog = 4096
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = true
[pipeline:main]
pipeline = healthcheck recon account-server
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
编辑/etc/swift/container-server.conf文件
# vi /etc/swift/container-server.conf
[DEFAULT]
bind_ip = 192.168.100.10 (存储节点管理IP:192.168.100.10、192.168.100.20)
bind_port = 6001
# bind_timeout = 30
# backlog = 4096
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = true
[pipeline:main]
pipeline = healthcheck recon container-server
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
编辑/etc/swift/object-server.conf文件
# vi /etc/swift/object-server.conf
[DEFAULT]
bind_ip = 192.168.100.10 (存储节点管理IP:192.168.100.10、192.168.100.20)
bind_port = 6000
# bind_timeout = 30
# backlog = 4096
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = true
[pipeline:main]
pipeline = healthcheck recon object-server
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
recon_lock_path = /var/lock
4)修改挂载目录权限
# chown -R swift:swift /srv/node/
# ls -l /srv/
total 0
drwxr-xr-x. 4 swift swift 26 Nov 2 11:27 node
# mkdir -p /var/cache/swift
# chown -R root:swift /var/cache/swift/
# chown -R 775 /var/cache/swift/
5)将配置文件拷贝至compute节点的/root目录
# scp /etc/swift/account-server.conf /etc/swift/container-server.conf /etc/swift/object-server.conf [email protected]:/root
The authenticity of host 'compute (192.168.100.20)' can't be established.
ECDSA key fingerprint is fc:c6:ce:fa:d7:95:90:b9:38:cf:96:61:a3:75:52:e7.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'compute,192.168.100.20' (ECDSA) to the list of known hosts.
[email protected]'s password:
account-server.conf 100% 6633 6.5KB/s 00:00
container-server.conf 100% 7492 7.3KB/s 00:00
object-server.conf 100% 12KB 12.0KB/s 00:00
Compute节点
1)安装软件包
# yum install -y openstack-swift-account openstack-swift-container openstack-swift-object
2)编辑accounting、container、object服务配置文件
# cp -rvf account-server.conf /etc/swift/
# cp -rvf container-server.conf /etc/swift/
# cp -rvf object-server.conf /etc/swift/
# vi /etc/swift/account-server.conf
[DEFAULT]
bind_ip = 192.168.100.20
# vi /etc/swift/container-server.conf
[DEFAULT]
bind_ip = 192.168.100.20
# vi /etc/swift/object-server.conf
[DEFAULT]
bind_ip = 192.168.100.20
3)修改挂载点目录权限
# chown -R swift:swift /srv/node/
# ls -l /srv/
total 0
drwxr-xr-x. 4 swift swift 26 Nov 4 14:35 node
# mkdir -p /var/cache/swift
# chown -R root:swift /var/cache/swift/
# chown -R 775 /var/cache/swift/
四、创建并分发Ring
Controller节点
1.创建账户Ring
1)创建account.builder文件
# cd /etc/swift/
# swift-ring-builder account.builder create 10 2 1
2)添加所有存储节点到Ring中
# swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6002 --device sdc --weight 100
# swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6002 --device sdd --weight 100
# swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.100.10 --port 6002 --device sdc --weight 100
# swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.100.10 --port 6002 --device sdb --weight 100
# swift-ring-builder account.builder
# swift-ring-builder account.builder rebalance
2.创建容器Ring
1)创建account.builder文件
# cd /etc/swift/
# swift-ring-builder container.builder create 10 2 1
2)添加所有存储节点到Ring中
# swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.100.10 --port 6001 --device sdb --weight 100
# swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.100.10 --port 6001 --device sdc --weight 100
# swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6001 --device sdc --weight 100
# swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6001 --device sdd --weight 100
# swift-ring-builder container.builder
# swift-ring-builder container.builder rebalance
2.创建对象Ring
1)创建account.builder文件
# cd /etc/swift/
# swift-ring-builder object.builder create 10 2 1
2)添加所有存储节点到Ring中
# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.10 --port 6000 --device sdb --weight 100
# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.10 --port 6000 --device sdc --weight 100
# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6000 --device sdc --weight 100
# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6000 --device sdd --weight 100
# swift-ring-builder object.builder
# swift-ring-builder object.builder rebalance
五、完成安装
# scp /etc/swift/*.gz 192.168.100.20:/etc/swift/
# ls /opt/mitaka/swift/
# cp -rvf /opt/mitaka/swift/swift.conf /etc/swift/
注:也可以通过命令下载配置文件
# curl -o /etc/swift/swift.conf \
https://git.openstack.org/cgit/openstack/swift/plain/etc/swift.conf-sample?h=mitaka-eol
1.编辑/etc/swift/swift.conf文件
# vi /etc/swift/swift.conf
[swift-hash]
配置哈希路径前缀和后缀(获取的配置文件有默认值不用改)
swift_hash_path_suffix = changeme
swift_hash_path_prefix = changeme
[storage-policy:0]
配置默认存储策略(获取的配置文件中这两个值是打开的其实不用管)
name = Policy-0
default = yes
# scp /etc/swift/swift.conf 192.168.100.20:/etc/swift/
2.启动Swift服务并设置开机自启
Controller节点
# chown -R root:swift /etc/swift
# systemctl enable openstack-swift-proxy.service memcached.service
# systemctl start openstack-swift-proxy.service memcached.service
Controller、Compute节点
# chown -R root:swift /etc/swift
# systemctl enable openstack-swift-account.service openstack-swift-account-auditor.service \
openstack-swift-account-reaper.service openstack-swift-account-replicator.service
# systemctl enable openstack-swift-container.service \
openstack-swift-container-auditor.service openstack-swift-container-replicator.service \
openstack-swift-container-updater.service
# systemctl enable openstack-swift-object.service openstack-swift-object-auditor.service \
openstack-swift-object-replicator.service openstack-swift-object-updater.service
# systemctl start openstack-swift-account.service openstack-swift-account-auditor.service \
openstack-swift-account-reaper.service openstack-swift-account-replicator.service
# systemctl start openstack-swift-container.service \
openstack-swift-container-auditor.service openstack-swift-container-replicator.service \
openstack-swift-container-updater.service
# systemctl start openstack-swift-object.service openstack-swift-object-auditor.service \
openstack-swift-object-replicator.service openstack-swift-object-updater.service
六、验证swift操作
Controller节点
# . /root/admin-openrc
# swift stat
# openstack container create container_hang
# touch file_test
# openstack object create container_hang file_test
# openstack object list container_hang
# openstack object save container_hang file_test
|
请发表评论