SELS-11-SP3负载均衡_LVS+keepalived

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

SUSE11SP3负载均衡部署方法把开发包gccC++选上,编译安装软件时需用上。到了网络配置要把防火墙关掉,点击“disable”按默认配置全部配置完成。中途会要求设置root用户密码和创建一个新用户密码。二.LVSMASTER机器安装配置更改网卡IP地址cd/etc/sysconfig/networkviifcfg-eth0以下是参考内容:BOOTPROTO='static'把原来的dhcp改成staticBROADCAST=''ETHTOOL_OPTIONS=''IPADDR='192.168.168.10'MTU=''NAME='VMXNET3EthernetController'NETMASK='255.255.255.0'NETWORK=''REMOTE_IPADDR=''STARTMODE='auto'USERCONTROL='no'增加网关:在同一目录/etc/sysconfig/network新增一个名为routes的文件,直接命令Viroutes内容为default192.168.168.254重启网卡服务Servicenetworkrestart用ifconfig–a命令查看ip地址配置是否正确。用netstat–rn命令查看路由是否正确启用。使用远程工具SecureCRT登录。并使用工具自带的Sftp功能把需要安装的软件包上传到服务器上放软件包的本地电脑以下是sftp的操作过程:sftplcdE:\software\linux_opensftpcd/tmpsftpputcluster-network-kmp-default-1.4_3.0.76_0.9-2.23.24.x86_64.rpmUploadingcluster-network-kmp-default-1.4_3.0.76_0.9-2.23.24.x86_64.rpmto/tmp/cluster-network-kmp-default-1.4_3.0.76_0.9-2.23.24.x86_64.rpm100%86KB86KB/s00:00:00E:/software/linux_open/cluster-network-kmp-default-1.4_3.0.76_0.9-2.23.24.x86_64.rpm:88709bytestransferredin0seconds(86KB/s)sftpputipvsadm-1.26-5.9.1.x86_64.rpmUploadingipvsadm-1.26-5.9.1.x86_64.rpmto/tmp/ipvsadm-1.26-5.9.1.x86_64.rpm100%37KB37KB/s00:00:00E:/software/linux_open/ipvsadm-1.26-5.9.1.x86_64.rpm:38828bytestransferredin0seconds(37KB/s)sftpputopenssl-devel-0.9.8j-2.1.x86_64.rpmUploadingopenssl-devel-0.9.8j-2.1.x86_64.rpmto/tmp/openssl-devel-0.9.8j-2.1.x86_64.rpm100%995KB995KB/s00:00:00E:/software/linux_open/openssl-devel-0.9.8j-2.1.x86_64.rpm:1018912bytestransferredin0seconds(995KB/s)sftpputkeepalived-1.2.15.tar.gzUploadingkeepalived-1.2.15.tar.gzto/tmp/keepalived-1.2.15.tar.gz100%337KB337KB/s00:00:00E:/software/linux_open/keepalived-1.2.15.tar.gz:345471bytestransferredin0seconds(337KB/s)sftp已经上传到/tmp目录上。安装查看ip_vs模块是否在核心里susetest:/tmp#lsmod|grepip_vs没有,需要安装下面这个包才有susetest:/tmp#rpm-ivhcluster-network-kmp-default-1.4_3.0.76_0.9-2.23.24.x86_64.rpmPreparing...###########################################[100%]packagecluster-network-kmp-default-1.4_3.0.76_0.9-2.23.24.x86_64isalreadyinstalledsusetest:/tmp#modprobeip_vs再查看,已经有了,表示支持LVS.susetest:/tmp#lsmod|grepip_vsip_vs_wlc125191ip_vs1543223ip_vs_wlcnf_conntrack871191ip_vsip6_tables275241ip_vslibcrc32c126441ip_vsipv6_lib34491430ip_vs,ipv6接下来安装下面的包susetest:/tmp#rpm-ivhipvsadm-1.26-5.9.1.x86_64.rpmPreparing...###########################################[100%]packageipvsadm-1.26-5.9.1.x86_64isalreadyinstalledsusetest:/tmp#rpm-ivhopenssl-devel-0.9.8j-2.1.x86_64.rpmwarning:openssl-devel-0.9.8j-2.1.x86_64.rpm:HeaderV3DSAsignature:NOKEY,keyID3e34cec9Preparing...###########################################[100%]packageopenssl-devel-0.9.8j-2.1.x86_64isalreadyinstalledsusetest:/tmp#解压keepalivedsusetest:/tmp#tar-zxvfkeepalived-1.2.15.tar.gzsusetest:/tmp#cdkeepalived-1.2.15/编译安装susetest:/tmp/keepalived-1.2.15#./configuresusetest:/tmp/keepalived-1.2.15#echo$?这句验证上一句执行返回码,如果为0则正常,1或2为不正常。0susetest:/tmp/keepalived-1.2.15#makesusetest:/tmp/keepalived-1.2.15#echo$?0susetest:/tmp/keepalived-1.2.15#makeinstallsusetest:/tmp/keepalived-1.2.15#echo$?0新建目录keepalived在/etc下susetest:/usr/local/etc/keepalived#mkdir-p/etc/keepalivedsusetest:/usr/local/etc#cd/etc/keepalived/创建keepalived.conf配置文件susetest:/etc/keepalived#vikeepalived.conf!ConfigurationFileforkeepalivedglobal_defs{router_idLVS_DEVEL}vrrp_instanceVI_1{stateBACKUPinterfaceeth0virtual_router_id51priority100advert_int1nopreepmt#此句作用为防止强制接管服务authentication{auth_typePASSauth_pass1111}virtual_ipaddress{192.168.168.100}}virtual_server192.168.168.10080{delay_loop6lb_algowlclb_kindDRpersistence_timeout300protocolTCPreal_server192.168.168.11180{weight1HTTP_GET{url{path/status_code200}connect_timeout3nb_get_retry3delay_before_retry1}}real_server192.168.168.11280{weight1HTTP_GET{url{path/status_code200}connect_timeout3nb_get_retry3delay_before_retry1}}}保存退出。把启动脚本写入系统自启动susetest:/etc/rc.d#vi/etc/rc.d/boot.local#!/bin/sh##Copyright(c)2002SuSELinuxAGNuernberg,Germany.Allrightsreserved.##Author:WernerFinkwerner@suse.de,1996#BurchardSteinbild,1996##/etc/init.d/boot.local##scriptwithlocalcommandstobeexecutedfrominitonsystemstartup##Hereyoushouldaddthings,thatshouldhappendirectlyafterbooting#beforewe'regoingtothefirstrunlevel.#启动加入下面这句/usr/local/sbin/keepalived启动时直接执行/usr/local/sbin/keepalived更改了配置以后,直接使用kill–HUP进程号进行更新,此方法不中断进程运行。susetest:/etc/keepalived#ps-ef|grepkeepalivedroot41851010:14?00:00:00/usr/local/sbin/keepalivedroot41864185010:14?00:00:00/usr/local/sbin/keepalivedroot41874185010:14?00:00:00/usr/local/sbin/keepalivedroot42823988010:17pts/200:00:00grepkeepalivedsusetest:/etc/keepalived#kill-HUP4185停止时使用kill的方式来杀进程,使用ps–ef|grepkeepalived查看进程号。三.LVSBACKUP机器安装配置安装软件包及方法与MASTER一样,只有/etc/keepalived/keepalived.conf的配置把以下两句修改成:为了防止让主LVS在重新online的时候把服务接管,则主备都把state改成BACKUPpriority100改为90(比主LVS的小一点)其他一样。四.app服务器上的LVS部署无论有多少台应用服务器,配置都一致。只需运行一个脚本就可以实现,运行前请修改脚本内容IP地址为实际IP。在系统启动脚本中加入以下红色内容:susetest:/etc/rc.d#vi/etc/rc.d/boot.local#!/bin/sh##Copyright(c)2002SuSELinuxAGNuernberg,Germany.Allrightsreserved.##Author:WernerFinkwerner@suse.de,1996#BurchardSteinbild,1996##/etc/ini

1 / 12
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功