20170627_jeffrey - silenceuncrio/diary GitHub Wiki

0905

keepalived 只要設定好 /etc/keepalived/keepalived.conf 之後

shell 下直接執行 keepalived 就好了

keepalived 瘋狂的打印 message 的地方如下

/* report_child_status returns true if the exit is a hard error, so unable to continue */
bool
report_child_status(int status, pid_t pid, char const *prog_name)
{
	...
	if (WIFSIGNALED(status)) {
		if (WTERMSIG(status) == SIGSEGV) {
			log_message(LOG_INFO, "%s exited due to segmentation fault (SIGSEGV).", prog_id);
			log_message(LOG_INFO, "  Please report a bug at %s", "https://github.com/acassen/keepalived/issues");
			log_message(LOG_INFO, "  %s", "and include this log from when keepalived started, what happened");
			log_message(LOG_INFO, "  %s", "immediately before the crash, and your configuration file.");
		}
		else
			log_message(LOG_INFO, "%s exited due to signal %d", prog_id, WTERMSIG(status));

		return false;
	}

	return false;
}

雖然利用 logread | grep keep 只看到下面的 log 一直在循環

2017-06-27 01:11:36 Mobile Router daemon.info Keepalived[24794]:   Please report a bug at https://github.com/acassen/keepalived/issues
2017-06-27 01:11:36 Mobile Router daemon.info Keepalived[24794]:   and include this log from when keepalived started, what happened
...
2017-06-27 01:11:39 Mobile Router daemon.info Keepalived[24794]:   Please report a bug at https://github.com/acassen/keepalived/issues
2017-06-27 01:11:39 Mobile Router daemon.info Keepalived[24794]:   and include this log from when keepalived started, what happened

不過稍微往上捲一下 console 畫面總算看到了完整的訊息

...

2017-06-27 01:11:05 Mobile Router daemon.alert Keepalived[24794]: Healthcheck child process(29316) died: Respawning
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]: Starting Healthcheck child process, pid=29318
2017-06-27 01:11:05 Mobile Router local2.debug Keepalived_healthcheckers[29318]: Initializing ipvs
2017-06-27 01:11:05 Mobile Router user.err modprobe: module ip_vs not found in modules.dep
2017-06-27 01:11:05 Mobile Router local2.info Keepalived_healthcheckers[29318]: IPVS: Can't initialize ipvs: Protocol not available
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]: Keepalived_healthcheckers exited due to segmentation fault (SIGSEGV).
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]:   Please report a bug at https://github.com/acassen/keepalived/issues
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]:   and include this log from when keepalived started, what happened
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]:   immediately before the crash, and your configuration file.

2017-06-27 01:11:05 Mobile Router daemon.alert Keepalived[24794]: Healthcheck child process(29318) died: Respawning
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]: Starting Healthcheck child process, pid=29321
2017-06-27 01:11:05 Mobile Router local2.debug Keepalived_healthcheckers[29321]: Initializing ipvs
2017-06-27 01:11:05 Mobile Router user.err modprobe: module ip_vs not found in modules.dep
2017-06-27 01:11:05 Mobile Router local2.info Keepalived_healthcheckers[29321]: IPVS: Can't initialize ipvs: Protocol not available
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]: Keepalived_healthcheckers exited due to segmentation fault (SIGSEGV).
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]:   Please report a bug at https://github.com/acassen/keepalived/issues
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]:   and include this log from when keepalived started, what happened
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]:   immediately before the crash, and your configuration file.

2017-06-27 01:11:05 Mobile Router daemon.alert Keepalived[24794]: Healthcheck child process(29321) died: Respawning
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]: Starting Healthcheck child process, pid=29324
2017-06-27 01:11:05 Mobile Router local2.debug Keepalived_healthcheckers[29324]: Initializing ipvs
2017-06-27 01:11:05 Mobile Router user.err modprobe: module ip_vs not found in modules.dep
2017-06-27 01:11:05 Mobile Router local2.info Keepalived_healthcheckers[29324]: IPVS: Can't initialize ipvs: Protocol not available
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]: Keepalived_healthcheckers exited due to segmentation fault (SIGSEGV).
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]:   Please report a bug at https://github.com/acassen/keepalived/issues
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]:   and include this log from when keepalived started, what happened
2017-06-27 01:11:05 Mobile Router daemon.info Keepalived[24794]:   immediately before the crash, and your configuration file.

...

0935

將 log 去個頭看得比較清楚

Healthcheck child process(29321) died: Respawning
Starting Healthcheck child process, pid=29324
Initializing ipvs
module ip_vs not found in modules.dep
IPVS: Can't initialize ipvs: Protocol not available
Keepalived_healthcheckers exited due to segmentation fault (SIGSEGV).
Please report a bug at https://github.com/acassen/keepalived/issues
and include this log from when keepalived started, what happened
immediately before the crash, and your configuration file.

看起來就是 Healthcheck 這個 child process 掛了

參考一下 keepalived 有哪些 option 可以用

root@Mobile Router:~# keepalived -h
Usage: keepalived [OPTION...]
  -f, --use-file=FILE          Use the specified configuration file
  -P, --vrrp                   Only run with VRRP subsystem
  -C, --check                  Only run with Health-checker subsystem
  -l, --log-console            Log messages to local console
  -D, --log-detail             Detailed log messages
  -S, --log-facility=[0-7]     Set syslog facility to LOG_LOCAL[0-7]
  -X, --release-vips           Drop VIP on transition from signal.
  -V, --dont-release-vrrp      Don't remove VRRP VIPs and VROUTEs on daemon stop
  -I, --dont-release-ipvs      Don't remove IPVS topology on daemon stop
  -R, --dont-respawn           Don't respawn child processes
  -n, --dont-fork              Don't fork the daemon process
  -d, --dump-conf              Dump the configuration data
  -p, --pid=FILE               Use specified pidfile for parent process
  -r, --vrrp_pid=FILE          Use specified pidfile for VRRP child process
  -c, --checkers_pid=FILE      Use specified pidfile for checkers child process
  -a, --address-monitoring     Report all address additions/deletions notified via netlink
  -s, --namespace=NAME         Run in network namespace NAME (overrides config)
  -m, --core-dump              Produce core dump if terminate abnormally
  -M, --core-dump-pattern=PATN Also set /proc/sys/kernel/core_pattern to PATN (default 'core')
  -i, --config_id id           Skip any configuration lines beginning '@' that don't match id
  -v, --version                Display the version number
  -h, --help                   Display this help message

使用 -P - Only run with VRRP subsystem

keepalived 已經不會瘋狂的打印 message 了

1025

目前測試環境如下

+-------------+
|DHCP Server  |
|192.168.0.250|
+---+---------+
    |
    +----------------------+---+ WAN
    |                      |
+---+----------------+ +---+----------------+
|M300                | |M301                |
|* WAN: DHCP Client  | |* WAN: DHCP Client  |
|* LAN: 192.168.1.100| |* LAN: 192.168.1.101|
+---+----------------+ +---+----------------+
    |                      |
+---+----------------------+----------------+
|Virtual Router: 192.168.1.200              |
+---+---------------------------------------+
    |
    +--------------------------+ LAN
    |
+---+----------------+
|PC                  |
|* LAN: 192.168.1.1  |
|* GW:  192.168.1.200|
+--------------------+

M300 的 VRRP 設定 - /etc/keepalived/keepalived.conf

vrrp_instance m30x {
  state MASTER
  interface lan
  virtual_router_id 200
  priority 150
  advert_int 1
  virtual_ipaddress {
    192.168.1.200
  }
}

M301 的 VRRP 設定 - /etc/keepalived/keepalived.conf

vrrp_instance m30x {
  state BACKUP
  interface lan
  virtual_router_id 200
  priority 160
  advert_int 1
  virtual_ipaddress {
    192.168.1.200
  }
}

PC 端進行測試

jeffrey@jeffrey-U-100:~$ ping 192.168.1.100
PING 192.168.1.100 (192.168.1.100) 56(84) bytes of data.
64 bytes from 192.168.1.100: icmp_seq=1 ttl=64 time=0.548 ms
64 bytes from 192.168.1.100: icmp_seq=2 ttl=64 time=0.487 ms
64 bytes from 192.168.1.100: icmp_seq=3 ttl=64 time=0.488 ms
64 bytes from 192.168.1.100: icmp_seq=4 ttl=64 time=0.490 ms
^C
--- 192.168.1.100 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3067ms
rtt min/avg/max/mdev = 0.487/0.503/0.548/0.030 ms
jeffrey@jeffrey-U-100:~$ ping 192.168.1.101
PING 192.168.1.101 (192.168.1.101) 56(84) bytes of data.
64 bytes from 192.168.1.101: icmp_seq=1 ttl=64 time=0.602 ms
64 bytes from 192.168.1.101: icmp_seq=2 ttl=64 time=0.492 ms
64 bytes from 192.168.1.101: icmp_seq=3 ttl=64 time=0.541 ms
64 bytes from 192.168.1.101: icmp_seq=4 ttl=64 time=0.812 ms
^C
--- 192.168.1.101 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3050ms
rtt min/avg/max/mdev = 0.492/0.611/0.812/0.125 ms
jeffrey@jeffrey-U-100:~$ ping 192.168.1.200
PING 192.168.1.200 (192.168.1.200) 56(84) bytes of data.
64 bytes from 192.168.1.200: icmp_seq=1 ttl=64 time=0.618 ms
64 bytes from 192.168.1.200: icmp_seq=2 ttl=64 time=0.520 ms
64 bytes from 192.168.1.200: icmp_seq=3 ttl=64 time=0.537 ms
64 bytes from 192.168.1.200: icmp_seq=4 ttl=64 time=0.806 ms
^C
--- 192.168.1.200 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3057ms
rtt min/avg/max/mdev = 0.520/0.620/0.806/0.114 ms
jeffrey@jeffrey-U-100:~$ arp
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.1.100            ether   00:03:79:03:00:00   C                     enp1s0
192.168.1.200            ether   00:03:79:03:01:00   C                     enp1s0
192.168.1.101            ether   00:03:79:03:01:00   C                     enp1s0
jeffrey@jeffrey-U-100:~$ ping 192.168.0.250
PING 192.168.0.250 (192.168.0.250) 56(84) bytes of data.
64 bytes from 192.168.0.250: icmp_seq=1 ttl=63 time=4.75 ms
64 bytes from 192.168.0.250: icmp_seq=2 ttl=63 time=1.74 ms
64 bytes from 192.168.0.250: icmp_seq=3 ttl=63 time=1.03 ms
64 bytes from 192.168.0.250: icmp_seq=4 ttl=63 time=1.21 ms
^C
--- 192.168.0.250 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 1.035/2.187/4.753/1.504 ms
jeffrey@jeffrey-U-100:~$ tracepath 192.168.0.250
 1?: [LOCALHOST]                                         pmtu 1500
 1:  192.168.1.101                                         2.608ms 
 1:  192.168.1.101                                         1.338ms 
 2:  192.168.0.250                                         2.736ms reached
     Resume: pmtu 1500 hops 2 back 2 

拔掉 M310 的 LAN 端 網路線

jeffrey@jeffrey-U-100:~$ tracepath 192.168.0.250
 1?: [LOCALHOST]                                         pmtu 1500
 1:  192.168.1.100                                         1.531ms 
 1:  192.168.1.100                                         0.799ms 
 2:  192.168.0.250                                         3.234ms reached
     Resume: pmtu 1500 hops 2 back 2 

1055

不太確定這樣的測試結果正不正確

回頭看一下之前 survey 的文章

1110

先收集一下兩邊的 log

利用 logread | grep -i keep - -i 表示忽略大小寫

M300

root@Mobile Router:~# logread | grep -i keep
2017-06-27 02:23:07 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Received advert with higher priority 160, ours 150
2017-06-27 02:23:07 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Entering BACKUP STATE
2017-06-27 02:29:32 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Transition to MASTER STATE
2017-06-27 02:29:33 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Entering MASTER STATE
2017-06-27 02:48:39 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Received advert with higher priority 160, ours 150
2017-06-27 02:48:39 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Entering BACKUP STATE
2017-06-27 02:53:42 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Transition to MASTER STATE
2017-06-27 02:53:43 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Entering MASTER STATE
2017-06-27 02:54:15 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Received advert with higher priority 160, ours 150
2017-06-27 02:54:15 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Entering BACKUP STATE
2017-06-27 02:54:35 Mobile Router local1.info Keepalived_vrrp[28754]: Kernel is reporting: interface lan DOWN
2017-06-27 02:54:35 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Now in FAULT state
2017-06-27 02:54:39 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Entering BACKUP STATE
2017-06-27 02:54:45 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Transition to MASTER STATE
2017-06-27 02:54:46 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Entering MASTER STATE
2017-06-27 02:54:54 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Received advert with higher priority 160, ours 150
2017-06-27 02:54:54 Mobile Router local1.info Keepalived_vrrp[28754]: VRRP_Instance(m30x) Entering BACKUP STATE

M310

root@Mobile Router:/var/log# logread | grep -i keep
2017-06-27 02:23:07 Mobile Router daemon.info Keepalived[13127]: Starting Keepalived v1.3.5 (06/09,2017), git commit v1.5-23-g30d98fd+
2017-06-27 02:23:07 Mobile Router daemon.info Keepalived[13127]: Unable to resolve default script username 'keepalived_script' - ignoring
2017-06-27 02:23:07 Mobile Router daemon.info Keepalived[13127]: Opening file '/etc/keepalived/keepalived.conf'.
2017-06-27 02:23:07 Mobile Router daemon.info Keepalived[13128]: Starting VRRP child process, pid=13129
2017-06-27 02:23:07 Mobile Router local1.info Keepalived_vrrp[13129]: Registering Kernel netlink reflector
2017-06-27 02:23:07 Mobile Router local1.info Keepalived_vrrp[13129]: Registering Kernel netlink command channel
2017-06-27 02:23:07 Mobile Router local1.info Keepalived_vrrp[13129]: Registering gratuitous ARP shared channel
2017-06-27 02:23:07 Mobile Router local1.info Keepalived_vrrp[13129]: Opening file '/etc/keepalived/keepalived.conf'.
2017-06-27 02:23:07 Mobile Router local1.info Keepalived_vrrp[13129]: Using LinkWatch kernel netlink reflector...
2017-06-27 02:23:07 Mobile Router local1.info Keepalived_vrrp[13129]: VRRP_Instance(m30x) Entering BACKUP STATE
2017-06-27 02:23:07 Mobile Router local1.info Keepalived_vrrp[13129]: VRRP_Instance(m30x) forcing a new MASTER election
2017-06-27 02:23:08 Mobile Router local1.info Keepalived_vrrp[13129]: VRRP_Instance(m30x) Transition to MASTER STATE
2017-06-27 02:23:09 Mobile Router local1.info Keepalived_vrrp[13129]: VRRP_Instance(m30x) Entering MASTER STATE
2017-06-27 02:48:40 Mobile Router local1.info Keepalived_vrrp[13129]: VRRP_Instance(m30x) Received advert with lower priority 150, ours 160, forcing new election
2017-06-27 02:54:15 Mobile Router local1.info Keepalived_vrrp[13129]: VRRP_Instance(m30x) Received advert with lower priority 150, ours 160, forcing new election

看起來 VRRP 有在動了... 試著解析一下 log

1140

在進行 icos module 之前要先測一下 IPv6 的部分

1305

monkeyjj time

1425

回頭再 review 一下 VRRP 的進度

感覺這禮拜五周會可以先報告一下 keepalived 的測試結果

最好能加上 WEB UI 的構想

1640

花點時間再整理一下 Proscend MCSV

不勉強用英文

因為是為了方便 M30x 小組參考用途