IP地址 主机名 操做系统 192.168.56.11 linux-node1 CentOS7 192.168.56.12 linux-node2 CentOS7
其中,linux-node1看成控制节点html
linux-node2看成计算节点node
咱们把除了nova-compute组件以外的节点都安装在一台主机上,称为控制节点;把nava-compute安装在另一台主机上,称为计算节点;计算节点是用来建立虚拟机的python
nova有不少服务mysql
- API:负责接收和响应外部请求,支持OpenStack API,EC2 API - Cert:负责身份认证EC2 - Schedule:用于云主机调度 - Conductor:计算节点访问数据的中间件 - Consoleauth:用于控制台的受权验证 - Novncproxy:VNC代理
scheduler模块在openstack中的做用就是决策虚拟机建立在哪一个主机(计算节点)上。linux
决策一个虚拟机应该调度到某物理节点,须要分两个步骤: - 过滤(Filter) - 计算权值(Weight)
在控制节点上sql
[root@linux-node1 ~]# yum install -y openstack-nova-api openstack-nova-cert \ openstack-nova-conductor openstack-nova-console \ openstack-nova-novncproxy openstack-nova-scheduler
先决条件数据库
已在安装mariadb后建立完成vim
建立用户centos
配置数据库链接api
vim /etc/nova/nova.conf [api_database] connection=mysql+pymysql://nova:nova@192.168.56.11/nova_api [database] connection=mysql+pymysql://nova:nova@192.168.56.11/nova
[root@linux-node1 ~]# su -s /bin/sh -c "nova-manage api_db sync" nova [root@linux-node1 ~]# su -s /bin/sh -c "nova-manage db sync" nova
验证是否同步成功
mysql -h 192.168.56.11 -unova -pnova -e "use nova;show tables;" mysql -h 192.168.56.11 -unova -pnova -e "use nova_api;show tables;"
vim /etc/nova/nova.conf #打开注释,认证方式选择keystone auth_strategy=keystone #在[keystone_authtoken]下添加 auth_uri = http://192.168.56.11:5000 auth_url = http://192.168.56.11:35357 memcached_servers = 192.168.56.11:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = nova
[root@linux-node1 ~]# grep '^r' /etc/nova/nova.conf rabbit_host=192.168.56.11 rabbit_port=5672 rabbit_userid=openstack rabbit_password=openstack rpc_backend=rabbit
vim /etc/nova/nova.conf #在[DEFAULT]部分,只使用计算和元数据API enabled_apis=osapi_compute,metadata #和网络相关,使用neutron use_neutron=true #使用nova的防火墙,而且关闭 firewall_driver=nova.virt.firewall.NoopFirewallDriver #在[vnc]部分,配置VNC代理使用控制节点的管理接口IP地址 vncserver_listen=192.168.56.11 vncserver_proxyclient_address=192.168.56.11 #在 [glance] 区域,配置镜像服务 API 的位置: api_servers=http://192.168.56.11:9292 #在 [oslo_concurrency] 部分,配置锁路径: lock_path=/var/lib/nova/tmp
[root@linux-node1 ~]# systemctl enable openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-api.service to /usr/lib/systemd/system/openstack-nova-api.service. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-consoleauth.service to /usr/lib/systemd/system/openstack-nova-consoleauth.service. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-scheduler.service to /usr/lib/systemd/system/openstack-nova-scheduler.service. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-conductor.service to /usr/lib/systemd/system/openstack-nova-conductor.service. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-novncproxy.service to /usr/lib/systemd/system/openstack-nova-novncproxy.service. [root@linux-node1 ~]# systemctl start openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
在建立以前,要先执行环境变量脚本 [root@linux-node1 ~]# source admin-openstack.sh
再建立nova服务实体
[root@linux-node1 ~]# openstack service create --name nova --description "OpenStack Compute" compute +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Compute | | enabled | True | | id | 4d3ec9545a5549598a0b7e458b8f7bcd | | name | nova | | type | compute | +-------------+----------------------------------+
建立镜像服务的API endpoint
[root@linux-node1 ~]# openstack endpoint create --region RegionOne compute public http://192.168.56.11:8774/v2.1/%\(tenant_id\)s +--------------+----------------------------------------------+ | Field | Value | +--------------+----------------------------------------------+ | enabled | True | | id | b3e8878ea8964039897bb56367364484 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 4d3ec9545a5549598a0b7e458b8f7bcd | | service_name | nova | | service_type | compute | | url | http://192.168.56.11:8774/v2.1/%(tenant_id)s | +--------------+----------------------------------------------+ [root@linux-node1 ~]# openstack endpoint create --region RegionOne compute admin http://192.168.56.11:8774/v2.1/%\(tenant_id\)s +--------------+----------------------------------------------+ | Field | Value | +--------------+----------------------------------------------+ | enabled | True | | id | 59b33390ae474bc5bd04fb8bc3affa90 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 4d3ec9545a5549598a0b7e458b8f7bcd | | service_name | nova | | service_type | compute | | url | http://192.168.56.11:8774/v2.1/%(tenant_id)s | +--------------+----------------------------------------------+ [root@linux-node1 ~]# openstack endpoint create --region RegionOne compute internal http://192.168.56.11:8774/v2.1/%\(tenant_id\)s +--------------+----------------------------------------------+ | Field | Value | +--------------+----------------------------------------------+ | enabled | True | | id | 0d8ed49cdded436bb2faadc133017049 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 4d3ec9545a5549598a0b7e458b8f7bcd | | service_name | nova | | service_type | compute | | url | http://192.168.56.11:8774/v2.1/%(tenant_id)s | +--------------+----------------------------------------------+
验证控制节点是否部署成功
[root@linux-node1 ~]# openstack host list +-------------+-------------+----------+ | Host Name | Service | Zone | +-------------+-------------+----------+ | linux-node1 | consoleauth | internal | | linux-node1 | conductor | internal | | linux-node1 | scheduler | internal | +-------------+-------------+----------+
rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
yum install -y centos-release-openstack-mitaka
yum install -y python-openstackclient
yum install -y openstack-selinux
[root@linux-node2 ~]# grep '^[a-Z]' /etc/nova/nova.conf enabled_apis=osapi_compute,metadata auth_strategy=keystone firewall_driver=nova.virt.firewall.NoopFirewallDriver use_neutron=true rpc_backend=rabbit api_servers=http://192.168.56.11:9292 auth_uri = http://192.168.56.11:5000 auth_url = http://192.168.56.11:35357 memcached_servers = 192.168.56.11:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = nova virt_type=kvm lock_path=/var/lib/nova/tmp rabbit_host=192.168.56.11 rabbit_port=5672 rabbit_userid=openstack rabbit_password=openstack enabled=true #启用并配置远程控制台访问 vncserver_listen=0.0.0.0 vncserver_proxyclient_address=192.168.56.12 novncproxy_base_url=http://192.168.56.11:6080/vnc_auto.html
systemctl enable libvirtd.service openstack-nova-compute.service systemctl start libvirtd.service openstack-nova-compute.service
在控制节点上执行 [root@linux-node1 ~]# source admin-openstack.sh [root@linux-node1 ~]# openstack host list +-------------+-------------+----------+ | Host Name | Service | Zone | +-------------+-------------+----------+ | linux-node1 | consoleauth | internal | | linux-node1 | conductor | internal | | linux-node1 | scheduler | internal | | linux-node2 | compute | nova | +-------------+-------------+----------+ 能够看到在计算节点上有compute服务,则说明配置成功 [root@linux-node1 ~]# nova service-list +----+------------------+-------------+----------+---------+-------+----------------------------+-----------------+ | Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason | +----+------------------+-------------+----------+---------+-------+----------------------------+-----------------+ | 1 | nova-consoleauth | linux-node1 | internal | enabled | up | 2016-10-28T13:22:42.000000 | - | | 2 | nova-conductor | linux-node1 | internal | enabled | up | 2016-10-28T13:22:49.000000 | - | | 3 | nova-scheduler | linux-node1 | internal | enabled | up | 2016-10-28T13:22:42.000000 | - | | 6 | nova-compute | linux-node2 | nova | enabled | up | 2016-10-28T13:22:44.000000 | - | +----+------------------+-------------+----------+---------+-------+----------------------------+-----------------+
若是能列出咱们已经上传的镜像,则证实nova与glance之间配置成功 [root@linux-node1 ~]# nova p_w_picpath-list +--------------------------------------+--------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+--------+--------+--------+ | 29d99654-ba91-4d04-8808-e1b8d16861fb | cirros | ACTIVE | | +--------------------------------------+--------+--------+--------+