2

Ubuntu12.04 OpenStack Folsom 安装(VLAN模式)

 3 years ago
source link: http://www.chenshake.com/openstack-folsom-install-guide-vlan-mode/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Ubuntu12.04 OpenStack Folsom 安装(VLAN模式) – 陈沙克日志

 

Openstack Folsom 安装比较复杂,尤其是Quantum部分,新的内容很多。Quantum的租户网络有两种模式:GRE和VLAN模式,这两种方式配置有很大的区别,一个明显的区别就是控制节点,Vlan模式2块网卡,GRE模式需要3块网卡。

英文原文

我基本会参考原文做翻译,下面的和原文差异的地方

  1. 我的网络会会原文不同, 文档我会在真实的环境下验证,由于每个人的网络基本都是不一样,所以文档和IP相关的地方,我基本采用变量,比较灵活的方式,大家可以用sed命令实现修改。很多朋友安装不成功,基本都是因为更换IP,导致有地方没修改,所以提供sed的命令修改。
  2. 对原文提供的两个keystone导入数据的脚本做了细微的修改,主要是采用变量,让他更加灵活。
  3. mysql直接采用IP访问,而不是localhost
  4. keystone的token采用随机生成,而不是password

文档修改记录

  • 2012年11月1日:copy以前的folsom的文档,专门针对vlan模式进行修改
  • 2012年11月2日:基本把文档整理完,包括租户网络创建,vnc也已经可以工作。目前存在的问题是:metadata无法工作,密钥无法住人到虚拟机里,还有就是虚拟机网络还不能访问。
  控制节点(2块网卡) 计算节点(2块网卡) 管理网络(eth0) 10.1.199.58/24 10.1.199.6/24   10.1.199.68/24   hostname controller compute1 服务 MySQL
RabbitMQ
Nova
Glance
Keystone
Quantum kvm
quantum client
nova-compute      
  1. 控制节点和计算节点需要2块网卡,计算节点需要支持虚拟化
  2. 全部的命令都是在root下运行

网络拓扑图

安装ubuntu 12.04.1 Server版本,最小化安装,只需要安装SSH server就可以。Cinder 需要一个单独的分区或者硬盘。

目前Folsom进入ubuntu 12.04的官方的源,不过需要你手工添加。源的官方说明

cat <<EOF >>/etc/apt/sources.list
deb  http://ubuntu-cloud.archive.canonical.com/ubuntu precise-proposed/folsom main
deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/folsom main
EOF

运行下面命令

apt-get install ubuntu-cloud-keyring
apt-get update && apt-get -y dist-upgrade

Hostname设置(可选)

# cat /etc/hostname 
controller

# cat /etc/hosts
127.0.0.1       localhost
10.1.199.58      controller.chenshake.com        controller
10.1.199.6      compute1.chenshake.com  compute1

# hostname
controller

# hostname -f
controller.chenshake.com

直接设置 /etc/network/interface

# cat /etc/network/interfaces 
# This file describes network interfaces avaiulable on your system
# and how to activate them. For more information, see interfaces(5).
# Modified by convert_static.sh.
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.1.199.58
hwaddress ether 00:25:90:2d:7a:42  
netmask 255.255.255.0
network 10.1.199.0
gateway 10.1.199.1
dns-search chenshake.com
dns-nameservers 8.8.8.8

auto eth1
iface eth1 inet static
address 10.1.199.68
netmask 255.255.255.0
/etc/init.d/networking restart

设置IP转发

sed -i -r 's/^\s*#(net\.ipv4\.ip_forward=1.*)/\1/' /etc/sysctl.conf
echo 1 > /proc/sys/net/ipv4/ip_forward

检查修改结果

# sysctl -p
net.ipv4.ip_forward = 1

NTP服务器

编辑 /etc/ntp.conf ,在 server ntp.ubuntu.com 下添加两行

server ntp.ubuntu.com
server 127.127.1.0
fudge 127.127.1.0 stratum 10

或者直接运行下面命令

sed -i 's/server ntp.ubuntu.com/server ntp.ubuntu.com\nserver 127.127.1.0\nfudge 127.127.1.0 stratum 10/g' /etc/ntp.conf

重启NTP服务

service ntp restart
cat >/root/novarc <<EOF
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=password
export MYSQL_PASS=password
export SERVICE_PASSWORD=password
export RABBIT_PASSWORD=password
export FIXED_RANGE=10.0.0.0/24
export FLOATING_RANGE=$(/sbin/ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -f2 -d ":" | awk -F "." '{print $1"."$2"."$3}').224/27
export OS_AUTH_URL="http://localhost:5000/v2.0/"
export SERVICE_ENDPOINT="http://localhost:35357/v2.0"
export SERVICE_TOKEN=$(openssl rand -hex 10)
export MASTER="$(/sbin/ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -f2 -d ":")"
export LOCAL_IP="$(/sbin/ifconfig eth1 | awk '/inet addr/ {print $2}' | cut -f2 -d ":")"
EOF

你可以根据你的需要调整用户的密码。

source novarc
echo "source novarc">>.bashrc

Mysql

下面是我们需要用到的数据库

数据库 用户 密码 mysql root password nova nova password keystone keystone password glance glance password cinder cinder password quantum quantum password      

设置自动安装,无需输入密码

cat <<MYSQL_PRESEED | debconf-set-selections
mysql-server-5.5 mysql-server/root_password password $MYSQL_PASS
mysql-server-5.5 mysql-server/root_password_again password $MYSQL_PASS
mysql-server-5.5 mysql-server/start_on_boot boolean true
MYSQL_PRESEED

安装mysql

apt-get -y install mysql-server python-mysqldb

运行远程访问mysql

sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
service mysql restart

创建数据库

mysql -uroot -p$MYSQL_PASS <<EOF
CREATE DATABASE nova;
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY '$MYSQL_PASS';
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '$MYSQL_PASS';
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%'IDENTIFIED BY '$MYSQL_PASS';
CREATE DATABASE cinder;
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%'IDENTIFIED BY '$MYSQL_PASS';
CREATE DATABASE quantum;
GRANT ALL PRIVILEGES ON quantum.* TO 'quantum'@'%'IDENTIFIED BY '$MYSQL_PASS';
FLUSH PRIVILEGES;
EOF

RabbitMQ

apt-get -y install rabbitmq-server

修改默认密码

我们把默认密码 guest,改成password

rabbitmqctl change_password guest $RABBIT_PASSWORD

Keystone

apt-get -y install keystone python-keystone python-keystoneclient

编辑 /etc/keystone/keystone.conf

[DEFAULT]
admin_token = d111cf2d97251a9e0422
bind_host = 0.0.0.0
public_port = 5000
admin_port = 35357
compute_port = 8774
verbose = True
debug = True
log_file = keystone.log
log_dir = /var/log/keystone
log_config = /etc/keystone/logging.conf
[sql]
connection = mysql://keystone:[email protected]:3306/keystone
idle_timeout = 200

或者直接运行下面脚本

sed -i -e " s/# admin_token = ADMIN/admin_token = $SERVICE_TOKEN/g; s/# bind_host = 0.0.0.0/bind_host = 0.0.0.0/g; s/# public_port = 5000/public_port = 5000/g; s/# admin_port = 35357/admin_port = 35357/g; s/# compute_port = 8774/compute_port = 8774/g; s/# verbose = True/verbose = True/g; s/# idle_timeout/idle_timeout/g" /etc/keystone/keystone.conf

使用mysql数据库

sed -i '/connection = .*/{s|sqlite:///.*|mysql://'"keystone"':'"$MYSQL_PASS"'@'"$MASTER"'/keystone|g}' /etc/keystone/keystone.conf

重启服务和初始化数据库

service keystone restart
keystone-manage db_sync

导入keystone数据

keystone-data.sh

wget http://www.chenshake.com/wp-content/uploads/2012/09/keystone-data.sh_.txt
mv keystone-data.sh_.txt keystone-data.sh
bash keystone-data.sh

导入endpoint

keystone-endpoints.sh

wget http://www.chenshake.com/wp-content/uploads/2012/09/keystone-endpoints.sh_.txt
mv keystone-endpoints.sh_.txt keystone-endpoints.sh
bash keystone-endpoints.sh

Glance

apt-get -y install glance glance-api python-glanceclient glance-common

编辑/etc/glance/glance-api.conf 和 /etc/glance/glance-registry.conf ,两个文件,都是修改4个地方

sql_connection = mysql://glance:[email protected]/glance
admin_tenant_name = service
admin_user = glance
admin_password = password

或者直接运行下面脚本实现

sed -i -e " s/%SERVICE_TENANT_NAME%/service/g; s/%SERVICE_USER%/glance/g; s/%SERVICE_PASSWORD%/$SERVICE_PASSWORD/g; " /etc/glance/glance-api.conf /etc/glance/glance-registry.conf
sed -i '/sql_connection = .*/{s|sqlite:///.*|mysql://'"glance"':'"$MYSQL_PASS"'@'"$MASTER"'/glance|g}' /etc/glance/glance-registry.conf /etc/glance/glance-api.conf

编辑 /etc/glance/glance-api.conf

#notifier_strategy = noop
notifier_strategy = rabbit

#rabbit_password = guest
rabbit_password = password

运行下面命令进行修改

sed -i " s/notifier_strategy = noop/notifier_strategy = rabbit/g;s/rabbit_password = guest/rabbit_password = $RABBIT_PASSWORD/g;" /etc/glance/glance-api.conf

运行下面命令

cat <<EOF >>/etc/glance/glance-api.conf
flavor = keystone+cachemanagement
EOF
cat <<EOF >>/etc/glance/glance-registry.conf 
flavor = keystone
EOF
service glance-api restart && service glance-registry restart

同步数据库

glance-manage db_sync

下载Image

我们下载CirrOS的image作为测试使用,只有10M。如果是ubuntu官方的image,220M,并且ubuntu官方的image,都是需要使用密钥登陆。

CirrOS

下载image

wget https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img

上传image

glance image-create --name=cirros-0.3.0-x86_64 --public  --container-format=bare \
--disk-format=qcow2 < /root/cirros-0.3.0-x86_64-disk.img

Cirros,是可以使用用户名和密码登陆,也可以使用密钥登陆

user:cirros
password:cubswin:)

Ubuntu官方image

下载image

wget http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img

上传image

glance image-create --name="Ubuntu 12.04 cloudimg amd64" --public \
--container-format=ovf --disk-format=qcow2 < /root/precise-server-cloudimg-amd64-disk1.img

user:ubuntu

只能使用密钥登陆。

查看image

glance image-list

查看image详细信息

glance image-show 12e2b864-9601-4506-b19d-3f663c0b2e15
apt-get -y install nova-api nova-cert nova-common \
nova-scheduler python-nova python-novaclient nova-consoleauth novnc nova-novncproxy

编辑 /etc/nova/api-paste.ini

[filter:authtoken]
paste.filter_factory = keystone.middleware.auth_token:filter_factory
auth_host = 10.1.199.58
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = nova
admin_password = password
signing_dirname = /tmp/keystone-signing-nova

或者直接运行命令

sed -i -e "s/127.0.0.1/$MASTER/g; s/%SERVICE_TENANT_NAME%/service/g;  s/%SERVICE_USER%/nova/g; s/%SERVICE_PASSWORD%/$SERVICE_PASSWORD/g; " /etc/nova/api-paste.ini

创建 /etc/nova/nova.conf 文件,直接copy下面的命令,运行就可以。

cat >/etc/nova/nova.conf <<EOF
[DEFAULT]
logdir=/var/log/nova
state_path=/var/lib/nova
lock_path=/run/lock/nova
verbose=False
api_paste_config=/etc/nova/api-paste.ini
scheduler_driver=nova.scheduler.simple.SimpleScheduler
s3_host=$MASTER
ec2_host=$MASTER
ec2_dmz_host=$MASTER
rabbit_host=$MASTER
rabbit_password=$RABBIT_PASSWORD
cc_host=$MASTER
nova_url=http://$MASTER:8774/v1.1/
sql_connection=mysql://nova:$MYSQL_PASS@$MASTER/nova
ec2_url=http://$MASTER:8773/services/Cloud
root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf

# Auth
use_deprecated_auth=false
auth_strategy=keystone
keystone_ec2_url=http://$MASTER:5000/v2.0/ec2tokens
# Imaging service
glance_api_servers=$MASTER:9292
image_service=nova.image.glance.GlanceImageService

# Vnc configuration
novnc_enabled=true
novncproxy_base_url=http://$MASTER:6080/vnc_auto.html
novncproxy_port=6080
vncserver_proxyclient_address=127.0.0.1
vncserver_listen=0.0.0.0

# Network settings
network_api_class=nova.network.quantumv2.api.API
quantum_url=http://$MASTER:9696
quantum_auth_strategy=keystone
quantum_admin_tenant_name=service
quantum_admin_username=quantum
quantum_admin_password=$SERVICE_PASSWORD
quantum_admin_auth_url=http://$MASTER:35357/v2.0
libvirt_vif_driver=nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver
linuxnet_interface_driver=nova.network.linux_net.LinuxOVSInterfaceDriver
firewall_driver=nova.virt.libvirt.firewall.IptablesFirewallDriver

# Compute #
compute_driver=libvirt.LibvirtDriver

# Cinder #
volume_api_class=nova.volume.cinder.API
osapi_volume_listen_port=5900
EOF

同步数据库

nova-manage db sync
service nova-api restart
service nova-cert restart
service nova-consoleauth restart
service nova-scheduler restart
service nova-novncproxy restart
cd /etc/init.d/; for i in $( ls nova-* ); do sudo service $i restart; done
nova-manage service list
nova

Open-vSwitch

apt-get install -y openvswitch-switch
ovs-vsctl add-br br-ex
ovs-vsctl add-port br-ex eth1

大家可以通过下面命令来查看你创建的效果, 具体的用途,正在学习中.

ovs-vsct -h
ovs-vsctl list-br
ovs-vsctl show

Quantum

apt-get -y install quantum-server python-cliff \
quantum-plugin-openvswitch-agent \
quantum-l3-agent quantum-dhcp-agent python-pyparsing

编辑 /etc/quantum/quantum.conf

auth_strategy = keystone
fake_rabbit = False
rabbit_host = 10.1.199.58
rabbit_password = password

或者运行下面命令

sed -i -e " s/# auth_strategy/auth_strategy/g; s/# fake_rabbit/fake_rabbit/g; s/# rabbit_host = localhost/rabbit_host = $MASTER/g; s/# rabbit_password = guest/rabbit_password = $RABBIT_PASSWORD/g" /etc/quantum/quantum.conf

编辑 /etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini

#Under the database section
[DATABASE]
sql_connection = mysql://quantum:[email protected]/quantum

#Under the OVS section
[OVS]
tenant_network_type=vlan
network_vlan_ranges = physnet1:1:4094

或者运行下面命令

sed -i -e " s/# Example: tenant_network_type = gre/tenant_network_type = vlan/g; s/# Example: network_vlan_ranges = physnet1:1000:2999/network_vlan_ranges = physnet1:1:4094/g" /etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini 
sed -i '/sql_connection = .*/{s|sqlite:///.*|mysql://'"quantum"':'"password"'@'"$MASTER"'/quantum|g}' /etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini

编辑 /etc/quantum/l3_agent.ini 和 /etc/quantum/api-paste.ini

[DEFAULT]
admin_tenant_name = service
admin_user = quantum
admin_password = password

或者运行下面命令

sed -i -e " s/%SERVICE_TENANT_NAME%/service/g; s/%SERVICE_USER%/quantum/g; s/%SERVICE_PASSWORD%/$SERVICE_PASSWORD/g; " /etc/quantum/l3_agent.ini  /etc/quantum/api-paste.ini
service quantum-server restart
service quantum-plugin-openvswitch-agent restart
service quantum-dhcp-agent restart
service quantum-l3-agent restart

Cinder

apt-get install -y cinder-api cinder-scheduler cinder-volume iscsitarget \
open-iscsi iscsitarget-dkms python-cinderclient

我的硬盘专门一个分区给volume使用

umount /dev/sda5
pvcreate /dev/sda5
vgcreate cinder-volumes /dev/sda5

去掉开机挂载

sed -i '/nova-volume/s/^/#/' /etc/fstab

iscsi

sed -i 's/false/true/g' /etc/default/iscsitarget
service iscsitarget restart
service open-iscsi restart

编辑 /etc/cinder/cinder.conf ,直接运行下面命令就可以.

cat >/etc/cinder/cinder.conf <<EOF
[DEFAULT]
rootwrap_config = /etc/cinder/rootwrap.conf
sql_connection = mysql://cinder:$MYSQL_PASS@$MASTER:3306/cinder
api_paste_confg = /etc/cinder/api-paste.ini
iscsi_helper = ietadm 
volume_group = cinder-volumes
volume_name_template = volume-%s
rabbit_password = $RABBIT_PASSWORD
logdir = /var/log/cinder
verbose = False
auth_strategy = keystone
EOF

编辑 /etc/cinder/api-paste.ini

admin_tenant_name = service
admin_user = cinder 
admin_password = password

或者用下面命令

sed -i -e " s/%SERVICE_TENANT_NAME%/service/g; s/%SERVICE_USER%/cinder/g; s/%SERVICE_PASSWORD%/$SERVICE_PASSWORD/g; " /etc/cinder/api-paste.ini

同步数据库

cinder-manage db sync
service cinder-api restart
service cinder-scheduler  restart
service cinder-volume restart

Horizon

apt-get -y install apache2 libapache2-mod-wsgi openstack-dashboard memcached python-memcache

编辑 /etc/openstack-dashboard/local_settings.py,删除ubuntu主题,默认的主题有问题,注释掉下面内容

#Comment these lines
#Enable the Ubuntu theme if it is present.
#try:
#    from ubuntu_theme import *
#except ImportError:
#    pass
service apache2 restart; service memcached restart

http://10.1.199.58/horizon
user:admin
pass:password
或者
user:demo
pass:password

看一下中文的Dashboard,由于在控制节点没有安装计算服务,所以你是无法创建虚拟机。

操作系统最小化安装,ssh server就可以。

添加Folsom源

cat <<EOF >>/etc/apt/sources.list
deb  http://ubuntu-cloud.archive.canonical.com/ubuntu precise-proposed/folsom main
deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/folsom main
EOF

运行下面命令

apt-get install ubuntu-cloud-keyring
apt-get update && apt-get -y dist-upgrade
# cat /etc/network/interfaces 
# This file describes network interfaces avaiulable on your system
# and how to activate them. For more information, see interfaces(5).
# Modified by convert_static.sh.
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.1.199.6
hwaddress ether 00:25:90:2d:7a:42  
netmask 255.255.255.0
network 10.1.199.0
gateway 10.1.199.1
dns-search chenshake.com
dns-nameservers 8.8.8.8

# VMs Networks with OVS in tunnel mode
auto eth1
    iface eth1 inet static
    address 10.0.0.4
    netmask 255.255.255.0

/etc/init.d/networking restart
sed -i -r 's/^\s*#(net\.ipv4\.ip_forward=1.*)/\1/' /etc/sysctl.conf
echo 1 > /proc/sys/net/ipv4/ip_forward 
cat >/root/novarc <<EOF
export CONTROLLER_IP=10.1.199.58
export MASTER="$(/sbin/ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -f2 -d ":")"
export LOCAL_IP="$(/sbin/ifconfig eth1 | awk '/inet addr/ {print $2}' | cut -f2 -d ":")"
EOF

你根据你的情况,调整控制节点的IP

source novarc
echo "source novarc">>.bashrc
apt-get -y install ntp

编辑 /etc/ntp.conf, 指向控制节点

server 10.1.199.58

或者运行命令

sed -i -e " s/server ntp.ubuntu.com/server $CONTROLLER_IP/g" /etc/ntp.conf
service ntp restart

Hypervisor

apt-get install -y kvm libvirt-bin pm-utils

编辑 /etc/libvirt/qemu.conf ,添加下面内容

cgroup_device_acl = [
    "/dev/null", "/dev/full", "/dev/zero",
    "/dev/random", "/dev/urandom",
    "/dev/ptmx", "/dev/kvm", "/dev/kqemu",
    "/dev/rtc", "/dev/hpet","/dev/net/tun",
]

或者运行命令:这个地方用命令修改有点复杂,还没找到太好的办法。

cat <<EOF>>/etc/libvirt/qemu.conf
cgroup_device_acl = [
    "/dev/null", "/dev/full", "/dev/zero",
    "/dev/random", "/dev/urandom",
    "/dev/ptmx", "/dev/kvm", "/dev/kqemu",
    "/dev/rtc", "/dev/hpet","/dev/net/tun",
]
EOF

删除默认 virtual bridge

virsh net-destroy default
virsh net-undefine default

编辑 /etc/libvirt/libvirtd.conf, 去掉这三行的注释

listen_tls = 0
listen_tcp = 1
auth_tcp = "none" 

或者运行下面命令

sed -i '/#listen_tls/s/#listen_tls/listen_tls/; /#listen_tcp/s/#listen_tcp/listen_tcp/; /#auth_tcp/s/#auth_tcp/auth_tcp/; /auth_tcp/s/sasl/none/'  /etc/libvirt/libvirtd.conf

编辑 /etc/init/libvirt-bin.conf

env libvirtd_opts="-d -l" 

或者使用命令

sed -i '/env libvirtd_opts/s/-d/-d –l/' /etc/init/libvirt-bin.conf

编辑 /etc/default/libvirt-bin

libvirtd_opts="-d -l"

或者使用命令

sed -i '/libvirtd_opts/s/-d/-d -l/' /etc/default/libvirt-bin
service libvirt-bin restart

Open-vSwitch

apt-get install -y openvswitch-switch

创建bridge

ovs-vsctl add-br br-int
ovs-vsctl add-br br-eth1
ovs-vsctl add-port br-eth1 eth1

Quantum

apt-get -y install quantum-plugin-openvswitch-agent

编辑 /etc/quantum/quantum.conf , 修改和控制节点一样,直接从控制直接复制过来

scp root@$CONTROLLER_IP:/etc/quantum/quantum.conf /etc/quantum/quantum.conf

编辑 /etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini,可以从控制节点copy过来

scp root@$CONTROLLER_IP:/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini /etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini

启动agent

service quantum-plugin-openvswitch-agent restart
apt-get -y install nova-api-metadata nova-compute-kvm novnc nova-novncproxy

编辑 /etc/nova/api-paste.ini

[filter:authtoken]
paste.filter_factory = keystone.middleware.auth_token:filter_factory
auth_host = 10.1.199.58
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = nova
admin_password = password
signing_dirname = /tmp/keystone-signing-nova

或者运行下面命令,直接从控制节点复制过来就可以。

scp root@$CONTROLLER_IP:/etc/nova/api-paste.ini /etc/nova/

编辑 /etc/nova/nova-compute.conf

[DEFAULT]
libvirt_type=kvm
libvirt_ovs_bridge=br-int
libvirt_vif_type=ethernet
libvirt_vif_driver=nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver
libvirt_use_virtio_for_bridges=True

或者运行下面命令

cat > /etc/nova/nova-compute.conf <<EOF
[DEFAULT]
libvirt_type=kvm
libvirt_ovs_bridge=br-int
libvirt_vif_type=ethernet
libvirt_vif_driver=nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver
libvirt_use_virtio_for_bridges=True
EOF

编辑 /etc/nova/nova.conf。我们可以从控制节点copy过来修改

scp root@$CONTROLLER_IP:/etc/nova/nova.conf /etc/nova/nova.conf

修改vnc

# Vnc configuration
novnc_enabled=true
novncproxy_base_url=http://10.1.199.58:6080/vnc_auto.html
novncproxy_port=6080
vncserver_proxyclient_address=10.1.199.6
vncserver_listen=10.1.199.6

或者使用下面命令修改

sed -i 's/^vncserver_proxyclient_address.*$/vncserver_proxyclient_address='"$(/sbin/ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -f2 -d ":")"'/g' /etc/nova/nova.conf
sed -i 's/^vncserver_listen.*$/vncserver_listen='"$(/sbin/ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -f2 -d ":")"'/g' /etc/nova/nova.conf
service nova-api-metadata restart
service nova-novncproxy restart 
service nova-compute restart
cd /etc/init.d/; for i in $( ls nova-* ); do sudo service $i restart; done
nova-manage service list

这是一个大工程,目前还没办法用脚本来实现,也就只能step by step。不过这个过程,倒是可以帮助你深入了解一下quantum。下面的步骤,大家需要小心就可以。我验证过一次。

查看member roles ID

keystone role-list

查看service 租户的ID

keystone tenant-list

创建一个租户

keystone tenant-create --name project_one

创建一个用户:user_one,roles是成员角色

keystone user-create --name=user_one --pass=user_one --tenant-id $put_id_of_project_one [email protected]
keystone user-role-add --tenant-id $put_id_of_project_one  --user-id $put_id_of_user_one --role-id $put_id_of_member_role

为该租户创建一个网络

quantum net-create --tenant-id $put_id_of_project_one net_proj_one --provider:network_type vlan --provider:physical_network physnet1 --provider:segmentation_id 1024

为租户创建一个子网

quantum subnet-create --tenant-id $put_id_of_project_one net_proj_one 10.10.10.0/24

为租户创建一个路由

quantum router-create --tenant_id $put_id_of_project_one router_proj_one

路由和网络进行关联

quantum router-interface-add $put_router_proj_one_id_here $put_subnet_id_here

创建外部网络(service 租户的ID,通过 keystone tenant-list 查看)

quantum net-create --tenant-id $put_id_of_service_tenant ext_net --router:external=True

编辑/etc/quantum/l3_agent.ini

gateway_external_net_id = $id_of_ext_net
router_id = $your_router_id

设置floating IP

quantum subnet-create --tenant-id $put_id_of_service_tenant --gateway 10.1.199.1 ext_net 10.1.199.224/27 --enable_dhcp=False

设置外部网络路由

quantum router-gateway-set $put_router_proj_one_id_here $put_id_of_ext_net_proj_one_here

更新br-ex

ip addr flush dev br-ex
ip addr add 10.1.199.224/27 dev br-ex
ip link set br-ex up

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK