作用
compute 用户启动 instance
compute 可以连接 ceph 作为 instance 外部存储
软件安装
# yum install -y openstack-neutron.noarch openstack-neutron-ml2.noarch openstack-neutron-openvswitch.noarch openstack-nova-api openstack-nova-compute openstack-nova-conductor openstack-nova-scheduler python-cinderclient openstack-utils openstack-nova-novncproxy
配置 neutron-metadata-agent, neutron-openvswitch-agent
定义 neutron 连接 keystone 认证
# openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone
# openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_host 240.10.130.25
# openstack-config --set /etc/neutron/neutron.conf keystone_authtoken admin_tenant_name service
# openstack-config --set /etc/neutron/neutron.conf keystone_authtoken admin_user neutron
# openstack-config --set /etc/neutron/neutron.conf keystone_authtoken admin_password neutron
定义 neutron 连接 rabbitmq
# openstack-config --set /etc/neutron/neutron.conf DEFAULT rpc_backend neutron.openstack.common.rpc.impl_kombu
# openstack-config --set /etc/neutron/neutron.conf DEFAULT rabbit_host 240.10.130.25
# openstack-config --set /etc/neutron/neutron.conf DEFAULT rabbit_port 5672
# openstack-config --set /etc/neutron/neutron.conf DEFAULT rabbit_userid neutron
# openstack-config --set /etc/neutron/neutron.conf DEFAULT rabbit_password openstack
定义 neutron 使用 ml2 的网络 plugin
# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
# openstack-config --set /etc/neutron/neutron.conf DEFAULT core_plugin neutron.plugins.ml2.plugin.Ml2Plugin
# openstack-config --set /etc/neutron/neutron.conf DEFAULT service_plugins neutron.services.l3_router.l3_router_plugin.L3RouterPlugin
# openstack-config --set /etc/neutron/plugin.ini ml2 type_drivers vxlan,flat
# openstack-config --set /etc/neutron/plugin.ini ml2 tenant_network_types vxlan,flat
# openstack-config --set /etc/neutron/plugin.ini ml2 mechanism_drivers openvswitch
# openstack-config --set /etc/neutron/plugin.ini agent l2_population True
配置 ovs plugin
# openstack-config --set /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini ovs bridge_mappings physnet1:br-ex
# openstack-config --set /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini ovs network_vlan_ranges physnet1
# openstack-config --set /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini ovs tunnel_type vxlan
# openstack-config --set /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini ovs local_ip 10.199.130.31
# openstack-config --set /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini ovs enable_tunneling True
# openstack-config --set /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini ovs integration_bridge br-int
# openstack-config --set /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini ovs tunnel_bridge br-tun
# openstack-config --set /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini agent tunnel_types vxlan
# openstack-config --set /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini securitygroup firewall_driver neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
桥接网络配置
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
HWADDR=48:46:FB:04:97:5C
TYPE=OVSPort
DEVICETYPE=ovs
OVS_BRIDGE=br-ex
/etc/sysconfig/network-scripts/ifcfg-br-ex
DEVICE=br-ex
DEVICETYPE=ovs
TYPE=OVSBridge
BOOTPROTO=static
IPADDR=10.199.130.31
NETMASK=255.255.252.0
GATEWAY=10.199.128.1
ONBOOT=yes
重启网络生效
service network restart
配置 compute
配置 keystone 验证
# openstack-config --set /etc/nova/nova.conf DEFAULT auth_strategy keystone
# openstack-config --set /etc/nova/api-paste.ini filter:authtoken auth_host 240.10.130.25
# openstack-config --set /etc/nova/api-paste.ini filter:authtoken admin_tenant_name service
# openstack-config --set /etc/nova/api-paste.ini filter:authtoken admin_user nova
# openstack-config --set /etc/nova/api-paste.ini filter:authtoken admin_password nova
连接 rabbitmq, 用于处理消息队列
# openstack-config --set /etc/nova/nova.conf DEFAULT rpc_backend rabbit
# openstack-config --set /etc/nova/nova.conf DEFAULT rabbit_host 240.10.130.25
# openstack-config --set /etc/nova/nova.conf DEFAULT rabbit_port 5672
# openstack-config --set /etc/nova/nova.conf DEFAULT rabbit_userid nova
# openstack-config --set /etc/nova/nova.conf DEFAULT rabbit_password openstack
连接 glance, 用于获取镜像信息
# openstack-config --set /etc/nova/nova.conf DEFAULT glance_host 10.199.130.25
# openstack-config --set /etc/nova/nova.conf DEFAULT glance_port 9292
# openstack-config --set /etc/nova/nova.conf DEFAULT glance_protocol http
# openstack-config --set /etc/nova/nova.conf DEFAULT glance_api_servers 10.199.130.25:9292
# openstack-config --set /etc/nova/nova.conf DEFAULT image_service nova.image.glance.GlanceImageService
连接 neutron 获得网络信息
# openstack-config --set /etc/nova/nova.conf DEFAULT network_api_class nova.network.neutronv2.api.API
# openstack-config --set /etc/nova/nova.conf DEFAULT neutron_url http://240.10.130.29:9696/
# openstack-config --set /etc/nova/nova.conf DEFAULT neutron_admin_tenant_name service
# openstack-config --set /etc/nova/nova.conf DEFAULT neutron_admin_username neutron
# openstack-config --set /etc/nova/nova.conf DEFAULT neutron_admin_password neutron
# openstack-config --set /etc/nova/nova.conf DEFAULT neutron_admin_auth_url http://240.10.130.25:35357/v2.0
# openstack-config --set /etc/nova/nova.conf DEFAULT security_group_api neutron
# openstack-config --set /etc/nova/nova.conf DEFAULT firewall_drivernova.virt.firewall.NoopFirewallDriver
获得 libvirt 虚拟化支持
# openstack-config --set /etc/nova/nova.conf DEFAULT compute_driver nova.virt.libvirt.LibvirtDriver
# openstack-config --set /etc/nova/nova.conf DEFAULT libvirt_inject_partition \-1
# openstack-config --set /etc/nova/nova.conf libvirt virt_type kvm
# openstack-config --set /etc/nova/nova.conf libvirt inject_password True
# openstack-config --set /etc/nova/nova.conf libvirt live_migration_uri qemu+ssh://nova@%s/system?keyfile=/etc/nova/ssh/nova_migration_key
# openstack-config --set /etc/nova/nova.conf libvirt vif_driver nova.virt.libvirt.vif.LibvirtGenericVIFDriver
# openstack-config --set /etc/nova/nova.conf libvirt cpu_mode host-model
设定云主机超配信息
openstack-config --set /etc/nova/nova.conf DEFAULT cpu_allocation_ratio=16.0
openstack-config --set /etc/nova/nova.conf DEFAULT ram_allocation_ratio=1.5
openstack-config --set /etc/nova/nova.conf DEFAULT reserved_host_memory_mb=8096
openstack-config --set /etc/nova/nova.conf DEFAULT reserved_host_disk_mb=80
配置连接 nova 的数据库
openstack-config --set /etc/nova/nova.conf DEFAULT sql_connection mysql://nova:openstack@240.10.130.25/nova
配置 vnc 连接
# openstack-config --set /etc/nova/nova.conf DEFAULT novncproxy_base_url http://10.199.130.30:6080/vnc_auto.html
# openstack-config --set /etc/nova/nova.conf DEFAULT vncserver_listen 0.0.0.0
# openstack-config --set /etc/nova/nova.conf DEFAULT vncserver_proxyclient_address 240.10.130.30
# openstack-config --set /etc/nova/nova.conf DEFAULT vnc_enabled True
compute 节点服务启动
service messagebus restart
service libvirtd restart
service openstack-nova-compute restart
service neutron-openvswitch-agent restart
验证
检测服务
[root@hh-yun-compute-130025 ~]# source /root/keystonerc_admin
[root@hh-yun-compute-130025 ~(keystone_admin)]# nova service-list
+------------------+-----------------------------------+----------+---------+-------+----------------------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+------------------+-----------------------------------+----------+---------+-------+----------------------------+-----------------+
| nova-consoleauth | hh-yun-compute-130030.vclound.com | internal | enabled | up | 2014-10-14T09:48:59.000000 | - |
| nova-scheduler | hh-yun-compute-130030.vclound.com | internal | enabled | up | 2014-10-14T09:49:02.000000 | - |
| nova-conductor | hh-yun-compute-130030.vclound.com | internal | enabled | up | 2014-10-14T09:48:55.000000 | - |
| nova-compute | hh-yun-compute-130030.vclound.com | nova | enabled | down | 2014-10-11T08:31:52.000000 | - |
| nova-compute | hh-yun-compute-130031.vclound.com | nova | enabled | up | 2014-10-14T09:48:55.000000 | - |
| nova-compute | hh-yun-compute-130032.vclound.com | nova | enabled | up | 2014-10-14T09:48:54.000000 | - |
+------------------+-----------------------------------+----------+---------+-------+----------------------------+-----------------+
[root@hh-yun-compute-130025 ~(keystone_admin)]# neutron agent-list
+--------------------------------------+--------------------+-----------------------------------+-------+----------------+
| id | agent_type | host | alive | admin_state_up |
+--------------------------------------+--------------------+-----------------------------------+-------+----------------+
| 21fa636f-141f-4d59-8be4-9d85d71498e8 | Open vSwitch agent | hh-yun-compute-130032.vclound.com | :-) | True |
| 2ec500b0-84f7-4f4d-8565-8ba0abdb3c50 | Open vSwitch agent | hh-yun-compute-130031.vclound.com | :-) | True |
| 6f24029b-e24e-424f-a0c3-bfb507eae6da | L3 agent | hh-yun-compute-130029.vclound.com | :-) | True |
| 730a9541-ae3d-4448-8798-b825f80514a2 | Metadata agent | hh-yun-compute-130029.vclound.com | :-) | True |
| 98ef41f5-46c7-48b3-a8a0-5f638a15c881 | Metadata agent | hh-yun-compute-130031.vclound.com | :-) | True |
| a03f5dd1-cc2f-4b5e-ad58-1b0186638bc9 | DHCP agent | hh-yun-compute-130029.vclound.com | :-) | True |
| dbc049c1-7101-4470-bc45-9b21c76265ec | Metadata agent | hh-yun-compute-130032.vclound.com | :-) | True |
| ec475da6-9a76-498b-a3e7-c711be90673c | Open vSwitch agent | hh-yun-compute-130029.vclound.com | :-) | True |
+--------------------------------------+--------------------+-----------------------------------+-------+----------------+
创建云主机
nova boot --flavor m1.small --image centos5.8 --security_group terry_test_rule --nic net-id=b26b81fc-bda9-4882-950c-614e9546bcd1 terry_test
+--------------------------------------+--------------------------------------------------+
| Property | Value |
+--------------------------------------+--------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-SRV-ATTR:host | - |
| OS-EXT-SRV-ATTR:hypervisor_hostname | - |
| OS-EXT-SRV-ATTR:instance_name | instance-00000008 |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | - |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| adminPass | u7CNVSq5ceyv |
| config_drive | |
| created | 2014-10-13T08:00:48Z |
| flavor | m1.small (2) |
| hostId | |
| id | 1281d02c-a79e-4241-a596-3c1a10b3e7e9 |
| image | centos5.8 (438d5c5a-f595-45e5-8236-801b9da8f9ab) |
| key_name | - |
| metadata | {} |
| name | terry_test |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| security_groups | terry_test_rule |
| status | BUILD |
| tenant_id | 59728cade8b14853a8d3cee8c2567881 |
| updated | 2014-10-13T08:00:48Z |
| user_id | 43f38bc5c1314670b0cf1d925736ff3a |
+--------------------------------------+--------------------------------------------------+
检验
[root@hh-yun-compute-130025 ~(keystone_admin)]# nova list
+--------------------------------------+------------+--------+------------+-------------+------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------------+--------+------------+-------------+------------------------+
| 1281d02c-a79e-4241-a596-3c1a10b3e7e9 | terry_test | BUILD | spawning | NOSTATE | ext_net=10.199.131.209 |
+--------------------------------------+------------+--------+------------+-------------+------------------------+
[root@hh-yun-compute-130025 ~(keystone_admin)]# nova list
+--------------------------------------+------------+--------+------------+-------------+------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------------+--------+------------+-------------+------------------------+
| 1281d02c-a79e-4241-a596-3c1a10b3e7e9 | terry_test | ACTIVE | - | Running | ext_net=10.199.131.209 |
+--------------------------------------+------------+--------+------------+-------------+------------------------+
日志验证
[root@hh-yun-compute-130025 ~(keystone_admin)]# nova console-log terry_test
Starting cloud-init-local: Starting cloud-init: Cloud-init v. 0.7.4 running 'init-local' at Mon, 13 Oct 2014 08:01:44 +0000. Up 31.90 seconds.
[ OK ]
Starting cloud-init: Starting cloud-init: Cloud-init v. 0.7.4 running 'init' at Mon, 13 Oct 2014 08:01:44 +0000. Up 32.23 seconds.
ci-info: ++++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++
ci-info: +--------+-------+----------------+---------------+-------------------+
ci-info: | Device | Up | Address | Mask | Hw-Address |
ci-info: +--------+-------+----------------+---------------+-------------------+
ci-info: | sit0 | False | . | . | . |
ci-info: | lo | True | 127.0.0.1 | 255.0.0.0 | . |
ci-info: | eth0 | True | 10.199.131.209 | 255.255.252.0 | fa:16:3e:b6:10:59 |
ci-info: +--------+-------+----------------+---------------+-------------------+
ci-info: ++++++++++++++++++++++++++++++++Route info+++++++++++++++++++++++++++++++++
ci-info: +-------+--------------+--------------+---------------+-----------+-------+
ci-info: | Route | Destination | Gateway | Genmask | Interface | Flags |
ci-info: +-------+--------------+--------------+---------------+-----------+-------+
ci-info: | 0 | 10.199.128.0 | 0.0.0.0 | 255.255.252.0 | eth0 | U |
ci-info: | 1 | 169.254.0.0 | 0.0.0.0 | 255.255.0.0 | eth0 | U |
ci-info: | 2 | 0.0.0.0 | 10.199.128.1 | 0.0.0.0 | eth0 | UG |
ci-info: +-------+--------------+--------------+---------------+-----------+-------+
Successfully create eth0 nic configuration file
# Virtio Network Device
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
NETMASK=255.255.252.0
IPADDR=10.199.131.209
HWADDR=fa:16:3e:b6:10:59
BROADCAST=10.199.131.255
TYPE=Ethernet
MTU=1450
*****************
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
*****************
DNS resolv.conf:
; generated by /usr/sbin/change_dhcp2fixedip.sh
nameserver 10.199.129.21
*****************
Network configuration file is done.
[ OK ]
Starting cloud-config: Starting cloud-init: Cloud-init v. 0.7.4 running 'modules:config' at Mon, 13 Oct 2014 08:01:59 +0000. Up 46.85 seconds.
[ OK ]
Starting cloud-final: Starting cloud-init: Cloud-init v. 0.7.4 running 'modules:final' at Mon, 13 Oct 2014 08:02:00 +0000. Up 47.60 seconds.
ci-info: no authorized ssh keys fingerprints found for user apps.
ci-info: no authorized ssh keys fingerprints found for user apps.
ec2:
ec2: #############################################################
ec2: -----BEGIN SSH HOST KEY FINGERPRINTS-----
ec2: 1024 fe:e8:c5:5c:73:77:15:24:1f:12:ec:14:47:e2:6b:96 /etc/ssh/ssh_host_dsa_key.pub
ec2: 2048 41:70:b7:40:86:79:69:ed:82:6e:08:9e:26:32:25:65 /etc/ssh/ssh_host_key.pub
ec2: 2048 94:05:cb:3e:d1:a6:4b:5c:92:2c:4a:c5:33:e3:2b:c5 /etc/ssh/ssh_host_rsa_key.pub
ec2: -----END SSH HOST KEY FINGERPRINTS-----
ec2: #############################################################
-----BEGIN SSH HOST KEY KEYS-----
2048 35 24719050152202493952997764556808574180021483630571545678073814674834202864549990758294160432886566801351575961690720917902026807869558309589491740363104364672910884140833931316256583453042582305449902291903306361761690698760484435248642299693277384199758799190120646312710570653607607334393232605584218823199035894711152805635283940392739554801142234598490992296063909154465800405846799268020700973109825520692081165606126385351983258006278326660672731432219855911319945415678243385593968583270276881889985961899591589675998971591411582249557089252116513013337851462069105055419123305526546752802961464039386703608659
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwhlU3hJmVhTK9etyhVCmy/BeoqL8BIh3vPsXNLVQ8s/iw1hrJSFQE7C6GUECveIkZQv+DsbqNmmiSrpAmJnyMrc0+iNXt9kqaRUniiySXu7mE7fEajFTH1TTVEKy1733KSg4VXpWFgkqkyMjopJqR9i9A+n8RpW96mYodEeVsG991BQo0p9+cccKNObUbUllnl9EPWKUkaGqu5WvvmuGjOZEQrwnn4l7RXumkUQ5dtb7vqgIpZtlY30tz3JNHjjoF3BpqpcWX24+vJpji4lQ1Dgx6WNXseR5/gv6lICr8LoYJFSiBGZJACp60P2YLFiUe//Ln39Tvr+VA9GAhTDk9Q==
-----END SSH HOST KEY KEYS-----
Cloud-init v. 0.7.4 finished at Mon, 13 Oct 2014 08:02:00 +0000. Datasource DataSourceEc2. Up 47.75 seconds
[ OK ]
CentOS release 5.8 (Final)
Kernel 2.6.18-308.el5 on an x86_64
terry-test login:
网络连接测试
[root@hh-yun-compute-130025 ~(keystone_admin)]# ping -c 1 10.199.131.209
PING 10.199.131.209 (10.199.131.209) 56(84) bytes of data.
64 bytes from 10.199.131.209: icmp_seq=1 ttl=64 time=0.232 ms
--- 10.199.131.209 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.232/0.232/0.232/0.000 ms
[root@hh-yun-compute-130025 ~(keystone_admin)]# ssh 10.199.131.209
The authenticity of host '10.199.131.209 (10.199.131.209)' can't be established.
RSA key fingerprint is 94:05:cb:3e:d1:a6:4b:5c:92:2c:4a:c5:33:e3:2b:c5.
Are you sure you want to continue connecting (yes/no)?