Build LVs Load Balancer on LINUX,CENTOS7

Source: Internet
Author: User
Tags node server

Build LVS Load Balancer Pre-set on Linux,centos7
    • Prepare five virtual machines
    • Four sets of Centos7
    • One to do scheduling one to do NFS cache
    • Two do Wed clusters
    • One windows7 begins to be configured individually
      1. Configure Server for NFS (CENTOS7 is used to download the source code package online, but in order to do the experiment, the source code is installed with Yum instead of the host mode only)
    • ip:192.168.10.174
    • Use Rpm-q nfs-utils to see if the installation
    • Rpcbind (Remote Procedure Call)
    • Editing a configuration file
[[email protected] ~]# vim /etc/exports[[email protected] ~]# cat /etc/exports/usr/share *(ro,sync) #*所有 ro只读 sync同步/opt/benet 192.168.10.0/24(rw,sync) #rw可读可写  sync同步/opt/accp 192.168.10.0/24(rw,sync) #rw可读可写  sync同步[[email protected] ~]# mkdir /opt/accp #创建目录[[email protected] ~]# mkdir /opt/bent[[email protected] ~]# chmod 777 /opt/bent[[email protected] ~]# chmod 777 /opt/accp[[email protected] ~]# exportfs -rv #发布出去让其可见exporting 192.168.10.0/24:/opt/bentexporting 192.168.10.0/24:/opt/accpexporting *:/usr/share[[email protected] ~]# systemctl start nfs.service[[email protected] ~]# systemctl start rpcbind.service[[email protected] ~]# systemctl stop #关闭防火钱 firewalld.service [[email protected] ~]# setenforce 0 #关闭安全模块

2. Configuring 192.168.10.173-Node Server

    • IP 192.168.10.173
    • IP 192.168.10.172 (same configuration as 192.168.10.173)
    • Installing the HTTPD Service
      [[email protected] ~]# yum install http -y[[email protected] ~]# showmount -e 192.168.10.174 #查看共享的存储空间Export list for 192.168.10.174:/usr/share */opt/bent  192.168.10.0/24/opt/accp  192.168.10.0/24[[email protected] ~]# mount.nfs 192.168.10.174:/opt/accp /var/www/html/ #把共享的存储空间挂载到本站点网站首页[[email protected] ~]# vim /etc/httpd/conf/httpd.conf[[email protected] ~]# cat /etc/httpd/conf/httpd.conf #查看一下修改的端口和域名 | grep 80Listen 192.168.10.173:80#Listen 80ServerName www.accp.com:80[[email protected]ost ~]# systemctl start httpd.service  #开启服务[[email protected] ~]# systemctl stop firewalld.service [[email protected] ~]# setenforce 0

      Self - rated

3. Configure the Dispatch server 192.168.10.171

    • Configuring a dual NIC as a gateway
    • IP 192.168.10.1
    • IP 12.0.0.1
    • In the lower right corner of the virtual machine, right-click Settings--add-on network adapter-click OK

1): Dispatch server to do route forwarding

[[email protected] ~]# vim /etc/sysctl.conf #路由转发的配置文件[[email protected] ~]# cat /etc/sysctl.conf |grep netnet.ipv4.ip_forward=1 #在最后一行添加路由转发语句[[email protected] ~]# sysctl -p #重新加载让其生效[[email protected] ~]# iptables -t nat -F #清空防火墙[[email protected] ~]# iptables -F #清空iptables转发表[[email protected] ~]# iptables -t nat -A PROSTROUTING -o ens36 -s192.168.10.0/24 -j SNAT --to-source 12.0.0.1 #做SNAT规则
  • Verify forwarding
  • The Windows7 above Web site to the external Web site 12.0.0.12 with the intranet address ping12.0.0.12 external Web site to see if it can ping
  • Do dispatch server
    [[email protected] ~]# modprobe ip_vs[[email protected] ~]# cat/proc/net/ip_vs #查看ip_vs模块有没有加载IP Virtual Server version 1.2.1 (size=4096) Prot localaddress:port Scheduler flags-> remoteaddress:port Forward Weight activeconn Inactconn rpm-ivh/mnt/packages/ipvsadm-1.27-7.el7.x86_64.rpm #安装管理工具 [[email protected] ~]# systemctl start Ipvsadm.service #在centos7上面直接启动会有一个报错没有保存ob for Ipvsadm service failed because the control process EXITD with error code. See "Systemctl Start Ipvsadm.service" and "Journalctl-xe" for details[[email protected] ~]# ipvsadm--save >/et C/sysconfig/ipvsadm #开启管理工具时把规则做保存 (unique and 6 differences) [[email protected] ~]# systemctl start ipvsadm.service [email  protected] ~]# systemctl status Ipvsadm.service #查看状态显示绿色证明开启成功 [[email protected] opt]# vim net.sh # Scripting iptables firewall rules [[email protected] opt]# cat net.sh#!/bin/bashipvsadm-c #清除历史记录ipvsadm-A-t 12.0.0.1:80-s RR #添 Add virtual server with-a-t specify IP port-s specify algorithm (polling algorithm) ipvsadm-a-T 12.0.0.1:80-R 192.168.100.101:80-M #-a specifies the true node server-T to specify the IP address of the true node server-M-Specify NAT mode Ipvsadm-a-T 12.0.0.1:80-r 192.168.100.102:8 0-mipvsadm #启用 [[email protected] opt] source net.sh #没给执行权限用source gave permission to use./Start IP Virtual Server version 1.2.1 (size=40 Prot localaddress:port Scheduler flags-> remoteaddress:port Forward Weight activeconn inactconntcp Localh          Ost.localdomain:http rr-> 192.168.10.172:http masq 1 0 0 192.168.10.173:http  MASQ 1 0 0

    Testing with Windows Endpoint view

Build LVs Load Balancer on LINUX,CENTOS7

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.