一,工具信息

获取工具
    从VirtualBox的官网下载当前最新的5.1版本。
    下载地址:https://www.virtualbox.org/wiki/Downloads
    下载完毕就可以直接在计算机上安装。

安装虚拟机:

CentOS7.3

配置信息:64G硬盘,4CPU,4G内存,两个网卡(NAT、桥接各一个)

系统安装好之后,修改网卡的显示名称为ethx:

1. 编辑ifcfg-eth0, 将文件中的ensx改为ethx。文件名和里面内容

2. vim /etc/default/grub   
    修改GRUB_CMDLINE_LINUX 行内容,在后面加上 net.ifnames=0 biosdevname=0,如下:   
    GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0"

3. 重新生成grub.cfg文件
   # grub2-mkconfig -o /boot/grub2/grub.cfg

4. reboot 重启后生效

5. 保证/etc/ssh/sshd_config中的PermitRootLogin参数为yes,这样能保证ssh访问,后续使用方便。

6. 保证关掉selinux。


二,安装工具

1. 确保网络畅通

ping www.baidu.com

2. 安装git

yum -y install git
3. 安装pip
yum -y install epel-release
yum -y install pip


4. 配置pip
在/root目录下,查看是否有.pip目录,若没有,创建该目录。
执行命令mkdir .pip,进入该目录,创建对应配置文件pip.conf。
在配置文件中填入以下内容(这里是我最后实际用的,如果你看到过之前那个,也是可以的):
[global]
timeout = 6000
index-url = http://pypi.douban.com/simple/
[install]
trusted-host = pypi.douban.com

 
5. 下载devstack,进入/home目录,执行以下命令,下载DevStack,并指定openstack版本:

如果要下载最新代码,使用:

git clone http://git.trystack.cn/openstack-dev/devstack.git -b master

如果要指定分支,使用:

git clone http://git.trystack.cn/openstack-dev/devstack.git -b stable/newton

6. 由于当前DevStack脚本已不支持直接使用root用户,所以我们要创建stack用户。
    执行命令cd /home/devstack/tools,进入脚本目录。
    执行命令./create-stack-user.sh,创建stack用户。

7. 执行命令passwd stack,给stack用户设置密码。具体操作步骤同root用户。

执行命令chown -R stack:stack /home/devstack,将对应目录及其下的文件更换用户组。
执行命令chmod 777 /dev/pts/0,以便后续su切换到别的用户,也可执行screen命令。

8. 执行命令su stack,切换至stack用户。
执行cd ~,进入到stack用户名下的目录,默认是/opt/stack。
像对root用户那样,添加pip的配置文件。参考当前面步骤。
在/opt/stack目录下新增.pip目录,里面配置pip.conf。


9. 修改local.conf
从/home/devstack/samples子目录中中拷贝一份local.conf文件到/home/devstack目录然后编辑。参见local.conf配置。

10.最后执行stack脚本(home/devstack下)。安装过程中,只遇到了下载的image名称后面带双引号。
修改function脚本,将image_fname写死:cirros-0.3.4-x86_64-disk.img 问题解决。


11. 成功日志。
This is your host IP address: 192.168.0.162
This is your host IPv6 address: ::1
Horizon is now available at http://192.168.0.162/dashboard
Keystone is serving at http://192.168.0.162/identity/
The default users are: admin and demo
The password: password


local.conf配置文件内容:

# Sample ``local.conf`` for user-configurable variables in ``stack.sh``

# NOTE: Copy this file to the root DevStack directory for it to work properly.

# ``local.conf`` is a user-maintained settings file that is sourced from ``stackrc``.
# This gives it the ability to override any variables set in ``stackrc``.
# Also, most of the settings in ``stack.sh`` are written to only be set if no
# value has already been set; this lets ``local.conf`` effectively override the
# default values.

# This is a collection of some of the settings we have found to be useful
# in our DevStack development environments. Additional settings are described
# in http://docs.openstack.org/developer/devstack/configuration.html#local-conf
# These should be considered as samples and are unsupported DevStack code.

# The ``localrc`` section replaces the old ``localrc`` configuration file.
# Note that if ``localrc`` is present it will be used in favor of this section.
[[local|localrc]]
GIT_BASE=http://git.trystack.cn
NOVNC_REPO=http://git.trystack.cn/kanaka/noVNC.git
SPICE_REPO=http://git.trystack.cn/git/spice/spice-html5.git

RECLONE=no

# Minimal Contents
# ----------------

# While ``stack.sh`` is happy to run without ``localrc``, devlife is better when
# there are a few minimal variables set:

# If the ``*_PASSWORD`` variables are not set here you will be prompted to enter
# values for them by ``stack.sh``and they will be added to ``local.conf``.

DATABASE_PASSWORD=password
ADMIN_PASSWORD=password
SERVICE_PASSWORD=password
SERVICE_TOKEN=password
RABBIT_PASSWORD=password

DOWNLOAD_DEFAULT_IMAGES=False
IMAGE_URLS=“http://images.trystack.cn/cirros/cirros-0.3.4-x86_64-disk.img”

# ``HOST_IP`` and ``HOST_IPV6`` should be set manually for best results if
# the NIC configuration of the host is unusual, i.e. ``eth1`` has the default
# route but ``eth0`` is the public interface.  They are auto-detected in
# ``stack.sh`` but often is indeterminate on later runs due to the IP moving
# from an Ethernet interface to a bridge on the host. Setting it here also
# makes it available for ``openrc`` to include when setting ``OS_AUTH_URL``.
# Neither is set by default.
HOST_IP=192.168.0.150
#HOST_IPV6=2001:db8::7


# Logging
# -------

# By default ``stack.sh`` output only goes to the terminal where it runs.  It can
# be configured to additionally log to a file by setting ``LOGFILE`` to the full
# path of the destination log file.  A timestamp will be appended to the given name.
LOGFILE=$DEST/logs/stack.sh.log

# Old log files are automatically removed after 7 days to keep things neat.  Change
# the number of days by setting ``LOGDAYS``.
LOGDAYS=2

# Nova logs will be colorized if ``SYSLOG`` is not set; turn this off by setting
# ``LOG_COLOR`` false.
#LOG_COLOR=False


# Using milestone-proposed branches
# ---------------------------------

# Uncomment these to grab the milestone-proposed branches from the
# repos:
#CINDER_BRANCH=milestone-proposed
#GLANCE_BRANCH=milestone-proposed
#HORIZON_BRANCH=milestone-proposed
#KEYSTONE_BRANCH=milestone-proposed
#KEYSTONECLIENT_BRANCH=milestone-proposed
#NOVA_BRANCH=milestone-proposed
#NOVACLIENT_BRANCH=milestone-proposed
#NEUTRON_BRANCH=milestone-proposed
#SWIFT_BRANCH=milestone-proposed

HORIZON_BRANCH=master
KEYSTONE_BRANCH=master
NOVA_BRANCH=master
NEUTRON_BRANCH=master
GLANCE_BRANCH=master
CINDER_BRANCH=master

# Using git versions of clients
# -----------------------------
# By default clients are installed from pip.  See LIBS_FROM_GIT in
# stackrc for details on getting clients from specific branches or
# revisions.  e.g.
# LIBS_FROM_GIT="python-ironicclient"
# IRONICCLIENT_BRANCH=refs/changes/44/2.../1

#keystone

KEYSTONE_TOKEN_FORMAT=UUID

#Heat

HEAT_BRANCH=master
enable_service h-eng h-api h-api-cfn h-api-cw

# Swift
# -----

###SWIFT_BRANCH=master
###ENABLED_SERVICES+=,s-proxy,s-object,s-Container,s-account

# Swift is now used as the back-end for the S3-like object store. Setting the
# hash value is required and you will be prompted for it if Swift is enabled
# so just set it to something already:
###SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5

# For development purposes the default of 3 replicas is usually not required.
# Set this to 1 to save some resources:
###SWIFT_REPLICAS=1

# The data for Swift is stored by default in (``$DEST/data/swift``),
# or (``$DATA_DIR/swift``) if ``DATA_DIR`` has been set, and can be
# moved by setting ``SWIFT_DATA_DIR``. The directory will be created
# if it does not exist.
###SWIFT_DATA_DIR=$DEST/data

#Enabling Neutron (network) Service

disable_service n-net
enable_service q-svc
enable_service q-agt
enable_service q-dhcp
enable_service q-l3
enable_service q-meta
enable_service q-metering
enable_service neutron




问题记录
1. 虚拟机重启后,如何启动openstack的相关服务?

 screen -c stack-screenrc

2. 日志路径:根据local.conf找到logs目录(find / -name stack.sh.log)。所有日志都在那里

3. 安装ironic时提示ovs错误,需要手动启动ovs服务

systemctl start openvswitch

systemctl enable openvswitch

4. 安装好的虚拟机重启后lv丢失的问题:
[root@localhost ~]# losetup --list
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE
/dev/loop0         0      0         0  0 /opt/stack/data/stack-volumes-default-backing-file
/dev/loop1         0      0         0  0 /opt/stack/data/stack-volumes-lvmdriver-1-backing-file
[root@localhost ~]# losetup /dev/loop0 /opt/stack/data/stack-volumes-default-backing-file
[root@localhost ~]# losetup /dev/loop1 /opt/stack/data/stack-volumes-lvmdriver-1-backing-file

5.ironic的dev搭建时,遇到这样一个问题:gitclone或者yum安装时,都没有等待,直接向下,导致后续报错。
因为locla.conf中有个OFFLINE设置为TRUE了。改成下面形式。
#OFFLINE=True
RECLONE=True

6.ironic的dev搭建时,需要注意的地方:
tempest需要手动git下来;
需要手动安装qemu;
遇到过一次unstack时,没有彻底清理。导致再次stack的时候,网桥br-node-0还存在,报错网桥br-node-0不能创建。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐