找回密码
 注册
查看: 2760|回复: 56

ipvs的问题

[复制链接]
发表于 2004-10-18 12:02:37 | 显示全部楼层 |阅读模式
我的两台内网服务器ip是10.0.0.9和10.0.0.100,两台服务器均开启了ftp服务,两台机器的网关均是10.0.0.2,我的公网服务器eth0 ip是 10.0.0.2 eth1 ip是210.75.11.36,
我的脚本如下
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 10.0.0.0/8 -d 0.0.0.0/0 -o eth1 -j MASQUERADE
ipvsadm -C
ipvsadm -A -t 210.75.11.36:21 -s wrr
ipvsadm -a -t 210.75.11.36:21 -r 10.0.0.9:21 -m -w 2
ipvsadm -a -t 210.75.11.36:21 -r 10.0.0.100:21 -m -w 3
ipvsadm


我210.75.11.36的ftp服务没开
但是我的ipvs没有生效,在公网上无法访问210.75.11.36的ftp服务,请问这是为什么?
ipvsadm信息如下
[root@test9 root]# ipvsadm
IP Virtual Server version 1.0.8 (size=65536)
Prot LocalAddressort Scheduler Flags
-> RemoteAddressort Forward Weight ActiveConn InActConn
TCP test9:ftp wrr
-> 10.0.0.100:ftp Masq 3 0 1
-> test3:ftp Masq 2 0 0
发表于 2004-10-18 12:50:19 | 显示全部楼层
允许 FTP-DATA 端口(20/tcp)。
回复

使用道具 举报

 楼主| 发表于 2004-10-18 13:17:13 | 显示全部楼层
我没有用iptables建立防火墙亚,而且我又尝试了80端口也是不行
[root@test9 root]# ipvsadm -A -t 210.75.11.36:80 -s wrr
[root@test9 root]# ipvsadm -a -t 210.75.11.36:80 -r 10.0.0.9:80 -m -w 2
[root@test9 root]# ipvsadm -a -t 210.75.11.36:80 -r 10.0.0.100:80 -m -w 3
[root@test9 root]# ipvsadm
IP Virtual Server version 1.0.8 (size=65536)
Prot LocalAddressort Scheduler Flags
  -> RemoteAddressort           Forward Weight ActiveConn InActConn
TCP  test9:http wrr
  -> 10.0.0.100:http              Masq    3      0          1         
  -> test3:http                   Masq    2      0          0
回复

使用道具 举报

 楼主| 发表于 2004-10-18 13:19:58 | 显示全部楼层
[root@test9 root]# iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
[root@test9 root]#
回复

使用道具 举报

发表于 2004-10-18 13:56:59 | 显示全部楼层
[quote:28ff3949d0="lues"][root@test9 root]# ipvsadm
IP Virtual Server version 1.0.8 (size=65536)
Prot LocalAddressort Scheduler Flags
  -> RemoteAddressort           Forward Weight ActiveConn InActConn
TCP  test9:http wrr
  -> 10.0.0.100:http              Masq    3      0          1         
  -> test3:http                   Masq    2      0          0[/quote]
这个输出表明你的LVS-NAT已经应该正常工作了呀?

检查一下你的“公网服务器”的路由如何?
回复

使用道具 举报

 楼主| 发表于 2004-10-18 14:06:02 | 显示全部楼层
检查一下你的“公网服务器”的路由如何?

什么意思?
回复

使用道具 举报

发表于 2004-10-18 14:11:26 | 显示全部楼层
我不知道你是从哪个地址上访问你的“公网服务器”的呀?

看一下 netstat -nr 的结果呗。
回复

使用道具 举报

 楼主| 发表于 2004-10-18 14:13:42 | 显示全部楼层
一语惊醒梦中人,我前面都是在内网试的,跑到外网一试,http ok了,但是ftp还不行
回复

使用道具 举报

发表于 2004-10-18 14:18:45 | 显示全部楼层
FTP 的 LVS 没有试过。按原理说应该要给 20 端口也要转发的,或者使用 PASV 模式。
回复

使用道具 举报

 楼主| 发表于 2004-10-18 14:21:20 | 显示全部楼层
我加了20端口也不行,而且我感觉nat方式的负载均衡不怎么样,我连续五次访问了我的http,但是连续5次的服务都指向同一台服务器去了
回复

使用道具 举报

 楼主| 发表于 2004-10-18 14:22:39 | 显示全部楼层
[root@test9 ha.d]# ipvsadm -C
[root@test9 ha.d]# ipvsadm -A -t 210.75.11.36:80 -s wrr
[root@test9 ha.d]# ipvsadm -a -t 210.75.11.36:80 -r 10.0.0.9:80 -m -w 2
[root@test9 ha.d]# ipvsadm -a -t 210.75.11.36:80 -r 10.0.0.100:80 -m -w 3
[root@test9 ha.d]# ipvsadm -A -t 210.75.11.36:21 -s wrr
[root@test9 ha.d]#  ipvsadm -a -t 210.75.11.36:21 -r 10.0.0.9:21 -m -w 2
[root@test9 ha.d]# ipvsadm -a -t 210.75.11.36:21 -r 10.0.0.100:21 -m -w 3
[root@test9 ha.d]# ipvsadm -A -t 210.75.11.36:20 -s wrr
[root@test9 ha.d]# ipvsadm -a -t 210.75.11.36:20 -r 10.0.0.9:20 -m -w 2
[root@test9 ha.d]# ipvsadm -a -t 210.75.11.36:20  -r 10.0.0.100:20  -m -w 3
[root@test9 ha.d]# ipvsadm
IP Virtual Server version 1.0.8 (size=65536)
Prot LocalAddressort Scheduler Flags
  -> RemoteAddressort           Forward Weight ActiveConn InActConn
TCP  test9:ftp-data wrr
  -> 10.0.0.100:ftp-data          Masq    3      0          0         
  -> test3:ftp-data               Masq    2      0          0         
TCP  test9:ftp wrr
  -> 10.0.0.100:ftp               Masq    3      0          0         
  -> test3:ftp                    Masq    2      0          0         
TCP  test9:http wrr
  -> 10.0.0.100:http              Masq    3      3          1         
  -> test3:http                   Masq    2      0          4         
[root@test9 ha.d]#
回复

使用道具 举报

 楼主| 发表于 2004-10-18 14:27:47 | 显示全部楼层
你有没有使用ipvs架设过企业应用?
回复

使用道具 举报

发表于 2004-10-18 20:17:39 | 显示全部楼层
[quote:680318fac4="lues"]我加了20端口也不行,而且我感觉nat方式的负载均衡不怎么样,我连续五次访问了我的http,但是连续5次的服务都指向同一台服务器去了[/quote]
NAT 方式的优点只是在于平台无关和地址私有,而负载均衡器常常会成为瓶颈。
连续5次指向同一服务器没有错,因为你指定使用的是 wrr 算法。另加一台客户机访问试试看,或者使用 rr / wlc 算法。

[quote:680318fac4="lues"]你有没有使用ipvs架设过企业应用?[/quote]
我架过的都是用VS-TUN方式,没有使用过 NAT 方式的。
回复

使用道具 举报

 楼主| 发表于 2004-10-19 10:13:52 | 显示全部楼层
我也想用VS/TUN方式来架设LVS集群,我现在用的操作系统是REDHAT LINUX AS 3.0,它的内核已经直接支持IPVS了,那我该怎么解决no arp的问题呢?我看到的配置过程都说要重新编译内核,有没有不重新编译内核的解决方法呢?
回复

使用道具 举报

 楼主| 发表于 2004-10-19 10:59:09 | 显示全部楼层
而且我的REDHAT LINUX AS 3.0没有/proc/sys/net/ipv4/conf/all/hidden这个文件
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2025-2-25 00:58 , Processed in 0.030501 second(s), 15 queries .

© 2001-2025 Discuz! Team. Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表