本次部署流程是基于测试环境部署的,实机部署可能会有所偏差,请参照生产环境自行检查。
先使用vmware workstation创建3台虚拟机(根据架构图应该是4台 但是宿主机资源有限,将存储节点和网络节点合并)
所有虚拟机 均使用以下配置 (宿主机至少拥有24g内存和6核心的英特尔处理器或者6核的AMD 4代ryzen以上)开启处理器虚拟化
控制节点ct:
处理器 | 2核2线程 | 实际上在宿主机应该是2核4线程,因为vm设置的虚拟机线程是每个核心的线程数 |
---|---|---|
内存/存储 | 8G | 300g+300g设置多个硬盘文件,不会立即分配所有空间 |
网卡 | net:20.0.0.20(模拟公网,面向用户) | vm1:192.168.100.10 (模拟局域网,面向内部服务) |
操作系统 | Centos7.6-1810 | 最小化安装(模拟生产环境) |
其他节点只需修改地址即可
c1:
ens33:20.0.0.21
ens37:192.168.100.11
c2:
ens33:20.0.0.22
ens37:192.168.100.12
过程太长博主会分篇介绍,本次只是glance部署
mysql -u root -p
CREATE DATABASE glance; #创建名为glance的库
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS'; #授权给本地
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS'; #授权给所有网段
flush privileges;
exit
openstack user create --domain default --password GLANCE_PASS glance
openstack role add --project service --user glance admin
Image" image #创建OpenStack中的glance用户密码并设置其为管理员
openstack endpoint create --region RegionOne image public http://ct:9292 #为其创建在数据网络域的端口
openstack endpoint create --region RegionOne image internal http://ct:9292 #为其创建在外部网络域的端口
openstack endpoint create --region RegionOne image admin http://ct:9292 #为其创建在管理网络域的端口
yum -y install openstack-glance #yum安装glance
cp -a /etc/glance/glance-api.conf{
,.bak} #备份原配置文件模板
grep -Ev '^$|#' /etc/glance/glance-api.conf.bak > /etc/glance/glance-api.conf #输出并覆盖原配置文件中的非注销项给原文件
openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@ct/glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken www_authenticate_uri http://ct:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers ct:11211
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password GLANCE_PASS
openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http
openstack-config --set /etc/glance/glance-api.conf glance_store default_store file
openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
cat /etc/glance/glance-api.conf
cp -a /etc/glance/glance-registry.conf{
,.bak} #备份
grep -Ev '^$|#' /etc/glance/glance-registry.conf.bak > /etc/glance/glance-registry.conf #输出并覆盖原配置文件中的非注销项给原文件
openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@ct/glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken www_authenticate_uri http://ct:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers ct:11211
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken password GLANCE_PASS
openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-registry.conf glance_store stores file,http
openstack-config --set /etc/glance/glance-registry.conf glance_store default_store file
openstack-config --set /etc/glance/glance-registry.conf glance_store filesystem_store_datadir /var/lib/glance/images/
cat /etc/glance/glance-registry.conf
[DEFAULT]
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@ct/glance #指定数据库的类型和数据库用户名密码
[keystone_authtoken]
www_authenticate_uri = http://ct:5000 、#指定keystone的地址端口
auth_url = http://ct:5000
memcached_servers = ct:11211 #指定token令牌缓存的地址端口
auth_type = password #访问keystone验证方式
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = GLANCE_PASS
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_policy]
[paste_deploy]
flavor = keystone #token的验证方式
[profiler]
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/ #指定镜像文件存储位置
su -s /bin/sh -c "glance-manage db_sync" glance #切换用户执行初始化
Database is synced successfully. #提示sync 表示同步成功
systemctl enable openstack-glance-api.service #开启glance-api服务开机自启
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-api.service to /usr/lib/systemd/system/openstack-glance-api.service.
systemctl start openstack-glance-api.service #开启glance-api服务
netstat -natp | grep 9292 #查看开放的端口
tcp 0 0 0.0.0.0:9292 0.0.0.0:* LISTEN 12365/python2
yum -y install lrzsz #安装Xshell文件传输软件
完毕!
rz -E #上传测试镜像文件
rz waiting to receive.
openstack image create --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public cirros #将镜像导入glance使其识别
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum | f8ab98ff5e73ebab884d80c9dc9c7290 |
| container_format | bare |
| created_at | 2020-12-21T12:02:59Z |
| disk_format | qcow2 #镜像格式 |
| file | /v2/images/b59d3ef0-b40d-43be-a1fa-e25039b46627/file |
| id | b59d3ef0-b40d-43be-a1fa-e25039b46627 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | dcff771374df4c618c93996fdcf87dad |
| properties | os_hash_algo='sha512', os_hash_value='f0fd1b50420dce4ca382ccfbb528eef3a38bbeff00b54e95e3876b9bafe7ed2d6f919ca35d9046d437c6d2d8698b1174a335fbd66035bb3edc525d2cdb187232', os_hidden='False' |
| protected | False |
| schema | /v2/schemas/image |
| size | 13267968 |
| status | active #上传的状态 该状态为传输完成可以调用 |
| tags | |
| updated_at | 2020-12-21T12:03:00Z |
| virtual_size | None |
| visibility | public |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
openstack image list #使用OpenStack命令查看镜像列表 可以看到镜像状态
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| b59d3ef0-b40d-43be-a1fa-e25039b46627 | cirros | active |
+--------------------------------------+--------+--------+
[root@localhost ~]# glance image-list #使用glance命令查看镜像列表 看不到镜像状态
+--------------------------------------+--------+
| ID | Name |
+--------------------------------------+--------+
| b59d3ef0-b40d-43be-a1fa-e25039b46627 | cirros |
+--------------------------------------+--------+