1.环境介绍
- 由于github的openstack liberty版本的代码已过期,无法使用devstack部署liberty版本,本篇介绍如何使用devstack部署openstack newton版本。
- devstack支持unbuntu 14.04、ubuntu 16.04、centos6和7, 本篇采用ubuntu16.04做为安装操作系统。
- 实验环境
- devstack-controller:
- 角色:控制节点+网络节点+存储节点
- 服务:mysql,rabbit-mq,network-time-server,nova,neutron ,keystone,glance,cinder,neutron-L3-Agent,neutron-DHCP-Agent,neutron-ML2-Plugin
- 配置:1cpus,4G,3nic(1hostonly,2hostonly,3nat)
- 网卡: ens33:192.168.56.10 ens34:manual ens35:dhcp
- devstack-compute:
- 角色:计算节点
- 服务,kvm- Hypervisor,nova,Neutron-agent
- 配置:1cpus,4G,3nic(1hostonly,2hostonly,3nat)
- 网卡:ens33:192.168.56.10 ens34:manual ens35: dhcp
- devstack-controller:
2.部署脚本
- devstack-controller node
devstack-controller.sh
# 设置主机名
hostnamectl set-hostname devstack-controller
# 配置网络
cat > /etc/network/interfaces << EOF
auto lo
iface lo inet loopback
auto ens33
iface ens33 inet static
address 192.168.56.10
network 192.168.56.0
netmask 255.255.255.0
broadcast 192.168.56.255
auto ens34
iface ens34 inet manual
auto ens35
iface ens35 inet dhcp
EOF
systemctl restart network
# 更换apt国内源
mv /etc/apt/sources.list /etc/apt/sources.list.bak
grep -Ev "^#|^$" /etc/apt/sources.list.bak > /etc/apt/sources.list
sed -i "s#http://us.archive.ubuntu.com/ubuntu/# http://mirrors.aliyun.com/ubuntu/#g" /etc/apt/sources.list
sed -i "/security/d" /etc/apt/sources.list
apt-get update
# 更换pip源for root
mkdir ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
disable-pip-version-check = true
timeout = 120
[install]
trusted-host = mirrors.aliyun.com
EOF
# 安装git,pip及依赖包
apt-get install -y git python-pip
pip install --upgrade pip
pip install -U os-testr
# clone newton 源代码
git clone http://git.trystack.cn/openstack-dev/devstack.git -b stable/newton
# 创建stack用户
./devstack/tools/create-stack-user.sh
mv devstack /opt/stack/
mkdir /opt/stack/.pip
cat ~/.pip/pip.conf > /opt/stack/.pip/pip.conf
chown -R stack.stack /opt/stack
chmod 777 /dev/pts/0
# 配置devstack local file
su - stack
cd devstack
cat > local.conf << EOF
[[local|localrc]]
# use TryStack git mirror
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
#OFFLINE=True
RECLONE=True
# Define images to be automatically downloaded during the DevStack built process.
DOWNLOAD_DEFAULT_IMAGES=False
IMAGE_URLS="http://images.trystack.cn/cirros/cirros-0.3.4-x86_64-disk.img"
HOST_IP=192.168.56.10
# Credentials
DATABASE_PASSWORD=admin
ADMIN_PASSWORD=admin
SERVICE_PASSWORD=admin
SERVICE_TOKEN=admin
RABBIT_PASSWORD=admin
HORIZON_BRANCH=stable/newton
KEYSTONE_BRANCH=stable/newton
NOVA_BRANCH=stable/newton
NEUTRON_BRANCH=stable/newton
GLANCE_BRANCH=stable/newton
CINDER_BRANCH=stable/newton
# enable neutron-ml2-vlan
disable_service n-net
enable_service q-svc,q-agt,q-dhcp,q-l3,q-meta,neutron,q-lbaas,q-fwaas,q-vpn
Q_AGENT=linuxbridge
ENABLE_TENANT_VLANS=True
TENANT_VLAN_RANGE=3001:4000
PHYSICAL_NETWORK=default
LOG_COLOR=False
LOGDIR=$DEST/logs
SCREEN_LOGDIR=$LOGDIR/screen
EOF
# 开始安装,如果安装失败一般是由于超时,重复执行./stack.sh;
# 安装成功后如果重启了服务器可以使用screen -c stack-screenrc启动服务
./stack.sh
- devstack-compute node
devstack-compute.sh
# 设置主机名
hostnamectl set-hostname devstack-compute
# 配置网络
cat > /etc/network/interfaces << EOF
auto lo
iface lo inet loopback
auto ens33
iface ens33 inet static
address 192.168.56.11
network 192.168.56.0
netmask 255.255.255.0
broadcast 192.168.56.255
auto ens34
iface ens34 inet manual
auto ens35
iface ens35 inet dhcp
EOF
systemctl restart network
# 更换apt国内源
mv /etc/apt/sources.list /etc/apt/sources.list.bak
grep -Ev "^#|^$" /etc/apt/sources.list.bak > /etc/apt/sources.list
sed -i "s#http://us.archive.ubuntu.com/ubuntu/# http://mirrors.aliyun.com/ubuntu/#g" /etc/apt/sources.list
sed -i "/security/d" /etc/apt/sources.list
apt-get update
# 更换pip源for root
mkdir ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
disable-pip-version-check = true
timeout = 120
[install]
trusted-host = mirrors.aliyun.com
EOF
# 安装git,pip及依赖包
apt-get install -y git python-pip
pip install --upgrade pip
pip install -U os-testr
# clone newton 源代码
git clone http://git.trystack.cn/openstack-dev/devstack.git -b stable/newton
# 创建stack用户
./devstack/tools/create-stack-user.sh
mv devstack /opt/stack/
mkdir /opt/stack/.pip
cat ~/.pip/pip.conf > /opt/stack/.pip/pip.conf
chown -R stack.stack /opt/stack
chmod 777 /dev/pts/0
# 配置devstack local file
su - stack
cd devstack
cat > local.conf << EOF
[[local|localrc]]
# use TryStack git mirror
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
#OFFLINE=True
RECLONE=True
# Define images to be automatically downloaded during the DevStack built process.
DOWNLOAD_DEFAULT_IMAGES=False
IMAGE_URLS="http://images.trystack.cn/cirros/cirros-0.3.4-x86_64-disk.img"
MULTI_HOST=true
HOST_IP=192.168.56.11
# Credentials
DATABASE_PASSWORD=admin
ADMIN_PASSWORD=admin
SERVICE_PASSWORD=admin
SERVICE_TOKEN=admin
RABBIT_PASSWORD=admin
NOVA_BRANCH=stable/newton
NEUTRON_BRANCH=stable/newton
# Service information
SERVICE_HOST=192.168.56.10
MYSQL_HOST=$SERVICE_HOST
RABBIT_HOST=$SERVICE_HOST
GLANCE_HOSTPORT=$SERVICE_HOST:9292
Q_HOST=$SERVICE_HOST
KEYSTONE_AUTH_HOST=$SERVICE_HOST
KEYSTONE_SERVICE_HOST=$SERVICE_HOST
CEILOMETER_BACKEND=mongodb
DATABASE_TYPE=mysql
ENABLED_SERVICES=n-cpu,q-agt,neutron
Q_AGENT=linuxbridge
ENABLE_TENANT_VLANS=True
TENANT_VLAN_RANGE=3001:4000
PHYSICAL_NETWORK=default
# vnc config
NOVA_VNC_ENABLED=True
NOVNCPROXY_URL="http://$SERVICE_HOST:6080/vnc_auto.html"
VNCSERVER_LISTEN=$HOST_IP
VNCSERVER_PROXYCLIENT_ADDRESS=$VNCSERVER_LISTEN
LOG_COLOR=False
LOGDIR=$DEST/logs
SCREEN_LOGDIR=$LOGDIR/screen
EOF
# 开始安装,如果安装失败一般是由于超时,重复执行./stack.sh;
# 安装成功后如果重启了服务器可以使用screen -c stack-screenrc启动服务
./stack.sh
3. 验证openstack
- 使用浏览器登录http://192.168.56.10 ,默认用户admin,密码admin
- 点击System --> System information
4.devstack openstack服务管理方式
devstack使用screen 来管理服务
5. 删除自动创建的网络
为了得到干净的openstack环境,我们将自动创建的网络删除