Linux操作系统下的集群工作原理及实战经历
作者 佚名技术
来源 Linux系统
浏览
发布时间 2012-05-12
|
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文件中.
Real Server的配置
Real Server的配置相对简单,主要是是以下几点:
配置telnet和WWW |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn
为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!
|