文章目录
- 1.配置Dashboard
- 1.安全并配置组件
- 2.在Dashboard创建云主机
- 2.配置私有网络
- 1 配置控制节点
- 2.配置计算节点
- 3.设置浮动IP
- 3.运行封装的镜像
- 1.封装镜像
- 2.创建镜像
- 3.创建云主机类型
- 4.创建云主机
- 5.设置浮动IP
- 4.块存储服务
- 1.安装并配置控制节点
- 2.在控制节点安装并配置组件
- 3.在控制节点配置计算节点以使用块设备存储
- 4.配置存储节点
- 5.存储节点安装并配置组件
- 6.创建云硬盘
- 7.拉伸云硬盘
实验环境:可参考
1.配置Dashboard
Dashboard(horizon)是一个web接口,使得云平台管理员以及用户可以管理不同的Openstack资源以及服务。这个部署示例使用的是 Apache Web 服务器。
在控制节点上安装和配置仪表板
1.安全并配置组件
安装软件包:yum install openstack-dashboard -y
编辑文件[root@controller ~]# vim /etc/openstack-dashboard/local_settings
并完成如下动作:
##在 controller 节点上配置仪表盘以使用 OpenStack 服务:
OPENSTACK_HOST = "controller"
##允许所有主机访问仪表板:
ALLOWED_HOSTS = ['*', ]
##配置 memcached 会话存储服务:
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': 'controller:11211',
}
}
##启用第3版认证API:
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST
##启用对域的支持
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
##配置API版本:
OPENSTACK_API_VERSIONS = {
"identity": 3,
"image": 2,
"volume": 2,
}
##通过仪表盘创建用户时的默认域配置为 default :
OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "default"
##通过仪表盘创建的用户默认角色配置为 user :
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"
##如果您选择网络参数1,禁用支持3层网络服务:
OPENSTACK_NEUTRON_NETWORK = {
...
'enable_router': False,
'enable_quotas': False,
'enable_distributed_router': False,
'enable_ha_router': False,
'enable_lb': False,
'enable_firewall': False,
'enable_vpn': False,
'enable_fip_topology_check': False,
}
##可以选择性地配置时区:
TIME_ZONE = "Asia/Shanghai"
重启web服务器以及会话存储服务:systemctl restart httpd.service memcached.service
验证仪表盘的操作
在浏览器中输入 http://controller/dashboard
访问仪表盘。
验证使用 admin 或者demo
用户凭证和default
域凭证。
2.在Dashboard创建云主机
以管理员身份创建网络
demo用户创建云主机
2.配置私有网络
1 配置控制节点
编辑/etc/neutron/neutron.conf
文件并完成如下操作:
##在 [database] 部分,配置数据库访问:
[database]
connection = mysql+pymysql://neutron:neutron@controller/neutron
##在``[DEFAULT]``部分,启用Modular Layer 2 (ML2)插件,路由服务和重叠的IP地址:
[DEFAULT]
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True
##在 “[DEFAULT]” 和 “[oslo_messaging_rabbit]”部分,配置 “RabbitMQ” 消息队列的连接:
[DEFAULT]
rpc_backend = rabbit
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstack
##在 “[DEFAULT]” 和 “[keystone_authtoken]” 部分,配置认证服务访问:
[DEFAULT]
auth_strategy = keystone
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = neutron
##在``[DEFAULT]``和``[nova]``部分,配置网络服务来通知计算节点的网络拓扑变化:
[DEFAULT]
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
[nova]
auth_url = http://controller:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = NOVA_PASS
##在 [oslo_concurrency] 部分,配置锁路径:
[oslo_concurrency]
lock_path = /var/lib/neutron/tmp
配置 Modular Layer 2 (ML2) 插件
ML2插件使用Linuxbridge机制来为实例创建layer-2虚拟网络基础设施
编辑/etc/neutron/plugins/ml2/ml2_conf.ini
文件并完成以下操作:
##在``[ml2]``部分,启用flat,VLAN以及VXLAN网络:
[ml2]
type_drivers = flat,vlan,vxlan
##在``[ml2]``部分,启用VXLAN私有网络:
[ml2]
tenant_network_types = vxlan
##在``[ml2]``部分,启用Linuxbridge和layer-2机制:
[ml2]
mechanism_drivers = linuxbridge,l2population
##在``[ml2]`` 部分,启用端口安全扩展驱动:
[ml2]
extension_drivers = port_security
##在``[ml2_type_flat]``部分,配置公共虚拟网络为flat网络
[ml2_type_flat]
flat_networks = provider
##在``[ml2_type_vxlan]``部分,为私有网络配置VXLAN网络识别的网络范围:
[ml2_type_vxlan]
vni_ranges = 1:1000
##在 ``[securitygroup]``部分,启用 ipset 增加安全组规则的高效性:
[securitygroup]
enable_ipset = True
配置Linuxbridge代理
Linuxbridge代理为实例建立layer-2虚拟网络并且处理安全组规则。
编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini
文件并且完成以下操作:
##在``[linux_bridge]``部分,将公共虚拟网络和公共物理网络接口对应起来:
[linux_bridge]
physical_interface_mappings = provider:eth1
##在``[vxlan]``部分,启用VXLAN覆盖网络,配置覆盖网络的物理网络接口的IP地址,启用layer-2 population:
[vxlan]
enable_vxlan = True
local_ip = 192.168.43.11
l2_population = True
##在 ``[securitygroup]``部分,启用安全组并配置 Linuxbridge iptables firewall driver:
[securitygroup]
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
配置layer-3代理
Layer-3代理为私有虚拟网络提供路由和NAT服务
编辑/etc/neutron/l3_agent.ini
文件并完成以下操作:
##在``[DEFAULT]``部分,配置Linuxbridge接口驱动和外部网络网桥:
[DEFAULT]
interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
external_network_bridge =
配置DHCP代理
编辑/etc/neutron/dhcp_agent.ini
文件并完成下面的操作:
##在``[DEFAULT]``部分,配置Linuxbridge驱动接口,DHCP驱动并启用隔离元数据,这样在公共网络上的实例就可以通过网络来访问元数据
[DEFAULT]
interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = True
重启服务systemctl restart neutron-server.service neutron-linuxbridge-agent.service
启用layer-3服务并设置其随系统自启动systemctl enable --now neutron-l3-agent.service
2.配置计算节点
配置Linuxbridge代理
Linuxbridge代理为实例建立layer-2虚拟网络并且处理安全组规则。
编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini
文件并且完成以下操作:
##在``[linux_bridge]``部分,将公共虚拟网络和公共物理网络接口对应起来:
[linux_bridge]
physical_interface_mappings = provider:eth1
##在``[vxlan]``部分,启用VXLAN覆盖网络,配置覆盖网络的物理网络接口的IP地址,启用layer-2 population:
[vxlan]
enable_vxlan = True
local_ip = 192.168.43.12
l2_population = True
##在 ``[securitygroup]``部分,启用安全组并配置 Linuxbridge iptables firewall driver:
[securitygroup]
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
重启服务systemctl restart neutron-linuxbridge-agent.service
支持3层网络服务
编辑文件 /etc/openstack-dashboard/local_settings
OPENSTACK_NEUTRON_NETWORK = {
...
'enable_router': True,
'enable_quotas': True,
'enable_distributed_router':True,
'enable_ha_router':True,
'enable_lb': True,
'enable_firewall':True,
'enable_vpn': True,
'enable_fip_topology_check': True,
}
重启服务systemctl restart httpd.service memcached.service
此时私有网络可以Ping外网,但是外网不能Ping私有网络
3.设置浮动IP
此时外网可以访问192.168.43.103这个浮动IP
3.运行封装的镜像
参考官网:https://docs.openstack.org/image-guide/centos-image.html
1.封装镜像
配置完后后
2.创建镜像
3.创建云主机类型
4.创建云主机
5.设置浮动IP
4.块存储服务
1.安装并配置控制节点
创建数据库、服务证书和API端点
创建数据库:
用数据库连接客户端以 root 用户连接到数据库服务器:mysql -p
创建 cinder 数据库:CREATE DATABASE cinder;
允许 cinder 数据库合适的访问权限:GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'cinder';
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'cinder';
要创建服务证书
获得 admin 凭证来获取只有管理员能执行的命令的访问权限:source admin-openrc
创建一个 cinder 用户:openstack user create --domain default --password cinder cinder
添加 admin 角色到 cinder 用户上。openstack role add --project service --user cinder admin
创建 cinder 和 cinderv2 服务实体:openstack service create --name cinder --description "OpenStack Block Storage" volume
openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
创建块设备存储服务的 API 入口点:openstack endpoint create --region RegionOne volume public http://controller:8776/v1/%\(tenant_id\)s
openstack endpoint create --region RegionOne volume internal http://controller:8776/v1/%\(tenant_id\)s
openstack endpoint create --region RegionOne volume admin http://controller:8776/v1/%\(tenant_id\)s
openstack endpoint create --region RegionOne volumev2 public http://controller:8776/v2/%\(tenant_id\)s
openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%\(tenant_id\)s
openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%\(tenant_id\)s
2.在控制节点安装并配置组件
安装软件包:yum install openstack-cinder
编辑 /etc/cinder/cinder.conf,同时完成如下动作:
##在 [database] 部分,配置数据库访问:
[database]
connection = mysql+pymysql://cinder:cinder@controller/cinder
##在 “[DEFAULT]” 和 “[oslo_messaging_rabbit]”部分,配置 “RabbitMQ” 消息队列访问:
[DEFAULT]
rpc_backend = rabbit
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstack
###在 “[DEFAULT]” 和 “[keystone_authtoken]” 部分,配置认证服务访问:
[DEFAULT]
auth_strategy = keystone
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = cinder
##在 [DEFAULT 部分,配置``my_ip`` 来使用控制节点的管理接口的IP 地址。
[DEFAULT]
my_ip = 192.168.43.11
##在 [oslo_concurrency] 部分,配置锁路径:
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
初始化块设备服务的数据库:su -s /bin/sh -c "cinder-manage db sync" cinder
3.在控制节点配置计算节点以使用块设备存储
编辑文件 /etc/nova/nova.conf 并添加如下到其中:
[cinder]
os_region_name = RegionOne
重启计算API 服务:systemctl restart openstack-nova-api.service
启动块设备存储服务,并将其配置为开机自启:systemctl enable --now openstack-cinder-api.service openstack-cinder-scheduler.service
4.配置存储节点
安装支持的工具包:
安装 LVM 包:
yum install lvm2
启动LVM的metadata服务并且设置该服务随系统启动:
systemctl enable --now 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/", "a/sdb/","r/.*/"]
5.存储节点安装并配置组件
安装软件包:yum install openstack-cinder targetcli python-keystone
编辑 /etc/cinder/cinder.conf,同时完成如下动作:
##在 [database] 部分,配置数据库访问:
[database]
connection = mysql+pymysql://cinder:cinder@controller/cinder
##在 “[DEFAULT]” 和 “[oslo_messaging_rabbit]”部分,配置 “RabbitMQ” 消息队列访问:
[DEFAULT]
rpc_backend = rabbit
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstack
##在 [DEFAULT] 部分,配置 my_ip 选项:
[DEFAULT]
my_ip = 192.168.43.13
##在``[lvm]``部分,配置LVM后端以LVM驱动结束,卷组``cinder-volumes`` ,iSCSI 协议和正确的 iSCSI服务:
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
iscsi_protocol = iscsi
iscsi_helper = lioadm
##在 [DEFAULT] 部分,启用 LVM 后端:
[DEFAULT]
enabled_backends = lvm
[DEFAULT]
glance_api_servers = http://controller:9292
##在 [oslo_concurrency] 部分,配置锁路径:
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
启动块存储卷服务及其依赖的服务,并将其配置为随系统启动:systemctl enable --now openstack-cinder-volume.service target.service
列出服务组件以验证是否每个进程都成功启动:cinder service-list
6.创建云硬盘
7.拉伸云硬盘