Cài đặt Openstack Neutron Self Service sử dụng OpenvSwitch.
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
- Controller:
- eth0: 192.168.30.172/24 - MGMT network
- eth1: 192.168.40.172/24 - Self-service
- eth2: no IP - Provider
- Controller:
- Hệ thống đã cài đặt keystone, glance, nova theo các tài liệu trước.
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-openvswitch 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:5672/ 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 = openvswitch,l2population extension_drivers = port_security
[ml2_type_flat] flat_networks = provider
[ml2_type_vxlan] vni_ranges = 1:1000
[securitygroup] enable_ipset = true EOF
- Cài đặt Openvswitch:
yum install -y openvswitch
- Tạo bridge:
ovs-vsctl add-br br-provider ovs-vsctl add-port br-provider eth2
- Cấu hình Linux Bridge agent. Sửa file **vi /etc/neutron/plugins/ml2/openvswitch_agent.ini**:
cp -p vi /etc/neutron/plugins/ml2/openvswitch_agent.ini vi /etc/neutron/plugins/ml2/openvswitch_agent.ini.origin cat « EOF > /etc/neutron/plugins/ml2/openvswitch_agent.ini [ovs] bridge_mappings = provider:br-provider local_ip = 192.168.40.171
[agent] tunnel_types = vxlan l2_population = True
[securitygroup] firewall_driver = iptables_hybrid
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 = openvswitch EOF
- Cấu hình DHCP agent:
yes |cp -p /etc/neutron/dhcp_agent.ini /etc/neutron/dhcp_agent.ini.origin cat « EOF > /etc/neutron/dhcp_agent.ini [DEFAULT] interface_driver = openvswitch 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**:
yes |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
- Sửa file cấu hình **/etc/neutron/rootwrap.conf**:
cp -p /etc/neutron/rootwrap.conf /etc/neutron/rootwrap.conf.origin
cat « EOF > /etc/neutron/rootwrap.conf
Configuration for neutron-rootwrap
This file should be owned by (and only-writeable by) the root user
[DEFAULT]
List of directories to load filter definitions from (separated by ‘,’).
These directories MUST all be only writeable by root !
filters_path=/etc/neutron/rootwrap.d,/usr/share/neutron/rootwrap
List of directories to search executables in, in case filters do not
explicitely specify a full path (separated by ‘,’)
If not specified, defaults to system PATH environment variable.
These directories MUST all be only writeable by root !
exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin,/usr/local/bin,/usr/local/sbin
Enable logging to syslog
Default value is False
use_syslog=False
Which syslog facility to use.
Valid values include auth, authpriv, syslog, local0, local1…
Default value is ‘syslog’
syslog_log_facility=syslog
Which messages to log.
INFO means log all usage
ERROR means only log unsuccessful attempts
syslog_log_level=ERROR
[xenapi]
XenAPI configuration is only required by the L2 agent if it is to
target a XenServer/XCP compute host’s dom0.
xenapi_connection_url=
### 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-openvswitch-agent.service neutron-dhcp-agent.service
neutron-metadata-agent.service neutron-l3-agent.service
systemctl restart neutron-server.service
neutron-openvswitch-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-openvswitch ebtables ipset openvswitch -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:5672/ 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
- Bật openvswitch:
systemctl restart openvswitch systemctl enable openvswitch
- Tạo bridge:
ovs-vsctl add-br br-provider ovs-vsctl add-port br-provider eth2
- Cấu hình cho openvswitch-agent theo mô hình selfservice:
cp -p /etc/neutron/plugins/ml2/openvswitch_agent.ini /etc/neutron/plugins/ml2/openvswitch_agent.ini.origin cat « EOF > /etc/neutron/plugins/ml2/openvswitch_agent.ini [ovs] bridge_mappings = provider:br-provider local_ip = 192.168.40.172
[agent] tunnel_types = vxlan l2_population = True
[securitygroup] firewall_driver = iptables_hybrid 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-openvswitch-agent.service systemctl start neutron-openvswitch-agent.service
## 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.168.199.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
- https://docs.openstack.org/neutron/train/admin/deploy-ovs.html