监控传统服务器
#1. 简介
DeepFlow 支持监控传统服务器。注意 DeepFlow Server 必须运行在 K8s 之上,如果你没有 K8s 集群,可参考 All-in-One 快速部署章节先部署 DeepFlow Server。
#2. 部署拓扑
#3. 配置 DeepFlow Server
#3.1 更新 deepflow-server 配置
检查服务器所有的网段是否在以下网段列表中
local_ip_ranges:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
- 169.254.0.0/15
- 224.0.0.0-240.255.255.255
2
3
4
5
6
若不在,需要在下面自定义配置文件内 local_ip_ranges
列表中添加缺失的服务器网段。例如:主机 IP 为 100.42.32.213,则需要把对应的 100.42.32.0/24 网段加入配置
修改 values-custom.yaml
自定义配置文件:
configmap:
server.yaml:
controller:
genesis:
local_ip_ranges:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
- 169.254.0.0/15
- 224.0.0.0-240.255.255.255
- 100.42.32.0/24 # FIXME
trisolaris:
trident-type-for-unkonw-vtap: 3 # required
2
3
4
5
6
7
8
9
10
11
12
13
更新 deepflow
helm upgrade deepflow -n deepflow -f values-custom.yaml deepflow/deepflow
## Restart deepflow-server
kubectl delete pods -n deepflow -l app=deepflow -l component=deepflow-server
2
3
#3.2 创建 Host Domain
就像监控多个 K8s 集群时,需要创建 K8s domain 一样,此处也需要创建一个专门用于同步服务器的 domain
unset DOMAIN_NAME
DOMAIN_NAME="legacy-host" # FIXME: domain name
cat << EOF | deepflow-ctl domain create -f -
name: $DOMAIN_NAME
type: agent_sync
EOF
2
3
4
5
6
7
#3.3 创建采集器组
创建采集器组:
unset AGENT_GROUP
AGENT_GROUP="legacy-host" # FIXME: domain name
deepflow-ctl agent-group create $AGENT_GROUP
deepflow-ctl agent-group list $AGENT_GROUP # Get agent-group ID
2
3
4
5
创建采集器组配置文件 agent-group-config.yaml
,指定 vtap_group_id
并开启 platform_enabled
让 deepflow-agent 将服务器的网络信息同步至 deepflow-server
vtap_group_id: g-ffffff # FIXME
platform_enabled: 1
2
创建采集器组配置:
deepflow-ctl agent-group-config create -f agent-group-config.yaml
#4. 部署 DeepFlow Agent
下载 deepflow-agent
curl -O https://deepflow-ce.oss-cn-beijing.aliyuncs.com/rpm/agent/stable/linux/$(arch | sed 's|x86_64|amd64|' | sed 's|aarch64|arm64|')/deepflow-agent-rpm.zip
unzip deepflow-agent-rpm.zip
yum -y localinstall x86_64/deepflow-agent-1.0*.rpm
2
3
curl -O https://deepflow-ce.oss-cn-beijing.aliyuncs.com/deb/agent/stable/linux/$(arch | sed 's|x86_64|amd64|' | sed 's|aarch64|arm64|')/deepflow-agent-deb.zip
unzip deepflow-agent-deb.zip
dpkg -i x86_64/deepflow-agent-1.0*.systemd.deb
2
3
curl -O https://deepflow-ce.oss-cn-beijing.aliyuncs.com/bin/agent/stable/linux/$(arch | sed 's|x86_64|amd64|' | sed 's|aarch64|arm64|')/deepflow-agent.tar.gz
tar -zxvf deepflow-agent.tar.gz -C /usr/sbin/
cat << EOF > /etc/systemd/system/deepflow-agent.service
[Unit]
Description=deepflow-agent.service
After=syslog.target network-online.target
[Service]
Environment=GOTRACEBACK=single
LimitCORE=1G
ExecStart=/usr/sbin/deepflow-agent
Restart=always
RestartSec=10
LimitNOFILE=1024:4096
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
touch /etc/deepflow-agent.yaml
cat << EOF > deepflow-agent-docker-compose.yaml
version: '3.2'
services:
deepflow-agent:
image: registry.cn-hongkong.aliyuncs.com/deepflow-ce/deepflow-agent:v6.5
container_name: deepflow-agent
restart: always
#privileged: true ## Docker version below 20.10.10 requires the opening of the privileged mode, See https://github.com/moby/moby/pull/42836
cap_add:
- SYS_ADMIN
- SYS_RESOURCE
- SYS_PTRACE
- NET_ADMIN
- NET_RAW
- IPC_LOCK
- SYSLOG
volumes:
- /etc/deepflow-agent.yaml:/etc/deepflow-agent/deepflow-agent.yaml:ro
- /sys/kernel/debug:/sys/kernel/debug:ro
- /var/run/docker.sock:/var/run/docker.sock
network_mode: "host"
pid: "host"
EOF
docker compose -f deepflow-agent-docker-compose.yaml up -d
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
修改 deepflow-agent 的配置文件 /etc/deepflow-agent.yaml
:
controller-ips:
- 10.1.2.3 # FIXME: K8s Node IPs
vtap-group-id-request: 'g-fffffff' # FIXME: agent-group ID
2
3
启动 deepflow-agent :
systemctl enable deepflow-agent
systemctl restart deepflow-agent
2
注意:
若 deepflow-agent 因缺少依赖库无法正常启动可下载静态链接编译的 deepflow-agent, 注意静态链接编译的 deepflow-agent 在多线程下有严重的性能问题:
curl -O https://deepflow-ce.oss-cn-beijing.aliyuncs.com/rpm/agent/stable/linux/static-link/$(arch | sed 's|x86_64|amd64|' | sed 's|aarch64|arm64|')/deepflow-agent-rpm.zip
unzip deepflow-agent-rpm.zip
yum -y localinstall x86_64/deepflow-agent-1.0*.rpm
2
3
curl -O https://deepflow-ce.oss-cn-beijing.aliyuncs.com/deb/agent/stable/linux/static-link/$(arch | sed 's|x86_64|amd64|' | sed 's|aarch64|arm64|')/deepflow-agent-deb.zip
unzip deepflow-agent-deb.zip
dpkg -i x86_64/deepflow-agent-1.0*.systemd.deb
2
3
curl -O https://deepflow-ce.oss-cn-beijing.aliyuncs.com/bin/agent/stable/linux/static-link/$(arch | sed 's|x86_64|amd64|' | sed 's|aarch64|arm64|')/deepflow-agent.tar.gz
tar -zxvf deepflow-agent.tar.gz -C /usr/sbin/
cat << EOF > /etc/systemd/system/deepflow-agent.service
[Unit]
Description=deepflow-agent.service
After=syslog.target network-online.target
[Service]
Environment=GOTRACEBACK=single
LimitCORE=1G
ExecStart=/usr/sbin/deepflow-agent
Restart=always
RestartSec=10
LimitNOFILE=1024:4096
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21