Openstack(三):glance镜像服务和placement服务-创新互联
glance镜像服务
创新互联是一家业务范围包括IDC托管业务,雅安服务器托管、主机租用、主机托管,四川、重庆、广东电信服务器租用,中国电信成都枢纽中心,成都网通服务器托管,成都服务器租用,业务范围遍及中国大陆、港澳台以及欧美等多个国家及地区的互联网数据服务公司。官方文档:https://docs.openstack.org/glance/stein/install/install-rdo.html#install-and-configure-components
一、数据库
1、 创建数据库
mysql -uroot -p123456 MariaDB [(none)]> CREATE DATABASE glance;2、 创建用户
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance123';测试能否连接# mysql -uglance -pglance123 -hopenstack-mysql.heng.net
二、创建相应的服务并注册api
1、导入admin账号的变量,创建glance用户,并加入admin角色组
source scripts/admin-stein.sh openstack user create --domain default --password-prompt glance 密码glance openstack role add --project service --user glance admin2、创建image服务
[root@controller1 ~]#openstack service create --name glance --description "OpenStack Image" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | 1616cdd9d4f54f87812dc183321cdcf1 |
| name | glance |
| type | image |
+-------------+----------------------------------+
3、注册后端api
openstack endpoint create --region RegionOne image public http://openstack-vip.heng.net:9292
openstack endpoint create --region RegionOne image internal http://openstack-vip.heng.net:9292
openstack endpoint create --region RegionOne image admin http://openstack-vip.heng.net:9292
三、安装对应服务的软件包并修改配置文件
1、安装openstack-glance客户端(先安装后注册服务也可以)
yum install openstack-glance2、为了实现以后实现控制端的高可用,将镜像放在nfs上,配置nfs
在数据库和控制端上安装nfs
yum install nfs-utils -yvi /etc/exports
/data/openstack/images *(rw,no_root_squash)mkdir -p /data/openstack/images
systemctl start nfs
systemctl enable nfs
控制端测试
showmount -e 192.168.12.19
3、修改配置文件glance-api.conf
vi /etc/glance/glance-api.conf
[database] connection = mysql+pymysql://glance:glance123@openstack-mysql.heng.net/glance [keystone_authtoken] www_authenticate_uri = http://openstack-vip.heng.net:5000 auth_url = http://openstack-vip.heng.net:5000 memcached_servers = openstack-mysql.heng.net:11211 memcached在mysql上 auth_type = password project_domain_name = Default user_domain_name = Default project_name = service username = glance password = glance glance账户的密码 [paste_deploy] flavor = keystone 认证方式取消注释即可,所有服务认证方式都是keystone [glance_store] stores = file,http default_store = file filesystem_store_datadir = /var/lib/glance/images/4、修改配置文件/etc/glance/glance-registry.conf
vi /etc/glance/glance-registry.conf
[database] connection = mysql+pymysql://glance:glance123@openstack-mysql.heng.net/glance [keystone_authtoken] www_authenticate_uri = http://openstack-vip.heng.net:5000 auth_url = http://openstack-vip.heng.net:5000 memcached_servers = openstack-mysql.heng.net:11211 auth_type = password project_domain_name = Default user_domain_name = Default project_name = service username = glance password = glance [paste_deploy] flavor = keystone5、初始化数据库
su -s /bin/sh -c "glance-manage db_sync" glance6、启动服务,并设置开机启动
systemctl enable openstack-glance-api.service openstack-glance-registry.service systemctl start openstack-glance-api.service openstack-glance-registry.service7、挂载nfs
启动服务之后自动生成/var/lib/glance/images
ll /var/lib/glance/images -d停止第6步的服务再挂载
vi /etc/fstab 设置自动挂载, _netdev表示无法挂载跳过,不影响开机
192.168.12.19:/data/openstack/images /var/lib/glance/images/ nfs defaults,_netdev 0 0mount -a
注意/var/lib/glance/images的权限必须是glance
8、验证glance能否上传
wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img [root@controller1 ~]# openstack image create "cirros-0.4.0" \ --file /root/cirros-0.4.0-x86_64-disk.img \ --disk-format qcow2 --container-format bare \ --publicopenstack image listcat /var/log/glance/*.log 日志 用于排错
placement服务
官方文档:https://docs.openstack.org/placement/stein/install/install-rdo.html
一、数据库
1、创建数据库授权
mysql -uroot -p123456 MariaDB [(none)]> CREATE DATABASE placement; GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY 'placement123';2、在控制端连接测试
mysql -uplacement -pplacement123 -h292.168.12.19二、创建相应的服务并注册api
1、创建placement用户
source scripts/admin-stein.sh openstack user create --domain default --password-prompt placement2、将placement用户加入admin角色组
openstack role add --project service --user placement admin3、创建placement服务
openstack service create --name placement --description "Placement API" placement
4、注册api到服务
openstack endpoint create --region RegionOne placement public http://openstack-vip.heng.net:8778
openstack endpoint create --region RegionOne placement internal http://openstack-vip.heng.net:8778
openstack endpoint create --region RegionOne placement admin http://openstack-vip.heng.net:8778
openstack endpoint list 现在就有3组endpoint
三、安装对应服务的软件包并修改配置文件
1、 安装包
yum install openstack-placement-api2、 修改配置文件
vi /etc/placement/placement.conf
[placement_database] connection=mysql+pymysql://placement:placement123@openstack-mysql.heng.net/placement [api] auth_strategy = keystone 去掉注释 [keystone_authtoken] auth_url = http://openstack-vip.heng.net:5000/v3 memcached_servers = openstack-mysql.heng.net:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = placement password = placement3、初始化数据库
su -s /bin/sh -c "placement-manage db sync" placement重启httpd
source scripts/admin-stein.sh placement-status upgrade check另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
文章名称:Openstack(三):glance镜像服务和placement服务-创新互联
浏览路径:http://myzitong.com/article/dpieoe.html