Ceph RGW 的 OSPF负载均衡 + quagga的配置

 

随着开源技术的发展,以及商业设备价格的不断攀升。大公司总是希望能使用开源的方案来替换过去使用的商业设备。比如之前大家用的很多的F5和A10,现在已经在逐步被LVS替换。传统的单个lvs的性能是比不上商业设备的,而且稳定性等也相对会差些。告诉大家很多大公司都在用这些技术的。

基本思路就是把多个LVS组成一个OSPF集群,这样可以使得LVS集群的性能可以远远超过单个传统的商业设备(当然,对于F5等等其实也可以做这样的集群做水平化的扩展)

原来就是把服务器也模拟成ospf中的一份子,是他可以在实现ospf的负载均衡,以及高可用性。

在这里网络层的东西就不写了,往简单配置,没意思。往难里配置我也不懂,上线服务器的时候,这些东西都是网络组的负责,我只是负责服务器上的ospf的介入和业务方面的。

我这里只是简单的说下ospf的框架

LVS在大流量下基于OSPF的负载均衡实施方案

OSPF(Open Shortest Path First开放式最短路径优先)是一个内部网关协议(Interior Gateway Protocol,简称IGP),用于在单一自治系统(autonomous system,AS)内决策路由。

ECMP(Equal-CostMultipathRouting)等价多路径,存在多条不同链路到达同一目的地址的网络环境中,如果使用传统的路由技术,发往该目的地址的数据包只能利用其中的一条链路,其它链路处于备份状态或无效状态,并且在动态路由环境下相互的切换需要一定时间,而等值多路径路由协议可以在该网络环境下同时使用多条链路,不仅增加了传输带宽,并且可以无时延无丢包地备份失效链路的数据传输。

特点:

4层负载均衡,效率高
配置简单,只需安装基于linux的路由软件quagga
无法进行监控检查,服务异常无法处理
无session保持等,功能过于简单

贴上一个操作的例子:

OSPF(Open Shortest Path First开放式最短路径优先)是一个内部网关协议(InteriorGateway Protocol,简称IGP),用于在单一自治系统(autonomous system,AS)内决策路由。

ECMP(Equal-CostMultipathRouting)等价多路径,存在多条不同链路到达同一目的地址的网络环境中,如果使用传统的路由技术,发往该目的地址的数据包只能利用其中的一条链路,其它链路处于备份状态或无效状态,并且在动态路由环境下相互的切换需要一定时间,而等值多路径路由协议可以在该网络环境下同时使用多条链路,不仅增加了传输带宽,并且可以无时延无丢包地备份失效链路的数据传输。

特点:

1.4层负载均衡,效率高

2.配置简单,只需安装基于linux的路由软件quagga

3.无法进行监控检查,服务异常无法处理

4. 无session保持等,功能过于简单

路由器上的ospf的操作 ,这只是简单的配置,大家可以按照自己的想法和网络组的同学们扯淡提需求就行了。

配置命令:

R0配置:

Router>en
Router#config t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname r0
r0(config)#
r0(config)#int e1/0
r0(config-if)#ip address 192.168.2.222 255.255.255.0
r0(config-if)#no shutdown
r0(config)#int e1/1
r0(config-if)#ip address 192.168.0.111 255.255.255.0
r0(config-if)#no shutdown
r0(config-if)#exit
r0(config)#router ospf 100
r0(config-router)#net
r0(config-router)#network 192.168.0.0 0.0.0.255 area 0
r0(config-router)#network 192.168.2.0 0.0.0.255 area 0
r0(config-router)#exit
r0(config)#int e1/1
r0(config-if)#ip ospf cost 2
r0(config-if)#int e1/0
r0(config-if)#ip ospf cost 2
r0(config-if)#end
r0#ping 192.168.0.14
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.14, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 64/93/1
==========================================================================

cisco默认的是hello时间是10s,死亡时间是hello时间的4倍,默认为40s,当然这个时间是可以修改的。在接口模式下面,通过命令:ip ospf hello-interval <time>来修改hello时间。ip ospf dead-interval <time>来修改死亡时间。

服务器端的配置

其实就是安装一个软路由,让他进到ospf的圈子里面。

先说下qugga的基本安装配置

1.      下载源码

quagga-0.99.10.tar.gz

2.      解压缩

tar xzvf quagga-0.99.10.tar.gz

3.      配置

cd quagga-0.99.10

    ./configure --prefix =/usr

                --sysconfdir=/etc/quagga

                --localstatedir=/var/run/quagga

                --enable-vtysh

                --enable-user='test'

                --enable-group='test'

                --enable-vty-group='test'

配置输出:

                                                                                                                                                                                                                                                                                                                                                                                                 

Quagga configuration

--------------------

quagga version          : 0.99.10

host operationg system  : linux-gnu

source code location    : .

compiler                : gcc

compiler flags          : -Os -fno-omit-frame-pointer -g -std=gnu99 -Wall -Wsign-compare -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wchar-subscripts -Wcast-qual

make                    : make

includes                :

linker flags            :  -lcrypt  -lcap  -ltermcap -lreadline -lm

state file directory    : /var/run/quagga

config file directory  : /etc/quagga

example directory      : /etc/quagga

user to run as          : test

group to run as        : test

group for vty sockets  : test

config file mask        : 0600

log file mask          : 0600

                                                                                                                                                                                                                                                                                                                                                                                                 

The above user and group must have read/write access

to the state file directory and

to the config files in the config file directory.

quagga :

1. sudo apt-get install quagga安装quagga
2. sudovim.tiny /etc/quagga/daemons将ospfd=no改成ospfd=yes
3. sudo touch/etc/quagga/ospfd.conf创建ospf配置文件
4. echo “password PASSWORD”>ospfd.conf,添加虚拟路由器登录密码,一定要设
5. chownquagga.quaggavty /etc/quagga/*.conf
chmod 640 /etc/quagga/*.conf
修改所有者与权限,否则配置无法保存
6. sudo/etc/init.d/quagga restart
7. telnet localhost 2604输入刚才设置的密码
enable进入特权模式,再configter进入配置模式开始对路由器进行配置,具体如下:
password cloud2.0
!
interface eth0
ipospf priority 0\优先级为0,不参与DR选举
!
interface eth1
!
interface lo
!
interfaceovs-system
!
routerospf
ospf router-id 192.168.123.3\指定router-id
auto-cost reference-bandwidth 100000
network 183.2.198.128/32 area 0.0.0.30 \宣告网段
network 192.168.123.0/24 area 0.0.0.30\宣告网段
!
linevty
!
end
注意:
(1)所有运行OSPF协议的路由器router-id一定要唯一,如果不手动指定则会从路由器所有IP中自动选举router-id。之前出现两个自动选举的router-id相同的现象,导致OSPF邻居关系不正常
(2)reference-bandwidth 100000,所有运行OSPF协议的路由器的参考带宽要一致
8. 配置完成后end退出到特权模式,用show ipospfnei与show ipospf route检查邻近关系和路由条目
9. write保存配置

原文地址:https://www.cnblogs.com/bodhitree/p/6149002.html