기업 실례~3.lvs+Keepalived 구성
5944 단어 기업 실례keepalive 서비스
완료 DR
https://blog.csdn.net/Stella_Pooter/article/details/87778029기업 실례~1.lvs 3가지 작업 모드 및 원리 - DR 모드
이번 실험은 rhel6.5 버전 가상 머신 기반
스케줄러 1 서버 1 IP: 172.25.35.1
스케줄러 2 server4 IP: 172.25.35.4
Server 1 server2 IP: 172.25.35.2
Server 2 server3 IP: 172.25.35.3
스케줄러 1, 마스터 구성
ldirectord 중지
/etc/init.d/ldirectord stop
Stopping ldirectord... success
chkconfig ldirectord off
이전 정책 삭제 ipvsadm-C 삭제 ip addrdel 172.25.35.100/24 dev eth0
keepalived 원본 컴파일
tar zxf keepalived-2.0.6.tar.gz
컴파일에 필요한 소프트웨어 설치
yum install openssl-devel
번역하다
./configure --prefix=/usr/local/keepalived --with-init=SYSV
시스템 환경 변수 추가
make && make install
실행 권한 추가
chmod +x /usr/local/keepalived/etc/rc.d/init.d/keepalived
소프트 링크
ln -s /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
ln -s /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
ln -s /usr/local/keepalived/etc/keepalived/ /etc/
ln -s /usr/local/keepalived/sbin/keepalived /sbin/
소프트웨어 프로필vim/etc/keepalived/keepalived를 수정합니다.conf
! Configuration File for keepalived
global_defs {
notification_email {
root@localhost # 1
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
vrrp_skip_check_adv_addr
#vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_instance VI_1 {
state MASTER #
interface eth0
virtual_router_id 35 #
priority 100 #
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.25.35.100
}
}
virtual_server 172.25.35.100 80 { #
delay_loop 6
lb_algo rr
lb_kind DR # DR
#persistence_timeout 50
protocol TCP
real_server 172.25.35.2 80 { #
TCP_CHECK { #
weight 1 #
connect_timeout 3
retry 3
delay_before_retry 3
}
}
real_server 172.25.35.3 80 {
TCP_CHECK {
weight 1
connect_timeout 3
retry 3
delay_before_retry 3
}
}
}
서비스 개시
/etc/init.d/keepalived start
생성된 정책을 볼 수 있습니다.
ipvsadm -l
서버 2, 3 httpd 서비스 클라이언트 테스트 시작:
[root@foundation35 images]# curl 172.25.35.100
server2's Apache server
[root@foundation35 images]# curl 172.25.35.100
server3's Apache server
[root@foundation35 images]# curl 172.25.35.100
server2's Apache server
[root@foundation35 images]# curl 172.25.35.100
server3's Apache server
2. 주 서브노드
스케줄러 2: 보조 노드 스케줄러 1:
[root@server1 ~]# scp -r /usr/local/keepalived [email protected]:/usr/local/
스케줄러 1과 소프트 연결
vim /etc/keepalived/keepalived.conf
18 state BACKUP #
21 priority 50 #
[root@server4 ~]# /etc/init.d/keepalived start
Starting keepalived: [ OK ]
테스트 1: 스케줄러 1 마스터 닫기
[root@server1 init.d]# /etc/init.d/keepalived stop
Stopping keepalived: [ OK ]
보조 노드 IP 보기:
[root@server4 ~]# ip addr show
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:b5:c9:f6 brd ff:ff:ff:ff:ff:ff
inet 172.25.35.4/24 brd 172.25.35.255 scope global eth0
inet 172.25.35.100/32 scope global eth0
inet6 fe80::5054:ff:feb5:c9f6/64 scope link
valid_lft forever preferred_lft forever
우리는 35.100의 주소가 부노드에 있는 것을 볼 수 있다. 이를 노드 표류라고 부른다
클라이언트가 여전히 정상적으로 액세스됨
테스트 2:
마스터 오픈
[root@server1 init.d]# /etc/init.d/keepalived start
[root@server1 init.d]# ip addr show
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:03:88:63 brd ff:ff:ff:ff:ff:ff
inet 172.25.35.1/24 brd 172.25.35.255 scope global eth0
inet 172.25.35.100/32 scope global eth0
inet6 fe80::5054:ff:fe03:8863/64 scope link
valid_lft forever preferred_lft forever
[root@server4 ~]# ip addr show
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:b5:c9:f6 brd ff:ff:ff:ff:ff:ff
inet 172.25.35.4/24 brd 172.25.35.255 scope global eth0
inet6 fe80::5054:ff:feb5:c9f6/64 scope link
valid_lft forever preferred_lft forever
노드 리턴 서버 1
테스트 3: 서버 3 httpd 서비스 종료
[root@foundation35 images]# curl 172.25.35.100
server2's Apache server
[root@foundation35 images]# curl 172.25.35.100
curl: (7) Failed connect to 172.25.35.100:80; Connection refused
[root@foundation35 images]# curl 172.25.35.100
server2's Apache server
[root@foundation35 images]# curl 172.25.35.100
curl: (7) Failed connect to 172.25.35.100:80; Connection refused
몇 초 후 정상 작동
[root@foundation35 images]# curl 172.25.35.100
server2's Apache server
[root@foundation35 images]# curl 172.25.35.100
server2's Apache server
[root@foundation35 images]# curl 172.25.35.100
server2's Apache server
[root@foundation35 images]# curl 172.25.35.100
server2's Apache server
keepalive 서버를 위한 다운타임 제거
keepalive 사용자 안내서 첨부