配置控制节点 创建数据库 [[email protected] ~]# mysql -e "CREATE DATABASE neutron;" 授权用户 [[email protected] ~]# mysql -e "GRANT ALL PRIVILEGES ON neutron.* TO ‘neutron‘@‘localhost‘ IDENTIFIED BY ‘neutron‘;" [[email protected] ~]# mysql -e "GRANT ALL PRIVILEGES ON neutron.* TO ‘neutron‘@‘%‘ IDENTIFIED BY ‘neutron‘;" 生效管理配置 [[email protected] ~]# source admin-openrc 在keystone当中创建一个用户 neutron [[email protected] ~]# openstack user create --domain default neutron --password neutron +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | 9a6c10205dba4952b1276b450c0a6c04 | | enabled | True | | id | f0a9e9b5eb5b402a9cf94ba113c82797 | | name | neutron | +-----------+----------------------------------+ 将neutron用户加入管理员组 [[email protected] ~]# openstack role add --project service --user neutron admin 创建一个网络服务 [[email protected] ~]# openstack service create --name neutron --description "OpenStack Networking" network +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Networking | | enabled | True | | id | 184796ed39de4f06ada1a2b59b634259 | | name | neutron | | type | network | +-------------+----------------------------------+ 创建服务访问接口 [[email protected] ~]# openstack endpoint create --region RegionOne network public http://controller:9696 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 76c6ef2dbe204f098c211ac16e6c6385 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 184796ed39de4f06ada1a2b59b634259 | | service_name | neutron | | service_type | network | | url | http://controller:9696 | +--------------+----------------------------------+ [[email protected] ~]# openstack endpoint create --region RegionOne network internal http://controller:9696 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 78f0a254496143a68a730104fa290ebd | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 184796ed39de4f06ada1a2b59b634259 | | service_name | neutron | | service_type | network | | url | http://controller:9696 | +--------------+----------------------------------+ [[email protected] ~]# openstack endpoint create --region RegionOne network admin http://controller:9696 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 7f35f435fd8b41448d4dc080b13466bc | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 184796ed39de4f06ada1a2b59b634259 | | service_name | neutron | | service_type | network | | url | http://controller:9696 | +--------------+----------------------------------+ [网络组件] 安装网络组件 [[email protected] ~]# yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables openstack-utils -y 配置 /etc/neutron/neutron.conf 文件 #数据库配置 openstack-config --set /etc/neutron/neutron.conf database connection mysql+pymysql://neutron:[email protected]/neutron grep "^connection" /etc/neutron/neutron.conf #DEFAULT配置 openstack-config --set /etc/neutron/neutron.conf DEFAULT core_plugin ml2 #核心插件 ml2 openstack-config --set /etc/neutron/neutron.conf DEFAULT service_plugins router #支持路由 openstack-config --set /etc/neutron/neutron.conf DEFAULT allow_overlapping_ips True #允许使用叠加网络 egrep "^core_plugin|^service_plugins|^allow_overlapping_ips" /etc/neutron/neutron.conf #RabbitMQ消息队列配置 openstack-config --set /etc/neutron/neutron.conf DEFAULT rpc_backend rabbit openstack-config --set /etc/neutron/neutron.conf oslo_messaging_rabbit rabbit_host controller #RabbitMQ服务器IP地址 openstack-config --set /etc/neutron/neutron.conf oslo_messaging_rabbit rabbit_userid openstack #RabbitMQ认证用户名 openstack-config --set /etc/neutron/neutron.conf oslo_messaging_rabbit rabbit_password 123456 #RabbitMQ密码 egrep "^rpc_backend|^rabbit_host|^rabbit_userid|^rabbit_password" /etc/neutron/neutron.conf #Keystone认证配置 openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_uri http://controller:5000 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_url http://controller:35357 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken memcached_servers controller:11211 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_type password openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_domain_name default openstack-config --set /etc/neutron/neutron.conf keystone_authtoken user_domain_name default openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_name service openstack-config --set /etc/neutron/neutron.conf keystone_authtoken username neutron openstack-config --set /etc/neutron/neutron.conf keystone_authtoken password neutron egrep "^auth_strategy|^auth_uri|^auth_url|^memcached_servers|^auth_type|^project_domain_name|^user_domain_name|^project_name|^username|^password" /etc/neutron/neutron.conf #不知道意思 官网就是要这样子配置 openstack-config --set /etc/neutron/neutron.conf DEFAULT notify_nova_on_port_status_changes True openstack-config --set /etc/neutron/neutron.conf DEFAULT notify_nova_on_port_data_changes True egrep "^notify_nova_on_por" /etc/neutron/neutron.conf #nova配置 openstack-config --set /etc/neutron/neutron.conf nova auth_url http://controller:35357 openstack-config --set /etc/neutron/neutron.conf nova auth_type password openstack-config --set /etc/neutron/neutron.conf nova project_domain_name default openstack-config --set /etc/neutron/neutron.conf nova user_domain_name default openstack-config --set /etc/neutron/neutron.conf nova region_name RegionOne openstack-config --set /etc/neutron/neutron.conf nova project_name service openstack-config --set /etc/neutron/neutron.conf nova username nova openstack-config --set /etc/neutron/neutron.conf nova password nova egrep "^auth_url|^auth_type|^project_domain_name|^user_domain_name|^region_name|^project_name|^username|^password" /etc/neutron/neutron.conf #最后一个也不知道干嘛用的 openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp grep "^lock_path" /etc/neutron/neutron.conf 配置二层模块插件 openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers flat,vlan,vxlan #支持平面网络 vlan子网划分 vxlan openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vxlan #现在采用vxlan模式 openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers linuxbridge,l2population #采用Linux自身提供的网桥 openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 extension_drivers port_security openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks provider openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_vxlan vni_ranges 1:1000 #地址范围 openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup enable_ipset True egrep "^type_drivers|^tenant_network_types|^mechanism_drivers|^extension_drivers|^ml2_type_flat|^ml2_type_vxlan|^securitygroup" /etc/neutron/plugins/ml2/ml2_conf.ini 配置Linux网桥配置 openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings provider:eno16777728 #采用哪块网卡连接到网桥上面 grep "^physical_interface_mappings" /etc/neutron/plugins/ml2/linuxbridge_agent.ini 叠加网络配置 openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan True openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan local_ip 192.168.188.128 #定义管理接口的IP地址 openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population True egrep "^enable_vxlan|^local_ip|^l2_population" /etc/neutron/plugins/ml2/linuxbridge_agent.ini openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup enable_security_group True openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver egrep "^enable_security_group|^firewall_driver" /etc/neutron/plugins/ml2/linuxbridge_agent.ini 配置三层插件 openstack-config --set /etc/neutron/l3_agent.ini DEFAULT interface_driver neutron.agent.linux.interface.BridgeInterfaceDriver openstack-config --set /etc/neutron/l3_agent.ini DEFAULT external_network_bridge #设置为空 必须要这么干嘛 egrep "^interface_driver|^external_network_bridge" /etc/neutron/l3_agent.ini 配置DHCP分配IP服务 openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT interface_driver neutron.agent.linux.interface.BridgeInterfaceDriver openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT dhcp_driver neutron.agent.linux.dhcp.Dnsmasq openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT enable_isolated_metadata True egrep "^interface_driver|^dhcp_driver|^enable_isolated_metadata" /etc/neutron/dhcp_agent.ini Return to Networking controller node configuration返回上一步 配置元数据 openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT nova_metadata_ip controller openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT metadata_proxy_shared_secret METADATA_SECRET #共享的密码 后面会用到 我们可以生成一个随机码 egrep "^nova_metadata_ip|^metadata_proxy_shared_secret" /etc/neutron/metadata_agent.ini [配置Nova项] openstack-config --set /etc/nova/nova.conf neutron url http://controller:9696 openstack-config --set /etc/nova/nova.conf neutron auth_url http://controller:35357 openstack-config --set /etc/nova/nova.conf neutron auth_type password openstack-config --set /etc/nova/nova.conf neutron project_domain_name default openstack-config --set /etc/nova/nova.conf neutron user_domain_name default openstack-config --set /etc/nova/nova.conf neutron region_name RegionOne openstack-config --set /etc/nova/nova.conf neutron project_name service openstack-config --set /etc/nova/nova.conf neutron username neutron openstack-config --set /etc/nova/nova.conf neutron password neutron openstack-config --set /etc/nova/nova.conf neutron service_metadata_proxy True openstack-config --set /etc/nova/nova.conf neutron metadata_proxy_shared_secret METADATA_SECRET egrep "^url|^auth_url|^auth_type|^project_domain_name|^user_domain_name|^region_name|^project_name|^username|^password|^service_metadata_proxy|^metadata_proxy_shared_secret" /etc/nova/nova.conf 创建一个软链接 ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini 同步数据库 su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron 重启nova-api服务 systemctl restart openstack-nova-api.service 设置neutron开机启动服务 systemctl enable neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service systemctl start neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service 启动三层服务 开机自动启动 systemctl enable neutron-l3-agent.service systemctl start neutron-l3-agent.service ############################################################################################################################################################################################# ############################################################################################################################################################################################# ############################################################################################################################################################################################# ############################################################################################################################################################################################# ############################################################################################################################################################################################# ############################################################################################################################################################################################# ############################################################################################################################################################################################# ############################################################################################################################################################################################# 开始配置compute计算节点的网络服务 [安装网络组件] yum install openstack-neutron-linuxbridge ebtables ipset openstack-utils -y [编辑配置] openstack-config --set /etc/neutron/neutron.conf DEFAULT rpc_backend rabbit openstack-config --set /etc/neutron/neutron.conf oslo_messaging_rabbit rabbit_host controller openstack-config --set /etc/neutron/neutron.conf oslo_messaging_rabbit rabbit_userid openstack openstack-config --set /etc/neutron/neutron.conf oslo_messaging_rabbit rabbit_password 123456 openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_uri http://controller:5000 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_url http://controller:35357 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken memcached_servers controller:11211 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_type password openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_domain_name default openstack-config --set /etc/neutron/neutron.conf keystone_authtoken user_domain_name default openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_name service openstack-config --set /etc/neutron/neutron.conf keystone_authtoken username neutron openstack-config --set /etc/neutron/neutron.conf keystone_authtoken password neutron openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp [配置网桥] openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings provider:eno16777728 openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan True openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan local_ip 192.168.188.129 openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population True openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup enable_security_group True openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver grep "^local_ip" /etc/neutron/plugins/ml2/linuxbridge_agent.ini [配置nova文件] openstack-config --set /etc/nova/nova.conf neutron url http://controller:9696 openstack-config --set /etc/nova/nova.conf neutron auth_url http://controller:35357 openstack-config --set /etc/nova/nova.conf neutron auth_type password openstack-config --set /etc/nova/nova.conf neutron project_domain_name default openstack-config --set /etc/nova/nova.conf neutron user_domain_name default openstack-config --set /etc/nova/nova.conf neutron region_name RegionOne openstack-config --set /etc/nova/nova.conf neutron project_name service openstack-config --set /etc/nova/nova.conf neutron username neutron openstack-config --set /etc/nova/nova.conf neutron password neutron [重新启动nova-compute服务] systemctl restart openstack-nova-compute.service [启用Linux网桥服务] systemctl enable neutron-linuxbridge-agent.service systemctl start neutron-linuxbridge-agent.service 切入到控制节点 source admin-openrc neutron ext-list neutron agent-list 此命令一共有5个组件启动 up 并且是笑脸 ok.... 进入后期网络配置工作 第一步:创建一个虚拟网络 provider模型 [生成管理配置] [[email protected] ~]# source admin-openrc [添加网络模型] [[email protected] ~]# neutron net-create --shared --provider:physical_network provider --provider:network_type flat provider Created a new network: +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | True | | availability_zone_hints | | | availability_zones | | | created_at | 2016-09-23T08:42:59 | | description | | | id | d70272cf-237e-418d-852a-e20fbea9fd3c | | ipv4_address_scope | | | ipv6_address_scope | | | mtu | 1500 | | name | provider | | port_security_enabled | True | | provider:network_type | flat | | provider:physical_network | provider | | provider:segmentation_id | | | router:external | False | | shared | True | | status | ACTIVE | | subnets | | | tags | | | tenant_id | b3e92847775042adad06934826e323be | | updated_at | 2016-09-23T08:42:59 | +---------------------------+--------------------------------------+ 注意以下配置 [[email protected] ~]# grep "^flat_networks" /etc/neutron/plugins/ml2/ml2_conf.ini flat_networks = provider [[email protected] ~]# grep "^physical_interface_mappings" /etc/neutron/plugins/ml2/linuxbridge_agent.ini physical_interface_mappings = provider:eno16777728 [配置provider子网] [[email protected] ~]# neutron subnet-create --name provider --allocation-pool start=172.16.10.200,end=172.16.10.250 \--dns-nameserver 202.96.128.166 --gateway 172.16.10.1 provider 172.16.10.0/16 Created a new subnet: +-------------------+----------------------------------------------------+ | Field | Value | +-------------------+----------------------------------------------------+ | allocation_pools | {"start": "172.16.10.200", "end": "172.16.10.250"} | | cidr | 172.16.0.0/16 | | created_at | 2016-09-23T08:46:59 | | description | | | dns_nameservers | 202.96.128.166 | | enable_dhcp | True | | gateway_ip | 172.16.10.1 | | host_routes | | | id | 8e3cb8f1-426c-43c5-93cc-8eb4eb303010 | | ip_version | 4 | | ipv6_address_mode | | | ipv6_ra_mode | | | name | provider | | network_id | d70272cf-237e-418d-852a-e20fbea9fd3c | | subnetpool_id | | | tenant_id | b3e92847775042adad06934826e323be | | updated_at | 2016-09-23T08:46:59 | +-------------------+----------------------------------------------------+ [创建一个模板] [[email protected] ~]# openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano +----------------------------+---------+ | Field | Value | +----------------------------+---------+ | OS-FLV-DISABLED:disabled | False | | OS-FLV-EXT-DATA:ephemeral | 0 | | disk | 1 | | id | 0 | | name | m1.nano | | os-flavor-access:is_public | True | | ram | 64 | | rxtx_factor | 1.0 | | swap | | | vcpus | 1 | +----------------------------+---------+ [为demo用户生成秘钥对] [[email protected] ~]# . demo-openrc [[email protected] ~]# ssh-keygen -q -N "" Enter file in which to save the key (/root/.ssh/id_rsa): [[email protected] ~]# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey +-------------+-------------------------------------------------+ | Field | Value | +-------------+-------------------------------------------------+ | fingerprint | 40:16:d3:a3:c4:9e:f8:0f:62:19:d6:ce:0e:82:ac:1a | | name | mykey | | user_id | 432de9a61ef34faaac80f00e3df02543 | +-------------+-------------------------------------------------+ [[email protected] ~]# openstack keypair list +-------+-------------------------------------------------+ | Name | Fingerprint | +-------+-------------------------------------------------+ | mykey | 40:16:d3:a3:c4:9e:f8:0f:62:19:d6:ce:0e:82:ac:1a | +-------+-------------------------------------------------+ [设置安全访问组 相当于网络防火墙] [[email protected] ~]# openstack security group rule create --proto icmp default +-----------------------+--------------------------------------+ | Field | Value | +-----------------------+--------------------------------------+ | id | 7cce9c91-9eb4-497e-a63f-deb37b67123c | | ip_protocol | icmp | | ip_range | 0.0.0.0/0 | | parent_group_id | f62f1007-7279-446f-9669-2595ea4acf97 | | port_range | | | remote_security_group | | +-----------------------+--------------------------------------+ [[email protected] ~]# openstack security group rule create --proto tcp --dst-port 22 default +-----------------------+--------------------------------------+ | Field | Value | +-----------------------+--------------------------------------+ | id | be8d4d22-10f2-4463-9fc0-2ba1ec5c3c89 | | ip_protocol | tcp | | ip_range | 0.0.0.0/0 | | parent_group_id | f62f1007-7279-446f-9669-2595ea4acf97 | | port_range | 22:22 | | remote_security_group | | +-----------------------+--------------------------------------+ ********************************************************************************************** ********************************************************************************************** ********************************************************************************************** ********************************************************************************************** ********************************************************************************************** ********************************************************************************************** ********************************************************************************************** ********************************************************************************************** ********************************************************************************************** ********************************************************************************************** 运行实例 [[email protected] ~]# . demo-openrc [[email protected] ~]# openstack flavor list +----+-----------+-------+------+-----------+-------+-----------+ | ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public | +----+-----------+-------+------+-----------+-------+-----------+ | 0 | m1.nano | 64 | 1 | 0 | 1 | True | | 1 | m1.tiny | 512 | 1 | 0 | 1 | True | | 2 | m1.small | 2048 | 20 | 0 | 1 | True | | 3 | m1.medium | 4096 | 40 | 0 | 2 | True | | 4 | m1.large | 8192 | 80 | 0 | 4 | True | | 5 | m1.xlarge | 16384 | 160 | 0 | 8 | True | +----+-----------+-------+------+-----------+-------+-----------+ [[email protected] ~]# openstack image list +--------------------------------------+-------------------+--------+ | ID | Name | Status | +--------------------------------------+-------------------+--------+ | 6cdaacdf-b968-4361-b39a-00a161b7952b | CentOS-6.4-x84_64 | active | | e8f9ee93-910d-4eb7-b516-a3052b8bbc47 | cirros | active | +--------------------------------------+-------------------+--------+ [[email protected] ~]# openstack network list +--------------------------------------+----------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+----------+--------------------------------------+ | d70272cf-237e-418d-852a-e20fbea9fd3c | provider | 8e3cb8f1-426c-43c5-93cc-8eb4eb303010 | +--------------------------------------+----------+--------------------------------------+ [[email protected] ~]# openstack security group list +--------------------------------------+---------+------------------------+----------------------------------+ | ID | Name | Description | Project | +--------------------------------------+---------+------------------------+----------------------------------+ | f62f1007-7279-446f-9669-2595ea4acf97 | default | Default security group | 2b4fb8c8cb29478c9e65c6f555df2bd7 | +--------------------------------------+---------+------------------------+----------------------------------+ [[email protected] ~]# openstack server create --flavor m1.nano --image cirros --nic net-id=d70272cf-237e-418d-852a-e20fbea9fd3c --security-group default --key-name mykey provider-instance [[email protected] ~]# openstack server list +--------------------------------------+-------------------+--------+------------------------+ | ID | Name | Status | Networks | +--------------------------------------+-------------------+--------+------------------------+ | dc1acea9-00ef-42d3-b724-fc4ebef7e371 | provider-instance | ACTIVE | provider=172.16.10.201 | +--------------------------------------+-------------------+--------+------------------------+ [[email protected] ~]# openstack console url show provider-instance +-------+---------------------------------------------------------------------------------+ | Field | Value | +-------+---------------------------------------------------------------------------------+ | type | novnc | | url | http://controller:6080/vnc_auto.html?token=5fdedd6d-f0c3-4cc7-96e2-efcb48a49c3f | +-------+---------------------------------------------------------------------------------+
时间: 2024-10-08 10:27:46