十、Openstack对象存储服务(swift)中
计算节点上(我把计算节点当存储节点用添加了sdb,sdc两块硬盘)
1.安装软件包:
yum install xfsprogs rsync openstack-swift-account openstack-swift-container openstack-swift-object
2.使用XFS格式化/dev/sdb和/dev/sdc两块盘
mkfs.xfs /dev/sdb
mkfs.xfs /dev/sdc
[root@compute ~]# mkfs.xfs /dev/sdb
meta-data=/dev/sdb isize=256 agcount=4, agsize=655360 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=2621440, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@compute ~]# mkfs.xfs /dev/sdc
meta-data=/dev/sdc isize=256 agcount=4, agsize=655360 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=2621440, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
3.创建挂载点目录
[root@compute ~]# mkdir -p /srv/node/sdb
[root@compute ~]# mkdir -p /srv/node/sdc
4.设置开机自动挂载
编辑文件/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
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
5.挂载设备
[root@compute ~]# mount /srv/node/sdb
[root@compute ~]# mount /srv/node/sdc
此操作无返回
验证是否挂载成功
[root@compute ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 28G 1.5G 26G 6% /
devtmpfs 903M 0 903M 0% /dev
tmpfs 913M 0 913M 0% /dev/shm
tmpfs 913M 8.6M 904M 1% /run
tmpfs 913M 0 913M 0% /sys/fs/cgroup
/dev/sda1 497M 169M 328M 35% /boot
tmpfs 183M 0 183M 0% /run/user/0
/dev/sdb 10G 33M 10G 1% /srv/node/sdb
/dev/sdc 10G 33M 10G 1% /srv/node/sdc
6.修改配置文件/etc/rsyncd.conf文件添加以下内容
vi /etc/rsyncd.conf
uid = swift#以哪个用户的身份来传输
gid = swift#以哪个组的身份来传输
log file = /var/log/rsyncd.log#指定rsync发送消息日志文件
pid file = /var/run/rsyncd.pid#守护进程pid文件
address = 192.168.100.20(存储节点管理ip我这里就是计算节点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#锁目录
7.启动 rsyncd 服务和配置它随系统启动
systemctl enable rsyncd.service
systemctl start rsyncd.service
[root@compute ~]# systemctl enable rsyncd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
[root@compute ~]# systemctl start rsyncd.service
8.从对象存储源仓库中获取accounting, container以及object服务配置文件
没有网就打开网址自己复制进文件,删除里面以前的内容
curl -o /etc/swift/account-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample
curl -o /etc/swift/container-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample
curl -o /etc/swift/object-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/object-server.conf-sample
[root@compute ~]# curl -o /etc/swift/account-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 9777 100 9777 0 0 5931 0 0:00:01 0:00:01 --:--:-- 5950
[root@compute ~]# curl -o /etc/swift/container-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 11028 100 11028 0 0 7342 0 0:00:01 0:00:01 --:--:-- 7347
[root@compute ~]# curl -o /etc/swift/object-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/object-server.conf-sample
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 17947 100 17947 0 0 11891 0 0:00:01 0:00:01 --:--:-- 11901
9.修改配置文件/etc/swift/account-server.conf (账户服务)
vi /etc/swift/account-server.conf
bind_ip = 192.168.100.20#存储节点管理ip我这里就是计算节点ip)
bind_port = 6002#绑定端口
user = swift#用户
swift_dir = /etc/swift#配置文件目录
devices = /srv/node#挂载目录
mount_check = True#挂载检查
启用合适的模块(从对象仓库获取后就有的其实不用管,不放心自己去看)
[pipeline:main]
pipeline = healthcheck recon account-server
配置recon (meters)缓存目录
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
10.修改配置文件/etc/swift/container-server.conf (容器服务)
vi /etc/swift/container-server.conf
bind_ip = 192.168.100.20#存储节点管理ip我这里就是计算节点ip)
bind_port = 6001#绑定端口
user = swift#用户
swift_dir = /etc/swift#配置文件目录
devices = /srv/node#挂载目录
mount_check = True#挂载检查
启用合适的模块(从对象仓库获取后就有的其实不用管,不放心自己去看)
[pipeline:main]
pipeline = healthcheck recon container-server
配置recon (meters)缓存目录
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
11.修改配置文件/etc/swift/object-server.conf(对象服务)
注意:[filter:recon]下有两个路径地址,并不和上面一样只有一个
vi /etc/swift/object-server.conf
bind_ip = 192.168.100.20#存储节点管理ip我这里就是计算节点ip)
bind_port = 6000#绑定端口
user = swift#用户
swift_dir = /etc/swift#配置文件目录
devices = /srv/node#挂载目录
mount_check = True#挂载检查
启用合适的模块(从对象仓库获取后就有的其实不用管,不放心自己去看)
[pipeline:main]
pipeline = healthcheck recon object-server
配置recon (meters)缓存目录
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
recon_lock_path = /var/lock
12.添加合适权限给目录挂载点
chown -R swift:swift /srv/node
[root@compute ~]# chown -R swift:swift /srv/node
13.创建 recon 目录授予它合适的所有权
mkdir -p /var/cache/swiftchown -R root:swift /var/cache/swift
chmod -R 775 /var/cache/swift
[root@compute ~]# mkdir -p /var/cache/swift
[root@compute ~]# chown -R root:swift /var/cache/swift
[root@compute ~]# chmod -R 775 /var/cache/swift