Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

OpenStack practice (5): Linux Bridge implementation of Load Balance

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Environment:

Openstack version pike control node host openstack-controller (ubuntu 16.04.5) 172.27.34.37

Compute node host openstack-computer (ubuntu 16.04.5) 172.27.34.38vlan100

Centos01 (172.27.100.17), centos02 (172.27.100.11)

For details of ubuntu installation, please see the full record of Ubuntu16.04.5 installation in lvm mode.

For more information on openstack installation, please see: OpenStack practice (1): build p version of OpenStack by DevStack under Ubuntu16.04

Topology Diagram:

Goal:

Public network pc accesses Load Balancers ip 172.27.34.11 and polls access to the backend web server

The contents of this article:

First, create a new vlan

2. Create a new instance centos01

3. Configure security groups

4. Configure float ip

5. Create a new instance centos02

6. Configure lbaas

First, create a new vlan

1. Configure ml2_conf.ini

Ml2_conf.ini is configured for both the master and the standby.

Stack@openstack-controller:~$ view / etc/neutron/plugins/ml2/ml2_ conf.ini [ml2] tenant_network_types = vlanextension_drivers = port_securitymechanism_drivers = openvswitch,linuxbridgetype_drivers = local,flat,vlan,gre,vxlan, Geneve [ML2 _ type_vlan] network_vlan_ranges = vlan:3001: 4000 [Linux _ bridge] physical_interface_mappings = vlan:ens192

two。 Restart neutron

Stack@openstack-controller:~$ sudo systemctl restart devstack@q*

3. Create vlan100

Stack@openstack-controller:/tmp$ openstack network create-provider-physical-network vlan-provider-network-type vlan-project admin vlan100

4. Create a subnet

Create a subnet subnet172.27.100.0

Stack@openstack-controller:/tmp$ openstack subnet create-- network vlan100-- subnet-range 172.27.100.0 subnet172.27.100.0 24-- gateway 172.27.100.1

5. View the created network

2. Create an instance centos01

1. Upload media

Upload media CentOS-7-x86_64-GenericCloud-1503.qcow2c to / tmp directory, download address: http://cloud.centos.org/centos/7/images/

two。 Make a mirror image

Root@openstack-controller:~# su-stackstack@openstack-controller:~$ source devstack/openrc admin adminstack@openstack-controller:/tmp$ openstack image create "centos7"-file CentOS-7-x86_64-GenericCloud-1503.qcow2c-disk-format qcow2-container-format bare-public

3. New key centos

Use stack users to create a new key pair centos

Stack@openstack-controller:~/key$ ssh-keygen-t rsa-f centos.keystack@openstack-controller:~/key$ more centos.pub

4. Import key

Import the public key

After creating the instance, log in to the instance using the private key

5. View instance types

Stack@openstack-controller:~$ nova flavor-list

Select m1.small for instance type

6. View Mirror

Stack@openstack-controller:~$ glance image-list

Select centos7

7. Check the hostname and zone

Stack@openstack-controller:~$ nova service-list

This paper selects the luanch instance of the control node

8. View the network

Stack@openstack-controller:~$ openstack network list

Select the newly created vlan100

9. View key pair

Stack@openstack-controller:~/key$ nova keypair-list

The newly created instance centos01 uses the secret key centos

10. Create a new instance centos01

Stack@openstack-controller:~/key$ nova boot-flavor m1.small-image centos7-availability-zone nova:openstack-controller-nic net-name=vlan100-key-name centos centos01

11. View the new instance

3. Create a new security group

1. Edit the default security group

two。 New rules

New rules allow access to ping, ssh, and port 80

4. Configure float ip

Public network access configuration

1. Configure ml2_conf.ini

Control node configuration ml2_conf.ini

Stack@openstack-controller:~$ view / etc/neutron/plugins/ml2/ml2_ conf.ini [ml2 _ type_flat] flat_networks = externalte [ml2 _ type_vlan] network_vlan_ranges = vlan:3001: 4000 [Linux _ bridge] physical_interface_mappings = vlan:ens192,externaltt:ens224

two。 Restart the network

Stack@openstack-controller:~$ sudo systemctl restart devstack@q*

Because the external network environment of this paper is flat network (the network card of the physical machine is connected to the access port of the switch), the external network is configured with flat, the corresponding network card ens224, the virtual machine internal network is vlan, and the corresponding network card ens192.

3. Create ext_net_flat

4. Create a subnet

5. Do not check dhcp

6. View the created public network

172.27.34.0 this network segment needs to be able to access the external network.

New Route

1. Newly built routing router100

The external network selects ext_net_flat to connect the external network to the virtual router

The API will be added with an ip of 172.27.34.6

two。 New interface

Create floating ip

1. Assign floating ip

Floating ip provides static NAT function, which is configured on the public network interface where router provides the gateway.

two。 Associated instance

Create a floating ip172.27.34.4 and associate it with the instance centos01

5. Create a new instance centos02

Instance centos02 is launched as a centos01 snapshot

Configure instance centos01

1. Log in to centos01

Log in to the instance and change the password

Stack@openstack-controller:~/key$ sudo ssh-I centos.key centos@172.27.34.4

two。 Modify the configuration file sshd_config

[root@centos01 ~] # view / etc/ssh/sshd_configPermitRootLogin yesPasswordAuthentication yes

3. Restart sshd

[root@centos01 ~] # service sshd restartRedirecting to / bin/systemctl restart sshd.service

The instance can be accessed remotely at this time

4. Close selinux

[root@centos01 ~] # setenforce 0 [root@centos01 ~] # sed-I's / ^ * SELINUX=enforcing/SELINUX=disabled/g' / etc/selinux/config

Take effect permanently after reboot

5. Configure sourc

[root@centos01 ~] # yum-y install wget [root@centos01 ~] # cd / etc/yum.repos.d/ [root@centos01 yum.repos.d] # mkdir repo_bak & & mv *. Repo repo_bak/ [root @ centos01 yum.repos.d] # wget http://mirrors.aliyun.com/repo/Centos-7.repo

6. Install the apache service and configure

[root@centos01] # yum-y install httpd [root@centos01 ~] # systemctl start httpd [root@centos01 ~] # systemctl enable httpd [root@centos01 ~] # echo web01-172.27.100.17 > / var/www/html/index.html

7. Visit centos01

Visit http://172.27.34.4/

Create an instance centos02

1. Create a snapshot

Create a snapshot centos based on the instance centos01

two。 Start the instance by the image

Start instance centos02 by mirrored centos

Network, instance type, etc. are consistent with centos01

3. Configure centos02

Refer to centos01 configuration, associate vip, connect centos02 for related configuration

4. Visit centos02

Visit http://172.27.34.5/

6. Configure lbaas

View Octavia services

This article implements lbaas in the way of Octavia. From the Pike version, Octavia can be used as an independent Keystone service rather than a service plugin of Neutron.

Stack@openstack-controller:~$ openstack service list

Load Balancers configuration

1. Create Load Balancers

Create a new Load Balancer 4 and select private subnet172.27.100.0 for the subnet

two。 Configure Listener

The protocol of Listener is HTTP, and the port defaults to 80.

3. Configure Pool

The method of Pool is round_robin

4. Join pool members

Add centos01 and centos02 to pool

5. Create a new monitor

6. Assign floating ip

Assign floating ip172.27.34.11 to load balance as vip

7. View the newly created Load Balancers

View vip

View an instance

8. Access test

Access vip at the compute node

Root@openstack-computer:~# for i in {1... 10}; do sleep 5; curl http://172.27.34.11; done

Visit vip and find that the back-end web server is accessed by polling, and the result is as expected.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report