• 体验devstack安装openstack


    由于公司制度,工作环境是不能直接上网的,所以在工作时间从没有体验过devstack或者其他联网方式安装openstack。

    因自己购置了一台不错的主机,因而决定尝试安装一番,经过一段为期不短的内心极度崩溃与愈合,终于看到了如下的打印:

    15 This is your host IP address: 192.168.0.105
    16 This is your host IPv6 address: ::1
    17 Horizon is now available at http://192.168.0.105/dashboard
    18 Keystone is serving at http://192.168.0.105:5000/
    19 The default users are: admin and demo
    20 The password: 123456
    21 2017-01-21 08:46:05.167 | stack.sh completed in 746 seconds.

    喔喔,这是成功了吗,可以登录了。

    好了,还是言归正传:

    工作环境:vmware 12

    操作系统:ubuntu 14.04.5

    虚拟机配置 内存: 4G , CPU : 4核 ,开启VTx-d等选项,内存是越大越好,不过俺的主机内存有限。

    安装完后:

    root@ubuntu:~# free -h
                 total       used       free     shared    buffers     cached
    Mem:          3.8G       3.7G       151M       3.2M       100M       1.1G
    -/+ buffers/cache:       2.5G       1.3G
    Swap:         1.0G       744K       1.0G

    apt源可以使用国内的默认源,也可以使用其他国内的源,不过博主居然遇到cn.archive.ubuntu.com当机了。。。

    因此测试了一下阿里的源,貌似比较稳定,于是:

    sed -i "s/cn.archive.ubuntu.com/mirrors.aliyun.com/g" /etc/apt/sources.list
    apt-get update

    pip的设置(首先创建目录: mkdir ~/.pip  && vim ~/.pip/pip.conf):

    1 stack@ubuntu:~/devstack$ cat ~/.pip/pip.conf
    2 [global]  
    3 index-url = http://mirrors.aliyun.com/pypi/simple/  
    4 [install]  
    5 trusted-host=mirrors.aliyun.com

    devstack本地配置:

     1 stack@ubuntu:~/devstack$ cat local.conf
     2 [[local|localrc]]
     3 
     4 # use TryStack git mirror
     5 GIT_BASE=http://git.trystack.cn
     6 NOVNC_REPO=http://git.trystack.cn/kanaka/noVNC.git
     7 SPICE_REPO=http://git.trystack.cn/git/spice/spice-html5.git
     8 
     9 #OFFLINE=True
    10 RECLONE=True
    11 
    12 # Define images to be automatically downloaded during the DevStack built process.
    13 DOWNLOAD_DEFAULT_IMAGES=False
    14 IMAGE_URLS="http://images.trystack.cn/cirros/cirros-0.3.4-x86_64-disk.img"
    15 
    16 ADMIN_PASSWORD=123456
    17 DATABASE_PASSWORD=$ADMIN_PASSWORD
    18 RABBIT_PASSWORD=$ADMIN_PASSWORD
    19 SERVICE_PASSWORD=$ADMIN_PASSWORD


    我一开始使用默认的国外源,是想安装newton版本,不过那个网速真的没法成功安装。。

    使用国内的源会快很多,但是好像只支持mitaka版本,因此就先安装这个,接下来就是:

    1、创建一个普通用户,比如官网推荐的 stack

    1 sudo adduser stack
    2 
    3 sudo echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

    2、切换到stack用户(执行su stack),然后:

    1 cd ~
    2 sudo apt-get install git 
    3 git clone https://github.com/openstack-dev/devstack.git -b stable/mitaka

    3、开始安装:

    1 cd devstack
    2 ./stack.sh

    4、中途遇到的问题:

     1 Traceback (most recent call last):
     2   File "/usr/local/bin/openstack", line 7, in <module>
     3     from openstackclient.shell import main
     4   File "/usr/local/lib/python2.7/dist-packages/openstackclient/shell.py", line 32, in <module>
     5     from openstackclient.common import clientmanager
     6   File "/usr/local/lib/python2.7/dist-packages/openstackclient/common/clientmanager.py", line 293, in <module>
     7     'openstack.cli.base',
     8   File "/usr/local/lib/python2.7/dist-packages/openstackclient/common/clientmanager.py", line 264, in get_plugin_modules
     9     __import__(ep.module_name)
    10   File "/usr/local/lib/python2.7/dist-packages/openstackclient/network/client.py", line 16, in <module>
    11     from openstack import connection
    12   File "/usr/local/lib/python2.7/dist-packages/openstack/connection.py", line 68, in <module>
    13     from openstack import session as _session
    14   File "/usr/local/lib/python2.7/dist-packages/openstack/session.py", line 29, in <module>
    15     DEFAULT_USER_AGENT = "openstacksdk/%s" % openstack.__version__
    16 AttributeError: 'module' object has no attribute '__version__

    好吧,发现是/usr/local/lib/python2.7/dist-packages/openstack/session.py里执行失败:

    代码行: DEFAULT_USER_AGENT = "openstacksdk/%s" % openstack.__version__

    于是如下处理一下:

     1 root@ubuntu:~# python
     2 Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
     3 [GCC 4.8.4] on linux2
     4 Type "help", "copyright", "credits" or "license" for more information.
     5 >>> import openstack
     6 >>> import pbr.version
     7 >>> print(pbr.version.VersionInfo('openstacksdk').version_string())
     8 0.8.1
     9 >>> quit()
    10 root@ubuntu:~# 

    修改为: DEFAULT_USER_AGENT = "openstacksdk/0.8.1"

    cd ~/devstack
    ./unstack.sh
    ./clean.sh
    ./stack.sh

    好运的话,会一次安装成功吧。

    然而博主是经历了断断续续历时约12个小时失败才安装成功。。。

    5、如何重启devstack

    devstack重启脚本是rejoin-stack.sh,但是git下来的版本却没有,只好去网上找一个,如下:

    #!/usr/bin/env bash
    
    # This script rejoins an existing screen, or re-creates a
    # screen session from a previous run of stack.sh.
    
    TOP_DIR=`dirname $0`
    
    # Import common functions in case the localrc (loaded via stackrc)
    # uses them.
    source $TOP_DIR/functions
    
    source $TOP_DIR/stackrc
    
    # if screenrc exists, run screen
    if [[ -e $TOP_DIR/stack-screenrc ]]; then
        if screen -ls | egrep -q "[0-9].stack"; then
            echo "Attaching to already started screen session.."
            exec screen -r stack
        fi
        exec screen -c $TOP_DIR/stack-screenrc
    fi
    
    echo "Couldn't find $TOP_DIR/stack-screenrc file; have you run stack.sh yet?"
    exit 1

    vim ~/devstack/rejoin-stack.sh将上面的内容复制进去。

    chmod +x ~/devstack/rejoin-stack.sh
    sudo chmod 777 /dev/pts/0
    ./rejoin-stack.sh

    即可重启服务咯,哈哈,我赶紧把内存加大1G~~~

    root@ubuntu:~# free -h
                 total       used       free     shared    buffers     cached
    Mem:          4.8G       3.0G       1.7G       3.4M        62M       230M
    -/+ buffers/cache:       2.7G       2.0G
    Swap:         1.0G         0B       1.0G

    接下来,就可以愉快的玩耍了。

    6、如何成为openstack的开发者:

    http://www.ibm.com/developerworks/cn/cloud/library/cl-contributecode-openstack/

  • 相关阅读:
    sessionstorage中存储JSON数据
    JS + Canvas画图Demo
    JavaWeb中实现通过邮箱找回密码
    javaWeb实现验证码--代码超简单
    maven的下载、安装及配置
    web端百度地图API实现实时轨迹动态展现
    java存储数据到本地txt文件中
    java读取地址数据文件
    在服务器的tomcat中部署手机apk项目,浏览器或手机下载不能根据URL下载和安装apk文件
    虚拟机类加载机制
  • 原文地址:https://www.cnblogs.com/danxi/p/6337401.html
Copyright © 2020-2023  润新知