Ubuntu14.04使用DevStack搭建OpenStack(Ocata,AllInOne)

一、条件(在VMWare上装的):

  1. 操作系统:Ubuntu14.04
  2. 磁盘空间:100G
    • 看你要装的实例了,最好是大点,如果只是单纯的测功能弄个40G也可以
    • 我是分了100G
  3. 内存:16G
    • 越大越好,一开始我分了4G,安装过程各种报错
  4. 处理器开启虚拟化
  5. 单网卡(桥接模式或NAT都可以,混杂模式)
    • 我本机桥接模式和NAT模式都测试过,没开混杂模式网络可以互通
    • 但在VMWare ESXI上用桥接模式,还得打开混杂模式才能正常
    • 本例介绍使用NAT模式吧,桥接模式也一样
  6. 管理IP网络(IP:192.168.187.130, mask:255.255.255.0, gw: 192.168.187.2)
  7. 浮动IP网络(IP段: 192.168.187.200-220, mask:255.255.255.0, gw: 192.168.187.2)

二、开始搭建

  1. 设置root用户密码
    sudo su
    passwd
    
  2. 安装配置ssh服务
    1. apt install openssh-server
    2. vi /etc/ssh/sshd_config
     将PermitRootLogin改为yes,保存退出。
    3. 重启ssh服务
     service ssh restart
    
  3. 配置静态IP
    // 切换到root   
    sudo su
    vi /etc/network/interfaces
    // 内容
    auto ens33
    iface ens33 inet static
    address 192.168.187.130
    netmask 255.255.255.0
    gateway 192.168.187.2
    dns-nameserver 114.114.114.114
    
    保存后重启网络:
     /etc/init.d/networking restart
    
  4. 将apt源换位国内源
    4.1. 备份:
    cp /etc/apt/sources.list /etc/apt/sources.list.bak
    
    4.2. 编辑:vi /etc/apt/sources.list
    deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
    
    1. 更新
    apt update
    apt upgrade
    
    1. 时间同步
    设定时区:dpkg-reconfigure tzdata
     选择Asia -> 再选择Shanghai -> OK
    同步时间命令:
         1. date -s <时间>
         或者:
         1. sudo apt-get install ntpdate // 安装时间同步工具
         2. sudo ntpdate cn.pool.ntp.org // 与网络服务器同步时间
         3. date // 查看时间是否已同步
    
    1. 安装pip,并配置pip源
    mkdir ~/.pip
    vi ~/.pip/pip.conf
    // 添加:
    [global]
    index-url = http://pypi.douban.com/simple/
    trusted-host = pypi.douban.com
    
    1. 安装git工具
    apt install git
    pip install -U os-testr
    
    1. 下载devstack(ocata版本)到/home目录
    // 如果之前下载过,直接解压到/home目录
    cd /home
    tar -xf devstack.tar.gz
    // 如果没有下载过则:
    git clone https://git.openstack.org/openstack-dev/devstack -b stable/ocata
    
    1. 创建stack用户
    cd /home/devstack/tools/
    ./create-stack-user.sh
    chown -R stack:stack /home/devstack
    
    1. 切换stack用户
    sudo su - stack
    
    1. 安装pip,并配置pip源
    mkdir ~/.pip
    vi ~/.pip/pip.conf
    // 添加:
    [global]
    index-url = http://pypi.douban.com/simple/
    trusted-host = pypi.douban.com
    
    1. 修改local.conf,配置IP
    cd /home/devstack
    // 修改网络
    // Credentials 设置密码,
    // Branches设置要装的openstack版本
    vim /home/devstack/local.conf
    // 我的配置
    
    [[local|localrc]]
    #Define images to be automatically downloaded during the DevStack built process.
    IMAGE_URLS="http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img"
    #change github to trystack
    GIT_BASE=${GIT_BASE:-http://git.trystack.cn}
    NOVNC_REPO=${NOVNC_REPO:-http://git.trystack.cn/kanaka/noVNC.git}
    # Credentials
    DATABASE_PASSWORD=password
    ADMIN_PASSWORD=password
    SERVICE_PASSWORD=password
    SERVICE_TOKEN=password
    RABBIT_PASSWORD=password
    #FLAT_INTERFACE=em1
    HOST_IP=192.168.187.130
    SERVICE_HOST=192.168.187.130
    MYSQL_HOST=192.168.187.130
    RABBIT_HOST=192.168.187.130
    GLANCE_HOSTPORT=192.168.187.130:9292
    ##Neutronoptions
    Q_USE_SECGROUP=True
    FLOATING_RANGE="192.168.187.0/24"
    FIXED_RANGE="10.0.0.0/24"
    Q_FLOATING_ALLOCATION_POOL=start=192.168.187.3,end=192.168.187.223
    PUBLIC_NETWORK_GATEWAY="192.168.187.2"
    Q_L3_ENABLED=True
    PUBLIC_INTERFACE=eth0
    Q_USE_PROVIDERNET_FOR_PUBLIC=True
    OVS_PHYSICAL_BRIDGE=br-ex
    PUBLIC_BRIDGE=br-ex
    OVS_BRIDGE_MAPPINGS=public:br-ex
    # Work offline
    #OFFLINE=True
    # Reclone each time
    RECLONE=yes
    # Branches Now the devstack have bug in keystone and neutron for liberty. so we need use master
    #KEYSTONE_BRANCH=stable/ocata
    #NOVA_BRANCH=stable/ocata
    #NEUTRON_BRANCH=stable/ocata
    #SWIFT_BRANCH=stable/ocata
    #GLANCE_BRANCH=stable/ocata
    #CINDER_BRANCH=stable/ocata
    #HEAT_BRANCH=stable/ocata
    #TROVE_BRANCH=stable/ocata
    #HORIZON_BRANCH=stable/ocata
    #SAHARA_BRANCH=stable/ocata
    #CEILOMETER_BRANCH=stable/ocata
    # 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=/opt/stack/logs/stack.sh.log
    VERBOSE=TrueLOG_COLOR=True
    SCREEN_LOGDIR=/opt/stack/logs
    # the number of days by setting ``LOGDAYS``.
    LOGDAYS=1
    # Database Backend MySQL
    enable_service mysql
    # RPC Backend RabbitMQ
    enable_service rabbit
    # Enable Keystone - OpenStack Identity Service
    enable_service key
    # Horizon - OpenStack Dashboard Service
    enable_service horizon
    # Enable Swift - Object Storage Service without replication.
    enable_service s-proxy s-object s-container s-account
    SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5
    SWIFT_REPLICAS=1
    # Enable Glance - OpenStack Image service
    enable_service g-api g-reg
    # Enable Cinder - Block Storage service for OpenStack
    #VOLUME_GROUP="cinder-volumes"
    enable_service cinder c-api c-vol c-sch c-bak
    # Enable Heat (orchestration) Service
    #enable_service heat h-api h-api-cfn h-api-cw h-eng
    # Enable Trove (database) Service
    enable_service trove tr-api tr-tmgr tr-cond
    # Enable Sahara (data_processing) Service
    #enable_service sahara
    # Enable Tempest - The OpenStack Integration Test Suite
    enable_service tempest
    # 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
    ## Neutron - Load Balancing
    #enable_service q-lbaas
    ## Neutron - Firewall as a Service
    #enable_service q-fwaas
    ## Neutron - VPN as a Service
    #enable_service q-vpn
    # VLAN configuration.
    Q_PLUGIN=ml2
    ENABLE_TENANT_VLANS=True
    # GRE tunnel configuration
    #Q_PLUGIN=ml2
    #ENABLE_TENANT_TUNNELS=True
    # VXLAN tunnel configuration
    #Q_PLUGIN=ml2
    #Q_ML2_TENANT_NETWORK_TYPE=vxlan
    # Enable Ceilometer - Metering Service (metering + alarming)
    enable_service ceilometer-acompute ceilometer-acentral ceilometer-collector ceilometer-api
    enable_service ceilometer-alarm-notify ceilometer-alarm-eval
    enable_service ceilometer-anotification
    ## Enable NoVNC
    enable_service n-novnc
    [[post-config|$NOVA_CONF]]
    [DEFAULT]
    # Ceilometer notification driverinstance_usage_audit=True
    instance_usage_audit_period=hour
    notify_on_state_change=vm_and_task_state
    notification_driver=nova.openstack.common.notifier.rpc_notifier
    notification_driver=ceilometer.compute.nova_notifier
    
    1. 修改git_base的协议为https
    cd /home/devstack
    vim stackrc
    修改GIT_BASE如下:
     GIT_BASE=${GIT_BASE:-http://git.openstack.org}
    
    1. 执行安装
    # 在stack用户下执行
    cd /home/devstack
    ./stack.sh
    
    1. 安装完成
    显示this is your ip等待,代表安装成功。
    
    1. 浏览器输入ip,访问openstack
    2. 注意: 虚拟机重启后openstack服务不会自动运行,
      18.1 恢复逻辑卷组
      sudo losetup /dev/loop0 /opt/stack/data/stack-volumes-default-backing-file
      sudo losetup /dev/loop1 /opt/stack/data/stack-volumes-lvmdriver-1-backing-file
      
      18.2 启动服务
      cd /home/devstack
      // 启动服务
      screen -c stack-screenrc 
      

常见问题

  1. 出现pip版本过低,或pip fail
sudo pip install -U os-testr
或者
sudo pip install --upgrade pip
去掉/home/devstack/tools/cap-pip.txt的版本比较
或者
修改cap-pip.txt文件
  vi /home/devstack/tools/cap-pip.txt
  显示 pip!=8,<10  将<10删除就可以了
  1. 出现Cannot uninstall 'httplib2'. It is a distutils installed project and thus we cannot accurately deter
解决方法:
cd /usr/lib/python2.7/dist-packages
ls | grep 'httplib2'
mv httplib2-0.8.egg-info httplib2-0.8.egg-info_bak
  1. 安装tempest时,执行tox --notest -efull时报错
    3.1. pip版本不对,需pip install --upgrade,这是执行这条指令无法解决。
    解决方法:
        cd /opt/stack/tempest
        1. vim tox.ini 修改如下:
            [testenv]
            ...
            #install_command = pip install {opts} {packages}
            install_command = ./create-env {opts} {packages}
        
        2. vim create-env // 创建create-env文件,文件内容如下
            #!/usr/bin/env sh
            set -e
            pip install --upgrade pip
            pip install $@
        
        3. 把https改为http 就不会报下面2这个问题。
    
    3.2. 错误如下:
    ERROR: could not install deps [-chttps://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt, -r/opt/stack/tempest/requirements.txt];
    v = InvocationError(u'/opt/stack/tempest/create-env -chttps://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt -r/opt/stack/tempest/requirements.txt', 1)
    
    解决方法:
    cd /opt/stack/tempest
        vim tox.ini 执行如下指令:
        替换https->http
        :0,$s/https/http/g
    
  2. devstack默认创建逻辑卷比较小(10G),安装前可以调整(stack用户下导入该环境变量)
```
export VOLUME_BACKING_FILE_SIZE=10240M
或者
// 在local.conf中添加
vim /home/devstack/local.conf
VOLUME_BACKING_FILE_SIZE=10240M
```
  1. 如果已经安装完成了,才发现逻辑卷不够大,可以使用vgextend扩展vg(逻辑卷组)
    参考:
    OpenStack使用本地磁盘创建或拓展逻辑卷组
    OpenStack添加新硬盘到LVM逻辑卷组

你可能感兴趣的:(Ubuntu14.04使用DevStack搭建OpenStack(Ocata,AllInOne))