linux云计算(keystone swift cinder配置)
Posted XxSec
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
[[email protected] ~]# yum -y install openstack-keystone openstack-selinux
[[email protected] ~]# yum -y install openstack-utils
[[email protected] ~]# openstack-db --init --service keystone(初始化数据库)
[[email protected] ~]# keystone-manage pki_setup --keystone-user keystone --keystone-group keystone(生成签名信息)
[[email protected] ~]# export SERVICE_TOKEN=$(openssl rand -hex 10)(设置环境变量)
[[email protected] ~]# export SERVICE_ENDPOINT=http://192.168.4.10:35357/v2.0(改为本机ip)
[[email protected] ~]# echo $SERVICE_TOKEN > /root/ks_admin_token(备份令牌)
[[email protected] ~]# crudini --set /etc/keystone/keystone.conf DEFAULT admin_token $SERVICE_TOKEN
[[email protected] ~]# systemctl start openstack-keystone
[[email protected] ~]# systemctl enable openstack-keystone
[[email protected] ~]# systemctl enable mariadb
[[email protected] ~]# keystone service-create --name=keystone --type=identity --description="Keystone Identity Service"
[[email protected] ~]# 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‘(为它创建端点)
[[email protected] ~]# keystone user-create --name admin --pass 123456
[[email protected] ~]# keystone role-create --name admin
[[email protected] ~]# keystone tenant-create --name admin
[[email protected] ~]# keystone user-role-add --user admin --role admin --tenant admin(创建用户)
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# yum -y install openstack-swift-proxy openstack-swift-object openstack-swift-container openstack-swift-account python-swiftclient memcached
[[email protected] ~]# keystone user-create --name swift --pass 123456
[[email protected] ~]# keystone tenant-create --name services
[[email protected] ~]# keystone user-role-add --role admin --tenant services --user swift
[[email protected] ~]# keystone service-create --name swift --type object-store --description "Swift Storage Service"
[[email protected] ~]# 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存储节点服务器安装两块额外的硬盘,分区,格式化
[[email protected] ~]# lsblk
vdb 252:16 0 20G 0 disk
vdc 252:32 0 20G 0 disk
vdd 252:48 0 20G 0 disk
[[email protected] ~]# parted /dev/vdb
(parted) mktable gpt
(parted) mkpart primary ext4 1M -1
[[email protected] ~]# parted /dev/vdc
(parted) mktable gpt
(parted) mkpart primary ext4 1M -1
[[email protected] ~]# mkfs.ext4 /dev/vdb1
[[email protected] ~]# mkfs.ext4 /dev/vdc1
[[email protected] ~]# mkdir -pv /srv/node/z{1,2}d1(创建目录)
[[email protected]rhel7v2 ~]# blkid /dev/vdb1(查看uuid)
[[email protected] ~]# blkid /dev/vdc1
[[email protected] ~]# 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
[[email protected] node]# mount -a(挂载)
[[email protected] ~]# chown -R swift:swift /srv/node/(修改权限)
[[email protected] ~]# crudini --set /etc/swift/swift.conf swift-hash swift_hash_path_prefix $(openssl rand -hex 10)(修改配置文件)
[[email protected] ~]# crudini --set /etc/swift/swift.conf swift-hash swift_hash_path_suffix $(openssl rand -hex 10)
[[email protected] ~]# crudini --set /etc/swift/account-server.conf DEFAULT bind_ip 192.168.4.10
[[email protected] ~]# crudini --set /etc/swift/container-server.conf DEFAULT bind_ip 192.168.4.10
[[email protected] ~]# 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表示数据迁移时间,小时)
[[email protected] ~]# swift-ring-builder /etc/swift/account.builder create 12 2 1
[[email protected] ~]# swift-ring-builder /etc/swift/container.builder create 12 2 1
[[email protected] ~]# swift-ring-builder /etc/swift/object.builder create 12 2 1
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# 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
生成文件并启动服务
[[email protected] ~]# swift-ring-builder /etc/swift/container.builder rebalance
[[email protected] ~]# swift-ring-builder /etc/swift/account.builder rebalance
[[email protected] ~]# swift-ring-builder /etc/swift/object.builder rebalance
[[email protected] ~]# systemctl start openstack-swift-account; systemctl enable openstack-swift-account
[[email protected] ~]# systemctl start openstack-swift-container; systemctl enable openstack-swift-containe
[[email protected] ~]# systemctl start openstack-swift-object; systemctl enable openstack-swift-object
[[email protected] ~]# chown -R root:swift /etc/swift/(更改权限)
[[email protected] ~]# crudini --set /etc/swift/proxy-server.conf filter:authtoken admin_tenant_name services
[[email protected] ~]# crudini --set /etc/swift/proxy-server.conf filter:authtoken identity_uri http://192.168.4.10:35357
[[email protected] ~]# crudini --set /etc/swift/proxy-server.conf filter:authtoken admin_user swift
[[email protected] ~]# crudini --set /etc/swift/proxy-server.conf filter:authtoken admin_password 123456
[[email protected] ~]# systemctl start memcached;systemctl enable memcached
[[email protected] ~]# systemctl start openstack-swift-proxy; systemctl enable openstack-swift-proxy
————————————————————————————————————————————————————————————————
cinder介绍
openstack从foleom开始使用cinder替换原来的nova-volume服务
为openstack云平台提供块存储,cinder为虚拟机提供了持久块存储
安装配置cinder
[[email protected] ~]# yum -y install openstack-cinder
[[email protected] ~]# cp /usr/share/cinder/cinder-dist.conf /etc/cinder/cinder.conf(复制配置文件)
[[email protected] ~]# openstack-db --init --service cinder --password 123456 --rootpw 123456
[[email protected] ~]# keystone user-create --name cinder --pass 123456
[[email protected] ~]# keystone role-create --name services
[[email protected] ~]# keystone user-role-add --user cinder --role admin --tenant services
[[email protected] ~]# keystone service-create --name=cinder --type=volume --description "OpenStack Block Storage Service"
[[email protected] ~]# 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‘
[[email protected] ~]# keystone service-create --name=cinderv2 --type=volumev2 --description "Cinder Volume Service V2"
[[email protected] ~]# 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‘
修改配置文件
[[email protected] ~]# crudini --set /etc/cinder/cinder.conf keystone_authtoken admin_tenant_name services
[[email protected] ~]# crudini --set /etc/cinder/cinder.conf keystone_authtoken admin_user cinder
[[email protected] ~]# crudini --set /etc/cinder/cinder.conf keystone_authtoken admin_password 123456
[[email protected] ~]# crudini --set /etc/cinder/cinder.conf DEFAULT rabbit_userid rabbitmqauth
[[email protected] ~]# crudini --set /etc/cinder/cinder.conf DEFAULT rabbit_host 192.168.4.10
[[email protected] ~]# crudini --set /etc/cinder/cinder.conf DEFAULT rabbit_use_ssl True
[[email protected] ~]# crudini --set /etc/cinder/cinder.conf DEFAULT rabbit_port 5671
创建一个cinder-volumes的vg
[[email protected] ~]# pvcreate /dev/vdd(把磁盘组合为卷组)
[[email protected] ~]# vgcreate cinder-volumes /dev/vdd(改名)
起服务
[[email protected] ~]# systemctl enable openstack-cinder-api
[[email protected] ~]# systemctl enable openstack-cinder-scheduler
[[email protected] ~]# systemctl enable openstack-cinder-volume
[[email protected] ~]# openstack-service start cinder
[[email protected] ~]# openstack-status
[[email protected] ~]# cinder create --display-name vol1 2
————————————————————————————————————————————————————————————————————————————————————
以上是关于linux云计算(keystone swift cinder配置)的主要内容,如果未能解决你的问题,请参考以下文章
云计算OpenStack:keystone身份认证服务--技术流ken
第五十六课 云计算模型 openstack架构keystone基础及部署