使用devstack 安装openstack
这篇文章写给初学者,如何buid 一个openstack 的环境,然后学习openstack,使用devstack 来安装openstack 是最简易快捷的方式了.
?
devstack 的官方网站:
http://devstack.org/
?
?
下面开始我们的openstack 体验之旅:
?
1. 准备 ubuntu-12.04 OS:
?
?? 我自己的desktop 上安装了 virtual box, 就用它虚拟一个 VM吧
?? a. 下载 ubuntu-12.04.1-alternate-amd64.iso http://releases.ubuntu.com/12.04/
?? b. 安装 ubuntu OS, 很简单的 就不赘述了
?
?
2. 设置 root 口令:
?
?
要先打开终端,?执行:sudo passwd -u rootADMIN_PASSWORD=novaMYSQL_PASSWORD=novaRABBIT_PASSWORD=novaSERVICE_PASSWORD=novaSERVICE_TOKEN=tokentokenFLAT_INTERFACE=br100???? d. source localrc
? ? e. ./stack.sh?? 开始按住了, 需要20+多分钟
9. 用openstack 创建一个vm
? a. 先创建一个flavor , 之所以创建一个新的flavor, 而不用已经存在的,是因为我想让vm 有256m 内存, ???? default 的几个flavor 最小的mem size 也是512m?
?? root@mystack:/opt/devstack# nova flavor-create xpp.test 6 256 0 1
+----+----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| ID | Name???? | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs |
+----+----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| 6? | xpp.test | 256?????? | 0??? | 0???????? |????? | 1???? | 1.0???????? | True????? | {}????????? |
+----+----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
root@mystack:/opt/devstack#
?b. boot instance
root@mystack:/opt/devstack# nova boot --flavor 6? --image cirros-0.3.0-x86_64-uec xhuvm1
+-------------------------------------+--------------------------------------+
| Property??????????????????????????? | Value??????????????????????????????? |
+-------------------------------------+--------------------------------------+
| OS-DCF:diskConfig?????????????????? | MANUAL?????????????????????????????? |
| OS-EXT-SRV-ATTR:host??????????????? | None???????????????????????????????? |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None???????????????????????????????? |
| OS-EXT-SRV-ATTR:instance_name?????? | instance-00000001??????????????????? |
| OS-EXT-STS:power_state????????????? | 0??????????????????????????????????? |
| OS-EXT-STS:task_state?????????????? | scheduling?????????????????????????? |
| OS-EXT-STS:vm_state???????????????? | building???????????????????????????? |
| accessIPv4????????????????????????? |????????????????????????????????????? |
| accessIPv6????????????????????????? |????????????????????????????????????? |
| adminPass?????????????????????????? | kfPJ4aYThBw6???????????????????????? |
| config_drive??????????????????????? |????????????????????????????????????? |
| created???????????????????????????? | 2012-12-31T13:45:32Z???????????????? |
| flavor????????????????????????????? | xpp.test???????????????????????????? |
| hostId????????????????????????????? |????????????????????????????????????? |
| id????????????????????????????????? | 88013d9e-20b3-41d7-a699-f1752af91755 |
| image?????????????????????????????? | cirros-0.3.0-x86_64-uec????????????? |
| key_name??????????????????????????? | None???????????????????????????????? |
| metadata??????????????????????????? | {}?????????????????????????????????? |
| name??????????????????????????????? | xhuvm1?????????????????????????????? |
| progress??????????????????????????? | 0??????????????????????????????????? |
| security_groups???????????????????? | [{u'name': u'default'}]????????????? |
| status????????????????????????????? | BUILD??????????????????????????????? |
| tenant_id?????????????????????????? | 42109310396440339051a0e7cb064bc9???? |
| updated???????????????????????????? | 2012-12-31T13:45:33Z???????????????? |
| user_id???????????????????????????? | 17150c9b069042dbbffc75ce02422874???? |
+-------------------------------------+--------------------------------------+
root@mystack:/opt/devstack#
c. check vm status
root@mystack:/opt/devstack# nova list
+--------------------------------------+--------+--------+------------------+
| ID?????????????????????????????????? | Name?? | Status | Networks???????? |
+--------------------------------------+--------+--------+------------------+
| 88013d9e-20b3-41d7-a699-f1752af91755 | xhuvm1 | ACTIVE | private=10.0.0.2 |
+--------------------------------------+--------+--------+------------------+
root@mystack:/opt/devstack#
10. 登陆 openstack dashbord?, 看看我们刚才创建的 vm(xhumv1) 在不在
http://192.168.1.102/admin/nova
10. 登陆 MySQL
?mysql -uroot -pnova
备忘:
1.? 安装 openstack的 vm 重启后, 所有的openstack sevice 不会重新启动, 需要手动run stack.sh, 但是这样,相当与重新初始化了环境,以前创建的instance 会不见了,数据库的数据也会刷新
2.? 国外有个哥们写了一个 restart openstak 的shell, 可以解决这个问题, 详见:http://www.scalegrid.net/blog/?p=52
我休改了2行, 主要是新版本的 openstack 多了一个service 名字是 nova-conductor, 他的脚本太老,没有handle 这个case.
3. 重启service 步骤:
? a. run? screen -list ,? kill -9 杀死所有的 screen session
? b. run restart_stack.sh
? c. check all services
root@mystack:/opt/devstack# nova-manage service list
Binary?????????? Host???????????????????????????????? Zone???????????? Status???? State Updated_At
nova-conductor?? mystack????????????????????????????? nova???????????? enabled??? :-)?? 2012-12-31 14:01:27
nova-cert??????? mystack????????????????????????????? nova???????????? enabled??? :-)?? 2012-12-31 14:01:27
nova-compute???? mystack????????????????????????????? nova???????????? enabled??? :-)?? 2012-12-31 14:01:27
nova-scheduler?? mystack????????????????????????????? nova???????????? enabled??? :-)?? 2012-12-31 14:01:26
nova-consoleauth mystack????????????????????????????? nova???????????? enabled??? :-)?? 2012-12-31 14:01:27
nova-network???? mystack????????????????????????????? nova???????????? enabled??? :-)?? 2012-12-31 14:01:26
4.? all services 的日志配置??? a. 创建日志目录:mkdir -p /var/log/nova??? b. 在/etc/nova/nova.conf 加上 “ logdir=/var/log/nova”??? c. 重启service
遗留的问题:
run restart_stack.sh重启了 service 以后, dashboard 不能登陆, 不过CLI 都能工作,其实我基本也不用dashboard.