| 贵州学习网—属于你的学习中心 |
|
然后,对内核打补丁,如下操作: [root@vs2 /root]# cd /usr/src/linux [root@vs2 linux]# patch -p1 < ipvs-1.0.6-2.2.19/ipvs-1.0.6-2.2.19. patch 下面就是重新配置和编译linux的内核。特别注意以下选项: 1 code maturity level options---> * [*]prompt for development and/or incomplete code/drivers 2 networking部分: [*] kernel/user netlink socket [*] routing messages <*> netlink device emulation * [*] network firewalls [*] socket filtering <*> unix domain sockets * [*] tcp/ip networking [*] ip: multicasting [*] ip: advanced router [ ] ip: policy routing [ ] ip: equal cost multipath [ ] ip: use tos value as routing key [ ] ip: verbose route monitoring [ ] ip: large routing tables [ ] ip: kernel level autoconfiguration * [*] ip: firewalling [ ] ip: firewall packet netlink device * [*] ip: transparent proxy support * [*] ip: masquerading --- protocol-specific masquerading support will be built as modules. * [*] ip: icmp masquerading --- protocol-specific masquerading support will be built as modules. * [*] ip: masquerading special modules support * ip: ipautofw masq support (experimental)(new) * ip: ipportfw masq support (experimental)(new) * ip: ip fwmark masq-forwarding support (experimental)(new) * [*] ip: masquerading virtual server support (experimental)(new) [*] ip virtual server debugging (new) <--最好选择此项,以便观察lvs的调试信息 * (12) ip masquerading vs table size (the nth power of 2) (new) * ipvs: round-robin scheduling (new) * ipvs: weighted round-robin scheduling (new) * ipvs: least-connection scheduling (new) * ipvs: weighted least-connection scheduling (new) * ipvs: locality-based least-connection scheduling (new) * ipvs: locality-based least-connection with replication scheduling (new) * [*] ip: optimize as router not host * ip: tunneling ip: gre tunnels over ip [*] ip: broadcast gre over ip [*] ip: multicast routing [*] ip: pim-sm version 1 support [*] ip: pim-sm version 2 support * [*] ip: aliasing support [ ] ip: arp daemon support (experimental) * [*] ip: tcp syncookie support (not enabled per default) --- (it is safe to leave these untouched) < > ip: reverse arp [*] ip: allow large windows (not recommended if <16mb of memory) < > the ipv6 protocol (experimental) 上面,带*号的为必选项。然后就是常规的编译内核过程,不再赘述。 在这里要注意一点:如果你使用的是redhat自带的内核或者从redhat下载的内核版本,已经预先打好了lvs的补丁。这可以通过查看/usr/src/linux/net/目录下有没有几个ipvs开头的文件来判断:如果有,则说明已经打过补丁。 编写lvs配置文件,实例中的配置文件如下: #lvs_dr.conf (c) joseph mack mack@ncifcrf.gov lvs_type=vs_dr initial_state=on vip=eth0:101 192.168.0.101 255.255.255.0 192.168.0.0 director_insideip=eth0 192.168.0.1 192.168.0.0 255.255.255.0 192.168.0. 255 service=t telnet rr rs1:telnet rs2:telnet service=t www rr rs1:www rs2:www server_vip_device=dummy0 server_net_device=eth0 #----------end lvs_dr.conf------------------------------------ 将该文件置于/etc/lvs目录下。 使用lvs的配置脚本产生lvs.conf文件。该配置脚本可以从http://www.linuxvirtualserver.org/joseph.mack/configure-lvs_0.8.tar.gz 单独下载,在ipvs-1.0.6-2.2.19.tar.gz包中也有包含脚本configure的使用方法: [root@vs2 lvs]# configure lvs.conf 这样会产生几个配置文件,这里我们只使用其中的rc.lvs_dr文件。修改/etc/rc.d/init.d/rc.local,增加如下几行: echo 1 > /proc/sys/net/ipv4/ip_forward echo 1 > /proc/sys/net/ipv4/ip_always_defrag # 显示最多调试信息 echo 10 > /proc/sys/net/ipv4/vs/debug_level 配置nfs服务。这一步仅仅是为了方便管理,不是必须的步骤。假设配置文件lvs.conf文件放在/etc/lvs目录下,则/etc/exports文件的内容为: /etc/lvs ro(rs1,rs2) 然后使用exportfs命令输出这个目录: [root@vs2 lvs]# exportfs 如果遇到什么麻烦,可以尝试: [root@vs2 lvs]# /etc/rc.d/init.d/nfs restart [root@vs2 lvs]# exportfs 这样,各个real server可以通过nfs获得rc.lvs_dr文件,方便了集群的配置:你每次修改lvs.conf中的配置选项,都可以即可反映在rs1,rs2的相应目录里。 修改/etc/syslogd.conf,增加如下一行: kern.* /var/log/kernel_log。这样,lvs的一些调试信息就会写入/var/log/kernel_log文件中。 |
责任编辑:gzu521