码迷,mamicode.com
首页 > 其他好文 > 详细

openstack学习(五):neutron、dashboard配置以及使用

时间:2015-04-19 15:52:27      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:

记录,方便查阅。


neutron配置

controller节点的配置

数据库建立:

mysql -p123456 -e "CREATE DATABASE neutron;GRANT ALL PRIVILEGES ON neutron.* TO ‘neutron‘@‘192.168.23.11‘ IDENTIFIED BY ‘neutron‘;GRANT ALL PRIVILEGES ON neutron.* TO ‘neutron‘@‘%‘ IDENTIFIED BY ‘neutron‘;"

创建keystone中用户、服务等:

keystone user-create --name neutron --pass neutron
keystone user-role-add --user neutron --tenant service --role admin
keystone service-create --name neutron --type network --description "OpenStack Networking"

keystone endpoint-create \
--service-id $(keystone service-list | awk / network / {print $2}) \
--publicurl http://controller:9696 \
--adminurl
http://controller:9696 \
--internalurl
http://controller:9696 \
--region regionOne

软件安装:

yum install openstack-neutron openstack-neutron-ml2 python-neutronclient which -y

编辑配置文件/etc/neutron/neutron.conf

[database]
connection = mysql://neutron:neutron@:controller/neutron

[DEFAULT]
auth_strategy = keystone
[keystone_authtoken]
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = neutron
admin_password = neutron

[DEFAULT]    #ml2插件配置
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True

[DEFAULT]
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
nova_url = http://controller:8774/v2
nova_admin_auth_url = http://controller:35357/v2.0
nova_region_name = regionOne
nova_admin_username = nova
nova_admin_tenant_id =295f25713db645feb19b246c1c249bb4 
nova_admin_password = nova

[DEFAULT]
verbose = True

编辑配置文件/etc/neutron/plugins/ml2/ml2_conf.ini

[ml2]
type_drivers = flat,gre  #网络类型
tenant_network_types = gre
mechanism_drivers = openvswitch

[ml2_type_gre]
tunnel_id_ranges = 1:1000  #gre网络标识范围

[securitygroup]    #启用安全组,使用iptables规则
enable_security_group = True
enable_ipset = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver

编辑配置文件/etc/nova/nova.conf

[DEFAULT]
network_api_class = nova.network.neutronv2.api.API
security_group_api = neutron
linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver    #禁用内部防火墙驱动,以接管

[neutron]    #配置访问参数
url = http://controller:9696
auth_strategy = keystone
admin_auth_url = http://controller:35357/v2.0
admin_tenant_name = service
admin_username = neutron
admin_password = neutron

 为了初始化网络服务,使用符号链接到配置文件夹中

ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini

 填充数据库

sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade juno" neutron

 重启nova中一些服务:

systemctl restart openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service

 启动neutron和自启动:

systemctl enable neutron-server.service
systemctl start neutron-server.service

 以下为网络节点的配置,这里集成到controller配置:

yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-openvswitch –y

编辑配置文件vim /etc/sysctl.conf

net.ipv4.ip_forward=1  #打开数据转发
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0

 应用更改:

sysctl –p

编辑配置文件/etc/neutron/neutron.conf

[DEFAULT]
rpc_backend = rabbit
rabbit_host = controller
rabbit_password = guest
[DEFAULT] auth_strategy
= keystone
[keystone_authtoken] auth_uri
= http://controller:5000/v2.0 identity_uri = http://controller:35357 admin_tenant_name = service admin_user = neutron admin_password = neutron
[DEFAULT] core_plugin
= ml2  #打开ml2 service_plugins = router  #打开router allow_overlapping_ips = True  #允许IP重叠
[DEFAULT] verbose
= True

 编辑配置文件/etc/neutron/plugins/ml2/ml2_conf.ini

[ml2]
type_drivers = flat,gre
tenant_network_types = gre
mechanism_drivers = openvswitch

[ml2_type_flat]
flat_networks = external  #配置flat网络提供为外部网络

[ml2_type_gre]
tunnel_id_ranges = 1:1000


[securitygroup]
enable_security_group = True
enable_ipset = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver

[ovs]
local_ip = 192.168.24.1  #gre本地IP,tunnel端点
enable_tunneling = True
bridge_mappings = external:br-ex  #映射关系

[agent]
tunnel_types = gre

编辑配置文件/etc/neutron/l3_agent.ini

[DEFAULT]
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
use_namespaces = True  #打开namespace
external_network_bridge = br-ex  #外部网络的网桥
router_delete_namespaces = True  #启用删除namespace功能

[DEFAULT]
verbose = True

编辑配置文件/etc/neutron/dhcp_agent.ini

[DEFAULT]
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
use_namespaces = True
dhcp_delete_namespaces = True
[DEFAULT]
verbose = True

编辑配置文件/etc/neutron/metadata_agent.ini

[DEFAULT]
auth_url = http://controller:5000/v2.0
auth_region = regionOne
admin_tenant_name = service
admin_user = neutron
admin_password = neutron

[DEFAULT]
nova_metadata_ip = controller

[DEFAULT]
metadata_proxy_shared_secret = yippee

[DEFAULT]
verbose = True

编辑配置文件/etc/nova/nova.conf

[neutron]
service_metadata_proxy = True  #打开metadata代理
metadata_proxy_shared_secret = yippee
启动和自启动:
systemctl restart openstack-nova-api.service
systemctl enable openvswitch.service
systemctl start openvswitch.service

 添加网桥并添加端口:

ovs-vsctl add-br br-ex  
ovs-vsctl add-port br-ex enps9

 

ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini

 这是一个bug,复制脚本文件:

cp /usr/lib/systemd/system/neutron-openvswitch-agent.service /usr/lib/systemd/system/neutron-openvswitch-agent.service.orig
sed -i s,plugins/openvswitch/ovs_neutron_plugin.ini,plugin.ini,g /usr/lib/systemd/system/neutron-openvswitch-agent.service

 启动和自启动:

systemctl enable neutron-openvswitch-agent.service neutron-l3-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-ovs-cleanup.service
systemctl start neutron-openvswitch-agent.service neutron-l3-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service

compute节点配置

 安装包:

yum install openstack-neutron-ml2 openstack-neutron-openvswitch –y

 /etc/sysctl.conf

net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
sysctl –p

 下面不做过多解释:

/etc/neutron/neutron.conf

[DEFAULT]
rpc_backend = rabbit
rabbit_host = controller
#rabbit_password = guest
[DEFAULT] auth_strategy
= keystone
[keystone_authtoken] auth_uri
= http://controller:5000/v2.0 identity_uri = http://controller:35357 admin_tenant_name = service admin_user = neutron admin_password = neutron
[DEFAULT] core_plugin
= ml2 service_plugins = router allow_overlapping_ips = True
[DEFAULT] verbose
= True

/etc/neutron/plugins/ml2/ml2_conf.ini

[ml2]
type_drivers = flat,gre
tenant_network_types = gre
mechanism_drivers = openvswitch
[ml2_type_gre] tunnel_id_ranges
= 1:1000

[securitygroup] enable_security_group = True enable_ipset = True firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
[ovs] local_ip
= 192.168.24.2 enable_tunneling = True
[agent] tunnel_types
= gre

 

systemctl enable openvswitch.service
systemctl start openvswitch.service

/etc/nova/nova.conf

[DEFAULT]
network_api_class = nova.network.neutronv2.api.API
security_group_api = neutron
linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver

[neutron]
url = http://controller:9696
auth_strategy = keystone
admin_auth_url = http://controller:35357/v2.0
admin_tenant_name = service
admin_username = neutron
admin_password = neutron
ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
cp /usr/lib/systemd/system/neutron-openvswitch-agent.service /usr/lib/systemd/system/neutron-openvswitch-agent.service.orig
sed -i s,plugins/openvswitch/ovs_neutron_plugin.ini,plugin.ini,g /usr/lib/systemd/system/neutron-openvswitch-agent.service
systemctl restart openstack-nova-compute.service
systemctl enable neutron-openvswitch-agent.service
systemctl start neutron-openvswitch-agent.service

neutron使用

 查看agent:

neutron agent-list

创建网络:

neutron net-create ext-net --router:external True --provider:physical_network external --provider:network_type flat  #创建一个外部网络
neutron subnet-create ext-net --name ext-subnet --allocation-pool start=10.0.3.201,end=10.0.3.254 --disable-dhcp --gateway 10.0.3.1 10.0.3.0/24  #外部网络子网
neutron net-create demo-net  #租户网络
neutron subnet-create demo-net --name demo-subnet --gateway 192.168.1.1 192.168.1.0/24  #租户子网
neutron router-create demo-router  #路由
neutron router-interface-add demo-router demo-subnet   #关联路由与网关
neutron router-gateway-set demo-router ext-net  #路由网关

 

dashboard(horizon)配置

 安装包:

yum install openstack-dashboard httpd mod_wsgi memcached pythonmemcached

编辑配置文件/etc/openstack-dashboard/local_settings

OPENSTACK_HOST = "controller"
ALLOWED_HOSTS = [*]
CACHES = {
default: {
BACKEND: django.core.cache.backends.memcached.MemcachedCache,
LOCATION: 127.0.0.1:11211,
}
}
TIME_ZONE = " Asia/Chongqing"
setsebool -P httpd_can_network_connect on  #配置selinux相关

 权限修改:

chown -R apache:apache /usr/share/openstack-dashboard/static

 启动和自启动:

systemctl enable httpd.service memcached.service
systemctl start httpd.service memcached.service

dashboard使用

 http://192.168.25.11/dashboard

 

至此,openstack重要组件完成部署。

openstack学习(五):neutron、dashboard配置以及使用

标签:

原文地址:http://www.cnblogs.com/yippee/p/4439047.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!