阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

OpenStack/devstack with Neutron on Ubuntu 14.04

217次阅读
没有评论

共计 14186 个字符,预计需要花费 36 分钟才能阅读完成。

安装前,推荐安装一个全新的 Ubuntu Server 14.04,如果使用之前的 Ubuntu,中间可能遇到各种的 Python 包依赖,以及软件版本不对应的问题

  • 环境准备,新建 stack 用户,给予 sudo 权限,更新系统软件包
 1 # add user 'stack'
 2 sudo su
 3 useradd -m -p welcome -s /bin/bash stack
 4 # add sudo previledge
 5 sudo su
 6 # Modify /etc/sudoers
 7 cat >>/etc/sudoers <<'EOF'
 8 
 9 stack   ALL=(ALL) NOPASSWD: ALL
10 Defaults:stack !requiretty
11 EOF
12 
13 exit
14 
15 
16 # Update software respository cache
17 sudo apt-get install -y python-software-properties
18 sudo add-apt-repository cloud-archive:juno
19 sudo apt-get update -y && sudo apt-get dist-upgrade -y
20 sudo shutdown -r now
  • 下载 devstack,配置 local.conf
# install git download devstack
sudo apt-get install -qqy git git clone http:
//www.github.com/openstack-dev/devstack.git cd devstack touch local.conf vim local.conf #place following in local.conf, change the HOST_IP and SERVICE_HOST to the IP of eth0 [[local|localrc]] HOST_IP=192.168.20.140 SERVICE_HOST=192.168.20.140 ADMIN_PASSWORD=welcome DATABASE_PASSWORD=$ADMIN_PASSWORD RABBIT_PASSWORD=$ADMIN_PASSWORD SERVICE_PASSWORD=$ADMIN_PASSWORD SERVICE_TOKEN=$ADMIN_PASSWORD DEST=/opt/stack LOGFILE=$DEST/logs/stack.sh.log SCREEN_LOGDIR=$DEST/logs/screen OFFLINE=False RECLONE=True LOG_COLOR=False disable_service horizon enable_service q-svc enable_service q-agt enable_service q-dhcp enable_service q-l3 enable_service q-meta enable_service neutron disable_service n-net disable_service tempest disable_service h-eng,h-api,h-api-cfn,h-api-cw PHYSICAL_NETWORK=physnet1 FIXED_RANGE=192.168.106.0/24 FIXED_NETWORK_SIZE=32 NETWORK_GATEWAY=192.168.106.1 [[post-config|/$Q_PLUGIN_CONF_FILE]] [ml2] tenant_network_types = vlan [ml2_type_vlan] network_vlan_ranges = physnet1:100:110 [ovs] bridge_mappings = physnet1:br-eth1 enable_tunneling = False
  • 启动安装 devstack
# 由于国内对 git 可能进行了 block,所以如果不能访问 git:这种地址,可以换成 http:的试试 
sed -i 's|GIT_BASE:-git://git.openstack.org|GIT_BASE:-http://git.openstack.org|' stackrc
cd ~/devstack
./stack.sh
  • 配置虚拟网桥
#add br-eth1 add connect with eth1
sudo ovs-vsctl add-br br-eth1
sudo ovs-vsctl --may-exist add-port br-eth1 eth1
# set eth1 to promisc mode, so that it can pass any package in L2
sudo ip link set dev eth1 promisc on
sudo ip addr flush eth1
sudo ip link set dev eth1 up

这样一个带 neutron 的 devstack 环境就架设好了,这个过程我想不会顺利,devstack/openstack 时常在更新,所以每天都会有不同的问题,大家如果安装遇到问题,可以留言讨论,当然如果文档有问题,也烦请指出。

下面是小编为你精选的 Openstack 相关知识,看看是否有你喜欢的

在 Ubuntu 12.10 上安装部署 Openstack http://www.linuxidc.com/Linux/2013-08/88184.htm

Ubuntu 12.04 OpenStack Swift 单节点部署手册 http://www.linuxidc.com/Linux/2013-08/88182.htm

OpenStack 云计算快速入门教程 http://www.linuxidc.com/Linux/2013-08/88186.htm

企业部署 OpenStack:该做与不该做的事 http://www.linuxidc.com/Linux/2013-09/90428.htm

CentOS 6.5 x64bit 快速安装 OpenStack http://www.linuxidc.com/Linux/2014-06/103775.htm

更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2016-01/127509p2.htm

在前面的文章中,已经完成了 devstack 的安装。下面,我会介绍如何使用 neutron

  • 首先创建两个 neutron net, vmnet1 和 vmnet2
stack@Ubuntu:~/devstack$ source openrc admin admin
stack@ubuntu:~/devstack$ neutron net-list
+--------------------------------------+---------+-------------------------------------------------------+
| id                                   | name    | subnets                                               |
+--------------------------------------+---------+-------------------------------------------------------+
| 5365b56f-9544-40d4-b065-a9d50126b55b | private | fc3a839e-412c-4f0d-b1ed-87be1a7b0bf8 192.168.106.0/24 |
| a101e11f-7bbe-4f4d-a52e-5bb312d5f8b9 | public  | 570e8b64-8332-41f7-8780-12d9bc54f195 172.24.4.0/24    |
+--------------------------------------+---------+-------------------------------------------------------+
stack@ubuntu:~/devstack$ neutron net-create vmnet1
Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| id                        | 54028daa-9158-4fc7-9f97-d400dc801e97 |
| name                      | vmnet1                               |
| provider:network_type     | vlan                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  | 352                                  |
| router:external           | False                                |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tenant_id                 | dcf6685a3e304e4c92af08bca762aa33     |
+---------------------------+--------------------------------------+
stack@ubuntu:~/devstack$ neutron net-create vmnet2
Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| id                        | 7b0394ec-34c0-48d3-a17d-82ef9bbc2cd9 |
| name                      | vmnet2                               |
| provider:network_type     | vlan                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  | 353                                  |
| router:external           | False                                |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tenant_id                 | dcf6685a3e304e4c92af08bca762aa33     |
+---------------------------+--------------------------------------+
stack@ubuntu:~/devstack$ neutron net-list
+--------------------------------------+---------+-------------------------------------------------------+
| id                                   | name    | subnets                                               |
+--------------------------------------+---------+-------------------------------------------------------+
| 5365b56f-9544-40d4-b065-a9d50126b55b | private | fc3a839e-412c-4f0d-b1ed-87be1a7b0bf8 192.168.106.0/24 |
| a101e11f-7bbe-4f4d-a52e-5bb312d5f8b9 | public  | 570e8b64-8332-41f7-8780-12d9bc54f195 172.24.4.0/24    |
| 54028daa-9158-4fc7-9f97-d400dc801e97 | vmnet1  |                                                       |
| 7b0394ec-34c0-48d3-a17d-82ef9bbc2cd9 | vmnet2  |                                                       |
+--------------------------------------+---------+-------------------------------------------------------+ 
  • 现在两个网络就创建好了,但现在其实这是两个独立的网络,是不互通的,接下来创建 router:router-vmnet1-vmnet2
stack@ubuntu:~/devstack$ neutron router-create router-vmnet1-vmnet2
Created a new router:
+-----------------------+--------------------------------------+
| Field                 | Value                                |
+-----------------------+--------------------------------------+
| admin_state_up        | True                                 |
| distributed           | False                                |
| external_gateway_info |                                      |
| ha                    | False                                |
| id                    | 4bef86df-3b13-4b23-80f0-3a2bd8d0c746 |
| name                  | router-vmnet1-vmnet2                 |
| routes                |                                      |
| status                | ACTIVE                               |
| tenant_id             | dcf6685a3e304e4c92af08bca762aa33     |
+-----------------------+--------------------------------------+
  • 在 vmnet1 和 vmnet2 中,分别创建 subnet
stack@ubuntu:~/devstack$ neutron subnet-create 54028daa-9158-4fc7-9f97-d400dc801e97 30.30.30.0/24
Created a new subnet:
+-------------------+------------------------------------------------+
| Field             | Value                                          |
+-------------------+------------------------------------------------+
| allocation_pools  | {"start": "30.30.30.2", "end": "30.30.30.254"} |
| cidr              | 30.30.30.0/24                                  |
| dns_nameservers   |                                                |
| enable_dhcp       | True                                           |
| gateway_ip        | 30.30.30.1                                     |
| host_routes       |                                                |
| id                | c0be451f-91a1-4f9f-a29b-13adea79798e           |
| ip_version        | 4                                              |
| ipv6_address_mode |                                                |
| ipv6_ra_mode      |                                                |
| name              |                                                |
| network_id        | 54028daa-9158-4fc7-9f97-d400dc801e97           |
| tenant_id         | dcf6685a3e304e4c92af08bca762aa33               |
+-------------------+------------------------------------------------+
stack@ubuntu:~/devstack$ neutron subnet-create 7b0394ec-34c0-48d3-a17d-82ef9bbc2cd9 40.40.40.0/24
Created a new subnet:
+-------------------+------------------------------------------------+
| Field             | Value                                          |
+-------------------+------------------------------------------------+
| allocation_pools  | {"start": "40.40.40.2", "end": "40.40.40.254"} |
| cidr              | 40.40.40.0/24                                  |
| dns_nameservers   |                                                |
| enable_dhcp       | True                                           |
| gateway_ip        | 40.40.40.1                                     |
| host_routes       |                                                |
| id                | 0b9c9ad8-3309-4c96-afda-ecb7e53dc519           |
| ip_version        | 4                                              |
| ipv6_address_mode |                                                |
| ipv6_ra_mode      |                                                |
| name              |                                                |
| network_id        | 7b0394ec-34c0-48d3-a17d-82ef9bbc2cd9           |
| tenant_id         | dcf6685a3e304e4c92af08bca762aa33               |
+-------------------+------------------------------------------------+
OpenStack/devstack with Neutron on Ubuntu 14.04
  • 接下来,给 router 加入 interface,分别连接到 vmnet1 的 subnet 和 vmnet2 的 subnet
stack@ubuntu:~/devstack$ neutron router-interface-add 4bef86df-3b13-4b23-80f0-3a2bd8d0c746 subnet=c0be451f-91a1-4f9f-a29b-13adea79798e
Added interface 8fc6f138-150c-47de-8c88-fa924ce2302d to router 4bef86df-3b13-4b23-80f0-3a2bd8d0c746.
stack@ubuntu:~/devstack$ neutron router-interface-add 4bef86df-3b13-4b23-80f0-3a2bd8d0c746 subnet=0b9c9ad8-3309-4c96-afda-ecb7e53dc519
Added interface 4e830e98-e24b-45dd-bc6e-338e47b31b1b to router 4bef86df-3b13-4b23-80f0-3a2bd8d0c746.
  • 然后,我们看,Linux 网络配置上的变化,首先是 network namespace,你会发现名为 qrouter-4bef86df-3b13-4b23-80f0-3a2bd8d0c746 的 Linux Namespace 创建成功
stack@ubuntu:~/devstack$ sudo ip netns exec qrouter-4bef86df-3b13-4b23-80f0-3a2bd8d0c746  ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link
/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet
127.0.0.1/8 scope host lo
      valid_lft forever preferred_lft forever
    inet6 ::
1/128 scope host
      valid_lft forever preferred_lft forever
15: qr-4e830e98-e2: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
    link
/ether fa:16:3e:8c:4d:c7 brd ff:ff:ff:ff:ff:ff
    inet
40.40.40.1/24 brd 40.40.40.255 scope global qr-4e830e98-e2
      valid_lft forever preferred_lft forever
    inet6 fe80::f816:3eff:fe8c:4dc7
/64 scope link
      valid_lft forever preferred_lft forever
16: qr-8fc6f138-15: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
    link
/ether fa:16:3e:67:b5:14 brd ff:ff:ff:ff:ff:ff
    inet
30.30.30.1/24 brd 30.30.30.255 scope global qr-8fc6f138-15
      valid_lft forever preferred_lft forever
    inet6 fe80::f816:3eff:fe67:b514
/64 scope link
      valid_lft forever preferred_lft forever
OpenStack/devstack with Neutron on Ubuntu 14.04
  • 上图的 qr-4e830e98-e2 和 qr-8fc6f138-15,可以理解为 vmnet1 和 vmnet2 的 gateway,同时它们也都连接在 ovs 的 br-int bridge 上,如下:
stack@ubuntu:~/devstack$ sudo ovs-vsctl show
…….
    Bridge br
int
        fail_mode: secure
        Port
patchtun
            Interface
patchtun
                type:
patch
                options: {peer
=patchint}
        Port
qr-4e830e98-e2
            tag:
3
            Interface
qr-4e830e98-e2
                type: internal
        Port br
int
            Interface br
int
                type: internal
        Port
int-br-eth1
            Interface
int-br-eth1
                type:
patch
                options: {peer
=phy-br-eth1}
        Port
qr-8fc6f138-15
            tag:
2
            Interface
qr-8fc6f138-15
                type: internal
        Port
qr-a6466103-17
            tag:
1
            Interface
qr-a6466103-17
                type: internal
从上面的输出可以看出 ”qr-4e830e98-e2″ is tagged with 3, “qr-8fc6f138-15″is tagged with 2
  • 接下来,我要在 vmnet1 和 vmnet2 上分别创建一个 virtual machine instance,看看 openstack neutron 中发生了什么!
# 注意,这个一定要先增加这个,不然,后面的 vm 启动无法得到 IP,参见我的异常处理部分
stack@ubuntu:
~/devstack$ nova secgroup-add-rule default icmp –11 0.0.0.0/0
stack@ubuntu:
~/devstack$ nova secgroup-add-rule default tcp 22 22 0.0.0.0/0

# 创建两个 vm

stack@ubuntu:~/devstack$ nova boot –image 54bdfba1-27f7-4fae-99f1-cfbbca78c9bd –flavor m1.tiny –nic net-id=54028daa-9158-4fc7-9f97-d400dc801e97 vm1

stack@ubuntu:~/devstack$ nova boot –image 54bdfba1-27f7-4fae-99f1-cfbbca78c9bd –flavor m1.tiny –nic net-id=7b0394ec-34c0-48d3-a17d-82ef9bbc2cd9 vm2

# 查看 vm 是否 ready

stack@ubuntu:~/devstack$ nova list

+————————————–+——+——–+————+————-+——————-+

| ID                                   | Name | Status | Task State | Power State | Networks          |

+————————————–+——+——–+————+————-+——————-+

| b22e706b-a1aa-4f73-9bd5-5f70bbf7e299 | vm1  | ACTIVE | –          | Running     | vmnet1=30.30.30.2 |

| 1f4fad7d-8eb9-4011-b196-337dea3d7d66 | vm2  | ACTIVE | –          | Running     | vmnet2=40.40.40.2 |

+————————————–+——+——–+————+————-+——————-+

现在这两个 ip 30.30.30.2 和 40.40.40.2 是无法直接 ping 同的,因为是被 Linux Namespace 隔离的
stack@ubuntu:~/devstack$ ping 30.30.30.2
PING 30.30.30.2 (30.30.30.2) 56(84) bytes of data.
^C
--- 30.30.30.2 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3000ms


stack@ubuntu:~/devstack$ ping 40.40.40.2
PING 40.40.40.2 (40.40.40.2) 56(84) bytes of data.
^C
--- 40.40.40.2 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3000ms
  • 你可以这样在主机上 ssh 到 vm 上,这里我们以 ssh 到 vm1 为例:首先确定 vm1 所在的 network 为 vmnet1,vmnet1 对应的 namespace 为 qdhcp-54028daa-9158-4fc7-9f97-d400dc801e97,然后
ip netns exec qqdhcp-54028daa-9158-4fc7-9f97-d400dc801e97 ssh cirros@30.30.30.2

密码为   cubswin:)

这样一个基于 neutron network 的 devstack 环境就搭建好了,大家有兴趣的话,可以一起探讨关于 neutron 跟多的东西,推荐大家几篇 Oracle 上的文章,讲的深入浅出的,很不错

https://blogs.oracle.com/ronen/entry/diving_into_openstack_network_architecture

https://blogs.oracle.com/ronen/entry/diving_into_openstack_network_architecture1

https://blogs.oracle.com/ronen/entry/diving_into_openstack_network_architecture2

https://blogs.oracle.com/ronen/entry/diving_into_openstack_network_architecture3

https://blogs.oracle.com/ronen/entry/running_openstack_icehouse_with_zfs

更多 Ubuntu 相关信息见 Ubuntu 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=2

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2016-01/127509.htm

安装前,推荐安装一个全新的 Ubuntu Server 14.04,如果使用之前的 Ubuntu,中间可能遇到各种的 Python 包依赖,以及软件版本不对应的问题

  • 环境准备,新建 stack 用户,给予 sudo 权限,更新系统软件包
 1 # add user 'stack'
 2 sudo su
 3 useradd -m -p welcome -s /bin/bash stack
 4 # add sudo previledge
 5 sudo su
 6 # Modify /etc/sudoers
 7 cat >>/etc/sudoers <<'EOF'
 8 
 9 stack   ALL=(ALL) NOPASSWD: ALL
10 Defaults:stack !requiretty
11 EOF
12 
13 exit
14 
15 
16 # Update software respository cache
17 sudo apt-get install -y python-software-properties
18 sudo add-apt-repository cloud-archive:juno
19 sudo apt-get update -y && sudo apt-get dist-upgrade -y
20 sudo shutdown -r now
  • 下载 devstack,配置 local.conf
# install git download devstack
sudo apt-get install -qqy git git clone http:
//www.github.com/openstack-dev/devstack.git cd devstack touch local.conf vim local.conf #place following in local.conf, change the HOST_IP and SERVICE_HOST to the IP of eth0 [[local|localrc]] HOST_IP=192.168.20.140 SERVICE_HOST=192.168.20.140 ADMIN_PASSWORD=welcome DATABASE_PASSWORD=$ADMIN_PASSWORD RABBIT_PASSWORD=$ADMIN_PASSWORD SERVICE_PASSWORD=$ADMIN_PASSWORD SERVICE_TOKEN=$ADMIN_PASSWORD DEST=/opt/stack LOGFILE=$DEST/logs/stack.sh.log SCREEN_LOGDIR=$DEST/logs/screen OFFLINE=False RECLONE=True LOG_COLOR=False disable_service horizon enable_service q-svc enable_service q-agt enable_service q-dhcp enable_service q-l3 enable_service q-meta enable_service neutron disable_service n-net disable_service tempest disable_service h-eng,h-api,h-api-cfn,h-api-cw PHYSICAL_NETWORK=physnet1 FIXED_RANGE=192.168.106.0/24 FIXED_NETWORK_SIZE=32 NETWORK_GATEWAY=192.168.106.1 [[post-config|/$Q_PLUGIN_CONF_FILE]] [ml2] tenant_network_types = vlan [ml2_type_vlan] network_vlan_ranges = physnet1:100:110 [ovs] bridge_mappings = physnet1:br-eth1 enable_tunneling = False
  • 启动安装 devstack
# 由于国内对 git 可能进行了 block,所以如果不能访问 git:这种地址,可以换成 http:的试试 
sed -i 's|GIT_BASE:-git://git.openstack.org|GIT_BASE:-http://git.openstack.org|' stackrc
cd ~/devstack
./stack.sh
  • 配置虚拟网桥
#add br-eth1 add connect with eth1
sudo ovs-vsctl add-br br-eth1
sudo ovs-vsctl --may-exist add-port br-eth1 eth1
# set eth1 to promisc mode, so that it can pass any package in L2
sudo ip link set dev eth1 promisc on
sudo ip addr flush eth1
sudo ip link set dev eth1 up

这样一个带 neutron 的 devstack 环境就架设好了,这个过程我想不会顺利,devstack/openstack 时常在更新,所以每天都会有不同的问题,大家如果安装遇到问题,可以留言讨论,当然如果文档有问题,也烦请指出。

下面是小编为你精选的 Openstack 相关知识,看看是否有你喜欢的

在 Ubuntu 12.10 上安装部署 Openstack http://www.linuxidc.com/Linux/2013-08/88184.htm

Ubuntu 12.04 OpenStack Swift 单节点部署手册 http://www.linuxidc.com/Linux/2013-08/88182.htm

OpenStack 云计算快速入门教程 http://www.linuxidc.com/Linux/2013-08/88186.htm

企业部署 OpenStack:该做与不该做的事 http://www.linuxidc.com/Linux/2013-09/90428.htm

CentOS 6.5 x64bit 快速安装 OpenStack http://www.linuxidc.com/Linux/2014-06/103775.htm

更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2016-01/127509p2.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计14186字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中