Cài đặt Openstack Neutron với Linux Bridge mô hình Self-service.
Chuẩn bị
- Mô hình cài đặt:
- Controller:
- eth0: 192.168.30.171/24 - MGMT network
- eth1: 192.168.40.171/24 - Self-service
- eth2: no IP - Provider
- Computer:
- eth0: 192.168.30.172/24 - MGMT network
- eth1: 192.168.40.172/24 - Self-service
- eth2: no IP - Provider
- Controller:
Cài đặt trên Controller node
Chuẩn bị
Trước khi cài đặt dịch vụ Openstack Neutron, bạn cần tạo database, thông tin đăng nhập cho dịch vụ, và API endpoint.
- Tạo database:
mysql -uroot -pSQLROOTPASS << EOF DROP DATABASE IF EXISTS neutron; CREATE DATABASE neutron; GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' \ IDENTIFIED BY 'NEUTRON_DBPASS'; GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' \ IDENTIFIED BY 'NEUTRON_DBPASS'; EOF
- Tạo và cấu hình user, service cho neutron:
```
. admin-openrc
openstack user create –domain default –password=NEUTRON_PASS neutron
openstack role add –project service –user neutron admin
openstack service create –name neutron
–description “OpenStack Networking” network openstack endpoint create –region RegionOne
network public http://controller:9696 openstack endpoint create –region RegionOne
network internal http://controller:9696 openstack endpoint create –region RegionOne
network admin http://controller:9696
### Cấu hình theo mô hình self-service sử dụng Linux bridge
- Cài đặt các gói cần thiết:
yum install openstack-neutron openstack-neutron-ml2
openstack-neutron-linuxbridge ebtables -y
- Sửa file cấu hình **/etc/neutron/neutron.conf**
cp -p /etc/neutron/neutron.conf /etc/neutron/neutron.conf.origin cat « EOF > /etc/neutron/neutron.conf
[DEFAULT] core_plugin = ml2 service_plugins = router allow_overlapping_ips = true transport_url = rabbit://openstack:RABBIT_PASS@controller auth_strategy = keystone notify_nova_on_port_status_changes = true notify_nova_on_port_data_changes = true
[database] connection = mysql+pymysql://neutron:NEUTRON_DBPASS@controller/neutron
[keystone_authtoken] www_authenticate_uri = http://controller:5000 auth_url = http://controller:5000 memcached_servers = controller:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = neutron password = NEUTRON_PASS
[nova] auth_url = http://controller:5000 auth_type = password project_domain_name = default user_domain_name = default region_name = RegionOne project_name = service username = nova password = NOVA_PASS
[oslo_concurrency] lock_path = /var/lib/neutron/tmp EOF
- Cấu hình ml2 plugin: Sửa file **/etc/neutron/plugins/ml2/ml2_conf.ini**.
cp -p /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugins/ml2/ml2_conf.ini.origin cat «EOF > /etc/neutron/plugins/ml2/ml2_conf.ini [ml2] type_drivers = flat,vlan,vxlan tenant_network_types = vxlan mechanism_drivers = linuxbridge,l2population extension_drivers = port_security
[ml2_type_flat] flat_networks = provider
[ml2_type_vxlan] vni_ranges = 1:1000
[securitygroup] enable_ipset = true EOF
- Cấu hình Linux Bridge agent. Sửa file **/etc/neutron/plugins/ml2/linuxbridge_agent.ini**:
cp -p /etc/neutron/plugins/ml2/linuxbridge_agent.ini /etc/neutron/plugins/ml2/linuxbridge_agent.ini.origin cat « EOF > /etc/neutron/plugins/ml2/linuxbridge_agent.ini [linux_bridge] physical_interface_mappings = provider:eth2
[vxlan] enable_vxlan = true local_ip = 192.168.40.171 l2_population = true
[securitygroup] enable_security_group = true firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver EOF
- Chạy lệnh sau để bật module br_netfilter:
modprobe br_netfilter
- Cấu hình layer 3 agent. sửa file **/etc/neutron/l3_agent.ini**:
cp -p /etc/neutron/l3_agent.ini /etc/neutron/l3_agent.ini.origin cat « EOF > /etc/neutron/l3_agent.ini [DEFAULT] interface_driver = linuxbridge EOF
- Cấu hình DHCP agent:
cp -p /etc/neutron/dhcp_agent.ini /etc/neutron/dhcp_agent.ini.origin cat « EOF > /etc/neutron/dhcp_agent.ini [DEFAULT] interface_driver = linuxbridge dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq enable_isolated_metadata = true EOF
- Cấu hình metadata agent. Sửa file **/etc/neutron/metadata_agent.ini**:
cp -p /etc/neutron/metadata_agent.ini /etc/neutron/metadata_agent.ini.origin cat « EOF > /etc/neutron/metadata_agent.ini [DEFAULT] nova_metadata_host = controller metadata_proxy_shared_secret = METADATA_SECRET EOF
- Cấu hình Openstack Nova tông tin đăng nhập của Neutron. Sửa file **/etc/nova/nova.conf**:
cat « EOF » /etc/nova/nova.conf [neutron] auth_url = http://controller:5000 auth_type = password project_domain_name = default user_domain_name = default region_name = RegionOne project_name = service username = neutron password = NEUTRON_PASS service_metadata_proxy = true metadata_proxy_shared_secret = METADATA_SECRET EOF
### Hoàn tất cài đặt trên controller
- Script khởi tạo dịch vụ Networking sẽ tìm file **/etc/neutron/plugin.ini** mà chỏ đến file cấu hình ML2, nếu không có, tạo symbolic link với câu lệnh sau:
rm -f /etc/neutron/plugin.ini ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
- Populate database:
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
- Khởi động lại Compute API:
systemctl restart openstack-nova-api.service
- Khởi động lại Neutron và các agent, bao gồm cả l3 agent:
systemctl enable neutron-server.service
neutron-linuxbridge-agent.service neutron-dhcp-agent.service
neutron-metadata-agent.service neutron-l3-agent.service
systemctl restart neutron-server.service
neutron-linuxbridge-agent.service neutron-dhcp-agent.service
neutron-metadata-agent.service neutron-l3-agent.service
## Cài đặt và cấu hình trên Compute Node.
### Chuẩn bị
- Cài đặt các gói thành phần:
yum install openstack-neutron-linuxbridge ebtables ipset -y
### Cấu hình neutron
- Chỉnh sửa file cấu hình của neutron:
cp -p /etc/neutron/neutron.conf /etc/neutron/neutron.conf.origin cat « EOF > /etc/neutron/neutron.conf [DEFAULT] transport_url = rabbit://openstack:RABBIT_PASS@controller auth_strategy = keystone
[keystone_authtoken] www_authenticate_uri = http://controller:5000 auth_url = http://controller:5000 memcached_servers = controller:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = neutron password = NEUTRON_PASS
[oslo_concurrency] lock_path = /var/lib/neutron/tmp
EOF
- Cấu hình cho linuxbridge-agent theo mô hình selfservice:
cp -p /etc/neutron/plugins/ml2/linuxbridge_agent.ini /etc/neutron/plugins/ml2/linuxbridge_agent.ini.origin cat « EOF > /etc/neutron/plugins/ml2/linuxbridge_agent.ini [linux_bridge] physical_interface_mappings = provider:eth2
[vxlan] enable_vxlan = true local_ip = 192.168.40.172 l2_population = true
[securitygroup] enable_security_group = true firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver EOF
- Bật module bridge netfilter:
modprobe br_netfilter
- Sửa nova-compute để thêm thông tin đăng nhập của neutron :
cat « EOF » /etc/nova/nova.conf [neutron] auth_url = http://controller:5000 auth_type = password project_domain_name = default user_domain_name = default region_name = RegionOne project_name = service username = neutron password = NEUTRON_PASS EOF
### Hoàn tất cài đặt trên compute node
- Khởi động lại dịch vụ Nova Compute để nhận cấu hình:
systemctl restart openstack-nova-compute.service
- Khởi động và cấu hình tự khởi động cho LinuxBridge Agent của Neutron:
systemctl enable neutron-linuxbridge-agent.service systemctl start neutron-linuxbridge-agent.service
- Trên controller node, cấu hình firewalld:
firewall-cmd –add-port=9696/tcp –permanent firewall-cmd –reload
## Hoàn tất cấu hình
### Tạo mạng provider
- Cấu hình những dòng sau trên controller node
- Tạo network provider1:
openstack network create –share –provider-physical-network provider
–provider-network-type flat provider1
- Tạo subnet cho mạng provider1:
openstack subnet create –subnet-range 192.168.50.0/24 –gateway 192.168.50.1
–network provider1 –allocation-pool start=192.168.50.170,end=192.168.50.179
–dns-nameserver 8.8.8.8 provider1-subnet
### Tạo mạng self-service
- Thêm cấu hình cho mạng provider1 thành external
openstack network set –external provider1
- Tạo mạng selfservice
openstack network create selfservice1
openstack subnet create –subnet-range 192.0.2.0/24
–network selfservice1 –dns-nameserver 8.8.4.4 selfservice1-v4
- Tạo router, thêm subnet mạng selfservice và thêm mạng provider để làm gateway cho router:
openstack router create router1 openstack router add subnet router1 selfservice1-v4 neutron router-gateway-set router1 provider1 ```
Kiểm tra lại bằng cách tạo máy ảo và sử dụng hai mạng này (máy ảo không sử dụng volume).
Nguồn tài liệu:
- https://docs.openstack.org/neutron/train/install/install-rdo.html