OpenStack Grizzly Quantum Multihost 部署

http://blog.csdn.net/xuensong520/article/details/8897710

本文主要介绍multihost模式下的openstack多节点部署,这种模式可以避免随着节点的增多,流量膨胀一个网络节点无法满足需求的情况。当然如果只是自己搞一台host,在上面虚拟几台VM做实验,或者小型创业公司,通过在五台十台机器上的虚拟化,创建一些VM给公司内部开发测试团队使用,那么使用多节点模式即可,即一个控制节点、一个网络节点、多个计算节点。在Essxinova-networkmutihost可以很好分担网络节点的负载,同样在Quantum中也有类似的功能,本文主要参考一位网友Geekblog所写,做了适当修改,在我的环境里验证没有问题,这里记录下来也仅供大家参考!

 

环境需求:

管理网络: 172.16.0.0/16
业务网络:
 10.10.10.0/24
外部网络: 192.168.80.0/24

我这里使用的是三台机器,你也可以横向扩展,增加计算节点的数量。

Node Role:

NICs

Control Node:

eth0 (192.168.80.21), eth1 (172.16.0.51)

Compute1 Node:

eth0(192.168.80.22),eth1(172.16.0.52),eth2(10.10.10.52)

Compute2 Node:

eth0(192.168.80.23),eth1(172.16.0.53),eth2(10.10.10.53)

 

 

控制节点

网络设置

[python]  view plain copy
  1. cat /etc/network/interfaces   
  2.   
  3. # This file describes the network interfaces available on your system  
  4.   
  5. # and how to activate them. For more information, see interfaces(5).  
  6.   
  7.    
  8.   
  9. # The loopback network interface  
  10.   
  11. auto lo  
  12.   
  13. iface lo inet loopback  
  14.   
  15.    
  16.   
  17. # The primary network interface  
  18.   
  19. auto eth0  
  20.   
  21. iface eth0 inet static  
  22.   
  23. address 192.168.80.21  
  24.   
  25. netmask 255.255.255.0  
  26.   
  27. gateway 192.168.80.1  
  28.   
  29. dns-nameservers 8.8.8.8  
  30.   
  31.    
  32.   
  33. auto eth1  
  34.   
  35. iface eth1 inet static  
  36.   
  37. address 172.16.0.51  
  38.   
  39. netmask 255.255.0.0  


 

添加源

添加 Grizzly 源,并升级系统

[python]  view plain copy
  1. cat > /etc/apt/sources.list.d/grizzly.list << _ESXU_  
  2.   
  3. deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/grizzly main  
  4.   
  5. deb  http://ubuntu-cloud.archive.canonical.com/ubuntu precise-proposed/grizzly main  
  6.   
  7. _ESXU_  
  8.   
  9. apt-get install ubuntu-cloud-keyring  
  10.   
  11. apt-get update  
  12.   
  13. apt-get upgrade  


 

MySQL & RabbitMQ

  • 安装 MySQL

 
 
[python] view plain copy
  1. apt-get install mysql-server python-mysqldb  
  • 使用sed编辑 /etc/mysql/my.cnf文件的更改绑定地址(0.0.0.0)从本地主机(127.0.0.1
    禁止 mysql 做域名解析,防止连接 mysql出现错误和远程连接 mysql慢的现象。
    然后重新启动mysql服务.

 
 
[python] view plain copy
  1. sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf  
  2. sed -i '44 i skip-name-resolve' /etc/mysql/my.cnf  
  3. /etc/init.d/mysql restart  
安装 RabbitMQ
apt-get install rabbitmq-server

NTP

  • 安装 NTP 服务

 
 
[python] view plain copy
  1. apt-get install ntp  
配置NTP服务器计算节点控制器节点之间的同步:
[python]  view plain copy
  1. sed -i 's/server ntp.ubuntu.com/server ntp.ubuntu.com\nserver 127.127.1.0\nfudge 127.127.1.0 stratum 10/g' /etc/ntp.conf  
  2.   
  3. service ntp restart  


 

  • 开启路由转发
[python]  view plain copy
  1. vim /etc/sysctl.conf  
  2.   
  3. net.ipv4.ip_forward=1  


 

Keystone

  • 安装 Keystone
[python]  view plain copy
  1. apt-get install keystone  


在 mysql 里创建 keystone 数据库并授权:

[python]  view plain copy
  1. mysql -uroot -p  
  2.   
  3. create database keystone;  
  4.   
  5. grant all on keystone.* to 'keystone'@'%' identified by 'keystone';  
  6.   
  7. quit;  


修改 /etc/keystone/keystone.conf 配置文件:

[python]  view plain copy
  1. admin_token = www.longgeek.com  
  2.   
  3. debug = True  
  4.   
  5. verbose = True  
  6.   
  7. [sql]  
  8.   
  9. connection = mysql://keystone:keystone@172.16.0.51/keystone       #必须写到 [sql] 下面  
  10.   
  11. [signing]  
  12.   
  13. token_format = UUID  


启动 keystone 然后同步数据库

[python]  view plain copy
  1. /etc/init.d/keystone restart  
  2.   
  3. keystone-manage db_sync  


用脚本导入数据:

用脚本来创建 user、role、tenant、service、endpoint,下载脚本:

[python]  view plain copy
  1. wget  http://192.168.80.8/ubuntu/keystone.sh  


 

修改脚本内容:

[python]  view plain copy
  1. ADMIN_PASSWORD=${ADMIN_PASSWORD:-password}  
  2.   
  3. SERVICE_PASSWORD=${SERVICE_PASSWORD:-password}  
  4.   
  5. export SERVICE_TOKEN="admin"  
  6.   
  7. export SERVICE_ENDPOINT="http://172.16.0.51:35357/v2.0"  
  8.   
  9. SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service}  
  10.   
  11. KEYSTONE_REGION=RegionOne  
  12.   
  13. # If you need to provide the service, please to open keystone_wlan_ip and swift_wlan_ip  
  14.   
  15. # of course you are a multi-node architecture, and swift service  
  16.   
  17. # corresponding ip address set the following variables  
  18.   
  19. KEYSTONE_IP="172.16.0.51"  
  20.   
  21. #KEYSTONE_WLAN_IP="172.16.0.51"  
  22.   
  23. SWIFT_IP="172.16.0.51"  
  24.   
  25. #SWIFT_WLAN_IP="172.16.0.51"  
  26.   
  27. COMPUTE_IP=$KEYSTONE_IP  
  28.   
  29. EC2_IP=$KEYSTONE_IP  
  30.   
  31. GLANCE_IP=$KEYSTONE_IP  
  32.   
  33. VOLUME_IP=$KEYSTONE_IP  
  34.   
  35. QUANTUM_IP=$KEYSTONE_IP  


在这里更改你的管理员密码即可,IP地址也可根据自己环境更改下!

 

执行脚本:


 
 
[python] view plain copy
  1. sh keystone.sh  
设置环境变量:

这里变量对于 keystone.sh 里的设置:

[python]  view plain copy
  1. cat > /etc/profile << _ESXU_  
  2.   
  3. export OS_TENANT_NAME=admin      #这里如果设置为 service 其它服务会无法验证.  
  4.   
  5. export OS_USERNAME=admin  
  6.   
  7. export OS_PASSWORD=password  
  8.   
  9. export OS_AUTH_URL=http://172.16.0.51:5000/v2.0/  
  10.   
  11. export OS_REGION_NAME=RegionOne  
  12.   
  13. export SERVICE_TOKEN=admin  
  14.   
  15. export SERVICE_ENDPOINT=http://172.16.0.51:35357/v2.0/  
  16.   
  17. _ESXU_  
  18.   
  19. # source /root/profile            #使环境变量生效  


 

Glance

  • 安装 Glance

 
 
[python] view plain copy
  1. apt-get install glance  
  • 创建一个 glance 数据库并授权:

 
 
[python] view plain copy
  1. mysql -uroot -p  
  2. create database glance;  
  3. grant all on glance.* to 'glance'@'%' identified by 'glance';  
 
  • 更新 /etc/glance/glance-api.conf 文件:

 

[python]  view plain copy
  1. verbose = True  
  2.   
  3. debug = True  
  4.   
  5. sql_connection = mysql://glance:glance@172.16.0.51/glance  
  6.   
  7. workers = 4  
  8.   
  9. registry_host = 172.16.0.51  
  10.   
  11. notifier_strategy = rabbit  
  12.   
  13. rabbit_host = 172.16.0.51  
  14.   
  15. rabbit_userid = guest  
  16.   
  17. rabbit_password = guest  
  18.   
  19. [keystone_authtoken]  
  20.   
  21. auth_host = 172.16.0.51  
  22.   
  23. auth_port = 35357  
  24.   
  25. auth_protocol = http  
  26.   
  27. admin_tenant_name = service  
  28.   
  29. admin_user = glance  
  30.   
  31. admin_password = password  
  32.   
  33. [paste_deploy]  
  34.   
  35. config_file = /etc/glance/glance-api-paste.ini  
  36.   
  37. flavor = keystone  


 

  • 更新 /etc/glance/glance-registry.conf 文件:
[python]  view plain copy
  1. verbose = True  
  2.   
  3. debug = True  
  4.   
  5. sql_connection = mysql://glance:glance@172.16.0.51/glance  
  6.   
  7. [keystone_authtoken]  
  8.   
  9. auth_host = 172.16.0.51  
  10.   
  11. auth_port = 35357  
  12.   
  13. auth_protocol = http  
  14.   
  15. admin_tenant_name = service  
  16.   
  17. admin_user = glance  
  18.   
  19. admin_password = password  
  20.   
  21. [paste_deploy]  
  22.   
  23. config_file = /etc/glance/glance-registry-paste.ini  
  24.   
  25. flavor = keystone  


启动 glance-api 和 glance-registry 服务并同步到数据库:

[python]  view plain copy
  1. /etc/init.d/glance-api restart  
  2.   
  3. /etc/init.d/glance-registry restart  
  4.   
  5. glance-manage version_control 0  
  6.   
  7. glance-manage db_sync  


测试 glance 的安装,上传一个镜像。下载 Cirros 镜像并上传:

[python]  view plain copy
  1. wget https://launchpad.net/cirros/trunk/0.3.0/+download/  
  2.   
  3. cirros-0.3.0-x86_64-disk.img  
  4.   
  5. glance image-create --name='cirros' --public --container-format=ovf --disk-format=qcow2 < ./cirros-0.3.0-x86_64-disk.img  


 

  • 查看上传的镜像:
[python]  view plain copy
  1. glance image-list  


 

Quantum

  • 安装 Quantum server OpenVSwitch包:

 
 
[python] view plain copy
  1. apt-get install quantum-server quantum-plugin-openvswitch  
  • 创建 quantum 数据库并授权用户访问:

 
 
[python] view plain copy
  1. mysql -uroot -p  
  2. create database quantum;  
  3. grant all on quantum.* to 'quantum'@'%' identified by 'quantum';  
  4. quit;  
编辑 /etc/quantum/quantum.conf文件
 
 
 
[python] view plain copy
  1. [DEFAULT]  
  2. debug = True  
  3.   
  4. verbose = True  
  5.   
  6. state_path = /var/lib/quantum  
  7.   
  8. lock_path = $state_path/lock  
  9.   
  10. bind_host = 0.0.0.0  
  11.   
  12. bind_port = 9696  
  13.   
  14. core_plugin = quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2  
  15.   
  16. api_paste_config = /etc/quantum/api-paste.ini  
  17.   
  18. control_exchange = quantum  
  19.   
  20. rabbit_host = 172.16.0.51  
  21.   
  22. rabbit_password = guest  
  23.   
  24. rabbit_port = 5672  
  25.   
  26. rabbit_userid = guest  
  27.   
  28. notification_driver = quantum.openstack.common.notifier.rpc_notifier  
  29.   
  30. default_notification_level = INFO  
  31.   
  32. notification_topics = notifications  
  33.   
  34. [QUOTAS]  
  35.   
  36. [DEFAULT_SERVICETYPE]  
  37.   
  38. [AGENT]  
  39.   
  40. root_helper = sudo quantum-rootwrap /etc/quantum/rootwrap.conf  
  41.   
  42. [keystone_authtoken]  
  43.   
  44. auth_host = 172.16.0.51  
  45.   
  46. auth_port = 35357  
  47.   
  48. auth_protocol = http  
  49.   
  50. admin_tenant_name = service  
  51.   
  52. admin_user = quantum  
  53.   
  54. admin_password = password  
  55.   
  56. signing_dir = /var/lib/quantum/keystone-signing  
 
  • 编辑 OVS 插件配置文件 /etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini:
[python]  view plain copy
  1. [DATABASE]  
  2.   
  3. sql_connection = mysql://quantum:quantum@172.16.0.51/quantum  
  4.   
  5. reconnect_interval = 2  
  6.   
  7. [OVS]  
  8.   
  9. tenant_network_type = gre  
  10.   
  11. enable_tunneling = True  
  12.   
  13. tunnel_id_ranges = 1:1000  
  14.   
  15. [AGENT]  
  16.   
  17. polling_interval = 2  
  18.   
  19. [SECURITYGROUP]  


启动 quantum 服务:

[python]  view plain copy
  1. /etc/init.d/quantum-server restart  


 

Nova

  • 安装 Nova 相关软件包:
[python]  view plain copy
  1. apt-get install nova-api nova-cert novnc nova-conductor nova-consoleauth nova-scheduler nova-novncproxy  

 

 

创建 nova 数据库,授权 nova 用户访问它:
[python]  view plain copy
  1. mysql -uroot -p  
  2.   
  3. create database nova;  
  4.   
  5. grant all on nova.* to 'nova'@'%' identified by 'nova';  
  6.   
  7. quit;  


在 /etc/nova/api-paste.ini 中修改 autotoken 验证部分:

[python]  view plain copy
  1. [filter:authtoken]  
  2.   
  3. paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory  
  4.   
  5. auth_host = 172.16.0.51  
  6.   
  7. auth_port = 35357  
  8.   
  9. auth_protocol = http  
  10.   
  11. admin_tenant_name = service  
  12.   
  13. admin_user = nova  
  14.   
  15. admin_password = password  
  16.   
  17. signing_dir = /tmp/keystone-signing-nova  
  18.   
  19. # Workaround for https://bugs.launchpad.net/nova/+bug/1154809  
  20.   
  21. auth_version = v2.0  


修改 /etc/nova/nova.conf, 类似下面这样:

[python]  view plain copy
  1. [DEFAULT]  
  2.   
  3. # LOGS/STATE  
  4.   
  5. debug = False  
  6.   
  7. verbose = True  
  8.   
  9. logdir = /var/log/nova  
  10.   
  11. state_path = /var/lib/nova  
  12.   
  13. lock_path = /var/lock/nova  
  14.   
  15. rootwrap_config = /etc/nova/rootwrap.conf  
  16.   
  17. dhcpbridge = /usr/bin/nova-dhcpbridge  
  18.   
  19. # SCHEDULER  
  20.   
  21. compute_scheduler_driver = nova.scheduler.filter_scheduler.FilterScheduler  
  22.   
  23. ## VOLUMES  
  24.   
  25. volume_api_class = nova.volume.cinder.API  
  26.   
  27. # DATABASE  
  28.   
  29. sql_connection = mysql://nova:nova@172.16.0.51/nova  
  30.   
  31. # COMPUTE  
  32.   
  33. libvirt_type = kvm  
  34.   
  35. compute_driver = libvirt.LibvirtDriver  
  36.   
  37. instance_name_template = instance-%08x  
  38.   
  39. api_paste_config = /etc/nova/api-paste.ini  
  40.   
  41. # COMPUTE/APIS: if you have separate configs for separate services  
  42.   
  43. # this flag is required for both nova-api and nova-compute  
  44.   
  45. allow_resize_to_same_host = True  
  46.   
  47. # APIS  
  48.   
  49. osapi_compute_extension = nova.api.openstack.compute.contrib.standard_extensions  
  50.   
  51. ec2_dmz_host = 172.16.0.51  
  52.   
  53. s3_host = 172.16.0.51  
  54.   
  55. metadata_host = 172.16.0.51  
  56.   
  57. metadata_listen = 0.0.0.0  
  58.   
  59. # RABBITMQ  
  60.   
  61. rabbit_host = 172.16.0.51  
  62.   
  63. rabbit_password = guest  
  64.   
  65. # GLANCE  
  66.   
  67. image_service = nova.image.glance.GlanceImageService  
  68.   
  69. glance_api_servers = 172.16.0.51:9292  
  70.   
  71. # NETWORK  
  72.   
  73. network_api_class = nova.network.quantumv2.api.API  
  74.   
  75. quantum_url = http://172.16.0.51:9696  
  76.   
  77. quantum_auth_strategy = keystone  
  78.   
  79. quantum_admin_tenant_name = service  
  80.   
  81. quantum_admin_username = quantum  
  82.   
  83. quantum_admin_password = password  
  84.   
  85. quantum_admin_auth_url = http://172.16.0.51:35357/v2.0  
  86.   
  87. service_quantum_metadata_proxy = True  
  88.   
  89. libvirt_vif_driver = nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver  
  90.   
  91. linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver  
  92.   
  93. firewall_driver = nova.virt.libvirt.firewall.IptablesFirewallDriver  
  94.   
  95. # NOVNC CONSOLE  
  96.   
  97. novncproxy_base_url = http://192.168.8.51:6080/vnc_auto.html  
  98.   
  99. # Change vncserver_proxyclient_address and vncserver_listen to match each compute host  
  100.   
  101. vncserver_proxyclient_address = 192.168.8.51  
  102.   
  103. vncserver_listen = 0.0.0.0  
  104.   
  105. # AUTHENTICATION  
  106.   
  107. auth_strategy = keystone  
  108.   
  109. [keystone_authtoken]  
  110.   
  111. auth_host = 172.16.0.51  
  112.   
  113. auth_port = 35357  
  114.   
  115. auth_protocol = http  
  116.   
  117. admin_tenant_name = service  
  118.   
  119. admin_user = nova  
  120.   
  121. admin_password = password  
  122.   
  123. signing_dir = /tmp/keystone-signing-nova  


同步数据库,启动 nova 相关服务:

[python]  view plain copy
  1. nova-manage db sync  
  2.   
  3. cd /etc/init.d/; for i in $( ls nova-* ); do sudo /etc/init.d/$i restart; done  


检查 nova 相关服务笑脸


 
 
[python] view plain copy
  1.  nova-manage service list  
  2. # nova-manage service list  
  3.   
  4. Binary           Host                                 Zone             Status     State Updated_At  
  5.   
  6. nova-cert        control                              internal         enabled    :-)   2013-05-07 07:09:56  
  7.   
  8. nova-conductor   control                              internal         enabled    :-)   2013-05-07 07:09:55  
  9.   
  10. nova-consoleauth control                              internal         enabled    :-)   2013-05-07 07:09:56  
  11.   
  12. nova-scheduler   control                              internal         enabled    :-)   2013-05-07 07:09:56  
Horizon
  • 安装 horizon
[python]  view plain copy
  1. apt-get install openstack-dashboard memcached  

 

 

如果你不喜欢 Ubuntu 的主题,可以禁用它,使用默认界面:

 
 
[python] view plain copy
  1. sed -i 's/127.0.0.1/172.16.0.51/g' /etc/openstack-dashboard/local_settings.py  
  2. sed -i 's/127.0.0.1/172.16.0.51/g' /etc/memcached.conf  
  3. vim /etc/openstack-dashboard/local_settings.py  
  4. DEBUG = True  
  5. # Enable the Ubuntu theme if it is present.  
  6. #try:  
  7. #    from ubuntu_theme import *  
  8. #except ImportError:  
  9. #    pass  
重新加载 apache2 和 memcache:
[python]  view plain copy
  1. /etc/init.d/apache2 restart  
  2.   
  3. /etc/init.d/memcached restart  


现在可以通过浏览器 http://192.168.8.51/horizon 使用 admin:password 来登录界面。

所有计算节点

网络设置

所有计算节点安装方法相同,只需要替换 IP 地址即可:

[python]  view plain copy
  1. #  cat /etc/network/interfaces  
  2.   
  3. # This file describes the network interfaces available on your system  
  4.   
  5. # and how to activate them. For more information, see interfaces(5).  
  6.   
  7.    
  8.   
  9. # The loopback network interface  
  10.   
  11. auto lo  
  12.   
  13. iface lo inet loopback  
  14.   
  15.    
  16.   
  17. # The primary network interface  
  18.   
  19. auto eth0  
  20.   
  21. iface eth0 inet manual  
  22.   
  23. up ifconfig $IFACE 0.0.0.0 up  
  24.   
  25.         up ip link set $IFACE promisc on   
  26.   
  27.         down ip link set $IFACE promisc off  
  28.   
  29.         down ifconfig $IFACE down  
  30.   
  31.    
  32.   
  33. auto br-ex  
  34.   
  35. iface br-ex inet static  
  36.   
  37.         address 192.168.80.22  
  38.   
  39.         netmask 255.255.255.0  
  40.   
  41.         gateway 192.168.80.1  
  42.   
  43.         dns-nameservers 8.8.8.8  
  44.   
  45. #address 192.168.80.22  
  46.   
  47. #netmask 255.255.255.0  
  48.   
  49. #gateway 192.168.80.1  
  50.   
  51. #dns-nameservers 8.8.8.8  
  52.   
  53.    
  54.   
  55. auto eth1  
  56.   
  57. iface eth1 inet static  
  58.   
  59. address 172.16.0.52  
  60.   
  61. netmask 255.255.0.0  
  62.   
  63.    
  64.   
  65. auto eth2  
  66.   
  67. iface eth2 inet static  
  68.   
  69. address 10.10.10.52  
  70.   
  71. netmask 255.255.255.0  


 

添加源

  • 添加 Grizzly 源,并升级系统

 
 
[delphi] view plain copy
  1. cat > /etc/apt/sources.list.d/grizzly.list << _GEEK_  
  2. deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/grizzly main  
  3. deb  http://ubuntu-cloud.archive.canonical.com/ubuntu precise-proposed/grizzly main  
  4. _GEEK_  
  5. apt-get update  
  6. apt-get upgrade  
  7. apt-get install ubuntu-cloud-keyring  
  • 设置 ntp 和开启路由转发:

 
 
[html] view plain copy
  1. # apt-get install ntp  
  2. # sed -i 's/server ntp.ubuntu.com/server 172.16.0.51/g' /etc/ntp.conf  
  3. # service ntp restart  
  4. # vim /etc/sysctl.conf  
  5. net.ipv4.ip_forward=1  
  6. # sysctl -p  
OpenVSwitch
  • 安装 openVSwitch:

必须按照下面安装顺序:


 
 
[html] view plain copy
  1. apt-get install openvswitch-datapath-source  
  2. module-assistant auto-install openvswitch-datapath  
  3. apt-get install openvswitch-switch openvswitch-brcompat  
设置 ovs-brcompatd 启动:

 
 
[html] view plain copy
  1. sed -i 's/# BRCOMPAT=no/BRCOMPAT=yes/g' /etc/default/openvswitch-switch  
  2. echo 'brcompat' >> /etc/modules  
启动 openvswitch-switch:
[html]  view plain copy
  1. /etc/init.d/openvswitch-switch restart  
  2.  * ovs-brcompatd is not running            # brcompatd 没有启动,尝试再次启动.  
  3.  * ovs-vswitchd is not running  
  4.  * ovsdb-server is not running  
  5.  * Inserting openvswitch module  
  6.  * /etc/openvswitch/conf.db does not exist  
  7.  * Creating empty database /etc/openvswitch/conf.db  
  8.  * Starting ovsdb-server  
  9.  * Configuring Open vSwitch system IDs  
  10.  * Starting ovs-vswitchd  
  11.  * Enabling gre with iptables  

 

 

再次启动,直到 ovs-brcompatdovs-vswitchdovsdb-server等服务都启动:

 
 
[html] view plain copy
  1. # /etc/init.d/openvswitch-switch restart  
  2. # lsmod | grep brcompat  
  3. brcompat               13512  0   
  4. openvswitch            84038  7 brcompat  
如果还是启动不了的话,用下面命令:

 
 
[html] view plain copy
  1. /etc/init.d/openvswitch-switch force-reload-kmod  
创建网桥:

 
 
[html] view plain copy
  1. ovs-vsctl add-br br-int        # br-int 用于 vm 整合  
  2. ovs-vsctl add-br br-ex              # br-ex 用于从互联网上访问 vm  
  3. ovs-vsctl add-port br-ex eth0       # br-ex 桥接到 eth0  
 
  • 重启网卡可能会出现:
[html]  view plain copy
  1.  /etc/init.d/networking restart  
  2.   
  3. RTNETLINK answers: File exists  
  4.   
  5. Failed to bring up br-ex.  


br-ex 可能有 ip 地址,但没有网关和 DNS,需要手工配置一下,或者重启机器. 重启机器后就正常了

  • 查看桥接的网络
[html]  view plain copy
  1. ovs-vsctl list-br  
  2.   
  3. ovs-vsctl show  


Quantum

  • 安装 Quantum openvswitch agent, metadata-agent l3 agent  dhcp agent:

 
 
[html] view plain copy
  1. apt-get install quantum-plugin-openvswitch-agent quantum-dhcp-agent quantum-l3-agent quantum-metadata-agent  
  • 编辑 /etc/quantum/quantum.conf 文件:

 
 
[html] view plain copy
  1. [DEFAULT]  
  2. debug = True  
  3. verbose = True  
  4. state_path = /var/lib/quantum  
  5. lock_path = $state_path/lock  
  6. bind_host = 0.0.0.0  
  7. bind_port = 9696  
  8. core_plugin = quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2  
  9. api_paste_config = /etc/quantum/api-paste.ini  
  10. control_exchange = quantum  
  11. rabbit_host = 172.16.0.51  
  12. rabbit_password = guest  
  13. rabbit_port = 5672  
  14. rabbit_userid = guest  
  15. notification_driver = quantum.openstack.common.notifier.rpc_notifier  
  16. default_notification_level = INFO  
  17. notification_topics = notifications  
  18. [QUOTAS]  
  19. [DEFAULT_SERVICETYPE]  
  20. [AGENT]  
  21. root_helper = sudo quantum-rootwrap /etc/quantum/rootwrap.conf  
  22. [keystone_authtoken]  
  23. auth_host = 172.16.0.51  
  24. auth_port = 35357  
  25. auth_protocol = http  
  26. admin_tenant_name = service  
  27. admin_user = quantum  
  28. admin_password = password  
  29. signing_dir = /var/lib/quantum/keystone-signing  
编辑 OVS 插件配置文件 /etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini:
[html]  view plain copy
  1. [DATABASE]  
  2.   
  3. sql_connection = mysql://quantum:quantum@172.16.0.51/quantum  
  4.   
  5. reconnect_interval = 2  
  6.   
  7. [OVS]  
  8.   
  9. enable_tunneling = True  
  10.   
  11. tenant_network_type = gre  
  12.   
  13. tunnel_id_ranges = 1:1000  
  14.   
  15. local_ip = 10.10.10.52  
  16.   
  17. integration_bridge = br-int  
  18.   
  19. tunnel_bridge = br-tun  
  20.   
  21. [AGENT]  
  22.   
  23. polling_interval = 2  
  24.   
  25. [SECURITYGROUP]  


编辑 /etc/quantum/l3_agent.ini:

[html]  view plain copy
  1. [DEFAULT]  
  2.   
  3. debug = True  
  4.   
  5. verbose = True  
  6.   
  7. use_namespaces = True  
  8.   
  9. external_network_bridge = br-ex  
  10.   
  11. signing_dir = /var/cache/quantum  
  12.   
  13. admin_tenant_name = service  
  14.   
  15. admin_user = quantum  
  16.   
  17. admin_password = password  
  18.   
  19. auth_url = http://172.16.0.51:35357/v2.0  
  20.   
  21. l3_agent_manager = quantum.agent.l3_agent.L3NATAgentWithStateReport  
  22.   
  23. root_helper = sudo quantum-rootwrap /etc/quantum/rootwrap.conf  
  24.   
  25. interface_driver = quantum.agent.linux.interface.OVSInterfaceDriver  
  26.   
  27. enable_multi_host = True  


编辑 /etc/quantum/dhcp_agent.ini:

[html]  view plain copy
  1. [DEFAULT]  
  2.   
  3. debug = True  
  4.   
  5. verbose = True  
  6.   
  7. use_namespaces = True  
  8.   
  9. signing_dir = /var/cache/quantum  
  10.   
  11. admin_tenant_name = service  
  12.   
  13. admin_user = quantum  
  14.   
  15. admin_password = password  
  16.   
  17. auth_url = http://172.16.0.51:35357/v2.0  
  18.   
  19. dhcp_agent_manager = quantum.agent.dhcp_agent.DhcpAgentWithStateReport  
  20.   
  21. root_helper = sudo quantum-rootwrap /etc/quantum/rootwrap.conf  
  22.   
  23. state_path = /var/lib/quantum  
  24.   
  25. interface_driver = quantum.agent.linux.interface.OVSInterfaceDriver  
  26.   
  27. dhcp_driver = quantum.agent.linux.dhcp.Dnsmasq  
  28.   
  29. enable_multi_host = True  
  30.   
  31. enable_isolated_metadata = False  


编辑 /etc/quantum/metadata_agent.ini:

[html]  view plain copy
  1. [DEFAULT]  
  2.   
  3. debug = True  
  4.   
  5. auth_url = http://172.16.0.51:35357/v2.0  
  6.   
  7. auth_region = RegionOne  
  8.   
  9. admin_tenant_name = service  
  10.   
  11. admin_user = quantum  
  12.   
  13. admin_password = password  
  14.   
  15. state_path = /var/lib/quantum  
  16.   
  17. nova_metadata_ip = 172.16.0.51  
  18.   
  19. nova_metadata_port = 8775  


启动 quantum 所有服务:

[html]  view plain copy
  1. service quantum-plugin-openvswitch-agent restart  
  2.   
  3. service quantum-dhcp-agent restart  
  4.   
  5. service quantum-l3-agent restart  
  6.   
  7. service quantum-metadata-agent restart  


Cinder

  • 安装 Cinder 需要的包:

 
 
[html] view plain copy
  1. apt-get install cinder-api cinder-common cinder-scheduler cinder-volume python-cinderclient iscsitarget open-iscsi iscsitarget-dkms  
配置 iscsi 并启动服务:
[html]  view plain copy
  1. sed -i 's/false/true/g' /etc/default/iscsitarget  
  2.   
  3. /etc/init.d/iscsitarget restart  
  4.   
  5. /etc/init.d/open-iscsi restart  


创建 cinder 数据库并授权用户访问:

[html]  view plain copy
  1. mysql -uroot -p  
  2.   
  3. create database cinder;  
  4.   
  5. grant all on cinder.* to 'cinder'@'%' identified by 'cinder';  
  6.   
  7. quit;  


修改 /etc/cinder/cinder.conf:

[html]  view plain copy
  1. cat /etc/cinder/cinder.conf  
  2.   
  3. [DEFAULT]  
  4.   
  5. # LOG/STATE  
  6.   
  7. verbose = True  
  8.   
  9. debug = False  
  10.   
  11. iscsi_helper = ietadm  
  12.   
  13. auth_strategy = keystone  
  14.   
  15. volume_group = cinder-volumes  
  16.   
  17. volume_name_template = volume-%s  
  18.   
  19. state_path = /var/lib/cinder  
  20.   
  21. volumes_dir = /var/lib/cinder/volumes  
  22.   
  23. rootwrap_config = /etc/cinder/rootwrap.conf  
  24.   
  25. api_paste_config = /etc/cinder/api-paste.ini  
  26.   
  27. # RPC  
  28.   
  29. rabbit_host = 172.16.0.51  
  30.   
  31. rabbit_password = guest  
  32.   
  33. rpc_backend = cinder.openstack.common.rpc.impl_kombu  
  34.   
  35. # DATABASE  
  36.   
  37. sql_connection = mysql://cinder:cinder@172.16.0.51/cinder  
  38.   
  39. # API  
  40.   
  41. osapi_volume_extension = cinder.api.contrib.standard_extensions  


修改 /etc/cinder/api-paste.ini 文件末尾 [filter:authtoken] 字段 :

[html]  view plain copy
  1. [filter:authtoken]  
  2.   
  3. paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory  
  4.   
  5. service_protocol = http  
  6.   
  7. service_host = 172.16.0.51  
  8.   
  9. service_port = 5000  
  10.   
  11. auth_host = 172.16.0.51  
  12.   
  13. auth_port = 35357  
  14.   
  15. auth_protocol = http  
  16.   
  17. admin_tenant_name = service  
  18.   
  19. admin_user = cinder  
  20.   
  21. admin_password = password  
  22.   
  23. signing_dir = /var/lib/cinder  


 

  • 创建一个卷组,命名为 cinder-volumes:

   创建一个普通分区,我这里用的sdb,创建了一个主分区,大小为所有空间


 
 
[html] view plain copy
  1. # fdisk /dev/sdb  
  2. n  
  3. p  
  4. 1  
  5. Enter  
  6. Enter  
  7. t  
  8. 8e  
  9. w  
  10. # partx -a /dev/sdb  
  11. # pvcreate /dev/sdb1  
  12. # vgcreate cinder-volumes /dev/sdb1  
  13. # vgs  
  14.   VG             #PV #LV #SN Attr   VSize VFree   
  15.   cinder-volumes   1   7   0 wz--n- 1.64t 75.50g    
 
  • 同步数据库并重启服务:
[html]  view plain copy
  1. cinder-manage db sync  
  2.   
  3. /etc/init.d/cinder-api restart  
  4.   
  5. /etc/init.d/cinder-scheduler restart  
  6.   
  7. /etc/init.d/cinder-volume restart  


最后,我们需要执行:

[html]  view plain copy
  1. /etc/init.d/iscsitarget stop  


具体请看这里

 

Nova

  • 安装 nova-compute:

 
 
[html] view plain copy
  1. apt-get install nova-compute  
/etc/nova/api-paste.ini 中修改 autotoken 验证部分:

 
 
[html] view plain copy
  1. [filter:authtoken]  
  2. paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory  
  3. auth_host = 172.16.0.51  
  4. auth_port = 35357  
  5. auth_protocol = http  
  6. admin_tenant_name = service  
  7. admin_user = nova  
  8. admin_password = password  
  9. signing_dir = /tmp/keystone-signing-nova  
  10. # Workaround for https://bugs.launchpad.net/nova/+bug/1154809  
  11. auth_version = v2.0  
修改 /etc/nova/nova.conf,类似下面这样:

 
 
[html] view plain copy
  1. cat /etc/nova/nova.conf   
  2. [DEFAULT]  
  3. dhcpbridge_flagfile=/etc/nova/nova.conf  
  4. dhcpbridge=/usr/bin/nova-dhcpbridge  
  5. logdir=/var/log/nova  
  6. state_path=/var/lib/nova  
  7. lock_path=/var/lock/nova  
  8. force_dhcp_release=True  
  9. iscsi_helper=tgtadm  
  10. #iscsi_helper = ietadm  
  11. libvirt_use_virtio_for_bridges=True  
  12. connection_type=libvirt  
  13. root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf  
  14. verbose=True  
  15. ec2_private_dns_show_ip=True  
  16. #api_paste_config=/etc/nova/api-paste.ini  
  17. volumes_path=/var/lib/nova/volumes  
  18. enabled_apis=ec2,osapi_compute,metadata  
  19.    
  20. # SCHEDULER  
  21. compute_scheduler_driver = nova.scheduler.filter_scheduler.FilterScheduler  
  22. ## VOLUMES  
  23. volume_api_class = nova.volume.cinder.API  
  24. osapi_volume_listen_port=5900  
  25. iscsi_ip_prefix=192.168.80  
  26. iscsi_ip_address=192.168.80.22  
  27. # DATABASE  
  28. sql_connection = mysql://nova:nova@172.16.0.51/nova  
  29. # COMPUTE  
  30. libvirt_type = kvm  
  31. compute_driver = libvirt.LibvirtDriver  
  32. instance_name_template = instance-%08x  
  33. api_paste_config = /etc/nova/api-paste.ini  
  34. # COMPUTE/APIS: if you have separate configs for separate services  
  35. # this flag is required for both nova-api and nova-compute  
  36. allow_resize_to_same_host = True  
  37. # APIS  
  38. osapi_compute_extension = nova.api.openstack.compute.contrib.standard_extensions  
  39. ec2_dmz_host = 172.16.0.51  
  40. s3_host = 172.16.0.51  
  41. metadata_host=172.16.0.51  
  42. metadata_listen=0.0.0.0  
  43. # RABBITMQ  
  44. rabbit_host = 172.16.0.51  
  45. rabbit_password = guest  
  46. # GLANCE  
  47. image_service = nova.image.glance.GlanceImageService  
  48. glance_api_servers = 172.16.0.51:9292  
  49. # NETWORK  
  50. network_api_class = nova.network.quantumv2.api.API  
  51. quantum_url = http://172.16.0.51:9696  
  52. quantum_auth_strategy = keystone  
  53. quantum_admin_tenant_name = service  
  54. quantum_admin_username = quantum  
  55. quantum_admin_password = password  
  56. quantum_admin_auth_url = http://172.16.0.51:35357/v2.0  
  57. service_quantum_metadata_proxy = True  
  58. libvirt_vif_driver = nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver  
  59. linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver  
  60. firewall_driver = nova.virt.libvirt.firewall.IptablesFirewallDriver  
  61. # NOVNC CONSOLE  
  62. novncproxy_base_url = http://192.168.80.21:6080/vnc_auto.html  
  63. # Change vncserver_proxyclient_address and vncserver_listen to match each compute host  
  64. vncserver_proxyclient_address = 192.168.80.22  
  65. vncserver_listen = 192.168.80.22  
  66. # AUTHENTICATION  
  67. auth_strategy = keystone  
  68. [keystone_authtoken]  
  69. auth_host = 172.16.0.51  
  70. auth_port = 35357  
  71. auth_protocol = http  
  72. admin_tenant_name = service  
  73. admin_user = nova  
  74. admin_password = password  
  75. signing_dir = /tmp/keystone-signing-nova  
启动 nova-compute 服务:
[html]  view plain copy
  1. service nova-compute restart  


检查 nova 相关服务笑脸:

发现 compute 节点已经加入:


 
 
[html] view plain copy
  1. # nova-manage service list  
  2. Binary           Host                                 Zone             Status     State Updated_At  
  3. nova-cert        control                              internal         enabled    :-)   2013-05-07 07:09:56  
  4. nova-conductor   control                              internal         enabled    :-)   2013-05-07 07:09:55  
  5. nova-consoleauth control                              internal         enabled    :-)   2013-05-07 07:09:56  
  6. nova-scheduler   control                              internal         enabled    :-)   2013-05-07 07:09:56  
  7. nova-compute     node-02                              nova             enabled    :-)   2013-05-07 07:10:03  
  8. nova-compute     node-03                              nova             enabled    :-)   2013-05-07 07:10:03  
 

 

到这里,计算节点就成功加入了,我们可以尝试新建节点验证是否成功,具体horizon的使用方法,后面再写文章详细介绍,主要就是网络的创建这块稍微有点复杂,需要稍微注意下!


本文主要介绍multihost模式下的openstack多节点部署,这种模式可以避免随着节点的增多,流量膨胀一个网络节点无法满足需求的情况。当然如果只是自己搞一台host,在上面虚拟几台VM做实验,或者小型创业公司,通过在五台十台机器上的虚拟化,创建一些VM给公司内部开发测试团队使用,那么使用多节点模式即可,即一个控制节点、一个网络节点、多个计算节点。在Essxinova-networkmutihost可以很好分担网络节点的负载,同样在Quantum中也有类似的功能,本文主要参考一位网友Geekblog所写,做了适当修改,在我的环境里验证没有问题,这里记录下来也仅供大家参考!

 

环境需求:

管理网络: 172.16.0.0/16
业务网络:
 10.10.10.0/24
外部网络: 192.168.80.0/24

我这里使用的是三台机器,你也可以横向扩展,增加计算节点的数量。

Node Role:

NICs

Control Node:

eth0 (192.168.80.21), eth1 (172.16.0.51)

Compute1 Node:

eth0(192.168.80.22),eth1(172.16.0.52),eth2(10.10.10.52)

Compute2 Node:

eth0(192.168.80.23),eth1(172.16.0.53),eth2(10.10.10.53)

 

 

控制节点

网络设置

[python]  view plain copy
  1. cat /etc/network/interfaces   
  2.   
  3. # This file describes the network interfaces available on your system  
  4.   
  5. # and how to activate them. For more information, see interfaces(5).  
  6.   
  7.    
  8.   
  9. # The loopback network interface  
  10.   
  11. auto lo  
  12.   
  13. iface lo inet loopback  
  14.   
  15.    
  16.   
  17. # The primary network interface  
  18.   
  19. auto eth0  
  20.   
  21. iface eth0 inet static  
  22.   
  23. address 192.168.80.21  
  24.   
  25. netmask 255.255.255.0  
  26.   
  27. gateway 192.168.80.1  
  28.   
  29. dns-nameservers 8.8.8.8  
  30.   
  31.    
  32.   
  33. auto eth1  
  34.   
  35. iface eth1 inet static  
  36.   
  37. address 172.16.0.51  
  38.   
  39. netmask 255.255.0.0  


 

添加源

添加 Grizzly 源,并升级系统

[python]  view plain copy
  1. cat > /etc/apt/sources.list.d/grizzly.list << _ESXU_  
  2.   
  3. deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/grizzly main  
  4.   
  5. deb  http://ubuntu-cloud.archive.canonical.com/ubuntu precise-proposed/grizzly main  
  6.   
  7. _ESXU_  
  8.   
  9. apt-get install ubuntu-cloud-keyring  
  10.   
  11. apt-get update  
  12.   
  13. apt-get upgrade  


 

MySQL & RabbitMQ

  • 安装 MySQL

 
 
[python] view plain copy
  1. apt-get install mysql-server python-mysqldb  
  • 使用sed编辑 /etc/mysql/my.cnf文件的更改绑定地址(0.0.0.0)从本地主机(127.0.0.1
    禁止 mysql 做域名解析,防止连接 mysql出现错误和远程连接 mysql慢的现象。
    然后重新启动mysql服务.

 
 
[python] view plain copy
  1. sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf  
  2. sed -i '44 i skip-name-resolve' /etc/mysql/my.cnf  
  3. /etc/init.d/mysql restart  
安装 RabbitMQ
apt-get install rabbitmq-server

NTP

  • 安装 NTP 服务

 
 
[python] view plain copy
  1. apt-get install ntp  
配置NTP服务器计算节点控制器节点之间的同步:
[python]  view plain copy
  1. sed -i 's/server ntp.ubuntu.com/server ntp.ubuntu.com\nserver 127.127.1.0\nfudge 127.127.1.0 stratum 10/g' /etc/ntp.conf  
  2.   
  3. service ntp restart  


 

  • 开启路由转发
[python]  view plain copy
  1. vim /etc/sysctl.conf  
  2.   
  3. net.ipv4.ip_forward=1  


 

Keystone

  • 安装 Keystone
[python]  view plain copy
  1. apt-get install keystone  


在 mysql 里创建 keystone 数据库并授权:

[python]  view plain copy
  1. mysql -uroot -p  
  2.   
  3. create database keystone;  
  4.   
  5. grant all on keystone.* to 'keystone'@'%' identified by 'keystone';  
  6.   
  7. quit;  


修改 /etc/keystone/keystone.conf 配置文件:

[python]  view plain copy
  1. admin_token = www.longgeek.com  
  2.   
  3. debug = True  
  4.   
  5. verbose = True  
  6.   
  7. [sql]  
  8.   
  9. connection = mysql://keystone:keystone@172.16.0.51/keystone       #必须写到 [sql] 下面  
  10.   
  11. [signing]  
  12.   
  13. token_format = UUID  


启动 keystone 然后同步数据库

[python]  view plain copy
  1. /etc/init.d/keystone restart  
  2.   
  3. keystone-manage db_sync  


用脚本导入数据:

用脚本来创建 user、role、tenant、service、endpoint,下载脚本:

[python]  view plain copy
  1. wget  http://192.168.80.8/ubuntu/keystone.sh  


 

修改脚本内容:

[python]  view plain copy
  1. ADMIN_PASSWORD=${ADMIN_PASSWORD:-password}  
  2.   
  3. SERVICE_PASSWORD=${SERVICE_PASSWORD:-password}  
  4.   
  5. export SERVICE_TOKEN="admin"  
  6.   
  7. export SERVICE_ENDPOINT="http://172.16.0.51:35357/v2.0"  
  8.   
  9. SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service}  
  10.   
  11. KEYSTONE_REGION=RegionOne  
  12.   
  13. # If you need to provide the service, please to open keystone_wlan_ip and swift_wlan_ip  
  14.   
  15. # of course you are a multi-node architecture, and swift service  
  16.   
  17. # corresponding ip address set the following variables  
  18.   
  19. KEYSTONE_IP="172.16.0.51"  
  20.   
  21. #KEYSTONE_WLAN_IP="172.16.0.51"  
  22.   
  23. SWIFT_IP="172.16.0.51"  
  24.   
  25. #SWIFT_WLAN_IP="172.16.0.51"  
  26.   
  27. COMPUTE_IP=$KEYSTONE_IP  
  28.   
  29. EC2_IP=$KEYSTONE_IP  
  30.   
  31. GLANCE_IP=$KEYSTONE_IP  
  32.   
  33. VOLUME_IP=$KEYSTONE_IP  
  34.   
  35. QUANTUM_IP=$KEYSTONE_IP  


在这里更改你的管理员密码即可,IP地址也可根据自己环境更改下!

 

执行脚本:


 
 
[python] view plain copy
  1. sh keystone.sh  
设置环境变量:

这里变量对于 keystone.sh 里的设置:

[python]  view plain copy
  1. cat > /etc/profile << _ESXU_  
  2.   
  3. export OS_TENANT_NAME=admin      #这里如果设置为 service 其它服务会无法验证.  
  4.   
  5. export OS_USERNAME=admin  
  6.   
  7. export OS_PASSWORD=password  
  8.   
  9. export OS_AUTH_URL=http://172.16.0.51:5000/v2.0/  
  10.   
  11. export OS_REGION_NAME=RegionOne  
  12.   
  13. export SERVICE_TOKEN=admin  
  14.   
  15. export SERVICE_ENDPOINT=http://172.16.0.51:35357/v2.0/  
  16.   
  17. _ESXU_  
  18.   
  19. # source /root/profile            #使环境变量生效  


 

Glance

  • 安装 Glance

 
 
[python] view plain copy
  1. apt-get install glance  
  • 创建一个 glance 数据库并授权:

 
 
[python] view plain copy
  1. mysql -uroot -p  
  2. create database glance;  
  3. grant all on glance.* to 'glance'@'%' identified by 'glance';  
 
  • 更新 /etc/glance/glance-api.conf 文件:

 

[python]  view plain copy
  1. verbose = True  
  2.   
  3. debug = True  
  4.   
  5. sql_connection = mysql://glance:glance@172.16.0.51/glance  
  6.   
  7. workers = 4  
  8.   
  9. registry_host = 172.16.0.51  
  10.   
  11. notifier_strategy = rabbit  
  12.   
  13. rabbit_host = 172.16.0.51  
  14.   
  15. rabbit_userid = guest  
  16.   
  17. rabbit_password = guest  
  18.   
  19. [keystone_authtoken]  
  20.   
  21. auth_host = 172.16.0.51  
  22.   
  23. auth_port = 35357  
  24.   
  25. auth_protocol = http  
  26.   
  27. admin_tenant_name = service  
  28.   
  29. admin_user = glance  
  30.   
  31. admin_password = password  
  32.   
  33. [paste_deploy]  
  34.   
  35. config_file = /etc/glance/glance-api-paste.ini  
  36.   
  37. flavor = keystone  


 

  • 更新 /etc/glance/glance-registry.conf 文件:
[python]  view plain copy
  1. verbose = True  
  2.   
  3. debug = True  
  4.   
  5. sql_connection = mysql://glance:glance@172.16.0.51/glance  
  6.   
  7. [keystone_authtoken]  
  8.   
  9. auth_host = 172.16.0.51  
  10.   
  11. auth_port = 35357  
  12.   
  13. auth_protocol = http  
  14.   
  15. admin_tenant_name = service  
  16.   
  17. admin_user = glance  
  18.   
  19. admin_password = password  
  20.   
  21. [paste_deploy]  
  22.   
  23. config_file = /etc/glance/glance-registry-paste.ini  
  24.   
  25. flavor = keystone  


启动 glance-api 和 glance-registry 服务并同步到数据库:

[python]  view plain copy
  1. /etc/init.d/glance-api restart  
  2.   
  3. /etc/init.d/glance-registry restart  
  4.   
  5. glance-manage version_control 0  
  6.   
  7. glance-manage db_sync  


测试 glance 的安装,上传一个镜像。下载 Cirros 镜像并上传:

[python]  view plain copy
  1. wget https://launchpad.net/cirros/trunk/0.3.0/+download/  
  2.   
  3. cirros-0.3.0-x86_64-disk.img  
  4.   
  5. glance image-create --name='cirros' --public --container-format=ovf --disk-format=qcow2 < ./cirros-0.3.0-x86_64-disk.img  


 

  • 查看上传的镜像:
[python]  view plain copy
  1. glance image-list  


 

Quantum

  • 安装 Quantum server OpenVSwitch包:

 
 
[python] view plain copy
  1. apt-get install quantum-server quantum-plugin-openvswitch  
  • 创建 quantum 数据库并授权用户访问:

 
 
[python] view plain copy
  1. mysql -uroot -p  
  2. create database quantum;  
  3. grant all on quantum.* to 'quantum'@'%' identified by 'quantum';  
  4. quit;  
编辑 /etc/quantum/quantum.conf文件
 
 
 
[python] view plain copy
  1. [DEFAULT]  
  2. debug = True  
  3.   
  4. verbose = True  
  5.   
  6. state_path = /var/lib/quantum  
  7.   
  8. lock_path = $state_path/lock  
  9.   
  10. bind_host = 0.0.0.0  
  11.   
  12. bind_port = 9696  
  13.   
  14. core_plugin = quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2  
  15.   
  16. api_paste_config = /etc/quantum/api-paste.ini  
  17.   
  18. control_exchange = quantum  
  19.   
  20. rabbit_host = 172.16.0.51  
  21.   
  22. rabbit_password = guest  
  23.   
  24. rabbit_port = 5672  
  25.   
  26. rabbit_userid = guest  
  27.   
  28. notification_driver = quantum.openstack.common.notifier.rpc_notifier  
  29.   
  30. default_notification_level = INFO  
  31.   
  32. notification_topics = notifications  
  33.   
  34. [QUOTAS]  
  35.   
  36. [DEFAULT_SERVICETYPE]  
  37.   
  38. [AGENT]  
  39.   
  40. root_helper = sudo quantum-rootwrap /etc/quantum/rootwrap.conf  
  41.   
  42. [keystone_authtoken]  
  43.   
  44. auth_host = 172.16.0.51  
  45.   
  46. auth_port = 35357  
  47.   
  48. auth_protocol = http  
  49.   
  50. admin_tenant_name = service  
  51.   
  52. admin_user = quantum  
  53.   
  54. admin_password = password  
  55.   
  56. signing_dir = /var/lib/quantum/keystone-signing  
 
  • 编辑 OVS 插件配置文件 /etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini:
[python]  view plain copy
  1. [DATABASE]  
  2.   
  3. sql_connection = mysql://quantum:quantum@172.16.0.51/quantum  
  4.   
  5. reconnect_interval = 2  
  6.   
  7. [OVS]  
  8.   
  9. tenant_network_type = gre  
  10.   
  11. enable_tunneling = True  
  12.   
  13. tunnel_id_ranges = 1:1000  
  14.   
  15. [AGENT]  
  16.   
  17. polling_interval = 2  
  18.   
  19. [SECURITYGROUP]  


启动 quantum 服务:

[python]  view plain copy
  1. /etc/init.d/quantum-server restart  


 

Nova

  • 安装 Nova 相关软件包:
[python]  view plain copy
  1. apt-get install nova-api nova-cert novnc nova-conductor nova-consoleauth nova-scheduler nova-novncproxy  

 

 

创建 nova 数据库,授权 nova 用户访问它:
[python]  view plain copy
  1. mysql -uroot -p  
  2.   
  3. create database nova;  
  4.   
  5. grant all on nova.* to 'nova'@'%' identified by 'nova';  
  6.   
  7. quit;  


在 /etc/nova/api-paste.ini 中修改 autotoken 验证部分:

[python]  view plain copy
  1. [filter:authtoken]  
  2.   
  3. paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory  
  4.   
  5. auth_host = 172.16.0.51  
  6.   
  7. auth_port = 35357  
  8.   
  9. auth_protocol = http  
  10.   
  11. admin_tenant_name = service  
  12.   
  13. admin_user = nova  
  14.   
  15. admin_password = password  
  16.   
  17. signing_dir = /tmp/keystone-signing-nova  
  18.   
  19. # Workaround for https://bugs.launchpad.net/nova/+bug/1154809  
  20.   
  21. auth_version = v2.0  


修改 /etc/nova/nova.conf, 类似下面这样:

[python]  view plain copy
  1. [DEFAULT]  
  2.   
  3. # LOGS/STATE  
  4.   
  5. debug = False  
  6.   
  7. verbose = True  
  8.   
  9. logdir = /var/log/nova  
  10.   
  11. state_path = /var/lib/nova  
  12.   
  13. lock_path = /var/lock/nova  
  14.   
  15. rootwrap_config = /etc/nova/rootwrap.conf  
  16.   
  17. dhcpbridge = /usr/bin/nova-dhcpbridge  
  18.   
  19. # SCHEDULER  
  20.   
  21. compute_scheduler_driver = nova.scheduler.filter_scheduler.FilterScheduler  
  22.   
  23. ## VOLUMES  
  24.   
  25. volume_api_class = nova.volume.cinder.API  
  26.   
  27. # DATABASE  
  28.   
  29. sql_connection = mysql://nova:nova@172.16.0.51/nova  
  30.   
  31. # COMPUTE  
  32.   
  33. libvirt_type = kvm  
  34.   
  35. compute_driver = libvirt.LibvirtDriver  
  36.   
  37. instance_name_template = instance-%08x  
  38.   
  39. api_paste_config = /etc/nova/api-paste.ini  
  40.   
  41. # COMPUTE/APIS: if you have separate configs for separate services  
  42.   
  43. # this flag is required for both nova-api and nova-compute  
  44.   
  45. allow_resize_to_same_host = True  
  46.   
  47. # APIS  
  48.   
  49. osapi_compute_extension = nova.api.openstack.compute.contrib.standard_extensions  
  50.   
  51. ec2_dmz_host = 172.16.0.51  
  52.   
  53. s3_host = 172.16.0.51  
  54.   
  55. metadata_host = 172.16.0.51  
  56.   
  57. metadata_listen = 0.0.0.0  
  58.   
  59. # RABBITMQ  
  60.   
  61. rabbit_host = 172.16.0.51  
  62.   
  63. rabbit_password = guest  
  64.   
  65. # GLANCE  
  66.   
  67. image_service = nova.image.glance.GlanceImageService  
  68.   
  69. glance_api_servers = 172.16.0.51:9292  
  70.   
  71. # NETWORK  
  72.   
  73. network_api_class = nova.network.quantumv2.api.API  
  74.   
  75. quantum_url = http://172.16.0.51:9696  
  76.   
  77. quantum_auth_strategy = keystone  
  78.   
  79. quantum_admin_tenant_name = service  
  80.   
  81. quantum_admin_username = quantum  
  82.   
  83. quantum_admin_password = password  
  84.   
  85. quantum_admin_auth_url = http://172.16.0.51:35357/v2.0  
  86.   
  87. service_quantum_metadata_proxy = True  
  88.   
  89. libvirt_vif_driver = nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver  
  90.   
  91. linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver  
  92.   
  93. firewall_driver = nova.virt.libvirt.firewall.IptablesFirewallDriver  
  94.   
  95. # NOVNC CONSOLE  
  96.   
  97. novncproxy_base_url = http://192.168.8.51:6080/vnc_auto.html  
  98.   
  99. # Change vncserver_proxyclient_address and vncserver_listen to match each compute host  
  100.   
  101. vncserver_proxyclient_address = 192.168.8.51  
  102.   
  103. vncserver_listen = 0.0.0.0  
  104.   
  105. # AUTHENTICATION  
  106.   
  107. auth_strategy = keystone  
  108.   
  109. [keystone_authtoken]  
  110.   
  111. auth_host = 172.16.0.51  
  112.   
  113. auth_port = 35357  
  114.   
  115. auth_protocol = http  
  116.   
  117. admin_tenant_name = service  
  118.   
  119. admin_user = nova  
  120.   
  121. admin_password = password  
  122.   
  123. signing_dir = /tmp/keystone-signing-nova  


同步数据库,启动 nova 相关服务:

[python]  view plain copy
  1. nova-manage db sync  
  2.   
  3. cd /etc/init.d/; for i in $( ls nova-* ); do sudo /etc/init.d/$i restart; done  


检查 nova 相关服务笑脸


 
 
[python] view plain copy
  1.  nova-manage service list  
  2. # nova-manage service list  
  3.   
  4. Binary           Host                                 Zone             Status     State Updated_At  
  5.   
  6. nova-cert        control                              internal         enabled    :-)   2013-05-07 07:09:56  
  7.   
  8. nova-conductor   control                              internal         enabled    :-)   2013-05-07 07:09:55  
  9.   
  10. nova-consoleauth control                              internal         enabled    :-)   2013-05-07 07:09:56  
  11.   
  12. nova-scheduler   control                              internal         enabled    :-)   2013-05-07 07:09:56  
Horizon
  • 安装 horizon
[python]  view plain copy
  1. apt-get install openstack-dashboard memcached  

 

 

如果你不喜欢 Ubuntu 的主题,可以禁用它,使用默认界面:

 
 
[python] view plain copy
  1. sed -i 's/127.0.0.1/172.16.0.51/g' /etc/openstack-dashboard/local_settings.py  
  2. sed -i 's/127.0.0.1/172.16.0.51/g' /etc/memcached.conf  
  3. vim /etc/openstack-dashboard/local_settings.py  
  4. DEBUG = True  
  5. # Enable the Ubuntu theme if it is present.  
  6. #try:  
  7. #    from ubuntu_theme import *  
  8. #except ImportError:  
  9. #    pass  
重新加载 apache2 和 memcache:
[python]  view plain copy
  1. /etc/init.d/apache2 restart  
  2.   
  3. /etc/init.d/memcached restart  


现在可以通过浏览器 http://192.168.8.51/horizon 使用 admin:password 来登录界面。

所有计算节点

网络设置

所有计算节点安装方法相同,只需要替换 IP 地址即可:

[python]  view plain copy
  1. #  cat /etc/network/interfaces  
  2.   
  3. # This file describes the network interfaces available on your system  
  4.   
  5. # and how to activate them. For more information, see interfaces(5).  
  6.   
  7.    
  8.   
  9. # The loopback network interface  
  10.   
  11. auto lo  
  12.   
  13. iface lo inet loopback  
  14.   
  15.    
  16.   
  17. # The primary network interface  
  18.   
  19. auto eth0  
  20.   
  21. iface eth0 inet manual  
  22.   
  23. up ifconfig $IFACE 0.0.0.0 up  
  24.   
  25.         up ip link set $IFACE promisc on   
  26.   
  27.         down ip link set $IFACE promisc off  
  28.   
  29.         down ifconfig $IFACE down  
  30.   
  31.    
  32.   
  33. auto br-ex  
  34.   
  35. iface br-ex inet static  
  36.   
  37.         address 192.168.80.22  
  38.   
  39.         netmask 255.255.255.0  
  40.   
  41.         gateway 192.168.80.1  
  42.   
  43.         dns-nameservers 8.8.8.8  
  44.   
  45. #address 192.168.80.22  
  46.   
  47. #netmask 255.255.255.0  
  48.   
  49. #gateway 192.168.80.1  
  50.   
  51. #dns-nameservers 8.8.8.8  
  52.   
  53.    
  54.   
  55. auto eth1  
  56.   
  57. iface eth1 inet static  
  58.   
  59. address 172.16.0.52  
  60.   
  61. netmask 255.255.0.0  
  62.   
  63.    
  64.   
  65. auto eth2  
  66.   
  67. iface eth2 inet static  
  68.   
  69. address 10.10.10.52  
  70.   
  71. netmask 255.255.255.0  


 

添加源

  • 添加 Grizzly 源,并升级系统

 
 
[delphi] view plain copy
  1. cat > /etc/apt/sources.list.d/grizzly.list << _GEEK_  
  2. deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/grizzly main  
  3. deb  http://ubuntu-cloud.archive.canonical.com/ubuntu precise-proposed/grizzly main  
  4. _GEEK_  
  5. apt-get update  
  6. apt-get upgrade  
  7. apt-get install ubuntu-cloud-keyring  
  • 设置 ntp 和开启路由转发:

 
 
[html] view plain copy
  1. # apt-get install ntp  
  2. # sed -i 's/server ntp.ubuntu.com/server 172.16.0.51/g' /etc/ntp.conf  
  3. # service ntp restart  
  4. # vim /etc/sysctl.conf  
  5. net.ipv4.ip_forward=1  
  6. # sysctl -p  
OpenVSwitch
  • 安装 openVSwitch:

必须按照下面安装顺序:


 
 
[html] view plain copy
  1. apt-get install openvswitch-datapath-source  
  2. module-assistant auto-install openvswitch-datapath  
  3. apt-get install openvswitch-switch openvswitch-brcompat  
设置 ovs-brcompatd 启动:

 
 
[html] view plain copy
  1. sed -i 's/# BRCOMPAT=no/BRCOMPAT=yes/g' /etc/default/openvswitch-switch  
  2. echo 'brcompat' >> /etc/modules  
启动 openvswitch-switch:
[html]  view plain copy
  1. /etc/init.d/openvswitch-switch restart  
  2.  * ovs-brcompatd is not running            # brcompatd 没有启动,尝试再次启动.  
  3.  * ovs-vswitchd is not running  
  4.  * ovsdb-server is not running  
  5.  * Inserting openvswitch module  
  6.  * /etc/openvswitch/conf.db does not exist  
  7.  * Creating empty database /etc/openvswitch/conf.db  
  8.  * Starting ovsdb-server  
  9.  * Configuring Open vSwitch system IDs  
  10.  * Starting ovs-vswitchd  
  11.  * Enabling gre with iptables  

 

 

再次启动,直到 ovs-brcompatdovs-vswitchdovsdb-server等服务都启动:

 
 
[html] view plain copy
  1. # /etc/init.d/openvswitch-switch restart  
  2. # lsmod | grep brcompat  
  3. brcompat               13512  0   
  4. openvswitch            84038  7 brcompat  
如果还是启动不了的话,用下面命令:

 
 
[html] view plain copy
  1. /etc/init.d/openvswitch-switch force-reload-kmod  
创建网桥:

 
 
[html] view plain copy
  1. ovs-vsctl add-br br-int        # br-int 用于 vm 整合  
  2. ovs-vsctl add-br br-ex              # br-ex 用于从互联网上访问 vm  
  3. ovs-vsctl add-port br-ex eth0       # br-ex 桥接到 eth0  
 
  • 重启网卡可能会出现:
[html]  view plain copy
  1.  /etc/init.d/networking restart  
  2.   
  3. RTNETLINK answers: File exists  
  4.   
  5. Failed to bring up br-ex.  


br-ex 可能有 ip 地址,但没有网关和 DNS,需要手工配置一下,或者重启机器. 重启机器后就正常了

  • 查看桥接的网络
[html]  view plain copy
  1. ovs-vsctl list-br  
  2.   
  3. ovs-vsctl show  


Quantum

  • 安装 Quantum openvswitch agent, metadata-agent l3 agent  dhcp agent:

 
 
[html] view plain copy
  1. apt-get install quantum-plugin-openvswitch-agent quantum-dhcp-agent quantum-l3-agent quantum-metadata-agent  
  • 编辑 /etc/quantum/quantum.conf 文件:

 
 
[html] view plain copy
  1. [DEFAULT]  
  2. debug = True  
  3. verbose = True  
  4. state_path = /var/lib/quantum  
  5. lock_path = $state_path/lock  
  6. bind_host = 0.0.0.0  
  7. bind_port = 9696  
  8. core_plugin = quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2  
  9. api_paste_config = /etc/quantum/api-paste.ini  
  10. control_exchange = quantum  
  11. rabbit_host = 172.16.0.51  
  12. rabbit_password = guest  
  13. rabbit_port = 5672  
  14. rabbit_userid = guest  
  15. notification_driver = quantum.openstack.common.notifier.rpc_notifier  
  16. default_notification_level = INFO  
  17. notification_topics = notifications  
  18. [QUOTAS]  
  19. [DEFAULT_SERVICETYPE]  
  20. [AGENT]  
  21. root_helper = sudo quantum-rootwrap /etc/quantum/rootwrap.conf  
  22. [keystone_authtoken]  
  23. auth_host = 172.16.0.51  
  24. auth_port = 35357  
  25. auth_protocol = http  
  26. admin_tenant_name = service  
  27. admin_user = quantum  
  28. admin_password = password  
  29. signing_dir = /var/lib/quantum/keystone-signing  
编辑 OVS 插件配置文件 /etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini:
[html]  view plain copy
  1. [DATABASE]  
  2.   
  3. sql_connection = mysql://quantum:quantum@172.16.0.51/quantum  
  4.   
  5. reconnect_interval = 2  
  6.   
  7. [OVS]  
  8.   
  9. enable_tunneling = True  
  10.   
  11. tenant_network_type = gre  
  12.   
  13. tunnel_id_ranges = 1:1000  
  14.   
  15. local_ip = 10.10.10.52  
  16.   
  17. integration_bridge = br-int  
  18.   
  19. tunnel_bridge = br-tun  
  20.   
  21. [AGENT]  
  22.   
  23. polling_interval = 2  
  24.   
  25. [SECURITYGROUP]  


编辑 /etc/quantum/l3_agent.ini:

[html]  view plain copy
  1. [DEFAULT]  
  2.   
  3. debug = True  
  4.   
  5. verbose = True  
  6.   
  7. use_namespaces = True  
  8.   
  9. external_network_bridge = br-ex  
  10.   
  11. signing_dir = /var/cache/quantum  
  12.   
  13. admin_tenant_name = service  
  14.   
  15. admin_user = quantum  
  16.   
  17. admin_password = password  
  18.   
  19. auth_url = http://172.16.0.51:35357/v2.0  
  20.   
  21. l3_agent_manager = quantum.agent.l3_agent.L3NATAgentWithStateReport  
  22.   
  23. root_helper = sudo quantum-rootwrap /etc/quantum/rootwrap.conf  
  24.   
  25. interface_driver = quantum.agent.linux.interface.OVSInterfaceDriver  
  26.   
  27. enable_multi_host = True  


编辑 /etc/quantum/dhcp_agent.ini:

[html]  view plain copy
  1. [DEFAULT]  
  2.   
  3. debug = True  
  4.   
  5. verbose = True  
  6.   
  7. use_namespaces = True  
  8.   
  9. signing_dir = /var/cache/quantum  
  10.   
  11. admin_tenant_name = service  
  12.   
  13. admin_user = quantum  
  14.   
  15. admin_password = password  
  16.   
  17. auth_url = http://172.16.0.51:35357/v2.0  
  18.   
  19. dhcp_agent_manager = quantum.agent.dhcp_agent.DhcpAgentWithStateReport  
  20.   
  21. root_helper = sudo quantum-rootwrap /etc/quantum/rootwrap.conf  
  22.   
  23. state_path = /var/lib/quantum  
  24.   
  25. interface_driver = quantum.agent.linux.interface.OVSInterfaceDriver  
  26.   
  27. dhcp_driver = quantum.agent.linux.dhcp.Dnsmasq  
  28.   
  29. enable_multi_host = True  
  30.   
  31. enable_isolated_metadata = False  


编辑 /etc/quantum/metadata_agent.ini:

[html]  view plain copy
  1. [DEFAULT]  
  2.   
  3. debug = True  
  4.   
  5. auth_url = http://172.16.0.51:35357/v2.0  
  6.   
  7. auth_region = RegionOne  
  8.   
  9. admin_tenant_name = service  
  10.   
  11. admin_user = quantum  
  12.   
  13. admin_password = password  
  14.   
  15. state_path = /var/lib/quantum  
  16.   
  17. nova_metadata_ip = 172.16.0.51  
  18.   
  19. nova_metadata_port = 8775  


启动 quantum 所有服务:

[html]  view plain copy
  1. service quantum-plugin-openvswitch-agent restart  
  2.   
  3. service quantum-dhcp-agent restart  
  4.   
  5. service quantum-l3-agent restart  
  6.   
  7. service quantum-metadata-agent restart  


Cinder

  • 安装 Cinder 需要的包:

 
 
[html] view plain copy
  1. apt-get install cinder-api cinder-common cinder-scheduler cinder-volume python-cinderclient iscsitarget open-iscsi iscsitarget-dkms  
配置 iscsi 并启动服务:
[html]  view plain copy
  1. sed -i 's/false/true/g' /etc/default/iscsitarget  
  2.   
  3. /etc/init.d/iscsitarget restart  
  4.   
  5. /etc/init.d/open-iscsi restart  


创建 cinder 数据库并授权用户访问:

[html]  view plain copy
  1. mysql -uroot -p  
  2.   
  3. create database cinder;  
  4.   
  5. grant all on cinder.* to 'cinder'@'%' identified by 'cinder';  
  6.   
  7. quit;  


修改 /etc/cinder/cinder.conf:

[html]  view plain copy
  1. cat /etc/cinder/cinder.conf  
  2.   
  3. [DEFAULT]  
  4.   
  5. # LOG/STATE  
  6.   
  7. verbose = True  
  8.   
  9. debug = False  
  10.   
  11. iscsi_helper = ietadm  
  12.   
  13. auth_strategy = keystone  
  14.   
  15. volume_group = cinder-volumes  
  16.   
  17. volume_name_template = volume-%s  
  18.   
  19. state_path = /var/lib/cinder  
  20.   
  21. volumes_dir = /var/lib/cinder/volumes  
  22.   
  23. rootwrap_config = /etc/cinder/rootwrap.conf  
  24.   
  25. api_paste_config = /etc/cinder/api-paste.ini  
  26.   
  27. # RPC  
  28.   
  29. rabbit_host = 172.16.0.51  
  30.   
  31. rabbit_password = guest  
  32.   
  33. rpc_backend = cinder.openstack.common.rpc.impl_kombu  
  34.   
  35. # DATABASE  
  36.   
  37. sql_connection = mysql://cinder:cinder@172.16.0.51/cinder  
  38.   
  39. # API  
  40.   
  41. osapi_volume_extension = cinder.api.contrib.standard_extensions  


修改 /etc/cinder/api-paste.ini 文件末尾 [filter:authtoken] 字段 :

[html]  view plain copy
  1. [filter:authtoken]  
  2.   
  3. paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory  
  4.   
  5. service_protocol = http  
  6.   
  7. service_host = 172.16.0.51  
  8.   
  9. service_port = 5000  
  10.   
  11. auth_host = 172.16.0.51  
  12.   
  13. auth_port = 35357  
  14.   
  15. auth_protocol = http  
  16.   
  17. admin_tenant_name = service  
  18.   
  19. admin_user = cinder  
  20.   
  21. admin_password = password  
  22.   
  23. signing_dir = /var/lib/cinder  


 

  • 创建一个卷组,命名为 cinder-volumes:

   创建一个普通分区,我这里用的sdb,创建了一个主分区,大小为所有空间


 
 
[html] view plain copy
  1. # fdisk /dev/sdb  
  2. n  
  3. p  
  4. 1  
  5. Enter  
  6. Enter  
  7. t  
  8. 8e  
  9. w  
  10. # partx -a /dev/sdb  
  11. # pvcreate /dev/sdb1  
  12. # vgcreate cinder-volumes /dev/sdb1  
  13. # vgs  
  14.   VG             #PV #LV #SN Attr   VSize VFree   
  15.   cinder-volumes   1   7   0 wz--n- 1.64t 75.50g    
 
  • 同步数据库并重启服务:
[html]  view plain copy
  1. cinder-manage db sync  
  2.   
  3. /etc/init.d/cinder-api restart  
  4.   
  5. /etc/init.d/cinder-scheduler restart  
  6.   
  7. /etc/init.d/cinder-volume restart  


最后,我们需要执行:

[html]  view plain copy
  1. /etc/init.d/iscsitarget stop  


具体请看这里

 

Nova

  • 安装 nova-compute:

 
 
[html] view plain copy
  1. apt-get install nova-compute  
/etc/nova/api-paste.ini 中修改 autotoken 验证部分:

 
 
[html] view plain copy
  1. [filter:authtoken]  
  2. paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory  
  3. auth_host = 172.16.0.51  
  4. auth_port = 35357  
  5. auth_protocol = http  
  6. admin_tenant_name = service  
  7. admin_user = nova  
  8. admin_password = password  
  9. signing_dir = /tmp/keystone-signing-nova  
  10. # Workaround for https://bugs.launchpad.net/nova/+bug/1154809  
  11. auth_version = v2.0  
修改 /etc/nova/nova.conf,类似下面这样:

 
 
[html] view plain copy
  1. cat /etc/nova/nova.conf   
  2. [DEFAULT]  
  3. dhcpbridge_flagfile=/etc/nova/nova.conf  
  4. dhcpbridge=/usr/bin/nova-dhcpbridge  
  5. logdir=/var/log/nova  
  6. state_path=/var/lib/nova  
  7. lock_path=/var/lock/nova  
  8. force_dhcp_release=True  
  9. iscsi_helper=tgtadm  
  10. #iscsi_helper = ietadm  
  11. libvirt_use_virtio_for_bridges=True  
  12. connection_type=libvirt  
  13. root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf  
  14. verbose=True  
  15. ec2_private_dns_show_ip=True  
  16. #api_paste_config=/etc/nova/api-paste.ini  
  17. volumes_path=/var/lib/nova/volumes  
  18. enabled_apis=ec2,osapi_compute,metadata  
  19.    
  20. # SCHEDULER  
  21. compute_scheduler_driver = nova.scheduler.filter_scheduler.FilterScheduler  
  22. ## VOLUMES  
  23. volume_api_class = nova.volume.cinder.API  
  24. osapi_volume_listen_port=5900  
  25. iscsi_ip_prefix=192.168.80  
  26. iscsi_ip_address=192.168.80.22  
  27. # DATABASE  
  28. sql_connection = mysql://nova:nova@172.16.0.51/nova  
  29. # COMPUTE  
  30. libvirt_type = kvm  
  31. compute_driver = libvirt.LibvirtDriver  
  32. instance_name_template = instance-%08x  
  33. api_paste_config = /etc/nova/api-paste.ini  
  34. # COMPUTE/APIS: if you have separate configs for separate services  
  35. # this flag is required for both nova-api and nova-compute  
  36. allow_resize_to_same_host = True  
  37. # APIS  
  38. osapi_compute_extension = nova.api.openstack.compute.contrib.standard_extensions  
  39. ec2_dmz_host = 172.16.0.51  
  40. s3_host = 172.16.0.51  
  41. metadata_host=172.16.0.51  
  42. metadata_listen=0.0.0.0  
  43. # RABBITMQ  
  44. rabbit_host = 172.16.0.51  
  45. rabbit_password = guest  
  46. # GLANCE  
  47. image_service = nova.image.glance.GlanceImageService  
  48. glance_api_servers = 172.16.0.51:9292  
  49. # NETWORK  
  50. network_api_class = nova.network.quantumv2.api.API  
  51. quantum_url = http://172.16.0.51:9696  
  52. quantum_auth_strategy = keystone  
  53. quantum_admin_tenant_name = service  
  54. quantum_admin_username = quantum  
  55. quantum_admin_password = password  
  56. quantum_admin_auth_url = http://172.16.0.51:35357/v2.0  
  57. service_quantum_metadata_proxy = True  
  58. libvirt_vif_driver = nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver  
  59. linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver  
  60. firewall_driver = nova.virt.libvirt.firewall.IptablesFirewallDriver  
  61. # NOVNC CONSOLE  
  62. novncproxy_base_url = http://192.168.80.21:6080/vnc_auto.html  
  63. # Change vncserver_proxyclient_address and vncserver_listen to match each compute host  
  64. vncserver_proxyclient_address = 192.168.80.22  
  65. vncserver_listen = 192.168.80.22  
  66. # AUTHENTICATION  
  67. auth_strategy = keystone  
  68. [keystone_authtoken]  
  69. auth_host = 172.16.0.51  
  70. auth_port = 35357  
  71. auth_protocol = http  
  72. admin_tenant_name = service  
  73. admin_user = nova  
  74. admin_password = password  
  75. signing_dir = /tmp/keystone-signing-nova  
启动 nova-compute 服务:
[html]  view plain copy
  1. service nova-compute restart  


检查 nova 相关服务笑脸:

发现 compute 节点已经加入:


 
 
[html] view plain copy
  1. # nova-manage service list  
  2. Binary           Host                                 Zone             Status     State Updated_At  
  3. nova-cert        control                              internal         enabled    :-)   2013-05-07 07:09:56  
  4. nova-conductor   control                              internal         enabled    :-)   2013-05-07 07:09:55  
  5. nova-consoleauth control                              internal         enabled    :-)   2013-05-07 07:09:56  
  6. nova-scheduler   control                              internal         enabled    :-)   2013-05-07 07:09:56  
  7. nova-compute     node-02                              nova             enabled    :-)   2013-05-07 07:10:03  
  8. nova-compute     node-03                              nova             enabled    :-)   2013-05-07 07:10:03  
 

 

到这里,计算节点就成功加入了,我们可以尝试新建节点验证是否成功,具体horizon的使用方法,后面再写文章详细介绍,主要就是网络的创建这块稍微有点复杂,需要稍微注意下!


本文主要介绍multihost模式下的openstack多节点部署,这种模式可以避免随着节点的增多,流量膨胀一个网络节点无法满足需求的情况。当然如果只是自己搞一台host,在上面虚拟几台VM做实验,或者小型创业公司,通过在五台十台机器上的虚拟化,创建一些VM给公司内部开发测试团队使用,那么使用多节点模式即可,即一个控制节点、一个网络节点、多个计算节点。在Essxinova-networkmutihost可以很好分担网络节点的负载,同样在Quantum中也有类似的功能,本文主要参考一位网友Geekblog所写,做了适当修改,在我的环境里验证没有问题,这里记录下来也仅供大家参考!

 

环境需求:

管理网络: 172.16.0.0/16
业务网络:
 10.10.10.0/24
外部网络: 192.168.80.0/24

我这里使用的是三台机器,你也可以横向扩展,增加计算节点的数量。

Node Role:

NICs

Control Node:

eth0 (192.168.80.21), eth1 (172.16.0.51)

Compute1 Node:

eth0(192.168.80.22),eth1(172.16.0.52),eth2(10.10.10.52)

Compute2 Node:

eth0(192.168.80.23),eth1(172.16.0.53),eth2(10.10.10.53)

 

 

控制节点

网络设置

[python]  view plain copy
  1. cat /etc/network/interfaces   
  2.   
  3. # This file describes the network interfaces available on your system  
  4.   
  5. # and how to activate them. For more information, see interfaces(5).  
  6.   
  7.    
  8.   
  9. # The loopback network interface  
  10.   
  11. auto lo  
  12.   
  13. iface lo inet loopback  
  14.   
  15.    
  16.   
  17. # The primary network interface  
  18.   
  19. auto eth0  
  20.   
  21. iface eth0 inet static  
  22.   
  23. address 192.168.80.21  
  24.   
  25. netmask 255.255.255.0  
  26.   
  27. gateway 192.168.80.1  
  28.   
  29. dns-nameservers 8.8.8.8  
  30.   
  31.    
  32.   
  33. auto eth1  
  34.   
  35. iface eth1 inet static  
  36.   
  37. address 172.16.0.51  
  38.   
  39. netmask 255.255.0.0  


 

添加源

添加 Grizzly 源,并升级系统

[python]  view plain copy
  1. cat > /etc/apt/sources.list.d/grizzly.list << _ESXU_  
  2.   
  3. deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/grizzly main  
  4.   
  5. deb  http://ubuntu-cloud.archive.canonical.com/ubuntu precise-proposed/grizzly main  
  6.   
  7. _ESXU_  
  8.   
  9. apt-get install ubuntu-cloud-keyring  
  10.   
  11. apt-get update  
  12.   
  13. apt-get upgrade  


 

MySQL & RabbitMQ

  • 安装 MySQL

 
 
[python] view plain copy
  1. apt-get install mysql-server python-mysqldb  
  • 使用sed编辑 /etc/mysql/my.cnf文件的更改绑定地址(0.0.0.0)从本地主机(127.0.0.1
    禁止 mysql 做域名解析,防止连接 mysql出现错误和远程连接 mysql慢的现象。
    然后重新启动mysql服务.

 
 
[python] view plain copy
  1. sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf  
  2. sed -i '44 i skip-name-resolve' /etc/mysql/my.cnf  
  3. /etc/init.d/mysql restart  
安装 RabbitMQ
apt-get install rabbitmq-server

NTP

  • 安装 NTP 服务

 
 
[python] view plain copy
  1. apt-get install ntp  
配置NTP服务器计算节点控制器节点之间的同步:
[python]  view plain copy
  1. sed -i 's/server ntp.ubuntu.com/server ntp.ubuntu.com\nserver 127.127.1.0\nfudge 127.127.1.0 stratum 10/g' /etc/ntp.conf  
  2.   
  3. service ntp restart  


 

  • 开启路由转发
[python]  view plain copy
  1. vim /etc/sysctl.conf  
  2.   
  3. net.ipv4.ip_forward=1  


 

Keystone

  • 安装 Keystone
[python]  view plain copy
  1. apt-get install keystone  


在 mysql 里创建 keystone 数据库并授权:

[python]  view plain copy
  1. mysql -uroot -p  
  2.   
  3. create database keystone;  
  4.   
  5. grant all on keystone.* to 'keystone'@'%' identified by 'keystone';  
  6.   
  7. quit;  


修改 /etc/keystone/keystone.conf 配置文件:

[python]  view plain copy
  1. admin_token = www.longgeek.com  
  2.   
  3. debug = True  
  4.   
  5. verbose = True  
  6.   
  7. [sql]  
  8.   
  9. connection = mysql://keystone:keystone@172.16.0.51/keystone       #必须写到 [sql] 下面  
  10.   
  11. [signing]  
  12.   
  13. token_format = UUID  


启动 keystone 然后同步数据库

[python]  view plain copy
  1. /etc/init.d/keystone restart  
  2.   
  3. keystone-manage db_sync  


用脚本导入数据:

用脚本来创建 user、role、tenant、service、endpoint,下载脚本:

[python]  view plain copy
  1. wget  http://192.168.80.8/ubuntu/keystone.sh  


 

修改脚本内容:

[python]  view plain copy
  1. ADMIN_PASSWORD=${ADMIN_PASSWORD:-password}  
  2.   
  3. SERVICE_PASSWORD=${SERVICE_PASSWORD:-password}  
  4.   
  5. export SERVICE_TOKEN="admin"  
  6.   
  7. export SERVICE_ENDPOINT="http://172.16.0.51:35357/v2.0"  
  8.   
  9. SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service}  
  10.   
  11. KEYSTONE_REGION=RegionOne  
  12.   
  13. # If you need to provide the service, please to open keystone_wlan_ip and swift_wlan_ip  
  14.   
  15. # of course you are a multi-node architecture, and swift service  
  16.   
  17. # corresponding ip address set the following variables  
  18.   
  19. KEYSTONE_IP="172.16.0.51"  
  20.   
  21. #KEYSTONE_WLAN_IP="172.16.0.51"  
  22.   
  23. SWIFT_IP="172.16.0.51"  
  24.   
  25. #SWIFT_WLAN_IP="172.16.0.51"  
  26.   
  27. COMPUTE_IP=$KEYSTONE_IP  
  28.   
  29. EC2_IP=$KEYSTONE_IP  
  30.   
  31. GLANCE_IP=$KEYSTONE_IP  
  32.   
  33. VOLUME_IP=$KEYSTONE_IP  
  34.   
  35. QUANTUM_IP=$KEYSTONE_IP  


在这里更改你的管理员密码即可,IP地址也可根据自己环境更改下!

 

执行脚本:


 
 
[python] view plain copy
  1. sh keystone.sh  
设置环境变量:

这里变量对于 keystone.sh 里的设置:

[python]  view plain copy
  1. cat > /etc/profile << _ESXU_  
  2.   
  3. export OS_TENANT_NAME=admin      #这里如果设置为 service 其它服务会无法验证.  
  4.   
  5. export OS_USERNAME=admin  
  6.   
  7. export OS_PASSWORD=password  
  8.   
  9. export OS_AUTH_URL=http://172.16.0.51:5000/v2.0/  
  10.   
  11. export OS_REGION_NAME=RegionOne  
  12.   
  13. export SERVICE_TOKEN=admin  
  14.   
  15. export SERVICE_ENDPOINT=http://172.16.0.51:35357/v2.0/  
  16.   
  17. _ESXU_  
  18.   
  19. # source /root/profile            #使环境变量生效  


 

Glance

  • 安装 Glance

 
 
[python] view plain copy
  1. apt-get install glance  
  • 创建一个 glance 数据库并授权:

 
 
[python] view plain copy
  1. mysql -uroot -p  
  2. create database glance;  
  3. grant all on glance.* to 'glance'@'%' identified by 'glance';  
 
  • 更新 /etc/glance/glance-api.conf 文件:

 

[python]  view plain copy
  1. verbose = True  
  2.   
  3. debug = True  
  4.   
  5. sql_connection = mysql://glance:glance@172.16.0.51/glance  
  6.   
  7. workers = 4  
  8.   
  9. registry_host = 172.16.0.51  
  10.   
  11. notifier_strategy = rabbit  
  12.   
  13. rabbit_host = 172.16.0.51  
  14.   
  15. rabbit_userid = guest  
  16.   
  17. rabbit_password = guest  
  18.   
  19. [keystone_authtoken]  
  20.   
  21. auth_host = 172.16.0.51  
  22.   
  23. auth_port = 35357  
  24.   
  25. auth_protocol = http  
  26.   
  27. admin_tenant_name = service  
  28.   
  29. admin_user = glance  
  30.   
  31. admin_password = password  
  32.   
  33. [paste_deploy]  
  34.   
  35. config_file = /etc/glance/glance-api-paste.ini  
  36.   
  37. flavor = keystone  


 

  • 更新 /etc/glance/glance-registry.conf 文件:
[python]  view plain copy
  1. verbose = True  
  2.   
  3. debug = True  
  4.   
  5. sql_connection = mysql://glance:glance@172.16.0.51/glance  
  6.   
  7. [keystone_authtoken]  
  8.   
  9. auth_host = 172.16.0.51  
  10.   
  11. auth_port = 35357  
  12.   
  13. auth_protocol = http  
  14.   
  15. admin_tenant_name = service  
  16.   
  17. admin_user = glance  
  18.   
  19. admin_password = password  
  20.   
  21. [paste_deploy]  
  22.   
  23. config_file = /etc/glance/glance-registry-paste.ini  
  24.   
  25. flavor = keystone  


启动 glance-api 和 glance-registry 服务并同步到数据库:

[python]  view plain copy
  1. /etc/init.d/glance-api restart  
  2.   
  3. /etc/init.d/glance-registry restart  
  4.   
  5. glance-manage version_control 0  
  6.   
  7. glance-manage db_sync  


测试 glance 的安装,上传一个镜像。下载 Cirros 镜像并上传:

[python]  view plain copy
  1. wget https://launchpad.net/cirros/trunk/0.3.0/+download/  
  2.   
  3. cirros-0.3.0-x86_64-disk.img  
  4.   
  5. glance image-create --name='cirros' --public --container-format=ovf --disk-format=qcow2 < ./cirros-0.3.0-x86_64-disk.img  


 

  • 查看上传的镜像:
[python]  view plain copy
  1. glance image-list  


 

Quantum

  • 安装 Quantum server OpenVSwitch包:

 
 
[python] view plain copy
  1. apt-get install quantum-server quantum-plugin-openvswitch  
  • 创建 quantum 数据库并授权用户访问:

 
 
[python] view plain copy
  1. mysql -uroot -p  
  2. create database quantum;  
  3. grant all on quantum.* to 'quantum'@'%' identified by 'quantum';  
  4. quit;  
编辑 /etc/quantum/quantum.conf文件
 
 
 
[python] view plain copy
  1. [DEFAULT]  
  2. debug = True  
  3.   
  4. verbose = True  
  5.   
  6. state_path = /var/lib/quantum  
  7.   
  8. lock_path = $state_path/lock  
  9.   
  10. bind_host = 0.0.0.0  
  11.   
  12. bind_port = 9696  
  13.   
  14. core_plugin = quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2  
  15.   
  16. api_paste_config = /etc/quantum/api-paste.ini  
  17.   
  18. control_exchange = quantum  
  19.   
  20. rabbit_host = 172.16.0.51  
  21.   
  22. rabbit_password = guest  
  23.   
  24. rabbit_port = 5672  
  25.   
  26. rabbit_userid = guest  
  27.   
  28. notification_driver = quantum.openstack.common.notifier.rpc_notifier  
  29.   
  30. default_notification_level = INFO  
  31.   
  32. notification_topics = notifications  
  33.   
  34. [QUOTAS]  
  35.   
  36. [DEFAULT_SERVICETYPE]  
  37.   
  38. [AGENT]  
  39.   
  40. root_helper = sudo quantum-rootwrap /etc/quantum/rootwrap.conf  
  41.   
  42. [keystone_authtoken]  
  43.   
  44. auth_host = 172.16.0.51  
  45.   
  46. auth_port = 35357  
  47.   
  48. auth_protocol = http  
  49.   
  50. admin_tenant_name = service  
  51.   
  52. admin_user = quantum  
  53.   
  54. admin_password = password  
  55.   
  56. signing_dir = /var/lib/quantum/keystone-signing  
 
  • 编辑 OVS 插件配置文件 /etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini:
[python]  view plain copy
  1. [DATABASE]  
  2.   
  3. sql_connection = mysql://quantum:quantum@172.16.0.51/quantum  
  4.   
  5. reconnect_interval = 2  
  6.   
  7. [OVS]  
  8.   
  9. tenant_network_type = gre  
  10.   
  11. enable_tunneling = True  
  12.   
  13. tunnel_id_ranges = 1:1000  
  14.   
  15. [AGENT]  
  16.   
  17. polling_interval = 2  
  18.   
  19. [SECURITYGROUP]  


启动 quantum 服务:

[python]  view plain copy
  1. /etc/init.d/quantum-server restart  


 

Nova

  • 安装 Nova 相关软件包:
[python]  view plain copy
  1. apt-get install nova-api nova-cert novnc nova-conductor nova-consoleauth nova-scheduler nova-novncproxy  

 

 

创建 nova 数据库,授权 nova 用户访问它:
[python]  view plain copy
  1. mysql -uroot -p  
  2.   
  3. create database nova;  
  4.   
  5. grant all on nova.* to 'nova'@'%' identified by 'nova';  
  6.   
  7. quit;  


在 /etc/nova/api-paste.ini 中修改 autotoken 验证部分:

[python]  view plain copy
  1. [filter:authtoken]  
  2.   
  3. paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory  
  4.   
  5. auth_host = 172.16.0.51  
  6.   
  7. auth_port = 35357  
  8.   
  9. auth_protocol = http  
  10.   
  11. admin_tenant_name = service  
  12.   
  13. admin_user = nova  
  14.   
  15. admin_password = password  
  16.   
  17. signing_dir = /tmp/keystone-signing-nova  
  18.   
  19. # Workaround for https://bugs.launchpad.net/nova/+bug/1154809  
  20.   
  21. auth_version = v2.0  


修改 /etc/nova/nova.conf, 类似下面这样:

[python]  view plain copy
  1. [DEFAULT]  
  2.   
  3. # LOGS/STATE  
  4.   
  5. debug = False  
  6.   
  7. verbose = True  
  8.   
  9. logdir = /var/log/nova  
  10.   
  11. state_path = /var/lib/nova  
  12.   
  13. lock_path = /var/lock/nova  
  14.   
  15. rootwrap_config = /etc/nova/rootwrap.conf  
  16.   
  17. dhcpbridge = /usr/bin/nova-dhcpbridge  
  18.   
  19. # SCHEDULER  
  20.   
  21. compute_scheduler_driver = nova.scheduler.filter_scheduler.FilterScheduler  
  22.   
  23. ## VOLUMES  
  24.   
  25. volume_api_class = nova.volume.cinder.API  
  26.   
  27. # DATABASE  
  28.   
  29. sql_connection = mysql://nova:nova@172.16.0.51/nova  
  30.   
  31. # COMPUTE  
  32.   
  33. libvirt_type = kvm  
  34.   
  35. compute_driver = libvirt.LibvirtDriver  
  36.   
  37. instance_name_template = instance-%08x  
  38.   
  39. api_paste_config = /etc/nova/api-paste.ini  
  40.   
  41. # COMPUTE/APIS: if you have separate configs for separate services  
  42.   
  43. # this flag is required for both nova-api and nova-compute  
  44.   
  45. allow_resize_to_same_host = True  
  46.   
  47. # APIS  
  48.   
  49. osapi_compute_extension = nova.api.openstack.compute.contrib.standard_extensions  
  50.   
  51. ec2_dmz_host = 172.16.0.51  
  52.   
  53. s3_host = 172.16.0.51  
  54.   
  55. metadata_host = 172.16.0.51  
  56.   
  57. metadata_listen = 0.0.0.0  
  58.   
  59. # RABBITMQ  
  60.   
  61. rabbit_host = 172.16.0.51  
  62.   
  63. rabbit_password = guest  
  64.   
  65. # GLANCE  
  66.   
  67. image_service = nova.image.glance.GlanceImageService  
  68.   
  69. glance_api_servers = 172.16.0.51:9292  
  70.   
  71. # NETWORK  
  72.   
  73. network_api_class = nova.network.quantumv2.api.API  
  74.   
  75. quantum_url = http://172.16.0.51:9696  
  76.   
  77. quantum_auth_strategy = keystone  
  78.   
  79. quantum_admin_tenant_name = service  
  80.   
  81. quantum_admin_username = quantum  
  82.   
  83. quantum_admin_password = password  
  84.   
  85. quantum_admin_auth_url = http://172.16.0.51:35357/v2.0  
  86.   
  87. service_quantum_metadata_proxy = True  
  88.   
  89. libvirt_vif_driver = nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver  
  90.   
  91. linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver  
  92.   
  93. firewall_driver = nova.virt.libvirt.firewall.IptablesFirewallDriver  
  94.   
  95. # NOVNC CONSOLE  
  96.   
  97. novncproxy_base_url = http://192.168.8.51:6080/vnc_auto.html  
  98.   
  99. # Change vncserver_proxyclient_address and vncserver_listen to match each compute host  
  100.   
  101. vncserver_proxyclient_address = 192.168.8.51  
  102.   
  103. vncserver_listen = 0.0.0.0  
  104.   
  105. # AUTHENTICATION  
  106.   
  107. auth_strategy = keystone  
  108.   
  109. [keystone_authtoken]  
  110.   
  111. auth_host = 172.16.0.51  
  112.   
  113. auth_port = 35357  
  114.   
  115. auth_protocol = http  
  116.   
  117. admin_tenant_name = service  
  118.   
  119. admin_user = nova  
  120.   
  121. admin_password = password  
  122.   
  123. signing_dir = /tmp/keystone-signing-nova  


同步数据库,启动 nova 相关服务:

[python]  view plain copy
  1. nova-manage db sync  
  2.   
  3. cd /etc/init.d/; for i in $( ls nova-* ); do sudo /etc/init.d/$i restart; done  


检查 nova 相关服务笑脸


 
 
[python] view plain copy
  1.  nova-manage service list  
  2. # nova-manage service list  
  3.   
  4. Binary           Host                                 Zone             Status     State Updated_At  
  5.   
  6. nova-cert        control                              internal         enabled    :-)   2013-05-07 07:09:56  
  7.   
  8. nova-conductor   control                              internal         enabled    :-)   2013-05-07 07:09:55  
  9.   
  10. nova-consoleauth control                              internal         enabled    :-)   2013-05-07 07:09:56  
  11.   
  12. nova-scheduler   control                              internal         enabled    :-)   2013-05-07 07:09:56  
Horizon
  • 安装 horizon
[python]  view plain copy
  1. apt-get install openstack-dashboard memcached  

 

 

如果你不喜欢 Ubuntu 的主题,可以禁用它,使用默认界面:

 
 
[python] view plain copy
  1. sed -i 's/127.0.0.1/172.16.0.51/g' /etc/openstack-dashboard/local_settings.py  
  2. sed -i 's/127.0.0.1/172.16.0.51/g' /etc/memcached.conf  
  3. vim /etc/openstack-dashboard/local_settings.py  
  4. DEBUG = True  
  5. # Enable the Ubuntu theme if it is present.  
  6. #try:  
  7. #    from ubuntu_theme import *  
  8. #except ImportError:  
  9. #    pass  
重新加载 apache2 和 memcache:
[python]  view plain copy
  1. /etc/init.d/apache2 restart  
  2.   
  3. /etc/init.d/memcached restart  


现在可以通过浏览器 http://192.168.8.51/horizon 使用 admin:password 来登录界面。

所有计算节点

网络设置

所有计算节点安装方法相同,只需要替换 IP 地址即可:

[python]  view plain copy
  1. #  cat /etc/network/interfaces  
  2.   
  3. # This file describes the network interfaces available on your system  
  4.   
  5. # and how to activate them. For more information, see interfaces(5).  
  6.   
  7.    
  8.   
  9. # The loopback network interface  
  10.   
  11. auto lo  
  12.   
  13. iface lo inet loopback  
  14.   
  15.    
  16.   
  17. # The primary network interface  
  18.   
  19. auto eth0  
  20.   
  21. iface eth0 inet manual  
  22.   
  23. up ifconfig $IFACE 0.0.0.0 up  
  24.   
  25.         up ip link set $IFACE promisc on   
  26.   
  27.         down ip link set $IFACE promisc off  
  28.   
  29.         down ifconfig $IFACE down  
  30.   
  31.    
  32.   
  33. auto br-ex  
  34.   
  35. iface br-ex inet static  
  36.   
  37.         address 192.168.80.22  
  38.   
  39.         netmask 255.255.255.0  
  40.   
  41.         gateway 192.168.80.1  
  42.   
  43.         dns-nameservers 8.8.8.8  
  44.   
  45. #address 192.168.80.22  
  46.   
  47. #netmask 255.255.255.0  
  48.   
  49. #gateway 192.168.80.1  
  50.   
  51. #dns-nameservers 8.8.8.8  
  52.   
  53.    
  54.   
  55. auto eth1  
  56.   
  57. iface eth1 inet static  
  58.   
  59. address 172.16.0.52  
  60.   
  61. netmask 255.255.0.0  
  62.   
  63.    
  64.   
  65. auto eth2  
  66.   
  67. iface eth2 inet static  
  68.   
  69. address 10.10.10.52  
  70.   
  71. netmask 255.255.255.0  


 

添加源

  • 添加 Grizzly 源,并升级系统

 
 
[delphi] view plain copy
  1. cat > /etc/apt/sources.list.d/grizzly.list << _GEEK_  
  2. deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/grizzly main  
  3. deb  http://ubuntu-cloud.archive.canonical.com/ubuntu precise-proposed/grizzly main  
  4. _GEEK_  
  5. apt-get update  
  6. apt-get upgrade  
  7. apt-get install ubuntu-cloud-keyring  
  • 设置 ntp 和开启路由转发:

 
 
[html] view plain copy
  1. # apt-get install ntp  
  2. # sed -i 's/server ntp.ubuntu.com/server 172.16.0.51/g' /etc/ntp.conf  
  3. # service ntp restart  
  4. # vim /etc/sysctl.conf  
  5. net.ipv4.ip_forward=1  
  6. # sysctl -p  
OpenVSwitch
  • 安装 openVSwitch:

必须按照下面安装顺序:


 
 
[html] view plain copy
  1. apt-get install openvswitch-datapath-source  
  2. module-assistant auto-install openvswitch-datapath  
  3. apt-get install openvswitch-switch openvswitch-brcompat  
设置 ovs-brcompatd 启动:

 
 
[html] view plain copy
  1. sed -i 's/# BRCOMPAT=no/BRCOMPAT=yes/g' /etc/default/openvswitch-switch  
  2. echo 'brcompat' >> /etc/modules  
启动 openvswitch-switch:
[html]  view plain copy
  1. /etc/init.d/openvswitch-switch restart  
  2.  * ovs-brcompatd is not running            # brcompatd 没有启动,尝试再次启动.  
  3.  * ovs-vswitchd is not running  
  4.  * ovsdb-server is not running  
  5.  * Inserting openvswitch module  
  6.  * /etc/openvswitch/conf.db does not exist  
  7.  * Creating empty database /etc/openvswitch/conf.db  
  8.  * Starting ovsdb-server  
  9.  * Configuring Open vSwitch system IDs  
  10.  * Starting ovs-vswitchd  
  11.  * Enabling gre with iptables  

 

 

再次启动,直到 ovs-brcompatdovs-vswitchdovsdb-server等服务都启动:

 
 
[html] view plain copy
  1. # /etc/init.d/openvswitch-switch restart  
  2. # lsmod | grep brcompat  
  3. brcompat               13512  0   
  4. openvswitch            84038  7 brcompat  
如果还是启动不了的话,用下面命令:

 
 
[html] view plain copy
  1. /etc/init.d/openvswitch-switch force-reload-kmod  
创建网桥:

 
 
[html] view plain copy
  1. ovs-vsctl add-br br-int        # br-int 用于 vm 整合  
  2. ovs-vsctl add-br br-ex              # br-ex 用于从互联网上访问 vm  
  3. ovs-vsctl add-port br-ex eth0       # br-ex 桥接到 eth0  
 
  • 重启网卡可能会出现:
[html]  view plain copy
  1.  /etc/init.d/networking restart  
  2.   
  3. RTNETLINK answers: File exists  
  4.   
  5. Failed to bring up br-ex.  


br-ex 可能有 ip 地址,但没有网关和 DNS,需要手工配置一下,或者重启机器. 重启机器后就正常了

  • 查看桥接的网络
[html]  view plain copy
  1. ovs-vsctl list-br  
  2.   
  3. ovs-vsctl show  


Quantum

  • 安装 Quantum openvswitch agent, metadata-agent l3 agent  dhcp agent:

 
 
[html] view plain copy
  1. apt-get install quantum-plugin-openvswitch-agent quantum-dhcp-agent quantum-l3-agent quantum-metadata-agent  
  • 编辑 /etc/quantum/quantum.conf 文件:

 
 
[html] view plain copy
  1. [DEFAULT]  
  2. debug = True  
  3. verbose = True  
  4. state_path = /var/lib/quantum  
  5. lock_path = $state_path/lock  
  6. bind_host = 0.0.0.0  
  7. bind_port = 9696  
  8. core_plugin = quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2  
  9. api_paste_config = /etc/quantum/api-paste.ini  
  10. control_exchange = quantum  
  11. rabbit_host = 172.16.0.51  
  12. rabbit_password = guest  
  13. rabbit_port = 5672  
  14. rabbit_userid = guest  
  15. notification_driver = quantum.openstack.common.notifier.rpc_notifier  
  16. default_notification_level = INFO  
  17. notification_topics = notifications  
  18. [QUOTAS]  
  19. [DEFAULT_SERVICETYPE]  
  20. [AGENT]  
  21. root_helper = sudo quantum-rootwrap /etc/quantum/rootwrap.conf  
  22. [keystone_authtoken]  
  23. auth_host = 172.16.0.51  
  24. auth_port = 35357  
  25. auth_protocol = http  
  26. admin_tenant_name = service  
  27. admin_user = quantum  
  28. admin_password = password  
  29. signing_dir = /var/lib/quantum/keystone-signing  
编辑 OVS 插件配置文件 /etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini:
[html]  view plain copy
  1. [DATABASE]  
  2.   
  3. sql_connection = mysql://quantum:quantum@172.16.0.51/quantum  
  4.   
  5. reconnect_interval = 2  
  6.   
  7. [OVS]  
  8.   
  9. enable_tunneling = True  
  10.   
  11. tenant_network_type = gre  
  12.   
  13. tunnel_id_ranges = 1:1000  
  14.   
  15. local_ip = 10.10.10.52  
  16.   
  17. integration_bridge = br-int  
  18.   
  19. tunnel_bridge = br-tun  
  20.   
  21. [AGENT]  
  22.   
  23. polling_interval = 2  
  24.   
  25. [SECURITYGROUP]  


编辑 /etc/quantum/l3_agent.ini:

[html]  view plain copy
  1. [DEFAULT]  
  2.   
  3. debug = True  
  4.   
  5. verbose = True  
  6.   
  7. use_namespaces = True  
  8.   
  9. external_network_bridge = br-ex  
  10.   
  11. signing_dir = /var/cache/quantum  
  12.   
  13. admin_tenant_name = service  
  14.   
  15. admin_user = quantum  
  16.   
  17. admin_password = password  
  18.   
  19. auth_url = http://172.16.0.51:35357/v2.0  
  20.   
  21. l3_agent_manager = quantum.agent.l3_agent.L3NATAgentWithStateReport  
  22.   
  23. root_helper = sudo quantum-rootwrap /etc/quantum/rootwrap.conf  
  24.   
  25. interface_driver = quantum.agent.linux.interface.OVSInterfaceDriver  
  26.   
  27. enable_multi_host = True  


编辑 /etc/quantum/dhcp_agent.ini:

[html]  view plain copy
  1. [DEFAULT]  
  2.   
  3. debug = True  
  4.   
  5. verbose = True  
  6.   
  7. use_namespaces = True  
  8.   
  9. signing_dir = /var/cache/quantum  
  10.   
  11. admin_tenant_name = service  
  12.   
  13. admin_user = quantum  
  14.   
  15. admin_password = password  
  16.   
  17. auth_url = http://172.16.0.51:35357/v2.0  
  18.   
  19. dhcp_agent_manager = quantum.agent.dhcp_agent.DhcpAgentWithStateReport  
  20.   
  21. root_helper = sudo quantum-rootwrap /etc/quantum/rootwrap.conf  
  22.   
  23. state_path = /var/lib/quantum  
  24.   
  25. interface_driver = quantum.agent.linux.interface.OVSInterfaceDriver  
  26.   
  27. dhcp_driver = quantum.agent.linux.dhcp.Dnsmasq  
  28.   
  29. enable_multi_host = True  
  30.   
  31. enable_isolated_metadata = False  


编辑 /etc/quantum/metadata_agent.ini:

[html]  view plain copy
  1. [DEFAULT]  
  2.   
  3. debug = True  
  4.   
  5. auth_url = http://172.16.0.51:35357/v2.0  
  6.   
  7. auth_region = RegionOne  
  8.   
  9. admin_tenant_name = service  
  10.   
  11. admin_user = quantum  
  12.   
  13. admin_password = password  
  14.   
  15. state_path = /var/lib/quantum  
  16.   
  17. nova_metadata_ip = 172.16.0.51  
  18.   
  19. nova_metadata_port = 8775  


启动 quantum 所有服务:

[html]  view plain copy
  1. service quantum-plugin-openvswitch-agent restart  
  2.   
  3. service quantum-dhcp-agent restart  
  4.   
  5. service quantum-l3-agent restart  
  6.   
  7. service quantum-metadata-agent restart  


Cinder

  • 安装 Cinder 需要的包:

 
 
[html] view plain copy
  1. apt-get install cinder-api cinder-common cinder-scheduler cinder-volume python-cinderclient iscsitarget open-iscsi iscsitarget-dkms  
配置 iscsi 并启动服务:
[html]  view plain copy
  1. sed -i 's/false/true/g' /etc/default/iscsitarget  
  2.   
  3. /etc/init.d/iscsitarget restart  
  4.   
  5. /etc/init.d/open-iscsi restart  


创建 cinder 数据库并授权用户访问:

[html]  view plain copy
  1. mysql -uroot -p  
  2.   
  3. create database cinder;  
  4.   
  5. grant all on cinder.* to 'cinder'@'%' identified by 'cinder';  
  6.   
  7. quit;  


修改 /etc/cinder/cinder.conf:

[html]  view plain copy
  1. cat /etc/cinder/cinder.conf  
  2.   
  3. [DEFAULT]  
  4.   
  5. # LOG/STATE  
  6.   
  7. verbose = True  
  8.   
  9. debug = False  
  10.   
  11. iscsi_helper = ietadm  
  12.   
  13. auth_strategy = keystone  
  14.   
  15. volume_group = cinder-volumes  
  16.   
  17. volume_name_template = volume-%s  
  18.   
  19. state_path = /var/lib/cinder  
  20.   
  21. volumes_dir = /var/lib/cinder/volumes  
  22.   
  23. rootwrap_config = /etc/cinder/rootwrap.conf  
  24.   
  25. api_paste_config = /etc/cinder/api-paste.ini  
  26.   
  27. # RPC  
  28.   
  29. rabbit_host = 172.16.0.51  
  30.   
  31. rabbit_password = guest  
  32.   
  33. rpc_backend = cinder.openstack.common.rpc.impl_kombu  
  34.   
  35. # DATABASE  
  36.   
  37. sql_connection = mysql://cinder:cinder@172.16.0.51/cinder  
  38.   
  39. # API  
  40.   
  41. osapi_volume_extension = cinder.api.contrib.standard_extensions  


修改 /etc/cinder/api-paste.ini 文件末尾 [filter:authtoken] 字段 :

[html]  view plain copy
  1. [filter:authtoken]  
  2.   
  3. paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory  
  4.   
  5. service_protocol = http  
  6.   
  7. service_host = 172.16.0.51  
  8.   
  9. service_port = 5000  
  10.   
  11. auth_host = 172.16.0.51  
  12.   
  13. auth_port = 35357  
  14.   
  15. auth_protocol = http  
  16.   
  17. admin_tenant_name = service  
  18.   
  19. admin_user = cinder  
  20.   
  21. admin_password = password  
  22.   
  23. signing_dir = /var/lib/cinder  


 

  • 创建一个卷组,命名为 cinder-volumes:

   创建一个普通分区,我这里用的sdb,创建了一个主分区,大小为所有空间


 
 
[html] view plain copy
  1. # fdisk /dev/sdb  
  2. n  
  3. p  
  4. 1  
  5. Enter  
  6. Enter  
  7. t  
  8. 8e  
  9. w  
  10. # partx -a /dev/sdb  
  11. # pvcreate /dev/sdb1  
  12. # vgcreate cinder-volumes /dev/sdb1  
  13. # vgs  
  14.   VG             #PV #LV #SN Attr   VSize VFree   
  15.   cinder-volumes   1   7   0 wz--n- 1.64t 75.50g    
 
  • 同步数据库并重启服务:
[html]  view plain copy
  1. cinder-manage db sync  
  2.   
  3. /etc/init.d/cinder-api restart  
  4.   
  5. /etc/init.d/cinder-scheduler restart  
  6.   
  7. /etc/init.d/cinder-volume restart  


最后,我们需要执行:

[html]  view plain copy
  1. /etc/init.d/iscsitarget stop  


具体请看这里

 

Nova

  • 安装 nova-compute:

 
 
[html] view plain copy
  1. apt-get install nova-compute  
/etc/nova/api-paste.ini 中修改 autotoken 验证部分:

 
 
[html] view plain copy
  1. [filter:authtoken]  
  2. paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory  
  3. auth_host = 172.16.0.51  
  4. auth_port = 35357  
  5. auth_protocol = http  
  6. admin_tenant_name = service  
  7. admin_user = nova  
  8. admin_password = password  
  9. signing_dir = /tmp/keystone-signing-nova  
  10. # Workaround for https://bugs.launchpad.net/nova/+bug/1154809  
  11. auth_version = v2.0  
修改 /etc/nova/nova.conf,类似下面这样:

 
 
[html] view plain copy
  1. cat /etc/nova/nova.conf   
  2. [DEFAULT]  
  3. dhcpbridge_flagfile=/etc/nova/nova.conf  
  4. dhcpbridge=/usr/bin/nova-dhcpbridge  
  5. logdir=/var/log/nova  
  6. state_path=/var/lib/nova  
  7. lock_path=/var/lock/nova  
  8. force_dhcp_release=True  
  9. iscsi_helper=tgtadm  
  10. #iscsi_helper = ietadm  
  11. libvirt_use_virtio_for_bridges=True  
  12. connection_type=libvirt  
  13. root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf  
  14. verbose=True  
  15. ec2_private_dns_show_ip=True  
  16. #api_paste_config=/etc/nova/api-paste.ini  
  17. volumes_path=/var/lib/nova/volumes  
  18. enabled_apis=ec2,osapi_compute,metadata  
  19.    
  20. # SCHEDULER  
  21. compute_scheduler_driver = nova.scheduler.filter_scheduler.FilterScheduler  
  22. ## VOLUMES  
  23. volume_api_class = nova.volume.cinder.API  
  24. osapi_volume_listen_port=5900  
  25. iscsi_ip_prefix=192.168.80  
  26. iscsi_ip_address=192.168.80.22  
  27. # DATABASE  
  28. sql_connection = mysql://nova:nova@172.16.0.51/nova  
  29. # COMPUTE  
  30. libvirt_type = kvm  
  31. compute_driver = libvirt.LibvirtDriver  
  32. instance_name_template = instance-%08x  
  33. api_paste_config = /etc/nova/api-paste.ini  
  34. # COMPUTE/APIS: if you have separate configs for separate services  
  35. # this flag is required for both nova-api and nova-compute  
  36. allow_resize_to_same_host = True  
  37. # APIS  
  38. osapi_compute_extension = nova.api.openstack.compute.contrib.standard_extensions  
  39. ec2_dmz_host = 172.16.0.51  
  40. s3_host = 172.16.0.51  
  41. metadata_host=172.16.0.51  
  42. metadata_listen=0.0.0.0  
  43. # RABBITMQ  
  44. rabbit_host = 172.16.0.51  
  45. rabbit_password = guest  
  46. # GLANCE  
  47. image_service = nova.image.glance.GlanceImageService  
  48. glance_api_servers = 172.16.0.51:9292  
  49. # NETWORK  
  50. network_api_class = nova.network.quantumv2.api.API  
  51. quantum_url = http://172.16.0.51:9696  
  52. quantum_auth_strategy = keystone  
  53. quantum_admin_tenant_name = service  
  54. quantum_admin_username = quantum  
  55. quantum_admin_password = password  
  56. quantum_admin_auth_url = http://172.16.0.51:35357/v2.0  
  57. service_quantum_metadata_proxy = True  
  58. libvirt_vif_driver = nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver  
  59. linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver  
  60. firewall_driver = nova.virt.libvirt.firewall.IptablesFirewallDriver  
  61. # NOVNC CONSOLE  
  62. novncproxy_base_url = http://192.168.80.21:6080/vnc_auto.html  
  63. # Change vncserver_proxyclient_address and vncserver_listen to match each compute host  
  64. vncserver_proxyclient_address = 192.168.80.22  
  65. vncserver_listen = 192.168.80.22  
  66. # AUTHENTICATION  
  67. auth_strategy = keystone  
  68. [keystone_authtoken]  
  69. auth_host = 172.16.0.51  
  70. auth_port = 35357  
  71. auth_protocol = http  
  72. admin_tenant_name = service  
  73. admin_user = nova  
  74. admin_password = password  
  75. signing_dir = /tmp/keystone-signing-nova  
启动 nova-compute 服务:
[html]  view plain copy
  1. service nova-compute restart  


检查 nova 相关服务笑脸:

发现 compute 节点已经加入:


 
 
[html] view plain copy
  1. # nova-manage service list  
  2. Binary           Host                                 Zone             Status     State Updated_At  
  3. nova-cert        control                              internal         enabled    :-)   2013-05-07 07:09:56  
  4. nova-conductor   control                              internal         enabled    :-)   2013-05-07 07:09:55  
  5. nova-consoleauth control                              internal         enabled    :-)   2013-05-07 07:09:56  
  6. nova-scheduler   control                              internal         enabled    :-)   2013-05-07 07:09:56  
  7. nova-compute     node-02                              nova             enabled    :-)   2013-05-07 07:10:03  
  8. nova-compute     node-03                              nova             enabled    :-)   2013-05-07 07:10:03  
 

 

到这里,计算节点就成功加入了,我们可以尝试新建节点验证是否成功,具体horizon的使用方法,后面再写文章详细介绍,主要就是网络的创建这块稍微有点复杂,需要稍微注意下!

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值