OpenStack实践(一):Ubuntu16.04下DevStack方式搭建p版OpenStack
OpenStack部署方式很多,常见的个人部署方式有DevStack、Rdo、all-in-one、multi-node、multi-HA-node等;企业部署方式有Ansible、SaltStack、Puppet、TripleO、Kolla、Fuel等。其中DevStack是众多开发者们的首选安装方式或工具,该方式主要是通过配置参数,执行shell脚本来安装一个OpenStack的开发环境。
OpenStack开源社区每年都会开两次设计峰会(Design Summit),发布两个正式版本。从2010年的首个版本至今,一共已经出了18个版本,每个版本都有独立名字,取自当次设计峰会所在城市中选一个地名,而且从A开始,然后B、C……。最新的版本是Rocky,字母R正好排序第18位。本文部署的版本为Pike。
本文OpenStack的控制节点和计算节点都是Esxi上新建的虚机,具体配置如下:
控制节点配置:
计算节点配置:
ubuntu安装详见:Ubuntu16.04.5以lvm方式安装全记录
控制节点和计算节点安装步骤相同,只是第6步中的配置不同,实际安装过程中应先装控制节点再装计算节点,本文以计算节点安装为例记录搭建过程。
1.pip安装
root@openstack-computer:~# pipThe program 'pip' is currently not installed. You can install it by typing:apt install python-piproot@openstack-computer:~# apt install -y python-pip
2.代码下载
root@openstack-computer:~# git clone https://git.openstack.org/openstack-dev/devstack -b stable/pike
本文的安装版本为pike
3.创建用户stack
root@openstack-computer:~# lltotal 36drwx------ 4 root root 4096 Nov 29 17:02 ./drwxr-xr-x 23 root root 4096 Nov 29 16:32 ../-rw------- 1 root root 49 Nov 29 16:47 .bash_history-rw-r--r-- 1 root root 3106 Oct 23 2015 .bashrcdrwx------ 2 root root 4096 Nov 29 16:47 .cache/drwxr-xr-x 17 root root 4096 Nov 29 17:02 devstack/-rw-r--r-- 1 root root 148 Aug 17 2015 .profile-rw------- 1 root root 3413 Nov 29 16:51 .viminfo-rw------- 1 root root 128 Nov 29 16:47 .Xauthorityroot@openstack-computer:~# devstack/tools/create-stack-user.shCreating a group called stackCreating a user called stackGiving stack user passwordless sudo privileges
4.修改pip源
root用户修改pip源
root@openstack-computer:~# mkdir ~/.piproot@openstack-computer:~# view ~/.pip/pip.conf[global]trusted-host=mirrors.aliyun.comindex-url=https://mirrors.aliyun.com/pypi/simple/
stack用户修改pip源
root@openstack-computer:~# su - stackstack@openstack-computer:~$ mkdir ~/.pipstack@openstack-computer:~$ view ~/.pip/pip.conf[global]trusted-host=mirrors.aliyun.comindex-url=https://mirrors.aliyun.com/pypi/simple/
5.移动devstack目录
将devstack目录由root的家目录移至/opt/stack
root@openstack-computer:~# mv devstack /opt/stackroot@openstack-computer:~# chown -R stack:stack /opt/stack/devstack
6.新建配置文件
控制节点:
[[local|localrc]]MULTI_HOST=true# management & api networkHOST_IP=172.27.34.37LOGFILE=/opt/stack/logs/stack.sh.log# CredentialsADMIN_PASSWORD=adminMYSQL_PASSWORD=loong576RABBIT_PASSWORD=loong576SERVICE_PASSWORD=loong576SERVICE_TOKEN=loong576# enable neutron-ml2-vlandisable_service n-net# Enable LBaaS v2enable_plugin neutron-lbaas https://git.openstack.org/openstack/neutron-lbaas stable/pikeenable_plugin octavia https://git.openstack.org/openstack/octavia stable/pikeenable_plugin neutron-lbaas-dashboard https://git.openstack.org/openstack/neutron-lbaas-dashboard stable/pike# enable FWaaS v2enable_plugin neutron-fwaas https://git.openstack.org/openstack/neutron-fwaas stable/pikeenable_plugin neutron-fwaas-dashboard https://git.openstack.org/openstack/neutron-fwaas-dashboard stable/pikeenable_service q-lbaasv2,octavia,o-cw,o-hk,o-hm,o-api,q-***,q-fwaas-v2,q-svc,q-agt,q-dhcp,q-l3,q-meta,neutronQ_AGENT=linuxbridgeENABLE_TENANT_VLANS=TrueTENANT_VLAN_RANGE=3001:4000PHYSICAL_NETWORK=default# loggingLOG_COLOR=TrueLOGDIR=$DEST/logsSCREEN_LOGDIR=$LOGDIR/screen# use TryStack git mirrorGIT_BASE=http://git.trystack.cnNOVNC_REPO=http://git.trystack.cn/kanaka/noVNC.gitSPICE_REPO=http://git.trystack.cn/git/spice/spice-html5.git
控制节点ip为:172.27.34.37,admin密码为admin,后面web登陆会用到。q-***星号为v and p and n
计算节点:
stack@openstack-computer:~$ more /opt/stack/devstack/local.conf [[local|localrc]]MULTI_HOST=true# management & api networkHOST_IP=172.27.34.38# CredentialsADMIN_PASSWORD=adminMYSQL_PASSWORD=loong576RABBIT_PASSWORD=loong576SERVICE_PASSWORD=loong576SERVICE_TOKEN=loong576# Service informationSERVICE_HOST=172.27.34.37MYSQL_HOST=$SERVICE_HOSTRABBIT_HOST=$SERVICE_HOSTGLANCE_HOSTPORT=$SERVICE_HOST:9292Q_HOST=$SERVICE_HOSTKEYSTONE_AUTH_HOST=$SERVICE_HOSTKEYSTONE_SERVICE_HOST=$SERVICE_HOSTENABLED_SERVICES=n-cpu,q-agt,neutronQ_AGENT=linuxbridgeENABLE_TENANT_VLANS=TrueTENANT_VLAN_RANGE=3001:4000PHYSICAL_NETWORK=default# vnc configNOVA_VNC_ENABLED=TrueNOVNCPROXY_URL="http://$SERVICE_HOST:6080/vnc_auto.html"VNCSERVER_LISTEN=$HOST_IPVNCSERVER_PROXYCLIENT_ADDRESS=$VNCSERVER_LISTEN# LoggingLOG_COLOR=TrueLOGDIR=$DEST/logsSCREEN_LOGDIR=$LOGDIR/screen# use TryStack git mirrorGIT_BASE=http://git.trystack.cnNOVNC_REPO=http://git.trystack.cn/kanaka/noVNC.gitSPICE_REPO=http://git.trystack.cn/git/spice/spice-html5.gitenable_service placement-api
HOST_IP=172.27.34.38为计算节点ip
本文中参数Q_AGENT配置为linuxbridge,表示网络选择为Linux Bridge方式,如果选择Open vSwitch,则Q_AGENT=openvswitch。
7.部署openstack
stack@openstack-computer:~/devstack$ ./stack.sh
控制节点安装完成:
计算节点安装完成:
8.登陆web
地址为:http://172.27.34.37,用户名密码为配置文件中的admin/admin
至此完成OpenStack安装。
9.卸载
若修改了local.conf则需先卸载再重新安装
卸载命令
stack@openstack-controller:~/devstack$ ./unstack.shstack@openstack-controller:~/devstack$ ./clean.sh
搭建脚本已上传github:https://github.com/loong576/openstack-devstack.git
本文参考:
http://cloudman.cc/
https://docs.openstack.org/devstack/latest/guides/devstack-with-lbaas-v2.html
https://docs.openstack.org/neutron-fwaas-dashboard/latest/contributor/devstack-plugin.html