keepalived高可用
keepalived简介
Keepalived是一个开源的高可用性解决方案,主要用于在Linux系统上实现IP负载均衡和故障切换。它可以将多个服务器组成一个虚拟的高可用性集群,通过共享一个虚拟IP地址来实现负载均衡和故障切换。
Keepalived的工作原理是通过VRRP(Virtual Router Redundancy Protocol)协议来实现高可用性。在Keepalived集群中,有一个Master节点和多个Backup节点,Master节点负责处理所有的请求,而Backup节点则处于备用状态。当Master节点发生故障时,Backup节点会自动接管Master节点的工作,确保服务的连续性。
keepalived的主要功能
- IP负载均衡:Keepalived可以将多个服务器组成一个虚拟的负载均衡集群,通过共享一个虚拟IP地址来分发请求,实现负载均衡。
- 故障切换:当Master节点发生故障时,Keepalived可以自动将Backup节点切换为Master节点,确保服务的连续性。
- 健康检查:Keepalived可以定期检查服务器的健康状态,如果发现某个服务器不可用,会自动将其从负载均衡集群中剔除。
- 配置灵活:Keepalived的配置文件可以根据需求进行灵活的定制,可以设置权重、优先级、检查间隔等参数。
- 日志和统计:Keepalived提供了详细的日志和统计信息,可以帮助管理员监控和调试集群的运行状态。
keepalived工作原理
Keepalived的工作原理主要基于VRRP(Virtual Router Redundancy Protocol)协议,它通过在多台服务器之间共享一个虚拟IP地址来实现负载均衡和故障切换。
在Keepalived集群中,有一个Master节点和多个Backup节点,Master节点负责处理所有的请求,而Backup节点则处于备用状态。Master节点会定期发送VRRP广播消息,告诉其他节点自己是Master节点,并提供虚拟IP地址。其他节点收到广播消息后,会根据Master节点的优先级和权重等参数来判断是否需要将自己切换为Master节点。
当Master节点发生故障时,其他节点会自动接管Master节点的工作,切换为新的Master节点,并重新分配虚拟IP地址。这样,即使某个节点发生故障,整个集群仍然可以保持高可用性和连续性。
除了VRRP协议,Keepalived还提供了健康检查和故障恢复等功能。它可以定期检查服务器的健康状态,如果发现某个服务器不可用,会自动将其从负载均衡集群中剔除。一旦故障节点恢复正常,Keepalived会自动将其重新加入集群。
总之,Keepalived的工作原理是基于VRRP协议和健康检查等功能,可以实现IP负载均衡和故障切换,确保服务的高可用性和连续性。
keepalived高可用故障转移的原理
Keepalived的高可用故障转移原理主要是通过VRRP(Virtual Router Redundancy Protocol)协议来实现的。VRRP是一种网络协议,用于在多个路由器之间共享一个虚拟IP地址,实现高可用性和故障转移。
在Keepalived集群中,有一个Master节点和多个Backup节点。Master节点负责处理所有的请求,而Backup节点处于备用状态。Master节点会定期发送VRRP广播消息,告诉其他节点自己是Master节点,并提供虚拟IP地址。
其他节点收到广播消息后,会根据Master节点的优先级和权重等参数来判断是否需要将自己切换为Master节点。如果某个Backup节点的优先级高于当前的Master节点,它会发送一个VRRP广播消息,通知其他节点将自己切换为Master节点,并重新分配虚拟IP地址。
当Master节点发生故障时,其他节点会自动接管Master节点的工作,切换为新的Master节点,并重新分配虚拟IP地址。这样,即使某个节点发生故障,整个集群仍然可以保持高可用性和连续性。
总之,Keepalived的高可用故障转移原理是基于VRRP协议和健康检查等功能,通过共享虚拟IP地址和切换节点角色来实现故障转移,确保服务的高可用性和连续性。
环境准备:
主机名 | ip地址 | 环境说明 |
---|---|---|
h1(主服务器) | 192.168.200.10 | 部署keepalived和haproxy |
h2(备服务器) | 192.168.200.20 | 部署keepalived和haproxy |
rs1 | 192.168.200.30 | 安装httpd服务 |
rs2 | 192.168.200.40 | 安装httpd服务 |
h1和h2的VIP为:192.168.200.250
部署haproxy
先在h1和h2主机上部署haproxy负载均衡,部署方法请参考:haproxy-CSDN博客
h1主机访问网页测试
h2主机访问网页测试
keepalived部署
配置epel源(在h1和h2主机上操作)
[root@h1 ~]# yum -y install https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
[root@h1 ~]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@h1 ~]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
[root@h1 ~]#
安装keepalived(在h1和h2主机上操作)
[root@h1 ~]# yum -y install epel-release vim wget gcc gcc-c++
[root@h1 ~]# yum -y install keepalived
查看安装生成的文件
[root@h1 ~]# rpm -ql keepalived
/etc/keepalived
/etc/keepalived/keepalived.conf
/etc/sysconfig/keepalived
/usr/bin/genhash
/usr/lib/.build-id
/usr/lib/.build-id/0a
...
[root@h1 ~]#
keepalived配置文件说明
keepalived 的主配置文件是 /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs { //全局配置
notification_email { //定义报警收件人邮件地址
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc //定义报警发件人邮箱
smtp_server 192.168.200.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 //指定keepalived节点的初始状态,可选值为MASTER|BACKUP
interface eth0 //VRRP实例绑定的网卡接口,用户发送VRRP包
virtual_router_id 51 //虚拟路由的ID,同一集群要一致
priority 100 //定义优先级,按优先级来决定主备角色,优先级越大越优先
nopreempt //设置不抢占
advert_int 1 //主备通讯时间间隔
authentication { //配置认证
auth_type PASS //认证方式,此处为密码
auth_pass 1111 //同一集群中的keepalived配置里的此处必须一致,推荐使用8位随机数
}
virtual_ipaddress { //配置要使用的VIP地址
192.168.200.16
}
}
virtual_server 192.168.200.16 1358 { //配置虚拟服务器
delay_loop 6 //健康检查的时间间隔
lb_algo rr //lvs调度算法
lb_kind NAT //lvs模式
persistence_timeout 50 //持久化超时时间,单位是秒
protocol TCP //4层协议
sorry_server 192.168.200.200 1358 //定义备用服务器,当所有RS都故障时用sorry_server来响应客户端
real_server 192.168.200.2 1358 { //定义真实处理请求的服务器
weight 1 //给服务器指定权重,默认为1
HTTP_GET {
url {
path /testurl/test.jsp //指定要检查的URL路径
digest 640205b7b0fc66c1ea91c463fac6334d //摘要信息
}
url {
path /testurl2/test.jsp
digest 640205b7b0fc66c1ea91c463fac6334d
}
url {
path /testurl3/test.jsp
digest 640205b7b0fc66c1ea91c463fac6334d
}
connect_timeout 3 //连接超时时间
nb_get_retry 3 //get尝试次数
delay_before_retry 3 //在尝试之前延迟多长时间
}
}
keepalived配置
配置主服务器keepalived
将keepalived.conf配置文件做个备份,修改keepalived.conf配置文件,并将不需要的内容删除
[root@h1 ~]# cp /etc/keepalived/keepalived.conf /opt/
[root@h1 ~]# ls /opt/
keepalived.conf
[root@h1 ~]#
[root@h1 ~]# vim /etc/keepalived/keepalived.conf
[root@h1 ~]# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id haproxy01
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 80
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.200.250
}
}
virtual_server 192.168.200.250 80 {
delay_loop 6
lb_algo rr
lb_kind NAT
persistence_timeout 50
protocol TCP
real_server 192.168.200.10 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.200.20 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
[root@h1 ~]#
设置keepalived服务开机自启
[root@h1 ~]# systemctl enable --now keepalived
Created symlink /etc/systemd/system/multi-user.target.wants/keepalived.service → /usr/lib/systemd/system/keepalived.service.
[root@h1 ~]#
[root@h1 ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:8189 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 [::]:22 [::]:*
[root@h1 ~]#
配置备服务器keepalived
将keepalived.conf配置文件做个备份,把h1主机的keepalived.conf配置文件远程拷贝过来
[root@h2 ~]# cp /etc/keepalived/keepalived.conf /opt/
[root@h2 ~]# cd /etc/keepalived/
[root@h2 keepalived]#
[root@h2 keepalived]# rm -rf keepalived.conf
[root@h2 keepalived]# ls
[root@h2 keepalived]#
[root@h2 keepalived]# scp 192.168.200.10:/etc/keepalived/keepalived.conf /etc/keepalived/
...
root@192.168.200.10's password:
keepalived.conf 100% 872 652.9KB/s 00:00
[root@h2 keepalived]#
[root@h2 keepalived]# ls
keepalived.conf
[root@h2 keepalived]#
修改keepalived.conf 配置文件,将state后面改成BACKUP,priority后面改低一点就行
[root@h2 keepalived]# vim keepalived.conf
[root@h2 keepalived]# cat keepalived.conf
! Configuration File for keepalived
global_defs {
router_id haproxy02
}
vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 80
priority 80
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.200.250
}
}
virtual_server 192.168.200.250 80 {
delay_loop 6
lb_algo rr
lb_kind NAT
persistence_timeout 50
protocol TCP
real_server 192.168.200.10 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.200.20 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
[root@h2 keepalived]#
同样重启keepalived服务
[root@h2 ~]# systemctl enable --now keepalived
Created symlink /etc/systemd/system/multi-user.target.wants/keepalived.service → /usr/lib/systemd/system/keepalived.service.
[root@h2 ~]#
[root@h2 ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 0.0.0.0:8189 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 128 [::]:111 [::]:*
[root@h2 ~]#
查看VIP
查看主服务器ip,此时VIP在主服务器上
[root@h1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:80:df:b8 brd ff:ff:ff:ff:ff:ff
inet 192.168.200.10/24 brd 192.168.200.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet 192.168.200.250/32 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe80:dfb8/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@h1 ~]#
被服务器中没有VIP
[root@h2 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:18:11:8c brd ff:ff:ff:ff:ff:ff
inet 192.168.200.20/24 brd 192.168.200.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe18:118c/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@h2 ~]#
访问网页,成功实现负载均衡
模拟宕机
关闭主服务器的keepalived服务
[root@h1 ~]# systemctl stop keepalived
[root@h1 ~]#
[root@h1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:80:df:b8 brd ff:ff:ff:ff:ff:ff
inet 192.168.200.10/24 brd 192.168.200.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe80:dfb8/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@h1 ~]#
将主服务器的keepalived关闭后,VIP被备服务器抢了过来
[root@h2 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:18:11:8c brd ff:ff:ff:ff:ff:ff
inet 192.168.200.20/24 brd 192.168.200.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet 192.168.200.250/32 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe18:118c/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@h2 ~]#
依旧可以访问网页
当再次开启主服务器的keepalived服务,VIP被抢了回来但无法访问网页
[root@h1 ~]# systemctl start keepalived
[root@h1 ~]#
[root@h1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:80:df:b8 brd ff:ff:ff:ff:ff:ff
inet 192.168.200.10/24 brd 192.168.200.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet 192.168.200.250/32 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe80:dfb8/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@h1 ~]#
此时关闭备服务器的haproxy服务,再次访问网页可以正常访问了
[root@h2 ~]# systemctl stop haproxy
[root@h2 ~]#
[root@h2 ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 128 [::]:111 [::]:*
[root@h2 ~]#
配置keepalived脚本监控负载均衡机状态
在主服务器上创建脚本并加上执行权限
[root@h1 ~]# mkdir /scripts
[root@h1 ~]#
[root@h1 ~]# vim /scripts/check_haproxy.sh
[root@h1 ~]# cat /scripts/check_haproxy.sh
#!/bin/bash
haproxy_status=$(ps -ef|grep -Ev "grep|$0"|grep '\bhaproxy\b'|wc -l)
if [ $haproxy_status -lt 1 ];then
systemctl stop keepalived
fi
[root@h1 ~]#
[root@h1 ~]# chmod +x /scripts/check_haproxy.sh
[root@h1 ~]#
[root@h1 ~]# ll /scripts/
total 4
-rwxr-xr-x. 1 root root 153 Oct 15 20:07 check_haproxy.sh
[root@h1 ~]#
编辑主服务器keepalived.conf配置文件,重启服务
[root@h1 ~]# vi /etc/keepalived/keepalived.conf
[root@h1 ~]# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id haproxy01
}
vrrp_script check_haproxy {
script "/scripts/check_haproxy.sh"
interval 1
weight -50
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 80
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.200.250
}
track_script {
check_haproxy
}
}
...
[root@h1 ~]#
[root@h1 ~]# systemctl restart keepalived
在备服务器上创建脚本并加上执行权限
[root@h2 ~]# mkdir /scripts
[root@h2 ~]# vim /scripts/notify.sh
[root@h2 ~]# cat /scripts/notify.sh
#!/bin/bash
case "$1" in
master)
haproxy_status=$(ps -ef|grep -Ev "grep|$0"|grep '\bhaproxy\b'|wc -l)
if [ $haproxy_status -lt 1 ];then
systemctl start haproxy
fi
;;
backup)
haproxy_status=$(ps -ef|grep -Ev "grep|$0"|grep '\bhaproxy\b'|wc -l)
if [ $haproxy_status -gt 0 ];then
systemctl stop haproxy
fi
;;
*)
echo "Usage:$0 master|backup"
;;
esac
[root@h2 ~]#
[root@h2 ~]# chmod +x /scripts/notify.sh
[root@h2 ~]#
[root@h2 ~]# ll /scripts/
total 4
-rwxr-xr-x. 1 root root 440 Oct 15 20:29 notify.sh
[root@h2 ~]#
编辑备服务器keepalived.conf配置文件,重启服务
[root@h2 ~]# vi /etc/keepalived/keepalived.conf
[root@h2 ~]# cat /etc/keepalived/keepalived.conf
...
virtual_ipaddress {
192.168.200.250
}
notify_master "/scripts/notify.sh master"
notify_backup "/scripts/notify.sh backup"
}
...
[root@h2 ~]#
[root@h2 ~]# systemctl restart keepalived
模拟宕机
当手动关闭主服务器的haproxy服务,脚本会自动执行停掉keepalived服务
[root@h1 ~]# systemctl stop haproxy
[root@h1 ~]#
[root@h1 ~]# systemctl status keepalived
● keepalived.service - LVS and VRRP High Availability Monitor
Loaded: loaded (/usr/lib/systemd/system/keepalived.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Sun 2023-10-15 21:02:56 CST; 6s ago
Process: 25825 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 25826 (code=exited, status=0/SUCCESS)
...
[root@h1 ~]#
此时VIP被备服务器抢了过来
[root@h2 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:18:11:8c brd ff:ff:ff:ff:ff:ff
inet 192.168.200.20/24 brd 192.168.200.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet 192.168.200.250/32 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe18:118c/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@h2 ~]#
当主服务器开启haproxy和keepalived服务时VIP被抢了回来,备服务器上的脚本会自动运行停掉haproxy服务
[root@h1 ~]# systemctl start haproxy
[root@h1 ~]# systemctl start keepalived
[root@h1 ~]#
[root@h1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:80:df:b8 brd ff:ff:ff:ff:ff:ff
inet 192.168.200.10/24 brd 192.168.200.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet 192.168.200.250/32 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe80:dfb8/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@h1 ~]#
查看备服务器上的haproxy服务状态
[root@h2 ~]# systemctl status haproxy
● haproxy.service - HAProxy Load Balancer
Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Sun 2023-10-15 21:10:06 CST; 1min 41s ago
Process: 25704 ExecStart=/usr/local/haproxy/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid
...
[root@h2 ~]#
[root@h2 ~]#
[root@h2 ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 128 [::]:111 [::]:*
[root@h2 ~]#