OpenStack Documentation

Ubuntu-12.04 OpenStack的安装和部署手册

Table 2.1.  OpenStack version names
Release nameRelease dateOpenStack Compute version numberOpenStack Object Storage version number
FolsomSeptember 20122012.21.7.2
EssexApril 20122012.11.4.8
DiabloOctober 20112011.31.4.3
CactusApril 20112011.21.3.0
BexarMarch 20112011.11.2.0
AustinOctober 20100.9.01.0.0
 
 
Code Names
Service nameCode name
IdentityKeystone
ComputeNova
ImageGlance
DashboardHorizon
Object StorageSwift
VolumesCinder
NetworkingQuantum
  
 
 
 
  1. 安装认证服务(keystone)。

  2. 配置认证服务。

  3. 安装镜像服务(Glance)。

  4. 配置镜像服务。

  5. 安装计算节点(nova)。

  6. 配置计算FlatDHCP网络使用192.168.100.0/24作为固定的范围为我们的客户虚拟机上的桥命名BR100

  7. 创建并初始化的nova与MySQL数据库。

  8. 添加Glance。

  9. 安装OpenStack的控制台。

更换ubuntu 默认apt源为 163

 
   
  1. root@ubuntu-ops:~# cat /etc/apt/sources.list 
  2. deb http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse 
  3. deb http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse 
  4. deb http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse 
  5. deb http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse 
  6. deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse 
  7. deb-src http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse 
  8. deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse 
  9. deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse 
  10. deb-src http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse 
  11. deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse 
  12.  
  13. root@ubuntu-ops:~# apt-get update 

配置NTP服务

 
   
  1. root@ubuntu-ops:~# apt-get install ntp 
  2.  
  3. root@ubuntu-ops:~# 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 
  4.  
  5. root@ubuntu-ops:~# /etc/init.d/ntp restart 

client 节点设置ntp服务器

 
   
  1. ntpdate 'controllernode ip' 
  2.  
  3. hwclock -w 

 添加openstack ubuntu 源

 
   
  1. root@ubuntu-ops:~# echo -e "deb http://ppa.launchpad.net/openstack-ubuntu-testing/folsom-trunk-testing/ubuntu precise main \n deb-src http://ppa.launchpad.net/openstack-ubuntu-testing/folsom-trunk-testing/ubuntu precise main" > /etc/apt/sources.list.d/folsom.list  
  2.  
  3. root@ubuntu-ops:~# sudo apt-get install ubuntu-cloud-keyring                        ###安装key 

安装mysql 服务并配置相应的数据库(设置mysql 密码为:ihaveu)

 
   
  1. root@ubuntu-ops:~# apt-get install mysql-server python-mysqldb 
  2.  
  3. sed  -i 's/bind-address.*/bind-address = 0.0.0.0/g' /etc/mysql/my.cnf  
  4.  
  5. service msyql restart 

安装keystone服务

 
   
  1. root@ubuntu-ops:~# apt-get install keystone python-keystone  

创建keystone 数据库

 
   
  1. mysql -u root -p'ihaveu' -e "create database keystone;"     ##本次用户 为root 

修改keystone配置文件 

 
   
  1. admin_token = admin 
  2.  
  3. connection = mysql://root:ihaveu@localhost/keystone   #数据库链接 
  • keystone的默认token是ADMIN,我这里修改admin
  • 默认是采用sqlite连接,我们需要改成mysql

重启keystone服务 

 
   
  1. root@ubuntu-ops:/etc/keystone# service keystone restart 

生成keystone 数据库表

 
   
  1. root@ubuntu-ops:/etc/keystone# keystone-manage db_sync 

添加keystone 环境变量

 
   
  1. root@ubuntu-ops:/etc/keystone# echo -e 'export SERVICE_ENDPOINT="http://192.168.10.23:35357/v2.0"\nexport SERVICE_TOKEN=admin>> /etc/profile 
  2. root@ubuntu-ops:/etc/keystone# source /etc/profile 

 服务管理

身份服务管理的两个主要概念有:

  • 服务

  • 端点

也保持了用户的认证服务,对应于每一个服务(例如,一个用户名为nova,compute)及特别服务tenant,这就是所谓 servie

添加用户 租户 角色 举例说明: 

 
   
  1. 创建用户 acme 
  2.  
  3. root@ubuntu-ops:/home/liming# keystone user-create --name=alice --pass=mypassword123 --email=alice@example.com 
  4.  
  5. 创建一个租户acme 
  6.  
  7. root@ubuntu-ops:/home/liming# keystone tenant-create --name=acme 
  8.  
  9. 创建一个角色  
  10.  
  11. root@ubuntu-ops:/home/liming# keystone role-create --name=compute-user 
  12.  
  13. 添加用户的角色.租户信息 
  14.  
  15. root@ubuntu-ops:/home/liming# keystone user-list 
  16. +----------------------------------+-------+---------+-------------------+ 
  17. | id | name | enabled | email | 
  18. +----------------------------------+-------+---------+-------------------+ 
  19. | 32063772dbea4e92bf800d2bcf6664ff | alice | True | alice@example.com | 
  20. +----------------------------------+-------+---------+-------------------+ 
  21. root@ubuntu-ops:/home/liming# keystone role-list 
  22. +----------------------------------+--------------+ 
  23. | id | name | 
  24. +----------------------------------+--------------+ 
  25. | 1eeab262539f40788fb49bfb49985f73 | compute-user | 
  26. +----------------------------------+--------------+ 
  27. root@ubuntu-ops:/home/liming# keystone tenant-list 
  28. +----------------------------------+------+---------+ 
  29. | id | name | enabled | 
  30. +----------------------------------+------+---------+ 
  31. | aa30c6c4c8e7453689e5ab7a03248121 | acme | True | 
  32. +----------------------------------+------+---------+ 
  33. root@ubuntu-ops:/home/liming# keystone user-role-add --user-id=32063772dbea4e92bf800d2bcf6664ff --role-id 1eeab262539f40788fb49bfb49985f73 --tenant-id=aa30c6c4c8e7453689e5ab7a03248121 

添加用户,角色,租户 用脚本,内容如下:

 
    
  1. #!/bin/bash 
  2. #Auth:Liming 
  3. #Date:2012.10.17 
  4.  
  5. # Tenant User Roles 
  6. ------------------------------------------------------------------ 
  7. # admin admin admin 
  8. # service glance admin 
  9. # service nova admin, [ResellerAdmin (swift only)] 
  10. # service quantum admin # if enabled 
  11. # service swift admin # if enabled 
  12. # demo admin admin 
  13. # demo demo Member, anotherrole 
  14. # invisible_to_admin demo Member 
  15. # Variables set before calling this script: 
  16. # SERVICE_TOKEN - aka admin_token in keystone.conf 
  17. # SERVICE_ENDPOINT - local Keystone admin endpoint 
  18. # SERVICE_TENANT_NAME - name of tenant containing service accounts 
  19. # ENABLED_SERVICES - stack.sh's list of services to start 
  20. # DEVSTACK_DIR - Top-level DevStack directory 
  21.  
  22. KEYSTONE_CONF=${KEYSTONE_CONF:-/etc/keystone/keystone.conf} 
  23. if [[ -r "$KEYSTONE_CONF" ]]; then 
  24. EC2RC="$(dirname "$KEYSTONE_CONF")/ec2rc" 
  25. else 
  26. KEYSTONE_CONF="" 
  27. EC2RC="ec2rc" 
  28. fi 
  29. #Password 
  30. echo "Pleasse input your password:" 
  31. read -p "(Default password: ihaveu ):" DEFAULT_PASSWORD 
  32. if [ "$DEFAULT_PASSWORD" = "" ]; then 
  33. DEFAULT_PASSWORD=ihaveu 
  34. fi 
  35. echo "=================================" 
  36. echo password = "$DEFAULT_PASSWORD" 
  37. echo "=================================" 
  38. ADMIN_PASSWORD=${ADMIN_PASSWORD:-$DEFAULT_PASSWORD} 
  39. echo "Installing ....... 
  40.  
  41. function get_id () { 
  42. echo `"$@" | grep ' id ' | awk '{print $4}'
  43.  
  44. #Tenants 
  45. ADMIN_TENANT=$(get_id keystone tenant-create --name admin) 
  46. SERVICE_TENANT=$(get_id keystone tenant-create --name service) 
  47. DEMO_TENANT=$(get_id keystone tenant-create --name demo) 
  48. INVIS_TENANT=$(get_id keystone tenant-create --name invisible_to_admin) 
  49.  
  50. #Users 
  51. DEMO_USER=$(get_id keystone user-create --name demo --pass $ADMIN_PASSWORD --email admin@example.com) 
  52. ADMIN_USER=$(get_id keystone user-create --name admin --pass $ADMIN_PASSWORD --email admin@ihaveu.net) 
  53. NOVA_USER=$(get_id keystone user-create --name nova --pass $ADMIN_PASSWORD --email nova@ihaveu.net) 
  54. GLANCE_USER=$(get_id keystone user-create --name glance --pass $ADMIN_PASSWORD --email glance@ihaveu.net) 
  55. SWIFT_USER=$(get_id keystone user-create --name swift --pass $ADMIN_PASSWORD --email swift@ihaveu.net) 
  56. QUANTUM_USER=$(get_id keystone user-create --name quantum --pass $ADMIN_PASSWORD --email quantum@ihaveu.net) 
  57.  
  58. #Roles 
  59. ADMIN_ROLE=$(get_id keystone role-create --name admin) 
  60. MEMBER_ROLE=$(get_id keystone role-create --name Member) 
  61. KEYSTONEADMIN_ROLE=$(get_id keystone role-create --name KeystoneAdmin) 
  62. KEYSTONESERVICE_ROLE=$(get_id keystone role-create --name KeystoneServiceAdmin) 
  63. SYSADMIN_ROLE=$(get_id keystone role-create --name sysadmin) 
  64. NETADMIN_ROLE=$(get_id keystone role-create --name netadmin) 
  65.  
  66. # Adding Roles to Users in Tenants 
  67. #keystone user-role-add --user-id $USER_ID --role-id $ROLE_ID --tenant_id $TENANT_ID 
  68. keystone user-role-add --user-id $ADMIN_USER --role-id $ADMIN_ROLE --tenant_id $ADMIN_TENANT 
  69. keystone user-role-add --user-id $ADMIN_USER --role-id $MEMBER_ROLE --tenant_id $ADMIN_TENANT 
  70. keystone user-role-add --user_id $ADMIN_USER --role_id $ADMIN_ROLE --tenant_id $DEMO_TENANT 
  71. keystone user-role-add --user_id $DEMO_USER --role_id $MEMBER_ROLE --tenant_id $DEMO_TENANT 
  72. keystone user-role-add --user_id $DEMO_USER --role_id $SYSADMIN_ROLE --tenant_id $DEMO_TENANT 
  73. keystone user-role-add --user_id $DEMO_USER --role_id $NETADMIN_ROLE --tenant_id $DEMO_TENANT 
  74. keystone user-role-add --user_id $DEMO_USER --role_id $MEMBER_ROLE --tenant_id $INVIS_TENANT 
  75. keystone user-role-add --user-id $NOVA_USER --role_id $ADMIN_ROLE --tenant_id $SERVICE_TENANT 
  76. keystone user-role-add --user_id $GLANCE_USER --role_id $ADMIN_ROLE --tenant_id $SERVICE_TENANT 
  77. keystone user-role-add --user_id $SWIFT_USER --role_id $ADMIN_ROLE --tenant_id $SERVICE_TENANT 
  78.  
  79. keystone user-role-add --user_id $QUANTUM_USER --role_id $ADMIN_ROLE --tenant_id $SERVICE_TENANT 
  80.  
  81. # TODO(termie): these two might be dubious 
  82. keystone user-role-add --user_id $ADMIN_USER --role_id $KEYSTONEADMIN_ROLE --tenant_id $ADMIN_TENANT 
  83. keystone user-role-add --user_id $ADMIN_USER --role_id $KEYSTONESERVICE_ROLE --tenant_id $ADMIN_TENANT 
  84.  
  85. # Creating Services 
  86. #keystone service-create --name service_name --type service_type --description 'Description of the service' 
  87. NOVA_SERVICE=$(get_id keystone service-create --name nova --type compute --description 'OpenStack Compute Service') 
  88. VOLUME_SERVICE=$(get_id keystone service-create --name volume --type volume --description 'OpenStack Volume Service') 
  89. GLANCE_SERVICE=$(get_id keystone service-create --name glance --type p_w_picpath --description 'OpenStack Image Service') 
  90. SWIFT_SERVICE=$(get_id keystone service-create --name swift --type object-store --description 'OpenStack Storage Service') 
  91. KEYSTONE_SERVICE=$(get_id keystone service-create --name keystone --type identity --description 'OpenStack Identity Service') 
  92. EC2_SERVICE=$(get_id keystone service-create --name ec2 --type ec2 --description 'EC2 Compatibility Layer') 
  93. QUANTUM_SERVICE=$(get_id keystone service-create --name quantum --type network --description "Quantum Service") 
  94. keystone service-create --name "horizon" --type dashboard --description "OpenStack Dashboard" 
  95.  
  96. # Creating Endpoints 
  97. #keystone endpoint-create --region region_name --service_id service_id --publicurl public_url --adminurl admin_url --internalurl internal_url 
  98. keystone endpoint-create --region myregion --service_id $NOVA_SERVICE --publicurl 'http://192.168.10.23:8774/v2/$(tenant_id)s' --adminurl 'http://192.168.10.23:8774/v2/$(tenant_id)s' --internalurl 'http://192.168.10.23:8774/v2/$(tenant_id)s' 
  99. keystone endpoint-create --region myregion --service_id $VOLUME_SERVICE --publicurl 'http://192.168.10.23:8776/v1/$(tenant_id)s' --adminurl 'http://192.168.10.23:8776/v1/$(tenant_id)s' --internalurl 'http://192.168.10.23:8776/v1/$(tenant_id)s' 
  100. keystone endpoint-create --region myregion --service_id $GLANCE_SERVICE --publicurl 'http://192.168.10.23:9292/v1' --adminurl 'http://192.168.10.23:9292/v1' --internalurl 'http://192.168.10.23:9292/v1' 
  101. keystone endpoint-create --region myregion --service_id $SWIFT_SERVICE --publicurl 'http://192.168.10.23:8080/v1/AUTH_$(tenant_id)s' --adminurl 'http://192.168.10.23:8080/v1' --internalurl 'http://192.168.10.23:8080/v1/AUTH_$(tenant_id)s' 
  102. keystone endpoint-create --region myregion --service_id $KEYSTONE_SERVICE --publicurl 'http://192.168.10.23:5000/v2.0' --adminurl 'http://192.168.10.23:35357/v2.0' --internalurl 'http://192.168.10.23:5000/v2.0' 
  103. keystone endpoint-create --region myregion --service_id $EC2_SERVICE --publicurl 'http://192.168.10.23:8773/services/Cloud' --adminurl 'http://192.168.10.23:8773/services/Admin' --internalurl 'http://192.168.10.23:8773/services/Cloud' 
  104. keystone endpoint-create --region myregion --service_id $QUANTUM_SERVICE --publicurl 'http://192.168.10.23:9696' --adminurl 'http://192.168.10.23:9696' --internalurl 'http://192.168.10.23:9696' 
  105.  
  106.  
  107. create ec2 creds and parse the secret and access key returned 
  108. RESULT=$(keystone ec2-credentials-create --tenant_id=$ADMIN_TENANT --user_id=$ADMIN_USER) 
  109. ADMIN_ACCESS=`echo "$RESULT" | grep access | awk '{print $4}'
  110.  
  111. ADMIN_SECRET=`echo "$RESULT" | grep secret | awk '{print $4}'
  112.  
  113. RESULT=$(keystone ec2-credentials-create --tenant_id=$DEMO_TENANT --user_id=$DEMO_USER) 
  114. DEMO_ACCESS=`echo "$RESULT" | grep access | awk '{print $4}'
  115. DEMO_SECRET=`echo "$RESULT" | grep secret | awk '{print $4}'
  116.  
  117. # write the secret and access to ec2rc 
  118. cat > $EC2RC <<EOF 
  119. ADMIN_ACCESS=$ADMIN_ACCESS 
  120. ADMIN_SECRET=$ADMIN_SECRET 
  121. DEMO_ACCESS=$DEMO_ACCESS 
  122. DEMO_SECRET=$DEMO_SECRET 
  123. EOF 
  124. echo "" 
  125. echo "user tenants role has been created !" 
  注:自己安装的时候,先修改下自己的ip~ 有的server 也许会报错,需要适当修改  适当对比/usr/share/keystone/sample_data.sh 或者直接修改也是可以.
在/etc/profile中添加如下 
 
    
  1. export OS_USERNAME=admin 
  2. export OS_PASSWORD=ihaveu 
  3. export OS_TENANT_NAME=admin 
  4. export OS_AUTH_URL="http://192.168.10.23:35357/v2.0" 
  5.  
  6. source /etc/profile  

安装OpenStack Compute and Image service

安装glance 服务

 
   
  1. root@ubuntu-ops:~# sudo apt-get install glance glance-api glance-common python-glanceclient glance-registry python-glance 

删除glance sqlite数据库,并修改glance 连接到mysql数据库

 
   
  1. root@ubuntu-ops:~# rm -rf /var/lib/glance/glance.sqlite  

创建glance 数据库

 
   
  1. mysql -u root -p ihaveu -e "create database glance;" 

修改glance配置

在/etc/glance/glance-api-paste.ini 配置 [filter:authtoken]

 
   
  1. admin_tenant_name = service 
  2. admin_user = glance 
  3. admin_password = ihaveu 

修改 glance-api.conf 如下

 
   
  1. [keystone_authtoken] 
  2. auth_host = 192.168.10.23 
  3. auth_port = 35357 
  4. auth_protocol = http 
  5. admin_tenant_name = service 
  6. admin_user = glance 
  7. admin_password = ihaveu 
  8.  
  9. [paste_deploy] 
  10. config_file = /etc/glance/glance-api-paste.ini 
  11. flavor=keystone 

修改数据库连接 /etc/glance/glance-registry.conf,如下

 
   
  1. sql_connection = mysql://root:ihaveu@localhost/glance 
  2. [keystone_authtoken] 
  3. auth_host = 192.168.10.23 
  4. auth_port = 35357 
  5. auth_protocol = http 
  6. admin_tenant_name = service 
  7. admin_user = glance 
  8. admin_password = ihaveu 
  9.  
  10. [paste_deploy] 
  11. config_file = /etc/glance/glance-registry-paste.ini 
  12. flavor=keystone 

重启glance-registry 使配置生效

 
   
  1. root@ubuntu-ops:/etc/glance# service glance-registry restart 

同步glance 数据库

 
   
  1. root@ubuntu-ops:/etc/glance# glance-manage version_control 0 
  2. root@ubuntu-ops:/etc/glance# glance-manage db_sync 
  3. /usr/lib/python2.7/dist-packages/glance/db/sqlalchemy/migrate_repo/versions/003_add_disk_format.py:46: SADeprecationWarning: useexisting is deprecated. Use extend_existing.useexisting=True
  4.  
  5.   

重启 glance-registry and glance-api 服务

 
   
  1. root@ubuntu-ops:/etc/glance# service glance-registry restart && service glance-api restart 

验证glance 之一:

root@ubuntu-ops:/etc/glance# glance index
ID Name Disk Format Container Format Size 
------------------------------------ ------------------------------ -------------------- -------------------- --------------

看到这里..glance 已经安装完毕了! 继续 ....

如有问题看日志

/var/log/glance/api.log    or  /var/log/glance/registry.log

验证glance之二:

root@ubuntu-ops:/etc/glance# mkdir /tmp/p_w_picpath
root@ubuntu-ops:/etc/glance# cd /tmp/p_w_picpath
root@ubuntu-ops:/tmp/p_w_picpath# wget http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-12.1_2.6.35-22_1.tar.gz^C
root@ubuntu-ops:/tmp/p_w_picpath# tar -zxvf ttylinux-uec-amd64-12.1_2.6.35-22_1.tar.gz ^C
root@ubuntu-ops:/tmp/p_w_picpath# cp /home/liming/ubuntu-12.04-server-cloudimg-amd64-disk1.img ./

root@ubuntu-ops:/tmp/p_w_picpath# glance add name="Ubuntu-12.04" disk_format=qcow2 container_format=ovf is_public=true < ubuntu-12.04-server-cloudimg-amd64-disk1.img 
Added new p_w_picpath with ID: 708a1732-a191-4595-8488-9ba8d5149ce0               ##added new 表示添加完成

root@ubuntu-ops:/tmp/p_w_picpath# glance index
ID Name Disk Format Container Format Size 
------------------------------------ ------------------------------ -------------------- -------------------- --------------
708a1732-a191-4595-8488-9ba8d5149ce0 Ubuntu-12.04 qcow2 ovf 230490112
root@ubuntu-ops:/tmp/p_w_picpath# du -sh 
220M .

这样看到的话表示glance完全没有问题

配置虚拟机管理程序KVM

root@ubuntu-ops:/tmp/p_w_picpath# sudo apt-get install -y bridge-utils kvm

测试KVM 

 
   
  1. root@ubuntu-ops:/etc/nova# kvm-ok 
  2.  
  3. INFO: /dev/kvm exists 
  4. KVM acceleration can be used 
如果KVM不存在,显示如下
 
   
  1. INFO: Your CPU does not support KVM extensions 
  2. KVM acceleration can NOT be used 

如果出现以上不支持,看看bios是否开启VT,cpu支持不支持vmx,如果是amd CPU 是否支持svm ,可以用以下命令查看

 
   
  1. root@ubuntu-ops:/etc/nova# egrep '(vmx|svm)' --color=always /proc/cpuinfo 

如若为空.表示都不支持..so 我的机器就不支持.现在只有通过qemu 或者 xen 去使用了

配置网卡信息

 
   
  1. root@ubuntu-ops:/tmp/p_w_picpath# cat /etc/network/interfaces  
  2.  
  3. auto lo 
  4.  
  5. iface lo inet loopback 
  6.  
  7. # The primary network interface 
  8. auto eth1 
  9. iface eth1 inet static 
  10. address 192.168.10.23 
  11. netmask 255.255.255.0 
  12. broadcast 192.168.10.255 
  13. gateway 192.168.10.1 
  14. dns-nameserver 8.8.8.8 
  15.  
  16. auto eth0 
  17. iface eth0 inet static 
  18. address 10.10.10.2 
  19. netmask 255.255.255.0 
  20. network 10.10.10.0 
  21. broadcast 10.10.10.255 
  22.  
  23. auto br100 
  24. iface br100 inet static 
  25. address 192.168.100.1 
  26. netmask 255.255.255.0 
  27. bridge_stp off 
  28. bridge_fd 0 

重启网卡

 
   
  1. root@ubuntu-ops:/tmp/p_w_picpath# /etc/init.d/networking restart 

设置桥接网卡,在nova.conf中设置flat_network_bridge=br100 

root@ubuntu-ops:/etc/nova# brctl addbr br100

root@ubuntu-ops:/etc/nova# brctl show   #查看桥接网卡

创建nova创建库

 
   
  1. root@ubuntu-ops:~# mysql -uroot -pihaveu -e "create database nova;" 

安装消息队列服务

 
   
  1. root@ubuntu-ops:~# sudo apt-get install -y rabbitmq-server 

安装nova 服务

 
   
  1. root@ubuntu-ops:~# sudo apt-get install -y nova-compute nova-volume nova-novncproxy novnc nova-api nova-ajax-console-proxy nova-cert nova-consoleauth nova-doc nova-scheduler nova-network 

 修改nova.conf配置如下

root@ubuntu-ops:/etc/nova# cat nova.conf

 
   
  1. [DEFAULT] 
  2.  
  3. # LOGS/STATE 
  4. verbose=True 
  5. logdir=/var/log/nova 
  6. state_path=/var/lib/nova 
  7. lock_path=/var/lock/nova 
  8.  
  9. # AUTHENTICATION 
  10. auth_strategy=keystone 
  11.  
  12. # SCHEDULER 
  13. compute_scheduler_driver=nova.scheduler.filter_scheduler.FilterScheduler 
  14.  
  15. # VOLUMES 
  16. volume_driver=nova.volume.driver.ISCSIDriver 
  17. volume_group=nova-volumes 
  18. volume_name_template=volume-%08x 
  19. iscsi_helper=tgtadm 
  20. iscsi_ip_prefix=192.168.10.23 
  21. iscsi_ip_address=192.168.10.23 
  22. iscsi_port=3260 
  23.  
  24. # DATABASE 
  25. sql_connection=mysql://root:ihaveu@localhost/nova 
  26.  
  27. # COMPUTE 
  28. connection_type=libvirt 
  29. libvirt_type=qemu 
  30. compute_driver=libvirt.LibvirtDriver 
  31. instance_name_template=instance-%08x 
  32. api_paste_config=/etc/nova/api-paste.ini 
  33. allow_resize_to_same_host=True 
  34.  
  35. # APIS 
  36. osapi_compute_extension=nova.api.openstack.compute.contrib.standard_extensions 
  37. ec2_dmz_host=192.168.10.23 
  38. s3_host=192.168.10.23 
  39.  
  40. # RABBITMQ 
  41.  
  42. rabbit_host=192.168.10.23 
  43.  
  44. # GLANCE 
  45. p_w_picpath_service=nova.p_w_picpath.glance.GlanceImageService 
  46. glance_api_servers=192.168.10.23:9292 
  47.  
  48. # NETWORK 
  49. network_manager=nova.network.manager.FlatDHCPManager 
  50. force_dhcp_release=True 
  51. dhcpbridge_flagfile=/etc/nova/nova.conf 
  52. firewall_driver=nova.virt.libvirt.firewall.IptablesFirewallDriver 
  53. # Change my_ip to match each host 
  54. my_ip=192.168.10.23 
  55. public_interface=br100 
  56. vlan_interface=eth1 
  57. flat_network_bridge=br100 
  58. flat_interface=eth1 
  59. fixed_range=192.168.100.0/24 
  60.  
  61. # NOVNC CONSOLE 
  62. novncproxy_base_url=http://192.168.10.23:6080/vnc_auto.html 
  63. # Change vncserver_proxyclient_address and vncserver_listen to match each compute host 
  64. vncserver_proxyclient_address=192.168.10.23 
  65. vncserver_listen=192.168.10.23 
  66.  
  67. [keystone_authtoken] 
  68. auth_host = 192.168.10.23 
  69. auth_port = 35357 
  70. auth_protocol = http 
  71. auth_uri = http://192.168.10.23:5000/ 
  72. admin_tenant_name = service 
  73. admin_user = nova 
  74. admin_password = ihaveu 

修改nova-compute.conf 为qemu (因为kvm不能用)

 
   
  1. [DEFAULT] 
  2. libvirt_type=qemu 

修改api-paste.ini 如下:

 
   
  1. [filter:authtoken] 
  2. paste.filter_factory = keystone.middleware.auth_token:filter_factory 
  3. auth_host = 192.168.10.23 
  4. auth_port = 35357 
  5. auth_protocol = http 
  6. admin_tenant_name = service 
  7. admin_user = nova 
  8. admin_password = ihaveu 
  9. signing_dirname = /tmp/keystone-signing-nova 

创建nova数据表 

 
   
  1. root@ubuntu-ops:/etc/nova# sudo nova-manage db sync 
  2. 2012-10-22 11:21:07 DEBUG nova.utils [-] backend <module 'nova.db.sqlalchemy.migration' from '/usr/lib/python2.7/dist-packages/nova/db/sqlalchemy/migration.pyc'> from (pid=29622) __get_backend /usr/lib/python2.7/dist-packages/nova/utils.py:494 

以上出来的是DEBUG ,可以忽略

如果看到不成功的日志,可以去看/var/log/nova/ nova-manange.log 去排除错误,如果出现以上debug 表示已经创建成功

创建nova-volumes 卷组

 
   
  1. root@ubuntu-ops:~# sudo pvcreate /dev/sdb 
  2. Physical volume "/dev/sdb" successfully created 
  3. root@ubuntu-ops:~# sudo vgcreate nova-volumes /dev/sdb 
  4. Volume group "nova-volumes" successfully created 

启动 nova 服务:

 
   
  1. cd /etc/init.d/; for i in $( ls nova-* ); do sudo service $i restart; done 

创建虚拟机网络ip

 
   
  1. nova-manage network create private --fixed_range_v4=192.168.100.1/24 --num_networks=1 --bridge=br100 --bridge_interface=eth0 --network_size=32 

       or

 
   
  1. nova-manage network create private --multi_host=T --fixed_range_v4=192.168.100.0/24 --bridge_interface=br100 --num_networks=1 --network_size=256 

验证nova服务

 
   
  1. root@ubuntu-ops:~# nova-manage service list 
  2.  
  3. Binary Host Zone Status State Updated_At 
  4.  
  5. nova-consoleauth ubuntu-ops nova enabled :-) 2012-10-22 10:37:01 
  6.  
  7. nova-cert ubuntu-ops nova enabled :-) 2012-10-22 10:37:01 
  8.  
  9. nova-scheduler ubuntu-ops nova enabled :-) 2012-10-22 10:37:03 
  10.  
  11. nova-compute ubuntu-ops nova enabled :-) 2012-10-22 10:37:05 
  12.  
  13. nova-network ubuntu-ops nova enabled :-) 2012-10-22 10:36:58 
  14.  
  15. nova-volume ubuntu-ops nova enabled :-) 2012-10-22 10:37:02 

如果返回的全是笑脸 证明安装没有问题,如果出现三个X  则表明某个服务没有安装成功 ,如果你安装的服务不在同一台机器上,在另一台机器上服务开启的,但是没有同步过来.你需要看下ntp服务器设置

可以用nova-manage 命令查看到你安装的版本为Folsom

 
   
  1. root@ubuntu-ops:~# nova-manage version list 
  2.  
  3. 2012.2 (2012.2-LOCALBRANCH:LOCALREVISION) 
  4.  
  5. root@ubuntu-ops:~# nova p_w_picpath-list                                    #ihaveu 
  6. Please set a password for your new keyring 
  7. Password (again):  
  8. Error: Your passwords didn't match 
  9. Please set a password for your new keyring 
  10. Password (again):  
  11. Please input your password for the keyring 
  12. +--------------------------------------+--------------+--------+--------+ 
  13. | ID | Name | Status | Server | 
  14. +--------------------------------------+--------------+--------+--------+ 
  15. | 708a1732-a191-4595-8488-9ba8d5149ce0 | Ubuntu-12.04 | ACTIVE | | 
  16. +--------------------------------------+--------------+--------+--------+ 

注册虚拟机:

列出nova secgroup 组

 
   
  1. root@ubuntu-ops:~# nova secgroup-list 
  2. Please input your password for the keyring                   #这里要输入你nova p_w_picpath-list设置的密码 
  3. +---------+-------------+ 
  4. | Name | Description | 
  5. +---------+-------------+ 
  6. | default | default | 
  7. +---------+-------------+ 

 创建允许所有22端口出去的规则

 
   
  1. root@ubuntu-ops:~# nova secgroup-add-rule default tcp 22 22 0.0.0.0/0 
  2. Please input your password for the keyring 
  3. +-------------+-----------+---------+-----------+--------------+ 
  4. | IP Protocol | From Port | To Port | IP Range | Source Group | 
  5. +-------------+-----------+---------+-----------+--------------+ 
  6. | tcp | 22 | 22 | 0.0.0.0/0 | | 
  7. +-------------+-----------+---------+-----------+--------------+ 

允许icmp ping 

 
   
  1. root@ubuntu-ops:~# nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 
  2. Please input your password for the keyring 
  3. +-------------+-----------+---------+-----------+--------------+ 
  4. | IP Protocol | From Port | To Port | IP Range | Source Group | 
  5. +-------------+-----------+---------+-----------+--------------+ 
  6. | icmp | -1 | -1 | 0.0.0.0/0 | | 
  7. +-------------+-----------+---------+-----------+--------------+ 

创建密钥对

root@ubuntu-ops:~# ssh-keygen  (一路回车)
 
添加一个密钥到nova
 
    
  1. root@ubuntu-ops:~# nova keypair-add --pub_key ~/.ssh/id_rsa.pub mykey 
  2. Please input your password for the keyring 
  3. root@ubuntu-ops:~# nova keypair-list                  #列出密钥 
  4. Please input your password for the keyring 
  5. +-------+-------------------------------------------------+ 
  6. | Name | Fingerprint | 
  7. +-------+-------------------------------------------------+ 
  8. | mykey | 4d:c9:a5:ba:43:6f:dc:c0:a6:d0:21:e6:82:ac:8b:4c | 
  9. +-------+-------------------------------------------------+ 

 启动一个实例

列出现有的模板类型

 
   
  1. root@ubuntu-ops:~# nova flavor-list 
  2.  
  3. +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+ 
  4. | ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs | 
  5. +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+ 
  6. | 1 | m1.tiny | 512 | 0 | 0 | | 1 | 1.0 | True | {} | 
  7. | 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | True | {} | 
  8. | 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True | {} | 
  9. | 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | True | {} | 
  10. | 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True | {} | 
  11. +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+ 

列出现有的镜像文件

 
   
  1. root@ubuntu-ops:~# nova p_w_picpath-list 
  2. Please input your password for the keyring 
  3. \+--------------------------------------+--------------+--------+--------+ 
  4. | ID | Name | Status | Server | 
  5. +--------------------------------------+--------------+--------+--------+ 
  6. | 708a1732-a191-4595-8488-9ba8d5149ce0 | Ubuntu-12.04 | ACTIVE | | 
  7. +--------------------------------------+--------------+--------+--------+ 

使用nova 创建地一个虚拟机

 
   
  1. root@ubuntu-ops:~# nova boot --flavor 1 --p_w_picpath 708a1732-a191-4595-8488-9ba8d5149ce0 --key_name mykey --security_group default ihaveu 
  2. Please input your password for the keyring 
  3. +-------------------------------------+----------------------------------------------------------+ 
  4. | Property | Value | 
  5. +-------------------------------------+----------------------------------------------------------+ 
  6. | OS-DCF:diskConfig | MANUAL | 
  7. | OS-EXT-SRV-ATTR:host | ubuntu-ops | 
  8. | OS-EXT-SRV-ATTR:hypervisor_hostname | ubuntu-ops | 
  9. | OS-EXT-SRV-ATTR:instance_name | instance-00000001 | 
  10. | OS-EXT-STS:power_state | 0 | 
  11. | OS-EXT-STS:task_state | scheduling | 
  12. | OS-EXT-STS:vm_state | building | 
  13. | accessIPv4 | | 
  14. | accessIPv6 | | 
  15. | adminPass | 8FxmnesjB7Fn | 
  16. | config_drive | | 
  17. | created | 2012-10-22T11:27:21Z | 
  18. | flavor | m1.tiny | 
  19. | hostId | ff32bc3f07c7bbd0b06c65436aaa13150d3cb2be04acf05e628d80fa | 
  20. | id | 618cbea9-79cf-438a-aded-dcb6ecf633b0 | 
  21. | p_w_picpath | Ubuntu-12.04 | 
  22. | key_name | mykey | 
  23. | metadata | {} | 
  24. | name | ihaveu | 
  25. | progress | 0 | 
  26. | security_groups | [{u'name': u'default'}] | 
  27. | status | BUILD | 
  28. | tenant_id | b739aa09ec3f4691afb34462d8f1da8d | 
  29. | updated | 2012-10-22T11:27:22Z | 
  30. | user_id | 2a8dea4d0b694079ba06b6a123e38e5b | 
  31. +-------------------------------------+----------------------------------------------------------+ 
  32.  
  33.   

 安装OpenStack的控制台 Dashboard

下面是创建OpenStack的dashboard的所有步骤。

安装OpenStack的dashboard框架,包括Apache和相关模块。。

 
   
  1. root@ubuntu-ops:~# apt-get install -y memcached libapache2-mod-wsgi openstack-dashboard 

修改dashboard 配置文件

在TEMPLATE_DEBUG = DEBUG 下添加

QUANTUM_ENABLED = False

设置dashboard 数据库为mysql

创建dashboard数据库

 
   
  1. root@ubuntu-ops:~# mysql -uroot -pihaveu -e "create database horizon;" 

 修改dashboard 数据库为mysql 

 
   
  1. DATABASES = { 
  2. 'default': { 
  3. 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 
  4. 'NAME': 'horizon', # Or path to database file if using sqlite3. 
  5. 'USER': 'root', # Not used with sqlite3. 
  6. 'PASSWORD': 'ihaveu', # Not used with sqlite3. 
  7. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 
  8. 'PORT': '', # Set to empty string for default. Not used with sqlite3. 

 重启apache2服务 和memached服务

 
   
  1. root@ubuntu-ops:~# sudo service apache2 restart; sudo service memcached restart 

 访问openstack dashboard 

http://192.168.10.23/horizon

 

用户名admin 密码是创建admin的时候的密码

不知道是我虚拟机的问题 还是版本的问题.我登录进去跟essex 版本的页面有些不同

 

这算是在虚拟机上安装完毕了~等下会找PC机 安装创建一些实例,把qemu都换成kvm 

一路摸索而来~

error 1 :

2012-10-22 16:25:14 CRITICAL nova [-] Unexpected error while running command.
Command: sudo iptables-save -c -t filter
Exit code: 1
Stdout: ''
Stderr: 'sudo: no tty present and no askpass program specified\nSorry, try again.\nsudo: no tty present and no askpass program specified\nSorry, try again.\nsudo: no tty present and no askpass program specified\nSorry, try again.\nsudo: 3 incorrect password attempts\n'
2012-10-22 16:25:14 TRACE nova Traceback (most recent call last):
2012-10-22 16:25:14 TRACE nova File "/usr/bin/nova-network", line 48, in <module>
2012-10-22 16:25:14 TRACE nova service.wait()
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/nova/service.py", line 659, in wait
2012-10-22 16:25:14 TRACE nova _launcher.wait()
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/nova/service.py", line 192, in wait
2012-10-22 16:25:14 TRACE nova super(ServiceLauncher, self).wait()
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/nova/service.py", line 162, in wait
2012-10-22 16:25:14 TRACE nova service.wait()
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/eventlet/greenthread.py", line 166, in wait
2012-10-22 16:25:14 TRACE nova return self._exit_event.wait()
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/eventlet/event.py", line 116, in wait
2012-10-22 16:25:14 TRACE nova return hubs.get_hub().switch()
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/eventlet/hubs/hub.py", line 177, in switch
2012-10-22 16:25:14 TRACE nova return self.greenlet.switch()
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/eventlet/greenthread.py", line 192, in main
2012-10-22 16:25:14 TRACE nova result = function(*args, **kwargs)
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/nova/service.py", line 132, in run_server
2012-10-22 16:25:14 TRACE nova server.start()
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/nova/service.py", line 398, in start
2012-10-22 16:25:14 TRACE nova self.manager.init_host()
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/nova/network/manager.py", line 1899, in init_host
2012-10-22 16:25:14 TRACE nova self.l3driver.initialize()
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/nova/network/l3.py", line 82, in initialize
2012-10-22 16:25:14 TRACE nova linux_net.init_host()
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/nova/network/linux_net.py", line 552, in init_host
2012-10-22 16:25:14 TRACE nova add_snat_rule(ip_range)
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/nova/network/linux_net.py", line 542, in add_snat_rule
2012-10-22 16:25:14 TRACE nova iptables_manager.apply()
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/nova/network/linux_net.py", line 345, in apply
2012-10-22 16:25:14 TRACE nova self._apply()
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/nova/utils.py", line 744, in inner
2012-10-22 16:25:14 TRACE nova retval = f(*args, **kwargs)
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/nova/network/linux_net.py", line 365, in _apply
2012-10-22 16:25:14 TRACE nova attempts=5)
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/nova/network/linux_net.py", line 948, in _execute
2012-10-22 16:25:14 TRACE nova return utils.execute(*cmd, **kwargs)
2012-10-22 16:25:14 TRACE nova File "/usr/lib/python2.7/dist-packages/nova/utils.py", line 198, in execute
2012-10-22 16:25:14 TRACE nova cmd=' '.join(cmd))
2012-10-22 16:25:14 TRACE nova ProcessExecutionError: Unexpected error while running command.
2012-10-22 16:25:14 TRACE nova Command: sudo iptables-save -c -t filter
2012-10-22 16:25:14 TRACE nova Exit code: 1
2012-10-22 16:25:14 TRACE nova Stdout: ''
2012-10-22 16:25:14 TRACE nova Stderr: 'sudo: no tty present and no askpass program specified\nSorry, try again.\nsudo: no tty present and no askpass program specified\nSorry, try again.\nsudo: no tty present and no askpass program specified\nSorry, try again.\nsudo: 3 incorrect password attempts\n'
2012-10-22 16:25:14 TRACE nova 

解决办法:

是由于nova用户没办法sudo过去,so 在/etc/sudoers 中添加

nova ALL=(ALL) NOPASSWD:ALL

 本文参考:http://docs.openstack.org/trunk/openstack-compute/install/apt/content/