首页 > 其他分享 >lvs基础配置

lvs基础配置

时间:2023-07-06 19:00:31浏览次数:20  
标签:00 lvs 0.0 配置 基础 192.168 100.250 root ens33

基础配置

[root@localhost ~]# systemctl disable --now firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.servic
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.servic
[root@localhost ~]# vi /etc/selinux/config 
[root@localhost ~]# setenforce  0
[root@localhost ~]# hostnamectl set-hostname LB
[root@localhost ~]# bash
[root@lb ~]# yum -y install net-tools network-scripts
[root@lb ~]# cd /etc/sysconfig/network-scripts/
[root@lb network-scripts]# vi ifcfg-ens33 
TYPE=Ethernet
BOOTPROTO=static
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.100.10
PREFIX=24
GATEWAY=192.168.100.2
DNS1=114.114.114.114
[root@lb network-scripts]# cd
[root@lb ~]# ifconfig ens33:0 192.168.100.250/32 broadcast 192.168.100.250 up

[root@slave1 network-scripts]# vi ifcfg-ens33 
[root@slave1 network-scripts]# systemctl restart network
[root@slave1 network-scripts]# cd
[root@slave1 ~]# vi /etc/sysctl.conf 
[root@slave1 ~]# sysctl -p
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
[root@slave1 ~]# ifconfig lo:0 192.168.100.250/32 broadcast 192.168.100.250 up
[root@slave1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 192.168.100.250/0 brd 192.168.100.250 scope global lo:0
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:e8:24:18 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.20/24 brd 192.168.100.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
       
[root@slave2 ~]# vi /etc/sysctl.conf 
[root@slave2 ~]# sysctl -p
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
[root@slave2 ~]# cd /etc/sysconfig/network-scripts/
[root@slave2 network-scripts]# vi ifcfg-ens33 
[root@slave2 network-scripts]# vi ifcfg-ens33 
[root@slave2 network-scripts]# systemctl restart network
[root@slave2 network-scripts]# ifconfig lo:0 192.168.100.250/32 broadcast 192.168.100.250 up
[root@slave2 network-scripts]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 192.168.100.250/0 brd 192.168.100.250 scope global lo:0
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:50:56:20:36:a0 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.30/24 brd 192.168.100.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe20:36a0/64 scope link 
       valid_lft forever preferred_lft forever

配置路由信息

[root@lb ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.100.2   0.0.0.0         UG    100    0        0 ens33
192.168.100.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33
[root@lb ~]# route add -host 192.168.100.250 dev ens33:0
[root@lb ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.100.2   0.0.0.0         UG    100    0        0 ens33
192.168.100.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33
192.168.100.250 0.0.0.0         255.255.255.255 UH    0      0        0 ens33

[root@slave1 ~]# route add -host 192.168.100.250 dev lo:0
[root@slave1 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.100.2   0.0.0.0         UG    100    0        0 ens33
192.168.100.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33
192.168.100.250 0.0.0.0         255.255.255.255 UH    0      0        0 lo

[root@slave2 network-scripts]# route add -host 192.168.100.250 dev lo:0
[root@slave2 network-scripts]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.100.2   0.0.0.0         UG    0      0        0 ens33
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 ens33
192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 ens33
192.168.100.250 0.0.0.0         255.255.255.255 UH    0      0        0 lo

在rs1,rs2安装httpd服务

[root@slave1 ~]# yum -y install httpd
[root@slave1 ~]# systemctl enable --now httpd
[root@slave2 ~]# yum -y install httpd
[root@slave2 ~]# systemctl enable --now httpd
#将slav1,slave2写入
[root@slave1 ~]# ss -antl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128        *:80                     *:*                  
LISTEN     0      128        *:22                     *:*                  
LISTEN     0      100    127.0.0.1:25                     *:*                  
LISTEN     0      128       :::22                    :::*                  
LISTEN     0      100      ::1:25                    :::*                  
[root@slave1 ~]# echo slave1 > /var/www/html/index.html
[root@slave2 ~]# echo slave2 > /var/www/html/index.html

在lb上添加保护规则

[root@lb ~]# yum -y install ipvsadm
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package ipvsadm.x86_64 0:1.27-8.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================
 Package          Arch            Version               Repository     Size
============================================================================
Installing:
 ipvsadm          x86_64          1.27-8.el7            base           45 k

Transaction Summary
============================================================================
Install  1 Package

Total download size: 45 k
Installed size: 75 k
Downloading packages:
ipvsadm-1.27-8.el7.x86_64.rpm                          |  45 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : ipvsadm-1.27-8.el7.x86_64                                1/1 
  Verifying  : ipvsadm-1.27-8.el7.x86_64                                1/1 

Installed:
  ipvsadm.x86_64 0:1.27-8.el7                                               

Complete!
[root@lb ~]# ipvsadm -L
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
[root@lb ~]# ipvsadm -A -t 192.168.100.250:80 -s rr
[root@lb ~]# ipvsadm -a -t 192.168.100.250:80 -r 192.168.100.20:80 -g
[root@lb ~]# ipvsadm -a -t 192.168.100.250:80 -r 192.168.100.30:80 -g
[root@lb ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.100.250:80 wlc
  -> 192.168.100.20:80            Route   1      0          0         
  -> 192.168.100.30:80            Route   1      0          0   

标签:00,lvs,0.0,配置,基础,192.168,100.250,root,ens33
From: https://www.cnblogs.com/shuangmu668/p/17533052.html

相关文章

  • centos7配置阿里云yum源
    #wget下载wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo#curl下载(如果yum安装wget失败的话用curl)curl-o/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo......
  • HBase 组件安装与配置
    HBase组件安装与配置1.1.实验目的完成本实验,您应该能够:掌握HBase安装与配置掌握HBase常用Shell命令1.2.实验要求了解HBase原理熟悉HBase常用Shell命令1.3.实验环境本实验所需之主要资源环境如表1-1所示。表1-1资源环境服务器集群单节点,机器最......
  • Sqoop 组件安装与配置
    1.Sqoop组件安装与配置1.1.实验目的完成本实验,您应该能够:下载和解压Sqoop配置Sqoop环境安装SqoopSqoop模板命令1.2.实验要求熟悉Sqoop环境熟悉Sqoop模板命令1.3.实验环境本实验所需之主要资源环境如表1-1所示。表1-1资源环境服务器集群单节点,机......
  • Flume 组件安装配置
    Flume组件安装配置1.1.实验目的完成本实验,您应该能够:掌握下载和解压Flume掌握Flume组件部署掌握使用Flume发送和接受信息1.2.实验要求了解Flume相关知识熟悉Flume功能应用熟悉Flume组件设置1.3.实验环境本实验所需之主要资源环境如表1-1所示。表1-1......
  • anconda配置tensorflow环境
    一、anconda的安装1.进入Anaconda官网并按照电脑配置选择合适的安装包Anaconda官网:https://www.anaconda.com/点击进入不同的三个版本,分别是windows,mac,linux根据自己的电脑配置下载对应的安装包点击next点击Iagree同意协议默认上面的选择,点击next安装位置可以......
  • 前端基础-js篇(一)
    1.usestrict (1)ES5规范增加了新的语言特性并且修改了一些已经存在的特性。为了保证旧的功能还能够使用,大部分的修改是默认不生效的。(2)需要一个特殊的指令—— "usestrict" 来明确地激活这些特性。(3)当它处于脚本文件的顶部时,则整个脚本文件都将以“现代”模式进行工作。"u......
  • C++基础
    学习C++,关键是要理解概念,而不应过于深究语言的技术细节。C++程序结构#include<iostream> //包含头文件<iostream>usingnamespacestd; //定义命名空间"std"intmain(){ //主函数main() cout<<"HelloWorld!"<<endl; //输出函数cout,en......
  • 【17.0】前端基础jQuery之jQuery补充
    【17.0】前端基础jQuery之jQuery补充【一】组织标签后续执行方式一<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>Title</title><scriptsrc="https://cdn.bootcdn.net/ajax/libs/jque......
  • 1.Vue3 配置开发-测试环境
    1、根目录新建.env.testing、.env.donline文件2、package.json=》scripts中配置"start":"vue-cli-serviceserve--modetesting","start-o":"vue-cli-serviceserve--modedonline"3、vue.config.jsconstBundleAnalyzerPlugin=require(&......
  • 激光雷达基础介绍与仿真测试流程
    随着智能驾驶领域的快速发展与普及,激光雷达的轻量化、电子化和芯片化也逐渐成为趋势。由于激光雷达不受光线影响、分辨力高、支持3D立体,点云还支持AI算法训练等优点,一些主流车型在L3级别的智驾功能应用上搭载了激光雷达,从而完成更可靠和准确的目标探测。 在L2+或L3级以上的智驾......