CentOS 7.5 OpenStack部署指南
简介
OpenStack是一个开源的云计算管理平台项目,由Rackspace和NASA共同发起,它是一个全面开源的云计算管理平台,可以提供云基础设施即服务(IaaS)功能,本文将详细介绍如何在CentOS 7.5操作系统上部署OpenStack。
环境准备
硬件要求
- CPU:至少2核
- 内存:至少4GB
- 硬盘:至少20GB
- 网卡:至少1个千兆网卡
软件要求
- 操作系统:CentOS 7.5
- 网络工具:ping, ssh, curl等
- 编译工具:gcc, make等
部署步骤
系统初始化
(1)关闭防火墙和SELinux
systemctl stop firewalld systemctl disable firewalld setenforce 0
(2)更新系统
yum update -y
(3)安装必要的软件包
yum install -y epel-release yum install -y openstack-puppet openstack-keystone openstack-glance openstack-nova openstack-neutron openstack-quantum openstack-ceilometer openstack-ceilometer-api openstack-ceilometer-collector openstack-ceilometer-notification openstack Horizon
配置Keystone服务
(1)编辑/etc/keystone/keystone.conf文件
vi /etc/keystone/keystone.conf
[database] connection = mysql+pymysql://keystone:keystone@controller/keystone [memcached] servers = 127.0.0.1:11211 [assignment] default_role_name = user role_name_column_name = role_name role_name_translated_name_column_name = role_translated_name
(2)初始化Keystone数据库
su -s /bin/sh -c "keystone-manage db_sync" keystone
(3)创建管理员用户
keystone user-create --name=admin --pass=adminpass --email=admin@example.com --user-domain default --password-domain default
(4)创建管理员角色
keystone role-create --name=admin
(5)将管理员角色添加到管理员用户
keystone user-role-add --user admin --role admin --project admin
(6)创建服务实体
keystone service-create --name=keystone --type=identity --description="OpenStack Identity"
(7)创建服务端点
keystone endpoint-create --service-id=$(keystone service-list | awk '/keystone/ {print $2}' | grep -v ID) --publicurl=http://controller:5000/v3 --internalurl=http://controller:5000/v3 --adminurl=http://controller:35357/v3 --region RegionOne 配置Glance服务
(1)编辑/etc/glance/glance-api.conf文件
vi /etc/glance/glance-api.conf
[database] connection = mysql+pymysql://glance:glance@controller/glance [keystone_authtoken] auth_url = http://controller:5000/v3 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = glancepass
(2)编辑/etc/glance/glance-registry.conf文件
vi /etc/glance/glance-registry.conf
[database] connection = mysql+pymysql://glance:glance@controller/glance [keystone_authtoken] auth_url = http://controller:5000/v3 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = glancepass
(3)初始化Glance数据库
su -s /bin/sh -c "glance-manage db_sync" glance
(4)重启Glance服务
systemctl restart openstack-glance-api systemctl restart openstack-glance-registry
配置Nova服务
(1)编辑/etc/nova/nova.conf文件
vi /etc/nova/nova.conf
[database] connection = mysql+pymysql://nova:novapass@controller/nova [api] auth_url = http://controller:5000/v3 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = novapass [compute] vncserver_listen = 0.0.0.0 vncserver_proxyclient_address = 127.0.0.1 novncproxy_base_url = http://controller:6080/vnc_auto.html
(2)初始化Nova数据库
su -s /bin/sh -c "nova-manage db_sync" nova
(3)创建虚拟网络接口
nova network-create --name=public --provider-network-type flat --physical-network physnet1 --network-type flat
(4)启动Nova服务
systemctl restart openstack-nova-api systemctl restart openstack-nova-conductor systemctl restart openstack-nova-scheduler
配置Neutron服务
(1)编辑/etc/neutron/neutron.conf文件
vi /etc/neutron/neutron.conf
[database] connection = mysql+pymysql://neutron:neutron@controller/neutron [keystone_authtoken] auth_url = http://controller:5000/v3 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = neutron password = neutronpass [service_providers] service_provider = network:Neutron:standard:1.0
(2)编辑/etc/neutron/plugins/ml2/ml2_conf.ini文件
[ml2] type_drivers = flat,vlan tenant_network_types = mechanism_drivers = openvswitch extension_drivers = port_security [securitygroup] enable_security_group = True
(3)编辑/etc/neutron/plugins/openvswitch/ovs MechanismDriver.ini文件
[securitygroup] firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
(4)重启Neutron服务
systemctl restart openstack-nova-api systemctl restart neutron-server systemctl restart neutron-openvswitch-agent
配置Horizon服务
(1)编辑/etc/openstack-dashboard/local_settings.py文件
from django.utils.translation import ugettext_lazy as _ OPENSTACK_HOST = 'controller' # Identity service OPENSTACK_KEYSTONE_URL = 'http://controller:5000/v3' # Image service OPENSTACK_GLANCE_URL = 'http://controller:9292' # Compute service OPENSTACK_Nova_URL = 'http://controller:8774/v2.1' # Network service OPENSTACK_NEUTRON_URL = 'http://controller:9696' # Volume service OPENSTACK_CINDER_URL = 'http://controller:8776/v2' # Object Storage service OPENSTACK_SWIFT_URL = 'http://controller:8080/v1/AUTH_default' # Enable OpenStack Dashboard OPENSTACK_DASHBOARD_URL = '/horizon'
(2)重启Horizon服务
systemctl restart openstack-dashboard
测试部署
登录Keystone服务
keystone user-list
登录Horizon服务
在浏览器中输入http://controller/horizon,使用管理员用户名和密码登录。
FAQs
Q1:如何查看OpenStack服务的状态?
A1:可以使用以下命令查看:
systemctl status openstack-keystone systemctl status openstack-glance-api systemctl status openstack-nova-api systemctl status neutron-server systemctl status openstack-dashboard
Q2:如何创建虚拟机?
A2:在Horizon服务中,点击“Compute”下的“Launch Instance”按钮,按照提示创建虚拟机即可。

