首页 > 代码库 > 学习OpenStack之 (1):安装devstack

学习OpenStack之 (1):安装devstack

1. 系统准备

ubuntu 12.04 server 虚拟机。 2G内存。

依次运行以下命令来安装git:

  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo apt-get install git

2. 下载安装包

$git clone https://github.com/openstack-dev/devstack.git  #克隆devstack的Git代码仓库
 
3. 配置
 
从2013/10起OpenStack引入新的配置方式即使用配置文件 local.conf。从官方网站看这个文件应该存在于devstack目录中,找了后发现在samples目录中。 创建 local.conf包含下面内容:
[[local|localrc]]ADMIN_PASSWORD=secrete #Admin密码DATABASE_PASSWORD=$ADMIN_PASSWORD //预设密码,这样在运行stack.sh的时候就不会要求输入密码RABBIT_PASSWORD=$ADMIN_PASSWORD //同上SERVICE_PASSWORD=$ADMIN_PASSWORD //同上
SERVICE_TOKEN=a682f596-76f3-11e3-b3b2-e716f9080d50

其他可使用配置项:
安装路径:
默认: DEST=/opt/stack
示例:DEST=/opt/mystack
屏幕输出目录:
默认只是console输出:SCREEN_LOGDIR=”“
示例:
SCREEN_LOGDIR=$DEST/logs/screen #输出到文件,每个screen输出用时间戳命名的一个文件
日志:
默认: ``LOGFILE=”” LOGDAYS=7 LOG_COLOR=True`` //日志相关。默认日志仅在console输出

示例local.conf文件:
[[local|localrc]]LOGDAYS=1LOGFILE=$DEST/logs/stack.sh.logSCREEN_LOGDIR=$DEST/logs/screenADMIN_PASSWORD=1111DATABASE_PASSWORD=$ADMIN_PASSWORDRABBIT_PASSWORD=$ADMIN_PASSWORDSERVICE_PASSWORD=$ADMIN_PASSWORD
SERVICE_TOKEN=a682f596-76f3-11e3-b3b2-e716f9080d50 
 
4. 以非root用户运行以下命令
cd devstack
./stack.sh
 
注意:
1. 不可以使用root用户运行该命令,可使用 /devstack/tools/create-stack-user.sh命令创建一个用户,比如stack
2. 保证该用户下sudo可以免密码运行,否则脚本执行过程中会出现权限问题

方法:修改/etc/sudoers, 在行 root    ALL=(ALL:ALL) ALL 后添加 stack      ALL=(ALL) ALL  然后保存文件

 

遇到的一些问题及解决办法:

1. 网速太慢,git clone失败:没找到办法,除了换个更快的网络

2. 一些依赖的包没有安装,比如下面的mysql-server-5.5:在ubuntu上装上这些包重新运行stack.sh即可

Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
mysql-server : Depends: mysql-server-5.5 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

 

成功:

Horizon is now available at http://9.*.236.90/
Keystone is serving at http://9.*.236.90:5000/v2.0/
Examples on using novaclient command line is in exercise.sh
The default users are: admin and demo
The password: 1111
This is your host ip: 9.*.236.90

 
5. 在浏览器中输入 http://9.*.236.90/  打开dashboard, 用admin和1111登录
 
参考:http://docs.openstack.org/developer/devstack/configuration.html
 

学习OpenStack之 (1):安装devstack