linux云计算(keystone swift cinder配置)

独立安装openstack组件

准备服务器,为安装openstack的服务器加3块额外硬盘
qemu-img create -f qcow2 rh71.img 20G
qemu-img create -f qcow2 rh71.img 20G
qemu-img create -f qcow2 rh71.img 20G


keystone介绍
keystone是openstack框架中的一个重要组成部分,负责身份认证
服务管理,服务规则和服务令牌的功能,它实现了openstack的identity api
keystone是整个openstack框架中的注册表,其他服务通过keystone来注册服务
任何服务之前相互的调用,都需要keystone的身份验证来获得目标服务
keystone包含两个主要部件,验证与服务目录

常见术语
租户(tenant):使用openstack云的客户
用户(user):表示拥有用户名,密码,邮箱等帐号信息的个人角色
角色(role):代表特定的租户中的用户操作权限
服务(service):一个openstack服务,如nova,swift,glance或keystone
端点(endpoint):一个可以通过网络访问的地址,代表了openstack服务的api入口
模板(template):一个端点集合,代表一组可用的openstack服务端点


安装配置keystone
[root@rhel7v2 ~]# yum -y install openstack-keystone openstack-selinux
[root@rhel7v2 ~]# yum -y install openstack-utils
[root@rhel7v2 ~]# openstack-db --init --service keystone(初始化数据库)
[root@rhel7v2 ~]# keystone-manage pki_setup --keystone-user keystone --keystone-group keystone(生成签名信息)
[root@rhel7v2 ~]# export SERVICE_TOKEN=$(openssl rand -hex 10)(设置环境变量)
[root@rhel7v2 ~]# export SERVICE_ENDPOINT=http://192.168.4.10:35357/v2.0(改为本机ip)
[root@rhel7v2 ~]# echo $SERVICE_TOKEN > /root/ks_admin_token(备份令牌)
[root@rhel7v2 ~]# crudini --set /etc/keystone/keystone.conf DEFAULT admin_token $SERVICE_TOKEN
[root@rhel7v2 ~]# systemctl start openstack-keystone
[root@rhel7v2 ~]# systemctl enable openstack-keystone
[root@rhel7v2 ~]# systemctl enable mariadb
[root@rhel7v2 ~]# keystone service-create --name=keystone --type=identity --description="Keystone Identity Service"
[root@rhel7v2 ~]# keystone endpoint-create --service-id 5cb86e5624ba43348b661d4031fd2de7 --publicurl 'http://192.168.4.10:5000/v2.0' --adminurl 'http://192.168.4.10:35357/v2.0' --internalurl 'http://192.168.4.11:5000/v2.0'(为它创建端点)
[root@rhel7v2 ~]# keystone user-create --name admin --pass 123456
[root@rhel7v2 ~]# keystone role-create --name admin
[root@rhel7v2 ~]# keystone tenant-create --name admin
[root@rhel7v2 ~]# keystone user-role-add --user admin --role admin --tenant admin(创建用户)
[root@rhel7v2 ~]# vim ~/keystonerc_admin(写入环境变量)
export OS_USERNAME=admin
export OS_TENANT_NAME=admin
export OS_PASSWORD=123456
export OS_AUTH_URL=http://192.168.4.10:35357/v2.0
[root@rhel7v2 ~]# source keystonerc_admin(生效)

——————————————————————————————————————————————————————————————

swift介绍
swift是openstack开源云计算项目的子项目之一,提供对象存储
swift最适合的就是永久类型的静态数据的长期存储
由于swift多节点和多副本的设计使得swift具有较高的数据持久性
完全对称是指系统中每个节点具有同等的地位,没有主从之分
扩容的时候只需要简单的添加机器,系统会自动完成数据的迁移
swift中元数据是完全随机存储的,并且与对象文件一样,也会保存多份在多个节点上,避免单点故障

常见术语
account(账户):出于访问安全性考虑,使用swift系统,每个用户必须有一个帐号才能访问
container(容器):容器的工作九三处理对象列表,它并不知道对象在哪,只知道容器里存有哪些对象
object:数据存储的内容,使用ext4或者xfs文件系统
replica(存储副本):确保数据的高可用,至少三个副本
zone(存储区域):用在数据复制,确保每份副本可用分开存储
region(存储范围):一组存储区域

数据存储原理:
ring是swift中最重要的组件,用于记录存储对象与物理位置间映射关系
ring用来确定数据驻留子啊集群中的位置,有单独对应与account,container和boject的ring
ring是存储在硬盘上的实体名称和物理位置间的映射,环使用区域,设备,分区和副本来维护这些映射信息

安装配置swift
[root@rhel7v2 ~]# yum -y install openstack-swift-proxy openstack-swift-object openstack-swift-container openstack-swift-account python-swiftclient memcached
[root@rhel7v2 ~]# keystone user-create --name swift --pass 123456
[root@rhel7v2 ~]# keystone tenant-create --name services
[root@rhel7v2 ~]# keystone user-role-add --role admin --tenant services --user swift
[root@rhel7v2 ~]# keystone service-create --name swift --type object-store --description "Swift Storage Service"
[root@rhel7v2 ~]# keystone endpoint-create --service-id ff942a7bffe0438aa16fb9266debd277 --publicurl "http://192.168.4.10:8080/v1/AUTH_%(tenant_id)s" --adminurl "http://192.168.4.10:8080/v1/AUTH_%(tenant_id)s" --internalurl "http://192.168.4.10:8080/v1/AUTH_%(tenant_id)s"

为swift存储节点服务器安装两块额外的硬盘,分区,格式化
[root@rhel7v2 ~]# lsblk
vdb 252:16 0 20G 0 disk
vdc 252:32 0 20G 0 disk
vdd 252:48 0 20G 0 disk
[root@rhel7v2 ~]# parted /dev/vdb
(parted) mktable gpt
(parted) mkpart primary ext4 1M -1
[root@rhel7v2 ~]# parted /dev/vdc
(parted) mktable gpt
(parted) mkpart primary ext4 1M -1
[root@rhel7v2 ~]# mkfs.ext4 /dev/vdb1
[root@rhel7v2 ~]# mkfs.ext4 /dev/vdc1
[root@rhel7v2 ~]# mkdir -pv /srv/node/z{1,2}d1(创建目录)
[root@rhel7v2 ~]# blkid /dev/vdb1(查看uuid)
[root@rhel7v2 ~]# blkid /dev/vdc1
[root@rhel7v2 ~]# vim /etc/fstab(复制uuid,开机自动挂载)
UUID=64945457-38bf-4c2e-b87d-c1d621c733e5 /srv/node/z1d1 ext4 defaults 0 0
UUID=277c033b-eccd-4236-9be0-49d5ecc0b23f /srv/node/z2d1 ext4 defaults 0 0
[root@rhel7v2 node]# mount -a(挂载)
[root@rhel7v2 ~]# chown -R swift:swift /srv/node/(修改权限)
[root@rhel7v2 ~]# crudini --set /etc/swift/swift.conf swift-hash swift_hash_path_prefix $(openssl rand -hex 10)(修改配置文件)
[root@rhel7v2 ~]# crudini --set /etc/swift/swift.conf swift-hash swift_hash_path_suffix $(openssl rand -hex 10)
[root@rhel7v2 ~]# crudini --set /etc/swift/account-server.conf DEFAULT bind_ip 192.168.4.10
[root@rhel7v2 ~]# crudini --set /etc/swift/container-server.conf DEFAULT bind_ip 192.168.4.10
[root@rhel7v2 ~]# crudini --set /etc/swift/object-server.conf DEFAULT bind_ip 192.168.4.10

创建rings
rings确定数据存储子啊集群存储的哪个节点使用swift-ring-builder命令创建ring文件
(12表示分区的数量,2的12次放,2表示副本的份数,1表示数据迁移时间,小时)
[root@rhel7v2 ~]# swift-ring-builder /etc/swift/account.builder create 12 2 1
[root@rhel7v2 ~]# swift-ring-builder /etc/swift/container.builder create 12 2 1
[root@rhel7v2 ~]# swift-ring-builder /etc/swift/object.builder create 12 2 1
[root@rhel7v2 ~]# for i in 1 2; do swift-ring-builder /etc/swift/account.builder add z${i}-192.168.4.10:6002/z${i}d1 100
[root@rhel7v2 ~]# for i in 1 2; do swift-ring-builder /etc/swift/container.builder add z${i}-192.168.4.10:6001/z${i}d1 100; done
[root@rhel7v2 ~]# for i in 1 2; do swift-ring-builder /etc/swift/object.builder add z${i}-192.168.4.11:6000/z${i}d1 100; done

生成文件并启动服务
[root@rhel7v2 ~]# swift-ring-builder /etc/swift/container.builder rebalance
[root@rhel7v2 ~]# swift-ring-builder /etc/swift/account.builder rebalance
[root@rhel7v2 ~]# swift-ring-builder /etc/swift/object.builder rebalance
[root@rhel7v2 ~]# systemctl start openstack-swift-account; systemctl enable openstack-swift-account
[root@rhel7v2 ~]# systemctl start openstack-swift-container; systemctl enable openstack-swift-containe
[root@rhel7v2 ~]# systemctl start openstack-swift-object; systemctl enable openstack-swift-object
[root@rhel7v2 ~]# chown -R root:swift /etc/swift/(更改权限)
[root@rhel7v2 ~]# crudini --set /etc/swift/proxy-server.conf filter:authtoken admin_tenant_name services
[root@rhel7v2 ~]# crudini --set /etc/swift/proxy-server.conf filter:authtoken identity_uri http://192.168.4.10:35357
[root@rhel7v2 ~]# crudini --set /etc/swift/proxy-server.conf filter:authtoken admin_user swift
[root@rhel7v2 ~]# crudini --set /etc/swift/proxy-server.conf filter:authtoken admin_password 123456
[root@rhel7v2 ~]# systemctl start memcached;systemctl enable memcached
[root@rhel7v2 ~]# systemctl start openstack-swift-proxy; systemctl enable openstack-swift-proxy

————————————————————————————————————————————————————————————————

cinder介绍
openstack从foleom开始使用cinder替换原来的nova-volume服务
为openstack云平台提供块存储,cinder为虚拟机提供了持久块存储


安装配置cinder
[root@rhel7v2 ~]# yum -y install openstack-cinder
[root@rhel7v2 ~]# cp /usr/share/cinder/cinder-dist.conf /etc/cinder/cinder.conf(复制配置文件)
[root@rhel7v2 ~]# openstack-db --init --service cinder --password 123456 --rootpw 123456
[root@rhel7v2 ~]# keystone user-create --name cinder --pass 123456
[root@rhel7v2 ~]# keystone role-create --name services
[root@rhel7v2 ~]# keystone user-role-add --user cinder --role admin --tenant services
[root@rhel7v2 ~]# keystone service-create --name=cinder --type=volume --description "OpenStack Block Storage Service"
[root@rhel7v2 ~]# keystone endpoint-create --service-id 68cb05a87bd24ff1b33b1187ffaeb497 --publicurl 'http://192.168.4.10:8776/v1/%(tenant_id)s' --adminurl 'http://192.168.4.10:8776/v1/%(tenant_id)s' --internalurl 'http://192.168.4.10:8776/v1/%(tenant_id)s'
[root@rhel7v2 ~]# keystone service-create --name=cinderv2 --type=volumev2 --description "Cinder Volume Service V2"
[root@rhel7v2 ~]# keystone endpoint-create --service-id f31adfd06ffe4733b2f3d3a5175f42ff --publicurl 'http://192.168.4.10:8776/v2/%(tenant_id)s' --adminurl 'http://192.168.4.10:8776/v2/%(tenant_id)s' --internalurl 'http://192.168.4.10:8776/v2/%(tenant_id)s'

修改配置文件
[root@rhel7v2 ~]# crudini --set /etc/cinder/cinder.conf keystone_authtoken admin_tenant_name services
[root@rhel7v2 ~]# crudini --set /etc/cinder/cinder.conf keystone_authtoken admin_user cinder
[root@rhel7v2 ~]# crudini --set /etc/cinder/cinder.conf keystone_authtoken admin_password 123456
[root@rhel7v2 ~]# crudini --set /etc/cinder/cinder.conf DEFAULT rabbit_userid rabbitmqauth
[root@rhel7v2 ~]# crudini --set /etc/cinder/cinder.conf DEFAULT rabbit_host 192.168.4.10
[root@rhel7v2 ~]# crudini --set /etc/cinder/cinder.conf DEFAULT rabbit_use_ssl True
[root@rhel7v2 ~]# crudini --set /etc/cinder/cinder.conf DEFAULT rabbit_port 5671

创建一个cinder-volumes的vg
[root@rhel7v2 ~]# pvcreate /dev/vdd(把磁盘组合为卷组)
[root@rhel7v2 ~]# vgcreate cinder-volumes /dev/vdd(改名)
起服务
[root@rhel7v2 ~]# systemctl enable openstack-cinder-api
[root@rhel7v2 ~]# systemctl enable openstack-cinder-scheduler
[root@rhel7v2 ~]# systemctl enable openstack-cinder-volume
[root@rhel7v2 ~]# openstack-service start cinder
[root@rhel7v2 ~]# openstack-status
[root@rhel7v2 ~]# cinder create --display-name vol1 2

————————————————————————————————————————————————————————————————————————————————————

相关推荐