首页 > OpenStack > OpenStack部署小记-网络节点

OpenStack部署小记-网络节点

2015年8月20日 发表评论 阅读评论

基础部署

1.IP地址设置

首先将系统安装完成,然后按照

OpenStack部署小记-架构设置


中配置网络节点的网卡
编辑 /etc/network/interfaces
写入如下内容

vi /etc/network/interfaces
# -----------------------------------------
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 10.0.1.30
        netmask 255.255.255.0

auto eth1
iface eth1 inet static
        address 10.0.3.30
        netmask 255.255.255.0

auto eth2
iface eth2 inet static
        address 10.0.8.30
        netmask 255.255.255.0
        gateway 10.0.8.254
# -----------------------------------------

然后重启网络,并启用网卡

service network restart
ifdown eth0
ifup eth0
ifdown eth1
ifup eth1
ifdown eth2
ifup eth2

查看网卡配置是否正确

ifconfig eth0
ifoonfig eth1
ifoonfig eth2

2.设置HOSTS

将四个节点的主机名分别写入到/etc/hosts中

rm -rfv /etc/hosts
echo "127.0.0.1       localhost"  >> /etc/hosts
echo "10.0.1.10       controller" >> /etc/hosts
echo "10.0.1.20       compute"    >> /etc/hosts
echo "10.0.1.30       network"    >> /etc/hosts
echo "10.0.1.40       storage"    >> /etc/hosts
echo "10.0.1.5       ubuntu-cloud.archive.canonical.com"     >> /etc/hosts

3.设置DNS

这里使用114的DNS,将DNS写入到/etc/resolv.conf中

echo "nameserver 114.114.114.114" >> /etc/resolv.conf

4.测试网络连通性

依次Ping 四个节点以及百度,测试外网是否通畅

ping -c 2 controller|grep "64 bytes from"
ping -c 2 compute|grep "64 bytes from"
ping -c 2 network|grep "64 bytes from"
ping -c 2 storage|grep "64 bytes from"
ping -c 2 www.baidu.com|grep "64 bytes from"

5.升级系统

更新软件源,升级系统

apt-get update
apt-get upgrade

6.安装 NTP 时间同步

apt-get -y install ntp

删除/var/lib/ntp/ntp.conf.dhcp

rm -rfv /var/lib/ntp/ntp.conf.dhcp

编辑/etc/ntp.conf
删除里面的所有server
server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org
ntp.ubuntu.com
新加一个server指向controller

vi /etc/ntp.conf
# -----------------------------------------
#将
#server 0.ubuntu.pool.ntp.org
#server 1.ubuntu.pool.ntp.org
#server 2.ubuntu.pool.ntp.org
#server 3.ubuntu.pool.ntp.org
#改为
server controller iburst
# -----------------------------------------

重新启动ntp服务

service ntp restart

7.配置 OpenStack 安装包源

安装Openstack的密钥环

apt-get -y install ubuntu-cloud-keyring

添加Openstack Kilo版本的安装源

echo "deb http://ubuntu-cloud.archive.canonical.com/ubuntu" "trusty-updates/kilo main">/etc/apt/sources.list.d/cloudarchive-kilo.list

这里因为OpenStack的官方源速度太酸爽,所以我花了一天时间把这个源的amd64版本全部同步下来了,在本地做了镜像源,详细过程在此

OpenStack部署小记-内网源搭建


更新源,然后升级系统

apt-get -y update
apt-get -y dist-upgrade

至此,基础服务部署完成

网络服务 Neutron

1.调整网络节点的网络参数

备份原有的参数文件

mv /etc/sysctl.conf /etc/sysctl.conf.bak
cat /etc/sysctl.conf.bak|grep -v "^#"|grep -v "^$">/etc/sysctl.conf

设置网络参数,编辑/etc/sysctl.conf

vi /etc/sysctl.conf
# -----------------------------------------
#开启ipv4的转发
net.ipv4.ip_forward = 1
#开启ipv4上所有的反向过滤
net.ipv4.conf.all.rp_filter = 0
#开启ipv4上默认的反向过滤
net.ipv4.conf.default.rp_filter = 0
# -----------------------------------------

生效配置

sysctl -p

2.安装 Neutron

apt-get -y install neutron-plugin-ml2 neutron-plugin-openvswitch-agent neutron-l3-agent neutron-dhcp-agent neutron-metadata-agent

3.配置 Neutron

首先去掉配置文件的注释和空行,并且进行备份

mv /etc/neutron/neutron.conf /etc/neutron/neutron.conf.bak
cat /etc/neutron/neutron.conf.bak |grep -v "^#"|grep -v "^$">/etc/neutron/neutron.conf
mv /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugins/ml2/ml2_conf.ini.bak
cat /etc/neutron/plugins/ml2/ml2_conf.ini.bak|grep -v "^#"|grep -v "^$">/etc/neutron/plugins/ml2/ml2_conf.ini
mv /etc/neutron/l3_agent.ini /etc/neutron/l3_agent.ini.bak
cat /etc/neutron/l3_agent.ini.bak|grep -v "^#"|grep -v "^$">/etc/neutron/l3_agent.ini
mv /etc/neutron/dhcp_agent.ini /etc/neutron/dhcp_agent.ini.bak
cat /etc/neutron/dhcp_agent.ini.bak|grep -v "^#"|grep -v "^$">/etc/neutron/dhcp_agent.ini
mv /etc/neutron/metadata_agent.ini /etc/neutron/metadata_agent.ini.bak
cat /etc/neutron/metadata_agent.ini.bak|grep -v "^#"|grep -v "^$">/etc/neutron/metadata_agent.ini

设置neutron,编辑/etc/neutron/neutron.conf

vi /etc/neutron/neutron.conf
# -----------------------------------------
[DEFAULT]
#消息队列使用RabbitMQ
rpc_backend = rabbit
#指定认证使用keystone
auth_strategy = keystone
#指定核心插件为ml2
core_plugin = ml2
#指定开启路由服务
service_plugins = router
#指定允许IP地址重叠
allow_overlapping_ips = True
#显示详细日志输出
verbose = True
# -----------------------------------------
[database]
#注释掉之前的连接信息
#connection = sqlite:////var/lib/neutron/neutron.sqlite
# -----------------------------------------
[keystone_authtoken]
#注释掉之前的内容
#auth_uri = http://127.0.0.1:35357/v2.0/
#identity_uri = http://127.0.0.1:5000
#admin_tenant_name = %SERVICE_TENANT_NAME%
#admin_user = %SERVICE_USER%
#admin_password = %SERVICE_PASSWORD%

#使用5000和35357端口进行身份校验
auth_uri = http://controller:5000
auth_url = http://controller:35357
#校验方式为密码(password)
auth_plugin = password
#指定项目和用户域为 defalut
project_domain_id = default
user_domain_id = default
#指定项目名称为service
project_name = service
#指定认证用户名为neutron
username = neutron
#指定认证密码为NEUTRON_PASS
password = NEUTRON_PASS
# -----------------------------------------
[oslo_messaging_rabbit]
#消息队列RabbitMQ的主机
rabbit_host = controller
#消息队列RabbitMQ的账号
rabbit_userid = openstack
#消息队列RabbitMQ的密码,该密码可查询密码表的RABBIT_PASS获得
rabbit_password = RABBIT_PASS
# -----------------------------------------

设置ML2插件,编辑/etc/neutron/plugins/ml2/ml2_conf.ini

vi /etc/neutron/plugins/ml2/ml2_conf.ini
# -----------------------------------------
[ml2]
#启用的网络驱动
type_drivers = flat,vlan,gre,vxlan
#指定租户使用的网络类型
tenant_network_types = gre
#指定OVS驱动
mechanism_drivers = openvswitch
# -----------------------------------------
[ml2_type_flat]
#指定flat网络为扩展网络
flat_networks = external
# -----------------------------------------
[ml2_type_gre]
#指定隧道ID范围
tunnel_id_ranges = 1:1000
# -----------------------------------------
[securitygroup]
#指定开启安全组
enable_security_group = True
#指定开启IPSET设置
enable_ipset = True
#指定OVS iptables的防火墙驱动
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
# -----------------------------------------
[ovs]
#指定本地IP,这里的IP填写与计算节点相连的IP地址
#我这里按照拓扑为10.0.2.30
local_ip = 10.0.2.30
#指定映射网络
bridge_mappings = external:br-ex
# -----------------------------------------
[agent]
#指定隧道类型
tunnel_types = gre
# -----------------------------------------

配置L3代理,编辑/etc/neutron/l3_agent.ini

vi /etc/neutron/l3_agent.ini
# -----------------------------------------
[DEFAULT]
#指定接口驱动
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
#指定外部网络桥接,这里设置为空,目的是为了在一个代理上启用多个外部网络
external_network_bridge =
#指定开启失效命名空间路由清除
router_delete_namespaces = True
#显示详细日志输出
verbose = True
# -----------------------------------------

配置DHCP代理,编辑/etc/neutron/dhcp_agent.ini

vi /etc/neutron/dhcp_agent.ini
# -----------------------------------------
[DEFAULT]
#指定接口驱动
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
#指定DHCP驱动
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
#指定开启失效命名空间路由清除
dhcp_delete_namespaces = True
#显示详细日志输出
verbose = True
# -----------------------------------------

配置Metadata,编辑/etc/neutron/metadata_agent.ini

vi /etc/neutron/metadata_agent.ini
# -----------------------------------------
[DEFAULT]
#注释掉之前的内容
#auth_uri = http://127.0.0.1:35357/v2.0/
#identity_uri = http://127.0.0.1:5000
#admin_tenant_name = %SERVICE_TENANT_NAME%
#admin_user = %SERVICE_USER%
#admin_password = %SERVICE_PASSWORD%

#使用5000和35357端口进行身份校验
auth_uri = http://controller:5000
auth_url = http://controller:35357
#校验方式为密码(password)
auth_plugin = password
#指定项目和用户域为 defalut
project_domain_id = default
user_domain_id = default
#指定项目名称为service
project_name = service
#指定认证用户名为neutron
username = neutron
#指定认证密码为NEUTRON_PASS
password = NEUTRON_PASS
#指定nova的metadata主机
nova_metadata_ip = controller
#指定metadata共享密钥,密钥可以在密码表中的METADATA_SECRET查询
metadata_proxy_shared_secret = METADATA_SECRET
#显示详细日志输出
verbose = True
# -----------------------------------------

4.配置 OVS 服务

service openvswitch-switch restart
#添加虚拟网卡br-ex
ovs-vsctl add-br br-ex
#设置虚拟网卡的映射,将br-ex与eth2进行映射
#这里的eth2为网络拓扑中网路节点的外网网卡
ovs-vsctl add-port br-ex eth2
#重启相关服务
service neutron-plugin-openvswitch-agent restart
service neutron-l3-agent restart
service neutron-dhcp-agent restart
service neutron-metadata-agent restart

至此,网络节点的安装就全部完成了

其他说明

如需转载烦请注明出处
来自于LinE's Blog
From: http://blog.l1n3.net
谢谢~~

分类: OpenStack 标签: ,
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.