OpsDaiLou - 2025年5月
type: channel
link: https://blog.opsdailou.top/index.php/2025/05/
description: 书写，记录，思考，成长。
items: Linux sudoers文件修改错误导致sudo无法使用
items: Ubuntu 下修改用户名
items: ssh 处理连接异常 no matching host key type found
items: Nginx中 $host $http_host $proxy_host的区别
items: Grafana+Prometheus+第三方Exporter 监控系统架构
items: Loki context deadline exceeded 错误排查与解决
items: Loki Per stream rate limit exceeded 错误排查与解决
items: Loki Ingestion rate limit exceeded 错误排查与解决
items: Nginx 报错 413 client intended to send too large body 处理
items: Docker 容器网络模式

Linux sudoers文件修改错误导致sudo无法使用
type: item
date: 2025-05-20T04:18:00+00:00
description: 问题错误修改/etc/sudoers文件，导致出现sudo命令无法正常使用的问题出现。>>> /etc/sudoers: syntax error near line 21 <<< sudo: parse error in /etc/sudoers near line 21 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin注意：这里的问题，是在Ubuntu系统环境下出现的，是基于该系统进行的整理。[...]

Ubuntu 下修改用户名
type: item
date: 2025-05-20T01:44:00+00:00
description: 背景：有时候，安装的Ubuntu系统，会有不满意一开始创建的用户名，但是又因为在该用户下装了一些东西，不希望重新创建新用户进行使用，想要直接修改用户名的需求。这里提供一个案例：将 dev 用户名修改为 test 用户[...]

ssh 处理连接异常 no matching host key type found
type: item
date: 2025-05-14T03:34:00+00:00
description: 通过ssh连接服务器失败$ ssh root@172.16.0.247 Unable to negotiate with 172.16.0.247 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dssSSH 客户端和远程服务器无法协商使用相同的 host key 类型。解决方法：添加参数# -oHostKeyAlgorithms=+ssh-rsa 允许接收远程主机提供的 ssh-rsa 类型的 主机密钥（连接握手阶段） # -oPubkeyAcceptedAlgorithms=+ssh-rsa 允许使用 ssh-rsa 类型的 用户身份验证公钥（登录认证阶段） ssh root@172.16.0.247 -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=+ssh-rsa[...]

Nginx中 $host $http_host $proxy_host的区别
type: item
date: 2025-05-13T04:12:32+00:00
description: 变量值来源是否显示端口说明$host按照 请求行中的Host > 请求头中的Host > server_name 的值 优先级获取否"Host:port"显示值为a:b的时候，只显示a$http_host请求头中的Host是"Host:port"，port存在就显示，请求头中Host是多少 $http_host就是多少$proxy_hostproxy_pass 指定的地址是（默认80不显示）"Host:port" proxy_pass指定的 "Host:port"，当port为80的时候只有“Host”，其它端口，正常显示为 “Host:port”[...]

Grafana+Prometheus+第三方Exporter 监控系统架构
type: item
date: 2025-05-12T03:24:28+00:00
description: 架构:Grafana + Prometheus + 第三方ExporterGrafana：查询数据，通过面板展示监控项，统一展示。Prometheus：配置不同的job，获取多方面监控指标数据，供Grafana查询获取展示。第三方Exporter：获取相关数据，供Prometheus获取存储。比如: node_exporter、blackbox_exporter、redis_exporter、postgres_exporter、nginx-module-vts[...]

Loki context deadline exceeded 错误排查与解决
type: item
date: 2025-05-08T07:40:01+00:00
description: Promtail报错level=warn ts=2025-05-07T06:44:22.715765487Z caller=client.go:369 component=client host=local-loki:3100 msg="error sending batch, will retry" status=500 error="server returned HTTP status 500 Internal Server Error (500): rpc error: code = DeadlineExceeded desc = context deadline exceeded"查看loki 日志level=info ts=2025-05-07T06:44:11.830518711Z caller=checkpoint.go:615 msg="starting checkpoint" level=info ts=2025-05-07T06:44:11.830788697Z caller=checkpoint.go:340 msg="attempting checkpoint for" dir=/data/wal/checkpoint.1237659 level=warn ts=2025-05-07T06:44:20.643216928Z caller=logging.go:86 traceID=1f665e71538b4138 orgID=fake msg="POST /loki/api/v1/push (500) 5.012615543s Response: \"rpc error: code = DeadlineExceeded desc = context deadline exceeded\\n\" ws: false; Connection: close; Content-Length: 266310; Content-Type: application/x-protobuf; User-Agent: promtail/2.6.1; " level=warn ts=2025-05-07T06:44:21.530545119Z caller=logging.go:86 traceID=1e71d2fb0b8fa807 orgID=fake msg="POST /loki/api/v1/push (500) 5.289903404s Response: \"rpc error: code = DeadlineExceeded desc = context deadline exceeded\\n\" ws: false; Connection: close; Content-Length: 217308; Content-Type: application/x-protobuf; User-Agent: promtail/2.6.1; " level=warn ts=2025-05-07T06:44:22.441075158Z caller=logging.go:86 traceID=646a00c6b84f9eff orgID=fake msg="POST /loki/api/v1/push (500) 5.100367208s Response: \"rpc error: code = DeadlineExceeded desc = context deadline exceeded\\n\" ws: false; Connection: close; Content-Length: 265673; Content-Type: application/x-protobuf; User-Agent: promtail/2.6.1; " level=warn ts=2025-05-07T06:44:22.448904508Z caller=logging.go:86 traceID=7c39e6b8a70cd408 orgID=fake msg="POST /loki/api/v1/push (500) 5.31823812s Response: \"rpc error: code = DeadlineExceeded desc = context deadline exceeded\\n\" ws: false; Connection: close; Content-Length: 267119; Content-Type: application/x-protobuf; User-Agent: promtail/2.6.1; " level=info ts=2025-05-07T06:45:04.0186…

Loki Per stream rate limit exceeded 错误排查与解决
type: item
date: 2025-05-08T07:25:57+00:00
description: 查看Promtail日志，发现存在Per stream rate limit exceeded (limit: 3MB/sec)报错，触发了Loki每个流每秒最大字节速率限制，可能导致数据丢失，查询异常问题出现。Promtail异常日志level=warn ts=2025-05-06T03:09:37.961274973Z caller=client.go:369 component=client host=local-loki:3100 msg="error sending batch, will retry" status=429 error="server returned HTTP status 429 Too Many Requests (429): entry with timestamp 2025-05-06 03:09:37.873760873 +0000 UTC ignored, reason: 'Per stream rate limit exceeded (limit: 3MB/sec) while attempting to ingest for stream '{agent=\"promtail\", filename=\"/opt/test_service/logs/info.log\", hostname=\"test-001\", job=\"service_logs\", service=\"test_service\"}' totaling 494791B, consider splitting a stream via additional labels or contact your Loki administrator to see if the limit can be increased' for stream: {agent=\"promtail\", filename=\"/opt/test_service/logs/info.log\", hostname=\"test-001\", job=\"service_logs\", service=\"test_service\"}," level=warn ts=2025-05-06T03:09:39.610424292Z caller=client.go:369 component=client host=local-loki:3100 msg="error sending batch, will retry" status=429 error="server returned HTTP status 429 Too Many Requests (429): entry with timestamp 2025-05-06 03:09:39.552467567 +0000 UTC ignored, reason: 'Per stream rate limit exceeded (limit: 3MB/sec) while attempting to ingest for stream '{agent=\"promtail\", filename=\"/opt/test_service/logs/info.log\", hostname=\"test-001\", job=\"service_logs\", service=\"test_service\"}' totaling 2404B, consider splitting a stream via additional labels or contact your Loki administrator to see if the limit can be increased' for stream: {agent=\"promtail\", filename=\"/opt/test_service/logs/info.log\", hostname=\"test-001\", job=\"service_logs\", service=\"test_service\"},"[...]

Loki Ingestion rate limit exceeded 错误排查与解决
type: item
date: 2025-05-08T07:25:31+00:00
description: 问题描述通过Grafana查询Loki数据源中的日志，发现存在指定时间段内，查询数据与实际文件中的日志不符的现象。排查发现Promtail存在报错日志server returned HTTP status 429 Too Many Requests (429): Ingestion rate limit exceeded for user fake (limit: 41943040 bytes/sec)，超过了Loki配置的速率上限，被限流了。遂进行调整Loki配置，进行处理。[...]

Nginx 报错 413 client intended to send too large body 处理
type: item
date: 2025-05-08T04:04:00+00:00
description: promtail通过nginx向loki发送数据，收到以下报错level=error ts=2025-05-08T01:21:05.955472787Z caller=client.go:380 component=client host=local-loki:3100 msg="final error sending batch" status=413 error="server returned HTTP status 413 Request Entity Too Large (413): "排查nginx日志，发现2025/05/08 09:21:06 [error] 21#21: *62769236 client intended to send too large body: 1312028 bytes, client: 10.40.30.155, server: , request: "POST /loki/api/v1/push HTTP/1.1", host: "local-loki:3100" - | 10.40.30.155 | - | 08/May/2025:09:21:06 +0800 | POST /loki/api/v1/push HTTP/1.1 | 413 | 183 | - | promtail/2.6.1 | - | 0.032 | - | - | - | local-loki:3100触发了Nginx的最大请求体限制，收到了 413 (Request Entity Too Large) error[...]

Docker 容器网络模式
type: item
date: 2025-05-06T07:43:46+00:00
description: Docker 容器支持多种网络模式（network modes），每种适用于不同的使用场景。下面是主要的几种 Docker 网络模式及其说明：bridge: 默认网络驱动程序。如果您未指定驱动程序，则此类型即为您创建的网络。桥接网络通常用于应用程序在需要与同一主机上的其他容器通信的容器中运行的情况。请参阅 桥接网络驱动程序。host: 移除容器与 Docker 主机之间的网络隔离，并直接使用主机的网络。请参阅 主机网络驱动程序。container:<name|id>: 多个容器共享同一个容器的网络命名空间。none: 将容器与主机及其他容器完全隔离。 none不适用于 Swarm 服务。请参阅 None 网络驱动程序。[...]