本文件为OpenStack计算节点搭建流程

一、  基本环境配置

1.  编辑/etc/network/interfaces文件,添加以下代码(ip地址根据实际配置):

auto eth0
iface eth0 inet static
address 10.17.x.x2
netmask 255.255.0.0
gateway 10.17.xxx.xxx
auto eth1
iface eth1 inet static
address 10.17.xx.x2
netmask 255.255.0.0

2.  编辑/etc/hosts文件,添加以下代码:

10.17.x.x1   controller(控制节点名称)
10.17.x.x2   compute1(计算节点名称)
10.17.x.x3   network(网络节点名称)

同时注释掉以下代码:

127.0.1.1       ubuntu

3.  编辑/etc/hostname文件,修改主机名为:

compute(计算节点名称)

4.  源包升级:

apt-get update
apt-get dist-upgrade(可选)

5.  service network restart,使更改生效

6.  安装网络时间协议(NTP)

# apt-get install ntp

打开文件/etc/ntp.conf增加或修改以下三行内容,目的是让本服务器时间与外部服务器时间同步

server ntp.ubuntu.com
server 127.127.1.0
fudge 127.127.1.0 stratum 10

注 以#开头的命令为使用root用户执行,以$开头的命令为使用普通用户执行

7.  使用OpenStack的RC文件设置环境变量:  

export OS_USERNAME=demo
export OS_PASSWORD=demo
export OS_TENANT_NAME=demo
exportOS_AUTH_URL=http://controller:35357/v2.0

二、  配置计算节点

1.  安装计算资源工具包:

#apt-get install nova-compute-kvm

2.  编辑/etc/nova/nova.conf文件,添加并修改以下配置:

[DEFAULT]
auth_strategy = keystone
[database]
connection = mysql://nova:nova@controller/nova
[keystone_authtoken]
auth_uri = http://controller:5000
auth_host = controller
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = nova
admin_password = nova

3.  继续添加以下配置:

[DEFAULT]
rpc_backend = rabbit
rabbit_host = controller
rabbit_password = 1234

4.  继续添加以下配置:

[DEFAULT]
my_ip = 10.17.x.x2(计算节点IP)
vnc_enabled = True
vncserver_listen = 0.0.0.0
vncserver_proxyclient_address = 10.17.x.x2(计算节点IP)
novncproxy_base_url =http://controller:6080/vnc_auto.html

5.  继续添加以下配置:

[DEFAULT]
glance_host = controller

6.  执行以下命令:

#egrep -c '(vmx|svm)' /proc/cpuinfo

如果返回值为0,需要修改/etc/nova/nova-compute.conf文件:

如果返回值不为0,则不用修改文件

[libvirt]
virt_type = qemu

7.  清理SQLite数据库:

#rm /var/lib/nova/nova.sqlite

8.  重启计算服务:

#service nova-compute restart

三、  网络服务配置

1.  编辑/etc/sysctl.conf文件,添加以下配置:

net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.bridge.bridge-nf-call-arptables=1(添加)
net.bridge.bridge-nf-call-iptables=1(添加)
net.bridge.bridge-nf-call-ip6tables=1(添加)

2.  使更改生效:

#sysctl -p

3.  安装网络服务组件:

#apt-get install neutron-commonneutron-plugin-ml2 neutron-plugin-openvswitch-agent \ openvswitch-datapath-dkms(3.11以上版本内核不用安装此包)

4.  编辑/etc/neutron/neutron.conf文件,添加以下配置:

[DEFAULT]
auth_strategy = keystone
[keystone_authtoken]
auth_uri = http://controller:5000
auth_host = controller
auth_protocol = http
auth_port = 35357
admin_tenant_name = service
admin_user = neutron
admin_password = neutron

注:admin_password为密码

5.  继续添加以下配置:

[DEFAULT]
rpc_backend =neutron.openstack.common.rpc.impl_kombu
rabbit_host = controller
rabbit_password = 1234

6.  继续添加以下配置:

[DEFAULT]
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True

7.  编辑/etc/neutron/plugins/ml2/ml2_conf.ini文件,添加以下配置:

[ml2]
type_drivers = gre
tenant_network_types = gre
mechanism_drivers = openvswitch
[ml2_type_gre]
tunnel_id_ranges = 1:1000
[ovs]
local_ip = 10.17.xx.x2(eth1配置的ip,实例隧道接口)
tunnel_type = gre
enable_tunneling = True
[securitygroup]
firewall_driver =neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
enable_security_group = True

8.  重启OVS服务:

#service openvswitch-switch restart

添加桥(如果报出桥已存在错误,可不予理睬):

#ovs-vsctl add-brbr-int

9.  编辑/etc/nova/nova.conf文件,添加以下配置:

[DEFAULT]
network_api_class =nova.network.neutronv2.api.API
neutron_url = http://controller:9696
neutron_auth_strategy = keystone
neutron_admin_tenant_name = service
neutron_admin_username = neutron
neutron_admin_password = neutron
neutron_admin_auth_url =http://controller:35357/v2.0
linuxnet_interface_driver =nova.network.linux_net.LinuxOVSInterfaceDriver
firewall_driver =nova.virt.firewall.NoopFirewallDriver
security_group_api = neutron

10. 禁用防火墙

#ufw disable

11. 完成安装,执行以下命令:

#service nova-compute restart
#service neutron-plugin-openvswitch-agentrestart

四、  生成实例

1.  配置环境变量(普通用户)

$source demo-openrc.sh

2.  产生公钥对

$ssh-keygen

       一路回车

3.  将公钥添加到环境中:

$nova keypair-add - -pub-key~/.ssh/id_rsa.pub demo-key

注   此命令不提供输出。

4.  验证配置:

$nova keypair-list
$nova flavor-list
$nova image-list
$neutron net-list
$nova secgroup-list

以上各项如果正常均返回相应表格

5.  创建实例:

$nova boot --flavor m1.tiny --DEMO_NAME --nic net-id=DEMO_NET_ID --security-group default--key-name demo-key demo-instance1

如果正常将返回实例属性表格

同时注意修改DEMO_NAME为镜像name,DEMO_NET_ID为neutronnet-list返回的内网网络ID

6.  查看实例列表:

$nova list

       如果创建的实例状态变为running,说明启动成功

7.  获取控制台URL并从浏览器中登录

$nova get-vnc-console demo-instance1 novnc