1. OpenStack使用OVS
1.1 控制节点
cat >> /etc/sysctl.conf << EOF
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
EOF
modprobe br_netfilter
sysctl -p
yum install -y openstack-neutron openstack-neutron-ml2 openstack-neutron-openvswitch
apt install neutron-server neutron-plugin-ml2 neutron-l3-agent neutron-dhcp-agent neutron-metadata-agent neutron-openvswitch-agent -y
cp /etc/neutron/neutron.conf{,.bak}
grep -Ev "^$|#" /etc/neutron/neutron.conf.bak > /etc/neutron/neutron.conf
vim /etc/neutron/neutron.conf
[DEFAULT]
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = true
auth_strategy = keystone
state_path = /var/lib/neutron
dhcp_agent_notification = true
allow_overlapping_ips = true
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true
transport_url = rabbit://openstack:000000@controller
[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
[database]
connection = mysql+pymysql://neutron:neutron123@controller/neutron
[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
[oslo_concurrency]
lock_path = /var/lib/neutron/tmp
cp /etc/neutron/plugins/ml2/ml2_conf.ini{,.bak}
grep -Ev "^$|#" /etc/neutron/plugins/ml2/ml2_conf.ini.bak > /etc/neutron/plugins/ml2/ml2_conf.ini
vim /etc/neutron/plugins/ml2/ml2_conf.ini
[DEFAULT]
[ml2]
type_drivers = flat,vlan,vxlan,gre
tenant_network_types = vxlan
mechanism_drivers = openvswitch,l2population
extension_drivers = port_security
[ml2_type_flat]
flat_networks = physnet1
[ml2_type_vxlan]
vni_ranges = 1:1000
[securitygroup]
enable_ipset = true
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
cp /etc/neutron/plugins/ml2/openvswitch_agent.ini{,.bak}
grep -Ev "^$|#" /etc/neutron/plugins/ml2/openvswitch_agent.ini.bak > /etc/neutron/plugins/ml2/openvswitch_agent.ini
vim /etc/neutron/plugins/ml2/openvswitch_agent.ini
[agent]
l2_population = True
tunnel_types = vxlan
prevent_arp_spoofing = True
[ovs]
local_ip = 10.0.0.12
bridge_mappings = physnet1:br-eth1
cp /etc/neutron/l3_agent.ini{,.bak}
grep -Ev "^$|#" /etc/neutron/l3_agent.ini.bak > /etc/neutron/l3_agent.ini
vim /etc/neutron/l3_agent.ini
[DEFAULT]
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
external_network_bridge =
cp /etc/neutron/dhcp_agent.ini{,.bak}
grep -Ev "^$|#" /etc/neutron/dhcp_agent.ini.bak > /etc/neutron/dhcp_agent.ini
vim /etc/neutron/dhcp_agent.ini
[DEFAULT]
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = True
cp /etc/neutron/metadata_agent.ini{,.bak}
grep -Ev "^$|#" /etc/neutron/metadata_agent.ini.bak > /etc/neutron/metadata_agent.ini
vim /etc/neutron/metadata_agent.ini
[DEFAULT]
nova_metadata_host = controller
metadata_proxy_shared_secret = xier
vim /etc/nova/nova.conf
[default]
linuxnet_interface_driver = nova.network.linux_net.LinuxOVSlnterfaceDriver
[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
service_metadata_proxy = true
metadata_proxy_shared_secret = xier
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
systemctl restart openstack-nova-api
systemctl enable --now neutron-server neutron-metadata-agent neutron-openvswitch-agent openvswitch neutron-l3-agent neutron-dhcp-agent
ovs-vsctl add-br br-eth1
ovs-vsctl add-port br-eth1 eth1
systemctl restart neutron-server neutron-metadata-agent neutron-openvswitch-agent openvswitch neutron-l3-agent neutron-dhcp-agent
1.2 计算节点
cat >> /etc/sysctl.conf << EOF
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
EOF
modprobe br_netfilter
sysctl -p
yum install -y openstack-neutron-openvswitch
apt install -y neutron-openvswitch-agent
cp /etc/neutron/neutron.conf{,.bak}
grep -Ev "^$|#" /etc/neutron/neutron.conf.bak > /etc/neutron/neutron.conf
vim /etc/neutron/neutron.conf
[DEFAULT]
core_plugin = ml2
service_plugins = router
auth_strategy = keystone
state_path = /var/lib/neutron
allow_overlapping_ips = true
transport_url = rabbit://openstack:000000@controller
[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
[oslo_concurrency]
lock_path = /var/lib/neutron/tmp
cp /etc/neutron/plugins/ml2/openvswitch_agent.ini{,.bak}
grep -Ev "^$|#" /etc/neutron/plugins/ml2/openvswitch_agent.ini.bak > /etc/neutron/plugins/ml2/openvswitch_agent.ini
vim /etc/neutron/plugins/ml2/openvswitch_agent.ini
[agent]
l2_population = True
tunnel_types = vxlan
prevent_arp_spoofing = True
[ovs]
local_ip = 10.0.0.11
bridge_mappings = physnet1:br-eth1
[securitygroup]
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
systemctl restart neutron-openvswitch-agent
vim /etc/nova/nova.conf
[DEFAULT]
linuxnet_interface_driver = nova.network.linux_net.LinuxOVSlnterfaceDriver
vif_plugging_is_fatal = true
vif_pligging_timeout = 300
[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
systemctl enable --now openvswitch
ovs-vsctl add-br br-eth1
ovs-vsctl add-port br-eth1 eth1
systemctl restart openstack-nova-compute
systemctl enable --now neutron-openvswitch-agent
1.3 创建一个实例
source /etc/keystone/admin-openrc.sh
openstack router create router01
openstack network create --provider-network-type vxlan intnet
openstack subnet create intsubnet --network intnet --subnet-range 166.66.66.0/24 --gateway 166.66.66.1 --dns-nameserver 114.114.114.114
openstack router add subnet router01 intsubnet
openstack network create --provider-physical-network physnet1 --provider-network-type flat --external extnet
openstack subnet create extsubnet --network extnet --subnet-range 10.0.0.0/24 --allocation-pool start=10.0.0.20,end=10.0.0.200 --gateway 10.0.0.254 --dns-nameserver 114.114.114.114 --no-dhcp
openstack router set router01 --external-gateway extnet
openstack security group rule create --proto icmp default
openstack security group rule create --proto tcp --dst-port 22:22 default
openstack security group rule list
openstack image create cirros04 --disk-format qcow2 --file cirros-0.4.0-x86_64-disk.img
ssh-keygen -N ""
openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
openstack flavor create --vcpus 1 --ram 512 --disk 1 test
openstack server create --flavor test --image cirros04 --security-group default --nic net-id=7f6957e5-ef33-493e-9e03-a1f75fe25c28 --key-name mykey vm1
openstack floating ip create extnet
openstack server add floating ip vm1 10.0.0.36
openstack console url show vm1
1.4 ovs命令
ovs-vsctl show
ovs-ofctl dump-flows br-eth1
ovs-vsctl list-br
ovs-vsctl add-br demo-br
ovs-vsctl list-ifaces br-eth1
ovs-vsctl get-manager
ovs-vsctl list-ports br-eth1
2 NFS的cinder后端存储
yum install -y nfs-utils
mkdir /opt/cinder-nfs
chmod 777 -R /opt/cinder-nfs/
vim /etc/exports
/opt/cinder-nfs 10.0.0.0/24(rw,no_root_squash)
systemctl restart nfs
yum install -y nfs-utils
systemctl enable --now rpcbind
vim /etc/cinder/cinder.conf
[DEFAULT]
'''
enabled_backends = lvm,nfs
[lvm]
volume_backend_name = lvm
[nfs]
volume_driver = cinder.volume.drivers.nfs.NfsDriver
nfs_shares_config = /etc/cinder/nfs_shares
volume_backend_name = nfs
'''
vim /etc/cinder/nfs_shares
10.0.0.10:/opt/cinder-nfs/
chown -R cinder. /var/lib/cinder/mnt/
systemctl restart openstack-cinder-volume
============================nfs存储类型=================================
openstack volume type create nfs
cinder --os-username admin --os-tenant-name admin type-key nfs set volume_backend_name=nfs
openstack volume type list
============================lvm存储类型==================================
openstack volume type create lvm
cinder --os-username admin --os-tenant-name admin type-key lvm set volume_backend_name=lvm
openstack volume type list