독까의 이야기

액티브디렉토리 (Active Directory) 및 MSCS 구축 테스트 #1 에 이어서 작성....

 

모든 사용자 접속 계정은 AD 관리자 계정으로 진행한다. 

 

가상화 서버 4대

AD DC : 211.115.90.51

DB1 : 211.115.90.52

DB2 : 211.115.90.53

Storage : 211.115.90.54

방화벽 정책 추가 : In/Outbound : TCP 135, 445, 3343 / UDP 3343

 

 

# 1 

가상화 서버 4대 중 스토리지 서버의 디스크 공간을 DB 의 공유 폴더로 사용을 하려고 한다. 

데이타 파티션 D 드라이브에 아무 폴더나 생성 하고 공유 설정을 진행한다. 

 

 

공유 경로 : \\STORAGE\AO_Storage

 

처음 의도는 iSCSI 를 구축해서 클러스터링 디스크를 만들려고 했는데, 테스트해보니깐 공유 폴더랑 차이가 없어서 그냥 진행한다. 

 

공유 폴더를 생성했으니, DB 서버에서 해당 폴더로 네트워크 연결을 시도해 본다. 이따가 AlwaysOn 구축시 필요하므로 꼭 연결 체크 해야한다. 

 

 

# 2

DB1 / DB2 서버에 장애 조치(Failover) 클러스터링을 설치를 한다.

 

DB1 / DB2 동일 작업

 

역할 및 기능 추가를 통해서 설치를 진행한다. 

 

 

DB1 단독 작업

 

DB1 의 관리 도구 열어서 장애 조치(Failover) 클러스터 관리자 실행한다. 

 

설정 된게 없기 때문에 아무것도 없다. 

 

 

클러스터 만들기를 선택 후 진행한다. 

 

 

서버 이름 입력에서 "찾아보기" 선택해서 DB1 과 DB2 를 넣어준다.

 

 

클러스트 관리 이름은 AO 로 한다. AlwaysOn 테스트 이기 때문이다. 뭐 본인이 편한거 아무거나 해도 된다. 딱히 큰 의미는 없다. 

아래에 추가해야 하는 클러스터 관리자 아이피는 AD 그룹과 동일 대역의 미사용 아이피를 입력한다. 

 

네트워크 : 211.115.90.0/26 

주소 : 211.115.90.55

 

 

Default 로 쭉쭉 간다. 완료 되면 아래와 같이 확인 가능하다. 

 

 

 

 

이제 장애 조치 설정은 대충 마무리 되었다. 

 

 

# 3

DB1 / DB2 에 MS-SQL 2016 및 SSMS 설치를 진행한다. 

그냥 본인이 원하는 방식대로 설치를 진행하면 된다. 

 

설치가 정상적으로 완료가 되었으면, 몇 가지 변경 작업을 진행해보자. 

 

DB1 및 DB2 동일 작업

 

서비스 실행 

SQL Server (MSSQLSERVER) 및 SQL Server 에이전트 (MSSQLSERVER) 의 로그온 계정을 AD 관리자 계정으로 변경한다. 

 

 

위 방식은 내가 편할려고 하는 거니깐 이 방식이 맞다고 할 수는 없다. 알아서 하면 되지 않을까 싶다. 

 

 SQL Server 2016 구성 관리자 실행 후 AlwaysOn 고가용성 사용을 체크한다. 

 

 

각 DB 서버에서 SSMS 실행 후, 

 

 

보안 - 로그인 - AD 계정 선택 - 속성

 

서버 역할 : sysadmin 추가

사용자 매핑 : master 선택 / db_owner 선택

 

 

 

여기까지가 DB 의 기본 설정 부분이다. 

 

 

# 4

DB 및 AlwaysOn 고가용성 그룹 생성을 진행한다. 

 

DB1 에서 임의의 데이타 베이스를 생성한다. 

나는 AO1 로 생성했다. 

 

Always On 고가용성 에서 가용성 그룹을 신규 생성한다. 마법사로 진행하면 편하다. 

 

 

다음 단계로 넘어가면 AO1 DB 에 백업이 되어 있지 않다고 진행이 안 된다. 한 번 전체 백업 실행 해주고 다음으로 넘어간다. 

 

 

 

복제본 지정 단계가 나오는데, 복제본 추가를 눌러서 DB2 를 끌어온다. 

 

모든 서버의 접속 계정 및 SQL 서비스 실행 계정이 AD 관리자 계정 이므로, Windows 인증으로 해도 된다. 본인이 다르게 설정 했으면 알아서 하면 된다. 

 

 

DB2 와 연결이 정상적으로 되면, 보조 영역에 추가 된다. 나머지 설정들은 그냥 스킵해도 된다. 

 

 

다음 단계에서 데이터 동기화를 위한 백업 경로 지정이 있는데, 여기에 아까 생성했던 스토리지의 공유 폴더 경로를 등록한다. 

 

 

 

그런데 오류가 발생해서 그룹 생성이 실패한다. 

 

 

오류 문구를 확인해 보니, 기존 클러스터 구성이 삭제 되었기 때문에 SQL 구성 관리자에서 AlwaysOn 기능을 해제 했다가 다시 적용을 해야 한단다. 

게시글 작성을 위해 모든 설정 초기화 하고 다시 진행 했더니 이런 오류가 생겼다. 

오류 발생 처리에 관해서도 확인이 됐으니 다행으로 생각한다. 

 

 

가용성 그룹 생성 완료 되면, DB1 에서는 아래와 같이 확인 된다. 

 

 

DB2 에서는 아래와 같이 데이타베이스 접근 불가 확인된다. 장애 대비를 위한 대기 상태 이므로 기능이 전부 제한된다. 

 

 

 

# 5

장애 조치 테스트를 진행해야 하므로, DB1 서버를 종료한다. 

 

장애 조치 클러스터 소유자 노드가 DB-2 로 변경 되었다. 

 

 

 

DB 가용성 그룹의 Master 와 Slave 역할이 변경 되었다. 

 

 

다시 DB1 서버를 켜고, 역할 복원을 진행한다. 

장애 조치로 역할이 변경 되면, 서비스가 복구 되어도 자동으로 원복이 되지 않는다. 

수동으로 역할 변경 해줘야 한다. 이 부분은 약간 좀 그런듯 하다. 

 

DB1 또는 DB2 에서 AOG그룹 선택 후 장애 조치 진행하면 된다. 

 

 

그 전에, 장애조치를 통한 데이타 동기화를 확인해야 하므로 활성화 된 DB2 에서 임시 테이블을 생성한다. 

 

create table gunnm_test (

Number varchar(50) null,

ID varchar(50) null,

PW varchar(50) null,

NAME varchar(50) null,

)

 

 

테이블 생성도 했으니깐, 장애 조치를 강제로 진행한다. 

 

 

 

장애 조치 수동 진행 후, 클러스터 소유자 노드가 다시 DB-1 로 변경 되었다. 

 

 

 

DB Master 와 Slave 역할도 변경 되었다. DB2 에서 생성한 임시 테이블도 조회가 된다. 

 

 

SQL 미러링은 모니터링 서버를 구축해야지만 자동 장애 조치가 진행되는데 반해, AD 를 통한 클러스터링은 자기들이 알아서 진행하니 편리하긴 한다. 

 

다만, 다시 원상태로 복구는 수동으로 진행해야 하므로, 반드시 서비스 장애 모니터링을 해야 한다. 

 

 

MS-SQL 의 단순 미러링 기능 보다 업그레이드 된 MS-SQL Always On 기능을 사용하기 위해서 액티브 디렉토리 및 MSCS 를 구축하려고 한다. 

 

준비물 : Windows 2012 R2 가상화 서버 4대

AD DC : 211.115.90.51

DB1 : 211.115.90.52

DB2 : 211.115.90.53

Storage : 211.115.90.54

방화벽 정책 추가 : In/Outbound : TCP 135, 445, 3343 / UDP 3343

 

 

# 1 

액티브 디렉토리 도메인 컨트롤러 (AD DC) 서버로 사용 될 211.115.90.51 서버에 AD DS 서비스를 설치한다. 

서버 관리자 에서 역할 및 기능 추가 들어간 다음, Active Directory 도메인 서비스 를 선택 후 설치를 진행한다. 

그냥 Default 로 진행하면 된다. 

해당 역할 설치시에 DNS 서비스도 같이 설치가 진행 되므로, 굳이 선택을 안 해줘도 된다. 

 

 

설치가 완료되면, 상단 알림창 클릭 후 "이 서버를 도메인 컨트롤러로 승격" 을 선택한다. 

 

 

배포 작업에서 "새 포리스트를 추가합니다." 를 선택 하고, 루트 도메인은 본인이 하고 싶은 도메인으로 하면 된다. 

 

 

나머지는 Default 로 쭉쭉 진행하자. 추가 값을 입력하거나 할 필요는 없을 것 같다. 

 

 

설치가 정상적으로 완료가 되면 서버 재시작이 필요하므로, 그전에 작업하고 있던 내역들은 저장하는 것이 좋다. 

 

리부팅 완료 후, 컴퓨터명을 아래와 같은 형식으로 변경해주자. 굳이 같은 이름으로 할 필요는 없다. 

 

 

컴퓨터명을 바꿨으니 또 서버 재시작을 해야 한다. 참고로 컴퓨터명은 AD 서비스 설치 전에 해도 무방하다. 

 

관리도구에서 Active Directory 사용자 및 컴퓨터 를 실행해서 확인하면 DC 서버가 정상 등록 된게 확인된다. 

 

AD DC 에서의 설정은 이 정도면 충분하다. 

 

 

 

# 2 

DB1 / DB2 / Storage 에서는 동일한 설정 변경을 통해 AD 그룹에 등록이 되도록 해야 한다. 

 

네트워크 어댑터 설정에서 DNS 주소 중 1개를 AD DC 의 IP 로 할당을 한다. 

 

 

네트워크 설정 완료 후, 컴퓨터명의 소속 그룹을 도메인 으로 변경 및 입력해 주어야 한다. 

 

 

확인을 누르면 로그인 화면이 뜨는데 AD DC 의 계정 정보를 입력한다. 

 

 

 

이런 식으로 DNS 정보 및 컴퓨터명을 변경 해주고나면 AD 그룹에 등록이 되는데, 확인은 AD DC 에서 진행한다. 

 

 

 

컴퓨터 그룹 및 DNS 에 정상적으로 해당 서버들이 등록되어 있음이 확인 되었다. 

 

참고로, 윈도우 방화벽에 AD 그룹 서버군에 대한 허용 정책 추가를 권장한다. (Inbound, Outbound)

 

테스트에 필요한 AD 그룹 구축은 이 정도에서 마무리 가능한 것 같다. 

 

MSCS 설정은 다음 게시글에 작성 하기로 한다. 

 

L4 스위치의 부하 분산 기능을 리눅스 서버를 통해 진행하고자 한다. 


서버의 구성은 아래와 같이 하면 될 것 같다. 


VIP : 121.254.175.70
LVS1 : 121.254.175.77
LVS2 : 121.254.175.78
WEB1 : 121.254.175.75
WEB2 : 121.254.175.74


임의 설정한 호스트네임 정보를 각 LVS 서버에 등록을 해야 한다.


/etc/hosts 

/etc/sysconfig/network
/proc/sys/kernel/hostname 


[Hostname]

LVS Active: lvsactive.gunnm.xyz

LVS Standby: lvsstandby.gunnm.xyz 



1.  LVS Active 서버에서의 설정 : 121.254.175.77


# echo 'lvsactive.gunnm.xyz' > /proc/sys/kernel/hostname 


# vi /etc/sysconfig/network


NETWORKING=yes

HOSTNAME=lvsactive.gunnm.xyz 


# vi /etc/hosts


121.254.175.77 lvsactive.gunnm.xyz

121.254.175.78 lvsstandby.gunnm.xyz 


# vi /etc/sysctl.conf


net.ipv4.ip_forward = 1


# 하단에 추가

net.ipv4.vs.secure_tcp=3

net.ipv4.vs.drop_packet=0

net.ipv4.vs.drop_entry=0

net.ipv4.vs.am_droprate=10

net.ipv4.vs.amemthresh=1024


# sysctl -p


heartbeat + ldirectord 설치


# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

# yum install heartbeat* -y


# yum -y install ipvsadm

# yum -y install perl-IO-Socket-INET6

# yum -y install perl-Email-Send

# yum -y install perl-MailTools

# yum -y install perl-Net-SSLeay

# yum -y install perl-libwww-perl

# yum install ldirect*


빨간색은 실패하는 설치 패키지이다. 

아래의 링크를 통해 ldirectord 파일 다운로드 및 설치를 진행해야 한다. 


- 32bit

# wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/i686/ldirectord-3.9.5-3.1.i686.rpm


- 64bit

# wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/x86_64/ldirectord-3.9.5-3.1.x86_64.rpm


# rpm -ivh ldirectord-3.9.5-3.1.x86_64.rpm 


HA 설정 (Standby 의 상태 체크)

/usr/share/doc/heartbeat-3.0.4/ha.cf 를 복사해와도 되지만 그냥 새로 만들고 아래 내용을 입력한다. 


# vi /etc/ha.d/ha.cf


debugfile /var/log/ha-debug.log

logfile /var/log/ha.log

keepalive 2

deadtime 10

udpport 694

ucast eth0 121.254.175.78

node lvsactive.gunnm.xyz

node lvsstandby.gunnm.xyz

ping 121.254.175.65

auto_failback on

respawn hacluster /usr/lib64/heartbeat/ipfail

apiauth ipfail gid=haclient uid=hacluster 


가상IP 를 설정한다. 


# vi /etc/ha.d/haresources


lvsactive.gunnm.xyz \ldirectord::ldirectord.cf \

IPaddr2::121.254.175.70/32/eth0 


authkey 를 생성한다. 

# vi /etc/ha.d/authkeys


auth 2

2 sha1 gunnmlvs


root 만 읽을수 있도록 권한을 설정한다.


# chmod 600 /etc/ha.d/authkeys


-rw-------. 1 root root 23 2018-08-08 13:07 /etc/ha.d/authkeys 


 분배 설정을 진행한다.

# vi /etc/ha.d/ldirectord.cf


checktimeout=10

checkinterval=10

autoreload=no

logfile="/var/log/ldirectord.log"

quiescent=no

# Web Server LVS

virtual=121.254.175.70:80

real=121.254.175.75:80 gate 10

real=121.254.175.74:80 gate 10

service=http

request="gunnm.lvs"

receive="gunnm"

scheduler=wlc

persistent=3600

protocol=tcp

checktype=negotiate


세션 동기화를 위한 방화벽 룰셋 추가


# iptables -t nat -A OUTPUT -d 224.0.0.81 -p udp --dport 8848 -j DNAT --to 121.254.175.78:8848

# iptables -t nat -A PREROUTING -s 121.254.175.78 -p udp --dport 8848 -j DNAT --to 224.0.0.81:8848

# iptables -t mangle -A PREROUTING -p tcp -s 0.0.0.0/0 -d 121.254.175.70/32 --dport 80 -j MARK --set-mark 1

# iptables -t mangle -A PREROUTING -p tcp -s 0.0.0.0/0 -d 121.254.175.70/32 --dport 443 -j MARK --set-mark 1 


# service iptables save 

# service iptables restart



2.  LVS Standby 서버에서의 설정 : 121.254.175.78


# echo 'lvsstandby.gunnm.xyz' > /proc/sys/kernel/hostname 


# vi /etc/sysconfig/network


NETWORKING=yes

HOSTNAME=lvsstandby.gunnm.xyz 


# vi /etc/hosts


121.254.175.77 lvsactive.gunnm.xyz

121.254.175.78 lvsstandby.gunnm.xyz 


# vi /etc/sysctl.conf


net.ipv4.ip_forward = 1


# 하단에 추가

net.ipv4.vs.secure_tcp=3

net.ipv4.vs.drop_packet=0

net.ipv4.vs.drop_entry=0

net.ipv4.vs.am_droprate=10

net.ipv4.vs.amemthresh=1024


# sysctl -p


heartbeat + ldirectord 설치


# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

# yum install heartbeat* -y


# yum -y install ipvsadm

# yum -y install perl-IO-Socket-INET6

# yum -y install perl-Email-Send

# yum -y install perl-MailTools

# yum -y install perl-Net-SSLeay

# yum -y install perl-libwww-perl

# yum install ldirect*


빨간색은 실패하는 설치 패키지이다. 

아래의 링크를 통해 ldirectord 파일 다운로드 및 설치를 진행해야 한다. 


- 32bit

# wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/i686/ldirectord-3.9.5-3.1.i686.rpm


- 64bit

# wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/x86_64/ldirectord-3.9.5-3.1.x86_64.rpm


# rpm -ivh ldirectord-3.9.5-3.1.x86_64.rpm 


HA 설정 (Active 의 상태 체크)

/usr/share/doc/heartbeat-3.0.4/ha.cf 를 복사해와도 되지만 그냥 새로 만들고 아래 내용을 입력한다. 


# vi /etc/ha.d/ha.cf


debugfile /var/log/ha-debug.log

logfile /var/log/ha.log

keepalive 2

deadtime 10

udpport 694

ucast eth0 121.254.175.77

node lvsactive.gunnm.xyz

node lvsstandby.gunnm.xyz

ping 121.254.175.65

auto_failback on

respawn hacluster /usr/lib64/heartbeat/ipfail

apiauth ipfail gid=haclient uid=hacluster 


가상IP 를 설정한다. 


# vi /etc/ha.d/haresources


lvsstandby.gunnm.xyz \ldirectord::ldirectord.cf \

IPaddr2::121.254.175.70/32/eth0 


authkey 를 생성한다. 

# vi /etc/ha.d/authkeys


auth 2

2 sha1 gunnmlvs


root 만 읽을수 있도록 권한을 설정한다.


# chmod 600 /etc/ha.d/authkeys


-rw-------. 1 root root 23 2018-08-08 14:12 /etc/ha.d/authkeys


 분배 설정을 진행한다.

# vi /etc/ha.d/ldirectord.cf


checktimeout=10

checkinterval=10

autoreload=no

logfile="/var/log/ldirectord.log"

quiescent=no

# Web Server LVS

virtual=121.254.175.70:80

real=121.254.175.74:80 gate 10

real=121.254.175.75:80 gate 10

service=http

request="gunnm.lvs"

receive="gunnm"

scheduler=wlc

persistent=3600

protocol=tcp

checktype=negotiate


세션 동기화를 위한 방화벽 룰셋 추가


# iptables -t nat -A OUTPUT -d 224.0.0.81 -p udp --dport 8848 -j DNAT --to 121.254.175.77:8848

# iptables -t nat -A PREROUTING -s 121.254.175.77 -p udp --dport 8848 -j DNAT --to 224.0.0.81:8848

# iptables -t mangle -A PREROUTING -p tcp -s 0.0.0.0/0 -d 121.254.175.70/32 --dport 80 -j MARK --set-mark 1

# iptables -t mangle -A PREROUTING -p tcp -s 0.0.0.0/0 -d 121.254.175.70/32 --dport 443 -j MARK --set-mark 1 


# service iptables save 

# service iptables restart



3.  LVS Active 및 Standby 서버에서 Heartbeat 구동


# service heartbeat start


Starting High-Availability services: ERROR: Cannot locate resource script \ldirectord

/usr/share/heartbeat/ResourceManager: line 209: ldirectord.cf: command not found

Done.


서비스 구동이 실패한다! 

실패 원인을 확인해 본다.  


 /etc/ha.d/ldirectord.cf 의 구문 띄어쓰기에 문제가 있었음이 확인됐다. (별 말도 안되는 걸로 오류가 남)


checktimeout=10

checkinterval=10

autoreload=no

logfile="/var/log/ldirectord.log"

quiescent=no

# Web Server LVS

virtual=121.254.175.70:80

        real=121.254.175.75:80 gate 10

        real=121.254.175.74:80 gate 10

        service=http

        request="gunnm.lvs"

        receive="gunnm"

        scheduler=wlc

        persistent=3600

        protocol=tcp

        checktype=negotiate


이렇게 수정하고 나니깐 정상적으로 작동 된다. 


LVS Active 에서 
# ip addr
을 통해서 아이피 두 개가 활성화 된 것을 확인 할 수 있다. 

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 5e:df:dd:9f:3b:e0 brd ff:ff:ff:ff:ff:ff
    inet 121.254.175.77/28 brd 121.254.175.79 scope global eth0
    inet 121.254.175.70/32 brd 121.254.175.79 scope global eth0
    inet6 fe80::5cdf:ddff:fe9f:3be0/64 scope link
       valid_lft forever preferred_lft forever

LVS Standby 에서는 아래와 같이 확인 된다. 

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 2a:8b:f9:ad:f0:30 brd ff:ff:ff:ff:ff:ff
    inet 121.254.175.78/28 brd 121.254.175.79 scope global eth0
    inet6 fe80::288b:f9ff:fead:f030/64 scope link
       valid_lft forever preferred_lft forever



4.  강제 failover 발생시 구동 상태 확인


LVS Active 에서 heartbeat 를 중지한다. 


#  service heartbeat stop

Stopping High-Availability services: Done.


# ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

    inet6 ::1/128 scope host

       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

    link/ether 5e:df:dd:9f:3b:e0 brd ff:ff:ff:ff:ff:ff

    inet 121.254.175.77/28 brd 121.254.175.79 scope global eth0

    inet6 fe80::5cdf:ddff:fe9f:3be0/64 scope link

       valid_lft forever preferred_lft forever


# vi /var/log/ha.log

ResourceManager(default)[10507]:        2018/08/08_16:33:14 info: Running /etc/ha.d/resource.d/ldirectord ldirectord.cf stop

Aug 08 16:33:15 lvsactive.gunnm.xyz heartbeat: [10494]: info: All HA resources relinquished.

Aug 08 16:33:16 lvsactive.gunnm.xyz heartbeat: [9790]: info: killing /usr/lib64/heartbeat/ipfail process group 9816 with signal 15

Aug 08 16:33:17 lvsactive.gunnm.xyz heartbeat: [9790]: WARN: 1 lost packet(s) for [lvsstandby.gunnm.xyz] [542:544]

Aug 08 16:33:17 lvsactive.gunnm.xyz heartbeat: [9790]: info: No pkts missing from lvsstandby.gunnm.xyz!

Aug 08 16:33:18 lvsactive.gunnm.xyz heartbeat: [9790]: info: killing HBFIFO process 9793 with signal 15

Aug 08 16:33:18 lvsactive.gunnm.xyz heartbeat: [9790]: info: killing HBWRITE process 9794 with signal 15

Aug 08 16:33:18 lvsactive.gunnm.xyz heartbeat: [9790]: info: killing HBREAD process 9795 with signal 15

Aug 08 16:33:18 lvsactive.gunnm.xyz heartbeat: [9790]: info: killing HBWRITE process 9796 with signal 15

Aug 08 16:33:18 lvsactive.gunnm.xyz heartbeat: [9790]: info: killing HBREAD process 9797 with signal 15

Aug 08 16:33:18 lvsactive.gunnm.xyz heartbeat: [9790]: info: Core process 9797 exited. 5 remaining

Aug 08 16:33:18 lvsactive.gunnm.xyz heartbeat: [9790]: info: Core process 9794 exited. 4 remaining

Aug 08 16:33:18 lvsactive.gunnm.xyz heartbeat: [9790]: info: Core process 9795 exited. 3 remaining

Aug 08 16:33:18 lvsactive.gunnm.xyz heartbeat: [9790]: info: Core process 9793 exited. 2 remaining

Aug 08 16:33:18 lvsactive.gunnm.xyz heartbeat: [9790]: info: Core process 9796 exited. 1 remaining

Aug 08 16:33:18 lvsactive.gunnm.xyz heartbeat: [9790]: info: lvsactive.gunnm.xyz Heartbeat shutdown complete.



LVS Standby 에서 상태 확인 한다. 


# ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

    inet6 ::1/128 scope host

       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

    link/ether 2a:8b:f9:ad:f0:30 brd ff:ff:ff:ff:ff:ff

    inet 121.254.175.78/28 brd 121.254.175.79 scope global eth0

    inet 121.254.175.70/32 brd 121.254.175.79 scope global eth0

    inet6 fe80::288b:f9ff:fead:f030/64 scope link

       valid_lft forever preferred_lft forever


# vi /var/log/ha.log
Aug 08 16:33:16 lvsstandby.gunnm.xyz heartbeat: [1415]: info: Received shutdown notice from 'lvsactive.gunnm.xyz'.
Aug 08 16:33:16 lvsstandby.gunnm.xyz heartbeat: [1415]: info: Resources being acquired from lvsactive.gunnm.xyz.
Aug 08 16:33:16 lvsstandby.gunnm.xyz heartbeat: [3108]: info: acquire all HA resources (standby).
ResourceManager(default)[3135]: 2018/08/08_16:33:16 info: Acquiring resource group: lvsstandby.gunnm.xyz ldirectord::ldirectord.cf IPaddr2::121.254.175.70/32/eth0
Aug 08 16:33:16 lvsstandby.gunnm.xyz heartbeat: [3109]: info: Local Resource acquisition completed.
ResourceManager(default)[3135]: 2018/08/08_16:33:16 info: Running /etc/ha.d/resource.d/ldirectord ldirectord.cf start
/usr/lib/ocf/resource.d//heartbeat/IPaddr2(IPaddr2_121.254.175.70)[3224]:       2018/08/08_16:33:17 INFO:  Resource is stopped
ResourceManager(default)[3135]: 2018/08/08_16:33:17 info: Running /etc/ha.d/resource.d/IPaddr2 121.254.175.70/32/eth0 start
IPaddr2(IPaddr2_121.254.175.70)[3356]:  2018/08/08_16:33:17 INFO: Adding inet address 121.254.175.70/32 with broadcast address 121.254.175.79 to device eth0
IPaddr2(IPaddr2_121.254.175.70)[3356]:  2018/08/08_16:33:17 INFO: Bringing device eth0 up


Active 다운시 자동으로 Standby 가 역할 전담하는 것을 확인했다. 

다시 Active 활성화시의 상태를 확인한다. 

Active log 

Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10859]: info: Pacemaker support: false
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10859]: WARN: Logging daemon is disabled --enabling logging daemon is recommended
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10859]: info: **************************
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10859]: info: Configuration validated. Starting heartbeat 3.0.4
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: heartbeat: version 3.0.4
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: Heartbeat generation: 1533705889
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: glib: ucast: write socket priority set to IPTOS_LOWDELAY on eth0
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: glib: ucast: bound send socket to device: eth0
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: glib: ucast: set SO_REUSEPORT(w)
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: glib: ucast: bound receive socket to device: eth0
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: glib: ucast: set SO_REUSEPORT(w)
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: glib: ucast: started on port 694 interface eth0 to 121.254.175.78
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: glib: ping heartbeat started.
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: G_main_add_TriggerHandler: Added signal manual handler
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: G_main_add_TriggerHandler: Added signal manual handler
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: G_main_add_SignalHandler: Added signal handler for signal 17
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: Local status now set to: 'up'
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: Link 121.254.175.65:121.254.175.65 up.
Aug 08 16:37:54 lvsactive.gunnm.xyz heartbeat: [10860]: info: Status update for node 121.254.175.65: status ping
Aug 08 16:37:56 lvsactive.gunnm.xyz heartbeat: [10860]: info: Link lvsstandby.gunnm.xyz:eth0 up.
Aug 08 16:37:56 lvsactive.gunnm.xyz heartbeat: [10860]: info: Status update for node lvsstandby.gunnm.xyz: status active
harc(default)[10869]:   2018/08/08_16:37:56 info: Running /etc/ha.d//rc.d/status status
Aug 08 16:37:56 lvsactive.gunnm.xyz heartbeat: [10860]: info: Comm_now_up(): updating status to active
Aug 08 16:37:56 lvsactive.gunnm.xyz heartbeat: [10860]: info: Local status now set to: 'active'
Aug 08 16:37:56 lvsactive.gunnm.xyz heartbeat: [10860]: info: Starting child client "/usr/lib64/heartbeat/ipfail" (496,495)
Aug 08 16:37:56 lvsactive.gunnm.xyz heartbeat: [10886]: info: Starting "/usr/lib64/heartbeat/ipfail" as uid 496  gid 495 (pid 10886)
Aug 08 16:37:57 lvsactive.gunnm.xyz heartbeat: [10860]: info: remote resource transition completed.
Aug 08 16:37:57 lvsactive.gunnm.xyz heartbeat: [10860]: info: remote resource transition completed.
Aug 08 16:37:57 lvsactive.gunnm.xyz heartbeat: [10860]: info: Local Resource acquisition completed. (none)
Aug 08 16:37:57 lvsactive.gunnm.xyz heartbeat: [10860]: info: lvsstandby.gunnm.xyz wants to go standby [foreign]
Aug 08 16:37:58 lvsactive.gunnm.xyz heartbeat: [10860]: info: standby: acquire [foreign] resources from lvsstandby.gunnm.xyz
Aug 08 16:37:58 lvsactive.gunnm.xyz heartbeat: [10890]: info: acquire local HA resources (standby).
ResourceManager(default)[10903]:        2018/08/08_16:37:58 info: Acquiring resource group: lvsactive.gunnm.xyz ldirectord::ldirectord.cf IPaddr2::121.254.175.70/32/eth0
ResourceManager(default)[10903]:        2018/08/08_16:37:58 info: Running /etc/ha.d/resource.d/ldirectord ldirectord.cf start
/usr/lib/ocf/resource.d//heartbeat/IPaddr2(IPaddr2_121.254.175.70)[10967]:      2018/08/08_16:37:59 INFO:  Resource is stopped
ResourceManager(default)[10903]:        2018/08/08_16:37:59 info: Running /etc/ha.d/resource.d/IPaddr2 121.254.175.70/32/eth0 start
IPaddr2(IPaddr2_121.254.175.70)[11098]: 2018/08/08_16:37:59 INFO: Adding inet address 121.254.175.70/32 with broadcast address 121.254.175.79 to device eth0
IPaddr2(IPaddr2_121.254.175.70)[11098]: 2018/08/08_16:37:59 INFO: Bringing device eth0 up
IPaddr2(IPaddr2_121.254.175.70)[11098]: 2018/08/08_16:37:59 INFO: /usr/libexec/heartbeat/send_arp -i 200 -r 5 -p /var/run/resource-agents/send_arp-121.254.175.70 eth0 121.254.175.70 auto not_used not_used
/usr/lib/ocf/resource.d//heartbeat/IPaddr2(IPaddr2_121.254.175.70)[11072]:      2018/08/08_16:37:59 INFO:  Success
Aug 08 16:37:59 lvsactive.gunnm.xyz heartbeat: [10890]: info: local HA resource acquisition completed (standby).
Aug 08 16:37:59 lvsactive.gunnm.xyz heartbeat: [10860]: info: Standby resource acquisition done [foreign].
Aug 08 16:37:59 lvsactive.gunnm.xyz heartbeat: [10860]: info: Initial resource acquisition complete (auto_failback)
Aug 08 16:38:00 lvsactive.gunnm.xyz heartbeat: [10860]: info: remote resource transition completed.
Aug 08 16:38:06 lvsactive.gunnm.xyz ipfail: [10886]: info: Telling other node that we have more visible ping nodes.
Aug 08 16:38:12 lvsactive.gunnm.xyz heartbeat: [10860]: info: lvsstandby.gunnm.xyz wants to go standby [all]
Aug 08 16:38:13 lvsactive.gunnm.xyz heartbeat: [10860]: info: standby: acquire [all] resources from lvsstandby.gunnm.xyz
Aug 08 16:38:13 lvsactive.gunnm.xyz heartbeat: [11183]: info: acquire all HA resources (standby).
ResourceManager(default)[11196]:        2018/08/08_16:38:13 info: Acquiring resource group: lvsactive.gunnm.xyz ldirectord::ldirectord.cf IPaddr2::121.254.175.70/32/eth0
ResourceManager(default)[11196]:        2018/08/08_16:38:14 info: Running /etc/ha.d/resource.d/ldirectord ldirectord.cf start
/usr/lib/ocf/resource.d//heartbeat/IPaddr2(IPaddr2_121.254.175.70)[11254]:      2018/08/08_16:38:14 INFO:  Running OK
Aug 08 16:38:14 lvsactive.gunnm.xyz heartbeat: [11183]: info: all HA resource acquisition completed (standby).
Aug 08 16:38:14 lvsactive.gunnm.xyz heartbeat: [10860]: info: Standby resource acquisition done [all].
Aug 08 16:38:15 lvsactive.gunnm.xyz heartbeat: [10860]: info: remote resource transition completed.

Standby log

Aug 08 16:37:55 lvsstandby.gunnm.xyz heartbeat: [1415]: info: Heartbeat restart on node lvsactive.gunnm.xyz
Aug 08 16:37:55 lvsstandby.gunnm.xyz heartbeat: [1415]: info: Link lvsactive.gunnm.xyz:eth0 up.
Aug 08 16:37:55 lvsstandby.gunnm.xyz heartbeat: [1415]: info: Status update for node lvsactive.gunnm.xyz: status init
Aug 08 16:37:55 lvsstandby.gunnm.xyz heartbeat: [1415]: info: Status update for node lvsactive.gunnm.xyz: status up
harc(default)[3761]:    2018/08/08_16:37:55 info: Running /etc/ha.d//rc.d/status status
harc(default)[3777]:    2018/08/08_16:37:55 info: Running /etc/ha.d//rc.d/status status
Aug 08 16:37:57 lvsstandby.gunnm.xyz heartbeat: [1415]: info: Status update for node lvsactive.gunnm.xyz: status active
harc(default)[3793]:    2018/08/08_16:37:57 info: Running /etc/ha.d//rc.d/status status
Aug 08 16:37:58 lvsstandby.gunnm.xyz heartbeat: [1415]: info: remote resource transition completed.
Aug 08 16:37:58 lvsstandby.gunnm.xyz heartbeat: [1415]: info: lvsstandby.gunnm.xyz wants to go standby [foreign]
Aug 08 16:37:58 lvsstandby.gunnm.xyz heartbeat: [1415]: info: standby: lvsactive.gunnm.xyz can take our foreign resources
Aug 08 16:37:58 lvsstandby.gunnm.xyz heartbeat: [3809]: info: give up foreign HA resources (standby).
Aug 08 16:37:58 lvsstandby.gunnm.xyz heartbeat: [3809]: info: foreign HA resource release completed (standby).
Aug 08 16:37:58 lvsstandby.gunnm.xyz heartbeat: [1415]: info: Local standby process completed [foreign].
Aug 08 16:38:00 lvsstandby.gunnm.xyz heartbeat: [1415]: WARN: 1 lost packet(s) for [lvsactive.gunnm.xyz] [12:14]
Aug 08 16:38:00 lvsstandby.gunnm.xyz heartbeat: [1415]: info: remote resource transition completed.
Aug 08 16:38:00 lvsstandby.gunnm.xyz heartbeat: [1415]: info: No pkts missing from lvsactive.gunnm.xyz!
Aug 08 16:38:00 lvsstandby.gunnm.xyz heartbeat: [1415]: info: Other node completed standby takeover of foreign resources.
Aug 08 16:38:12 lvsstandby.gunnm.xyz heartbeat: [1415]: info: lvsstandby.gunnm.xyz wants to go standby [all]
Aug 08 16:38:13 lvsstandby.gunnm.xyz heartbeat: [1415]: info: standby: lvsactive.gunnm.xyz can take our all resources
Aug 08 16:38:13 lvsstandby.gunnm.xyz heartbeat: [3849]: info: give up all HA resources (standby).
ResourceManager(default)[3862]: 2018/08/08_16:38:13 info: Releasing resource group: lvsstandby.gunnm.xyz ldirectord::ldirectord.cf IPaddr2::121.254.175.70/32/eth0
ResourceManager(default)[3862]: 2018/08/08_16:38:13 info: Running /etc/ha.d/resource.d/IPaddr2 121.254.175.70/32/eth0 stop
IPaddr2(IPaddr2_121.254.175.70)[3923]:  2018/08/08_16:38:13 INFO: IP status = ok, IP_CIP=
/usr/lib/ocf/resource.d//heartbeat/IPaddr2(IPaddr2_121.254.175.70)[3897]:       2018/08/08_16:38:13 INFO:  Success
ResourceManager(default)[3862]: 2018/08/08_16:38:13 info: Running /etc/ha.d/resource.d/ldirectord ldirectord.cf stop
Aug 08 16:38:13 lvsstandby.gunnm.xyz heartbeat: [3849]: info: all HA resource release completed (standby).
Aug 08 16:38:13 lvsstandby.gunnm.xyz heartbeat: [1415]: info: Local standby process completed [all].
Aug 08 16:38:15 lvsstandby.gunnm.xyz heartbeat: [1415]: WARN: 1 lost packet(s) for [lvsactive.gunnm.xyz] [26:28]
Aug 08 16:38:15 lvsstandby.gunnm.xyz heartbeat: [1415]: info: remote resource transition completed.
Aug 08 16:38:15 lvsstandby.gunnm.xyz heartbeat: [1415]: info: No pkts missing from lvsactive.gunnm.xyz!
Aug 08 16:38:15 lvsstandby.gunnm.xyz heartbeat: [1415]: info: Other node completed standby takeover of all resources.


Active 와 Standby 가 알아서 역할을 잘 설정한다. 



5.  실시간 모니터링 및 ldirectord 설정 변경시 적용 파일 생성


# vi /root/lvs.sh


#!/bin/sh

watch -n1 -t "echo ; ip addr ; echo ; ipvsadm -Ln ; ipvsadm -Ln --rate ; ipvsadm -Lnc"




# vi /root/ldirect.sh (/etc/ha.d/ldirectord.cf 파일 내용 수정 후, reload 하는 파일)


#!/bin/sh

/etc/ha.d/resource.d/ldirectord /etc/ha.d/ldirectord.cf reload 



Active 에서

# sh lvs.sh 입력시 접속 세션 확인 가능 


1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

    inet6 ::1/128 scope host

       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

    link/ether 5e:df:dd:9f:3b:e0 brd ff:ff:ff:ff:ff:ff

    inet 121.254.175.77/28 brd 121.254.175.79 scope global eth0

    inet 121.254.175.70/32 brd 121.254.175.79 scope global eth0

    inet6 fe80::5cdf:ddff:fe9f:3be0/64 scope link

       valid_lft forever preferred_lft forever


IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn

TCP  121.254.175.70:80 wlc persistent 3600

  -> 121.254.175.74:80            Route   10     0          1

  -> 121.254.175.75:80            Route   10     5          2

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port                 CPS    InPPS   OutPPS    InBPS   OutBPS

  -> RemoteAddress:Port

TCP  121.254.175.70:80                   0        1        0       85        0

  -> 121.254.175.74:80                   0        0        0       38        0

  -> 121.254.175.75:80                   0        0        0       47        0

IPVS connection entries

pro expire state       source             virtual            destination

TCP 48:09  NONE        92.31.1.6:0        121.254.175.70:80  121.254.175.75:80

TCP 14:37  ESTABLISHED 222.231.27.246:6060 121.254.175.70:80  121.254.175.75:80

TCP 05:11  ESTABLISHED 222.231.27.246:6005 121.254.175.70:80  121.254.175.75:80

TCP 14:36  ESTABLISHED 222.231.27.246:6064 121.254.175.70:80  121.254.175.75:80

TCP 01:08  FIN_WAIT    222.231.27.246:6061 121.254.175.70:80  121.254.175.75:80

TCP 01:36  FIN_WAIT    222.231.27.246:6062 121.254.175.70:80  121.254.175.75:80

TCP 05:11  ESTABLISHED 222.231.27.246:6020 121.254.175.70:80  121.254.175.75:80

TCP 00:00  CLOSE       118.69.170.35:60980 121.254.175.70:80  121.254.175.74:80

TCP 14:47  ESTABLISHED 121.254.171.226:52493 121.254.175.70:80  121.254.175.75:80

TCP 59:49  NONE        118.69.170.35:0    121.254.175.70:80  121.254.175.74:80

TCP 59:17  NONE        121.254.171.226:0  121.254.175.70:80  121.254.175.75:80

TCP 59:36  NONE        222.231.27.246:0   121.254.175.70:80  121.254.175.75:80




Standby 에서는 아무것도 연결이 되어 있지 않다. 


1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

    inet6 ::1/128 scope host

       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

    link/ether 2a:8b:f9:ad:f0:30 brd ff:ff:ff:ff:ff:ff

    inet 121.254.175.78/28 brd 121.254.175.79 scope global eth0

    inet 121.254.175.70/32 brd 121.254.175.79 scope global eth0

    inet6 fe80::288b:f9ff:fead:f030/64 scope link

       valid_lft forever preferred_lft forever


IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn

TCP  121.254.175.70:80 wlc persistent 3600

  -> 121.254.175.75:80            Route   10     3          0

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port                 CPS    InPPS   OutPPS    InBPS   OutBPS

  -> RemoteAddress:Port

TCP  121.254.175.70:80                   0        0        0        0        0

  -> 121.254.175.75:80                   0        0        0        0        0

IPVS connection entries

pro expire state       source             virtual            destination

TCP 11:27  ESTABLISHED 222.231.27.246:5992 121.254.175.70:80  121.254.175.75:80

TCP 56:27  NONE        222.231.27.246:0   121.254.175.70:80  121.254.175.75:80

TCP 11:27  ESTABLISHED 222.231.27.246:5991 121.254.175.70:80  121.254.175.75:80

TCP 11:27  ESTABLISHED 222.231.27.246:5993 121.254.175.70:80  121.254.175.75:80



이번 테스트는 동일 아이피 대역의 서버들끼로 진행을 했으니깐 간단하게 설정이 되었으나, 대역이 다른 서버들간의 구성시에는 라우트 추가가 진행되어야 한다. 

해당 방법은 차후에 다시 해보기로 한다.