1
2
3
4
|
4
层负载均衡,效率高
配置简单,只需安装基于linux的路由软件quagga
无法进行监控检查,服务异常无法处理
无session保持等,功能过于简单
|
特点:
1
.
4
层负载均衡,效率高
2
.配置简单,只需安装基于linux的路由软件quagga
3
.无法进行监控检查,服务异常无法处理
4
. 无session保持等,功能过于简单
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
配置命令:
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 dead-interval <time>来修改死亡时间。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
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.
4
. 编译和安装
make ;make install
5
. 添加test组和用户
groupadd test;
useradd test -g test
6
. 改变权限
//最好写入启动脚本
chown test:test /
var
/run/quagga
chmod
777
/
var
/run/quagga
chown test:test /etc/quagga
//需要将配置写入操作系统
chmod
777
/etc/quagga/*
7
. 增加log权限
//最好写入启动脚本
Mkdir /
var
/log/quagga/
Vi /
var
/log/quagga/zebra.log
Chmod
777
/
var
/log/quagga/zebra.log
8
. 修改 /etc/services
//just for telnet
zebrasrv
2600
/tcp # zebra service
zebra
2601
/tcp # zebra vty
ripd
2602
/tcp # RIPd vty
ripngd
2603
/tcp # RIPngd vty
ospfd
2604
/tcp # OSPFd vty
bgpd
2605
/tcp # BGPd vty
ospf6d
2606
/tcp # OSPF6d vty
ospfapi
2607
/tcp # ospfapi
isid
2608
/tcp # ISISd vty
9
. 编辑配置文件
copy /etc/quagga/zebra.conf.example /etc/quagga/zebra.conf
! -*- zebra -*-
!
! zebra sample configuration file
!
hostname Router
password zebra
enable password zebra
log file /
var
/log/quagga/zebra.log
//注意zebra.conf启用log,这样便于查找错误
10
. 启动
zebra –d
如果启动不成功,察看/
var
/log/quagga/zebra.log
一般由于权限设置会出现以下错误:
2008
/
10
/
22
16
:
59
:
22
ZEBRA: Could not lock pid_file /
var
/run/quagga/zebra.pid, exiting
11
. 登陆
telnet localhost zebra(0r
2601
)
[root@localhost quagga-
0.99
.
10
]# telnet localhost
2601
Trying
127.0
.
0.1
...
Connected to localhost.
Escape character
is
'^]'
.
Hello,
this
is
Quagga (version
0.99
.
10
).
Copyright
1996
-
2005
Kunihiro Ishiguro, et al.
User Access Verification
Password:
Router> enable
Password:
Router# help
Quagga VTY provides advanced help feature. When you need help,
anytime at the command line please press
'?'
.
If nothing matches, the help list will be empty and you must backup
until entering a
'?'
shows the available options.
Two styles of help are provided:
1
. Full help
is
available when you are ready to enter a
command argument (e.g.
'show ?'
) and describes
each
possible
argument.
2
. Partial help
is
provided when an abbreviated argument
is
entered
and you want to know what arguments match the input
(e.g.
'show me?'
.)
Router#
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
安装
LVS服务器
192.168
.
0.14
、
192.168
.
0.15
上安装quagga软件
配置
1
). 配置web服务器quagga
使用root用户登录
192.168
.
0.14
和
192.168
.
0.15
cd /etc/quagga
cp ospfd.conf.sample ospfd.conf
chkconfig zebra on
chkconfig ospfd on
service zebra start
service ospfd start
telnet localhost ospfd
输入默认密码zebra
ospfd> en
ospfd# conf t
ospfd(config)# router ospf
ospfd(config-router)# router-id
192.168
.
2.64
ospfd(config-router)# network
192.168
.
0.23
/
32
area
0.0
.
0.0
(lo IP)
ospfd(config-router)# network
192.168
.
2.64
/
24
area
0.0
.
0.0
(接口IP)
ospfd(config-router)#end
ospfd#wr
2
). 配置交换机端
根据交换机类型配置ospf与主机quagga建立ospf邻居关系
3
). 配置主机
使用root用户分别在
2
台web服务上执行以下命令
ifconfig lo:
0
192.168
.
0.23
netmask
255.255
.
255.255
up
验证
多次访问http:
//192.168.0.23显示相应页面即说明负载成功
3.2
功能测试
负载均衡测试
多次访问http:
//192.168.0.23显示realserver ip address 在192.168.0.14和
192.168
.
0.15
之间切换
服务切换测试
Down掉
192.168
.
0.14
/
15
上的服务IP
192.168
.
0.23
可以正常访问应用
|