openstack victoria 部署
环境准备
1.配置网络
2.vi /etc/hosts 添加controller信息
10.0.0.11 controller
3.安装sql
yum install mariadb mariadb-server python-PyMySQL
vim /etc/my.cnf.d/openstack.cnf创建并编辑以下内容
[mysqld]
bind-address = 10.0.0.11
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
启动服务
systemctl enable mariadb.service
systemctl start mariadb.service
4.安装RabbitMQ
yum install rabbitmq-server
启动服务
systemctl enable rabbitmq-server.service
systemctl start rabbitmq-server.service
rabbitmqctl add_user openstack RABBIT_PASS添加用户
rabbitmqctl set_permissions openstack “." ".” “.*” 设置读写权限
5.安装 Memcached
yum install memcached python3-memcached
vim /etc/sysconfig/memcached 编辑
启动服务
systemctl enable memcached.service
systemctl start memcached.service
安装openstack
1.创建keystone并授权
mysql -u root -p
MariaDB [(none)]> CREATE DATABASE keystone;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO ‘keystone’@‘localhost’
IDENTIFIED BY ‘KEYSTONE_DBPASS’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO ‘keystone’@’%’
IDENTIFIED BY ‘KEYSTONE_DBPASS’;
MariaDB [(none)]> exit
安装软件包
yum install openstack-keystone httpd mod_wsgi
配置数据库入口
vim /etc/keystone/keystone.conf
[database]
connection = mysql+pymysql://keystone:KEYSTONE_DBPASS@controller/keystone
[token]
provider = fernet
此处文件全为注释,去掉前面的#号。否则同步数据库时报错。
同步数据库
su -s /bin/sh -c “keystone-manage db_sync” keystone
初始化fernet密钥仓库
keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
keystone-manage credential_setup --keystone-user keystone --keystone-group keystone
权限需要修改否则出现错误
修改该文件的权限
成功执行
启动身份服务
keystone-manage bootstrap --bootstrap-password ADMIN_PASS
–bootstrap-admin-url http://controller:5000/v3/
–bootstrap-internal-url http://controller:5000/v3/
–bootstrap-public-url http://controller:5000/v3/
–bootstrap-region-id RegionOne
配置serverName
vim /etc/httpd/conf/httpd.conf,去掉前面的#号
创建符号链接
ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/
完成安装
systemctl enable httpd.service
systemctl start httpd.service
此时发现无法启动apache http service,报错:
Aug 12 10:11:01 localhost httpd[5165]: (13)Permission denied: AH00072: make_sock: could not bind to address [::]:8078
Aug 12 10:11:01 localhost httpd[5165]: (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:8078
Aug 12 10:11:01 localhost httpd[5165]: no listening sockets available, shutting down
Aug 12 10:11:01 localhost httpd[5165]: AH00015: Unable to open logs
Aug 12 10:11:01 localhost systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
此时是因为本机selinux而导致的错误,调整selinux状态即可,修改selinux的状态有两种方式,一种是修改配置文件,永久生效:
[root@localhost ~]# vi /etc/selinux/config
7 SELINUX=enforcing #把enforcing改为disabled
[root@localhost ~]# reboot #重新启动让其生效
设置环境变量
$ export OS_USERNAME=admin
$ export OS_PASSWORD=ADMIN_PASS
$ export OS_PROJECT_NAME=admin
$ export OS_USER_DOMAIN_NAME=Default
$ export OS_PROJECT_DOMAIN_NAME=Default
$ export OS_AUTH_URL=http://controller:5000/v3
$ export OS_IDENTITY_API_VERSION=3
分别执行如下命令,创建domain, projects, users, roles。
创建domain ‘example’:
$ openstack domain create --description “An Example Domain” example
出现错误
安装yum install -y python3-openstackclient后成功
domain ‘default’在 keystone-manage bootstrap 时已创建
创建project ‘service’:
$ openstack project create --domain default --description “Service Project” service
创建(non-admin)project ’myproject‘,user ’myuser‘ 和 role ’myrole‘,为‘myproject’和‘myuser’添加角色‘myrole’:
$ openstack project create --domain default --description “Demo Project” myproject
$ openstack user create --domain default --password-prompt myuser
这里记得输入密码 不然后面无法进行
$ openstack role create myrole
$ openstack role add --project myproject --user myuser myrole
取消临时环境变量OS_AUTH_URL和OS_PASSWORD:
$ unset OS_AUTH_URL OS_PASSWORD
为admin用户请求token:
$ openstack --os-auth-url http://controller:5000/v3
–os-project-domain-name Default --os-user-domain-name Default
–os-project-name admin --os-username admin token issue
输入当时的密码
为myuser用户请求token:
$ openstack --os-auth-url http://controller:5000/v3
–os-project-domain-name Default --os-user-domain-name Default
–os-project-name myproject --os-username myuser token issue
输入当时的密码
创建 OpenStack client 环境脚本
分别为admin和demo用户创建环境变量脚本:
vim admin-openrc
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=ADMIN_PASS
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
vim demo-openrc
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=myproject
export OS_USERNAME=myuser
export OS_PASSWORD=DEMO_PASS
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
替换ADMIN_PASS为admin用户的密码
替换DEMO_PASS为myuser用户的密码
运行脚本加载环境变量:
$ source admin-openrc
Glance安装
1.创建数据库、服务凭证和 API 端点
创建数据库:
以 root 用户访问数据库,创建 glance 数据库并授权。
$ mysql -u root -p
MariaDB [(none)]> CREATE DATABASE glance;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO ‘glance’@‘localhost’
IDENTIFIED BY ‘GLANCE_DBPASS’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO ‘glance’@’%’
IDENTIFIED BY ‘GLANCE_DBPASS’;
MariaDB [(none)]> exit
替换 GLANCE_DBPASS,为 glance 数据库设置密码。
$ source admin-openrc
执行以下命令,分别完成创建 glance 服务凭证、创建glance用户和添加‘admin’角色到用户‘glance’。
$ openstack user create --domain default --password-prompt glance
$ openstack role add --project service --user glance admin
$ openstack service create --name glance --description “OpenStack Image” image
创建镜像服务API端点:
$ openstack endpoint create --region RegionOne image public http://controller:9292
$ openstack endpoint create --region RegionOne image internal http://controller:9292
$ openstack endpoint create --region RegionOne image admin http://controller:9292
2.安装和配置
安装软件包:
#yum install openstack-glance openstack-glance-api
配置glance:
编辑 /etc/glance/glance-api.conf 文件:
在[database]部分,配置数据库入口
在[keystone_authtoken] [paste_deploy]部分,配置身份认证服务入口
在[glance_store]部分,配置本地文件系统存储和镜像文件的位置
#vi /etc/glance/glance-api.conf
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = GLANCE_PASS
[paste_deploy]
flavor = keystone
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
其中,替换 GLANCE_DBPASS 为 glance 数据库的密码,替换 GLANCE_PASS 为 glance 用户的密码。
同步数据库:
su -s /bin/sh -c “glance-manage db_sync” glance
启动镜像服务:
#systemctl enable openstack-glance-api.service
#systemctl start openstack-glance-api.service
3. 验证
下载镜像
$ source admin-openrc
#注意:如果您使用的环境是鲲鹏架构,请下载arm64版本的镜像。
$ wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
向Image服务上传镜像:
$ glance image-create --name “cirros” --file cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --container-format bare --visibility=public
出现
安装yum -y install openstack-glance python3-glanceclient
再次运行出现错误
9292端口未打开。
修改错误。uri应该为url
因为服务为启用,启动apache http服务和glance-api服务
#systemctl enable openstack-glance-api.service
#systemctl start openstack-glance-api.service
确认镜像上传并验证属性:
$ glance image-list
Placement安装
创建数据库、服务凭证和 API 端点
创建数据库:
作为 root 用户访问数据库,创建 placement 数据库并授权。
$ mysql -u root -p
MariaDB [(none)]> CREATE DATABASE placement;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO ‘placement’@‘localhost’
IDENTIFIED BY ‘PLACEMENT_DBPASS’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO ‘placement’@’%’
IDENTIFIED BY ‘PLACEMENT_DBPASS’;
MariaDB [(none)]> exit
替换 PLACEMENT_DBPASS,为 placement 数据库设置密码
$ source admin-openrc
执行如下命令,创建 placement 服务凭证、创建 placement 用户以及添加‘admin’角色到用户‘placement’。
创建Placement API服务
$ openstack user create --domain default --password-prompt placement
$ openstack role add --project service --user placement admin
$ openstack service create --name placement --description “Placement API” placement
创建placement服务API端点:
$ openstack endpoint create --region RegionOne placement public http://controller:8778
$ openstack endpoint create --region RegionOne placement internal http://controller:8778
$ openstack endpoint create --region RegionOne placement admin http://controller:8778
安装和配置
安装软件包:
yum install openstack-placement-api
配置placement:
编辑 /etc/placement/placement.conf 文件:
在[placement_database]部分,配置数据库入口
在[api] [keystone_authtoken]部分,配置身份认证服务入口
#vi /etc/placement/placement.conf
[placement_database]
…
connection = mysql+pymysql://placement:PLACEMENT_DBPASS@controller/placement
[api]
…
auth_strategy = keystone
[keystone_authtoken]
…
auth_url = http://controller:5000/v3
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = placement
password = PLACEMENT_PASS
其中,替换 PLACEMENT_DBPASS 为 placement 数据库的密码,替换 PLACEMENT_PASS 为 placement 用户的密码。
同步数据库:
#su -s /bin/sh -c “placement-manage db sync” placement
启动httpd服务:
#systemctl restart httpd
3. 验证
执行如下命令,执行状态检查:
$ . admin-openrc
$ placement-status upgrade check
安装osc-placement,列出可用的资源类别及特性:
$ yum install python3-osc-placement
$ openstack --os-placement-api-version 1.2 resource class list --sort-column name
$ openstack --os-placement-api-version 1.6 trait list --sort-column name
Nova安装
创建数据库、服务凭证和 API 端点
创建数据库:
作为root用户访问数据库,创建nova、nova_api、nova_cell0 数据库并授权
$ mysql -u root -p
MariaDB [(none)]> CREATE DATABASE nova_api;
MariaDB [(none)]> CREATE DATABASE nova;
MariaDB [(none)]> CREATE DATABASE nova_cell0;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO ‘nova’@‘localhost’
IDENTIFIED BY ‘NOVA_DBPASS’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO ‘nova’@’%’
IDENTIFIED BY ‘NOVA_DBPASS’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO ‘nova’@‘localhost’
IDENTIFIED BY ‘NOVA_DBPASS’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO ‘nova’@’%’
IDENTIFIED BY ‘NOVA_DBPASS’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO ‘nova’@‘localhost’
IDENTIFIED BY ‘NOVA_DBPASS’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO ‘nova’@’%’
IDENTIFIED BY ‘NOVA_DBPASS’;
MariaDB [(none)]> exit
替换NOVA_DBPASS,为nova数据库设置密码
执行如下命令,完成创建nova服务凭证、创建nova用户以及添加‘admin’角色到用户‘nova’。
$ . admin-openrc
$ openstack user create --domain default --password-prompt nova
$ openstack role add --project service --user nova admin
$ openstack service create --name nova --description “OpenStack Compute” compute
创建计算服务API端点:
$ openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1
$ openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1
$ openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1
安装和配置
安装软件包:
#yum install openstack-nova-api openstack-nova-conductor
openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-compute
配置nova:
编辑 /etc/nova/nova.conf 文件:
在[default]部分,启用计算和元数据的API,配置RabbitMQ消息队列入口,配置my_ip;
在[api_database] [database]部分,配置数据库入口;
在[api] [keystone_authtoken]部分,配置身份认证服务入口;
在[vnc]部分,启用并配置远程控制台入口;
在[glance]部分,配置镜像服务API的地址;
在[oslo_concurrency]部分,配置lock path;
在[placement]部分,配置placement服务的入口。
#vim /etc/nova/nova.conf
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:RABBIT_PASS@controller:5672/
my_ip = 10.0.0.11
[api_database]
connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova_api
[database]
connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova
[api]
auth_strategy = keystone
[keystone_authtoken]
www_authenticate_uri = http://controller:5000/
auth_url = http://controller:5000/
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = NOVA_PASS
[vnc]
enabled = true
server_listen = $my_ip
server_proxyclient_address = $my_ip
novncproxy_base_url = http://controller:6080/vnc_auto.html
[glance]
api_servers = http://controller:9292
[oslo_concurrency]
lock_path = /var/lib/nova/tmp
[placement]
region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://controller:5000/v3
username = placement
password = PLACEMENT_PASS
[neutron]
auth_url = http://controller:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = NEUTRON_PASS
替换RABBIT_PASS为RabbitMQ中openstack账户的密码;
配置my_ip为控制节点的管理IP地址;
替换NOVA_DBPASS为nova数据库的密码;
替换NOVA_PASS为nova用户的密码;
替换PLACEMENT_PASS为placement用户的密码;
替换NEUTRON_PASS为neutron用户的密码;
同步nova-api数据库:
su -s /bin/sh -c “nova-manage api_db sync” nova
注册cell0数据库:
su -s /bin/sh -c “nova-manage cell_v2 map_cell0” nova
创建cell1 cell:
su -s /bin/sh -c “nova-manage cell_v2 create_cell --name=cell1 --verbose” nova
同步nova数据库:
su -s /bin/sh -c “nova-manage db sync” nova
验证cell0和cell1注册正确:
su -s /bin/sh -c “nova-manage cell_v2 list_cells” nova
确定是否支持虚拟机硬件加速(x86架构):
$ egrep -c ‘(vmx|svm)’ /proc/cpuinfo
如果返回值为0则不支持硬件加速,需要配置libvirt使用QEMU而不是KVM:
#vi /etc/nova/nova.conf
[libvirt]
virt_type = qemu
如果返回值为1或更大的值,则支持硬件加速,不需要进行额外的配置
启动计算服务及其依赖项,并配置其开机启动:
#systemctl enable
openstack-nova-api.service
openstack-nova-scheduler.service
openstack-nova-conductor.service
openstack-nova-novncproxy.service
#systemctl start
openstack-nova-api.service
openstack-nova-scheduler.service
openstack-nova-conductor.service
openstack-nova-novncproxy.service
#systemctl enable libvirtd.service openstack-nova-compute.service
#systemctl start libvirtd.service openstack-nova-compute.service
出错
添加计算节点到cell数据库:
确认计算节点存在:
$ . admin-openrc
$ openstack compute service list --service nova-compute
注册计算节点:
#su -s /bin/sh -c “nova-manage cell_v2 discover_hosts --verbose” nova
3. 验证
$ . admin-openrc
列出服务组件,验证每个流程都成功启动和注册:
$ openstack compute service list
列出身份服务中的API端点,验证与身份服务的连接:
$ openstack catalog list
列出镜像服务中的镜像,验证与镜像服务的连接:
$ openstack image list
检查cells和placement API是否运作成功,以及其他必要条件是否已具备。
#nova-status upgrade check
Neutron安装
创建数据库、服务凭证和 API 端点
创建数据库:
作为root用户访问数据库,创建 neutron 数据库并授权。
$ mysql -u root -p
MariaDB [(none)]> CREATE DATABASE neutron;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO ‘neutron’@‘localhost’
IDENTIFIED BY ‘NEUTRON_DBPASS’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO ‘neutron’@’%’
IDENTIFIED BY ‘NEUTRON_DBPASS’;
MariaDB [(none)]> exit
替换NEUTRON_DBPASS,为neutron数据库设置密码。
$ . admin-openrc
执行如下命令,完成创建 neutron 服务凭证、创建neutron用户和添加‘admin’角色到‘neutron’用户操作。
创建neutron服务
$ openstack user create --domain default --password-prompt neutron
$ openstack role add --project service --user neutron admin
$ openstack service create --name neutron --description “OpenStack Networking” network
创建网络服务API端点:
$ openstack endpoint create --region RegionOne network public http://controller:9696
$ openstack endpoint create --region RegionOne network internal http://controller:9696
$ openstack endpoint create --region RegionOne network admin http://controller:9696
安装和配置 Self-service 网络
安装软件包:
yum install openstack-neutron openstack-neutron-ml2
openstack-neutron-linuxbridge ebtables ipset
配置neutron:
编辑 /etc/neutron/neutron.conf 文件:
在[database]部分,配置数据库入口;
在[default]部分,启用ml2插件和router插件,允许ip地址重叠,配置RabbitMQ消息队列入口;
在[default] [keystone]部分,配置身份认证服务入口;
在[default] [nova]部分,配置网络来通知计算网络拓扑的变化;
在[oslo_concurrency]部分,配置lock path。
vim /etc/neutron/neutron.conf
[database]
connection = mysql+pymysql://neutron:NEUTRON_DBPASS@controller/neutron
[DEFAULT]
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = true
transport_url = rabbit://openstack:RABBIT_PASS@controller
auth_strategy = keystone
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = NEUTRON_PASS
[nova]
auth_url = http://controller:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = NOVA_PASS
[oslo_concurrency]
lock_path = /var/lib/neutron/tmp
替换NEUTRON_DBPASS为neutron数据库的密码;
替换RABBIT_PASS为RabbitMQ中openstack账户的密码;
替换NEUTRON_PASS为neutron用户的密码;
替换NOVA_PASS为nova用户的密码。
配置ML2插件:
编辑 /etc/neutron/plugins/ml2/ml2_conf.ini 文件:
在[ml2]部分,启用 flat、vlan、vxlan 网络,启用网桥及 layer-2 population 机制,启用端口安全扩展驱动;
在[ml2_type_flat]部分,配置 flat 网络为 provider 虚拟网络;
在[ml2_type_vxlan]部分,配置 VXLAN 网络标识符范围;
在[securitygroup]部分,配置允许 ipset。
#vim /etc/neutron/plugins/ml2/ml2_conf.ini
[ml2]
type_drivers = flat,vlan,vxlan
tenant_network_types = vxlan
mechanism_drivers = linuxbridge,l2population
extension_drivers = port_security
[ml2_type_flat]
flat_networks = provider
[ml2_type_vxlan]
vni_ranges = 1:1000
[securitygroup]
enable_ipset = true
配置 Linux bridge 代理:
编辑 /etc/neutron/plugins/ml2/linuxbridge_agent.ini 文件:
在[linux_bridge]部分,映射 provider 虚拟网络到物理网络接口;
在[vxlan]部分,启用 vxlan 覆盖网络,配置处理覆盖网络的物理网络接口 IP 地址,启用 layer-2 population;
在[securitygroup]部分,允许安全组,配置 linux bridge iptables 防火墙驱动。
vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[linux_bridge]
physical_interface_mappings = provider:PROVIDER_INTERFACE_NAME
[vxlan]
enable_vxlan = true
local_ip = OVERLAY_INTERFACE_IP_ADDRESS
l2_population = true
[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
替换PROVIDER_INTERFACE_NAME为物理网络接口;
替换OVERLAY_INTERFACE_IP_ADDRESS为控制节点的管理IP地址。
配置Layer-3代理:
编辑 /etc/neutron/l3_agent.ini 文件:
在[default]部分,配置接口驱动为linuxbridge
vim /etc/neutron/l3_agent.ini
[DEFAULT]
interface_driver = linuxbridge
配置DHCP代理:
编辑 /etc/neutron/dhcp_agent.ini 文件:
在[default]部分,配置linuxbridge接口驱动、Dnsmasq DHCP驱动,启用隔离的元数据。
vim /etc/neutron/dhcp_agent.ini
[DEFAULT]
interface_driver = linuxbridge
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = true
配置metadata代理:
编辑 /etc/neutron/metadata_agent.ini 文件:
在[default]部分,配置元数据主机和shared secret。
vim /etc/neutron/metadata_agent.ini
[DEFAULT]
nova_metadata_host = controller
metadata_proxy_shared_secret = METADATA_SECRET
替换METADATA_SECRET为合适的元数据代理secret。
配置计算服务
编辑 /etc/nova/nova.conf 文件:
在[neutron]部分,配置访问参数,启用元数据代理,配置secret。
vim /etc/nova/nova.conf
[neutron]
auth_url = http://controller:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = NEUTRON_PASS
service_metadata_proxy = true
metadata_proxy_shared_secret = METADATA_SECRET
替换NEUTRON_PASS为neutron用户的密码;
替换METADATA_SECRET为合适的元数据代理secret。
完成安装
添加链接:
#ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
同步数据库:
#su -s /bin/sh -c “neutron-db-manage --config-file /etc/neutron/neutron.conf
–config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head” neutron
重启计算API服务:
#systemctl restart openstack-nova-api.service
启动网络服务并配置开机启动:
#systemctl enable neutron-server.service
neutron-linuxbridge-agent.service neutron-dhcp-agent.service
neutron-metadata-agent.service
#systemctl start neutron-server.service
neutron-linuxbridge-agent.service neutron-dhcp-agent.service
neutron-metadata-agent.service
#systemctl enable neutron-l3-agent.service
#systemctl start neutron-l3-agent.service
验证
列出代理验证 neutron 代理启动成功:
$ openstack network agent list
Cinder安装
创建数据库、服务凭证和 API 端点
创建数据库:
作为root用户访问数据库,创建cinder数据库并授权。
$ mysql -u root -p
MariaDB [(none)]> CREATE DATABASE cinder;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO ‘cinder’@‘localhost’
IDENTIFIED BY ‘CINDER_DBPASS’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO ‘cinder’@’%’
IDENTIFIED BY ‘CINDER_DBPASS’;
MariaDB [(none)]> exit
替换CINDER_DBPASS,为cinder数据库设置密码。
$ source admin-openrc
创建cinder服务凭证:
创建cinder用户
添加‘admin’角色到用户‘cinder’
创建cinderv2和cinderv3服务
$ openstack user create --domain default --password-prompt cinder
$ openstack role add --project service --user cinder admin
$ openstack service create --name cinderv2 --description “OpenStack Block Storage” volumev2
$ openstack service create --name cinderv3 --description “OpenStack Block Storage” volumev3
创建块存储服务API端点:
$ openstack endpoint create --region RegionOne volumev2 public http://controller:8776/v2/%s
$ openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%s
$ openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%s
$ openstack endpoint create --region RegionOne volumev3 public http://controller:8776/v3/%s
$ openstack endpoint create --region RegionOne volumev3 internal http://controller:8776/v3/%s
$ openstack endpoint create --region RegionOne volumev3 admin http://controller:8776/v3/%s
安装和配置控制节点
安装软件包:
#yum install openstack-cinder
配置cinder:
编辑 /etc/cinder/cinder.conf 文件:
在[database]部分,配置数据库入口;
在[DEFAULT]部分,配置RabbitMQ消息队列入口,配置my_ip;
在[DEFAULT] [keystone_authtoken]部分,配置身份认证服务入口;
在[oslo_concurrency]部分,配置lock path。
#vim /etc/cinder/cinder.conf
[database]
connection = mysql+pymysql://cinder:CINDER_DBPASS@controller/cinder
[DEFAULT]
transport_url = rabbit://openstack:RABBIT_PASS@controller
auth_strategy = keystone
my_ip = 10.0.0.11
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = CINDER_PASS
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
替换CINDER_DBPASS为cinder数据库的密码;
替换RABBIT_PASS为RabbitMQ中openstack账户的密码;
配置my_ip为控制节点的管理IP地址;
替换CINDER_PASS为cinder用户的密码;
同步数据库:
su -s /bin/sh -c “cinder-manage db sync” cinder
配置计算使用块存储:
编辑 /etc/nova/nova.conf 文件。
#vim /etc/nova/nova.conf
[cinder]
os_region_name = RegionOne
完成安装:
重启计算API服务
systemctl restart openstack-nova-api.service
启动块存储服务
#systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
#systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
安装和配置存储节点
安装软件包:
yum install lvm2 device-mapper-persistent-data targetcli python-keystone
此命令错误,修改为:
yum install lvm2 device-mapper-persistent-data targetcli python3-keystone
启动服务:
#systemctl enable lvm2-lvmetad.service
#systemctl start lvm2-lvmetad.service
创建LVM物理卷 /dev/sdb:
pvcreate /dev/sdb
创建LVM卷组 cinder-volumes:
vgcreate cinder-volumes /dev/sdb
编辑 /etc/lvm/lvm.conf 文件:
在devices部分,添加过滤以接受/dev/sdb设备拒绝其他设备。
devices {
…
filter = [ “a/sdb/”, “r/.*/“]
编辑 /etc/cinder/cinder.conf 文件:
在[lvm]部分,使用LVM驱动、cinder-volumes卷组、iSCSI协议和适当的iSCSI服务配置LVM后端。
在[DEFAULT]部分,启用LVM后端,配置镜像服务API的位置。
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
target_protocol = iscsi
target_helper = lioadm
[DEFAULT]
enabled_backends = lvm
glance_api_servers = http://controller:9292
完成安装:
#systemctl enable openstack-cinder-volume.service target.service
#systemctl start openstack-cinder-volume.service target.service
安装和配置备份服务
编辑 /etc/cinder/cinder.conf 文件:
在[DEFAULT]部分,配置备份选项
[DEFAULT]
#注意: openEuler 21.03中没有提供OpenStack Swift软件包,需要用户自行安装。或者使用其他的备份后端,例如,NFS。NFS已经过测试验证,可以正常使用。
backup_driver = cinder.backup.drivers.swift.SwiftBackupDriver
backup_swift_url = SWIFT_URL
替换SWIFT_URL为对象存储服务的URL,该URL可以通过对象存储API端点找到:
$ openstack catalog show object-store
完成安装:
#systemctl enable openstack-cinder-backup.service
#systemctl start openstack-cinder-backup.service
验证
列出服务组件验证每个步骤成功:
$ source admin-openrc
$ openstack volume service list
注:目前暂未对swift组件进行支持,有条件的同学可以配置对接ceph。