夜莺 v8.0.0-beta.10 部署

1. mariadb-server

sudo apt update
sudo apt install mariadb-server -y
sudo systemctl enable mariadb
sudo systemctl start mariadb
sudo mysql_secure_installation
# sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] n
 ... skipping.

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
配置过程解析
1. 初始登录:
系统询问root用户当前密码(新安装时为空)
直接按回车
2. Unix Socket认证:
询问是否切换到unix_socket认证
你选择了n,保持当前的认证方式
3. Root密码:
询问是否更改root密码
你选择了y,并设置了新密码
系统成功更新密码并重载了权限表
4. 匿名用户:
询问是否移除匿名用户
你选择了y,成功移除了匿名用户账户
5. Root远程登录:
询问是否禁止root远程登录
你选择了n,允许root用户从远程登录
⚠️ 注意:在生产环境中,通常建议禁止root远程登录以提高安全性
6. 测试数据库:
询问是否移除测试数据库及其访问权限
你选择了y,成功删除了测试数据库及其权限
7. 重载权限表:
询问是否重载权限表使设置立即生效
你选择了y,成功应用了所有更改

2. Redis安装

sudo apt update
sudo apt install redis-server -y
sudo systemctl enable redis-server
sudo systemctl start redis-server
# redis-cli ping
PONG

3. 下载 n9e-v8.0.0-beta.10-linux-amd64.tar.gz

mkdir n9e
cd n9e
wget https://github.com/ccfos/nightingale/releases/download/v8.0.0-beta.10/n9e-v8.0.0-beta.10-linux-amd64.tar.gz
tar -zxvf n9e-v8.0.0-beta.10-linux-amd64.tar.gz

设置 root 用户密码

mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('1234');"

配置文件 配置mariadb的登录密码

# 夜莺的主配置文件是 etc/config.toml
grep "1234" etc/config.toml

导入数据库表结构

mysql -uroot -p1234 < n9e.sql

修改DB为mysql

[DB]
# mysql postgres sqlite
#DBType = "sqlite"
DBType = "mysql"
# postgres: host=%s port=%s user=%s dbname=%s password=%s sslmode=%s
# postgres: DSN="host=127.0.0.1 port=5432 user=root dbname=n9e_v6 password=1234 sslmode=disable"
# mysql: DSN="root:1234@tcp(localhost:3306)/n9e_v6?charset=utf8mb4&parseTime=True&loc=Local"
DSN="root:1234@tcp(localhost:3306)/n9e_v6?charset=utf8mb4&parseTime=True&loc=Local"
#DSN = "n9e.db"

配置为 systemd 启动服务

vim /etc/systemd/system/n9e.service
[Unit]
Description=N9E Service
After=network.target

[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/root/n9e
ExecStart=/root/n9e/n9e
Restart=on-failure
RestartSec=10
Environment="PATH=/usr/bin:/usr/local/bin"

[Install]
WantedBy=multi-user.target

重新加载 systemd

systemctl daemon-reload
systemctl enable n9e
systemctl start n9e
systemctl status n9e
journalctl -fu n9e.service
# netstat -ntlp | grep n9e
tcp        0      0 127.0.0.1:40549         0.0.0.0:*               LISTEN      27860/n9e
tcp6       0      0 :::17000                :::*                    LISTEN      27860/n9e
tcp6       0      0 :::20090                :::*                    LISTEN      27860/n9e

配置日志

把日志输出到 logs 目录下,日志级别是 INFO,日志文件大小超过 256M 时,会自动切割,保留 3 个日志文件。

cat config.toml
[Log]
# log write dir
Dir = "logs"
# log level: DEBUG INFO WARNING ERROR
Level = "INFO"
# stdout, stderr, file
Output = "file"
# # rotate by time
# KeepHours = 4
# # rotate by size
RotateNum = 3
# # unit: MB
RotateSize = 256

访问夜莺

浏览器访问夜莺的端口,即 17000,默认用户是 root,密码是 root.2020

VictoriaMetrics 时序数据库安装

wget https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.21.0-victorialogs/victoria-logs-linux-amd64-v1.21.0-victorialogs.tar.gz
vim /etc/systemd/system/victoria-metrics-prod.service
[Unit]
Description=Victoria Metrics Service
After=network.target

[Service]
Type=simple
ExecStart=/root/victoria-logs-prod -storageDataPath=/root/victoria-metrics-data -retentionPeriod=12
Restart=on-failure
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=journal
StandardError=journal
SyslogIdentifier=victoriametrics

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable victoria-metrics-prod
systemctl start victoria-metrics-prod
systemctl status victoria-metrics-prod
journalctl -fu victoria-metrics-prod.service
wget https://github.com/prometheus/prometheus/releases/download/v3.3.0/prometheus-3.3.0.linux-amd64.tar.gz
wget https://github.com/prometheus/node_exporter/releases/download/v1.9.1/node_exporter-1.9.1.linux-amd64.tar.gz

接入数据源 Prometheus

  • 添加参数
    –web.enable-remote-write-receiver
vim /etc/systemd/system/prometheus.service
[Unit]
Description=prometheus service

[Service]
User=root
ExecStart=/root/prometheus/prometheus \
        --config.file=/root/prometheus/prometheus.yml \
        --storage.tsdb.path=/root/prometheus/prometheus_data \
        --web.enable-lifecycle \
        --storage.tsdb.retention.time=90d \
        --web.enable-remote-write-receiver

TimeoutStopSec=10
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

systemctl daemon-reload 
systemctl enable prometheus.service
systemctl restart prometheus.service 

node_exporter 服务

vim /etc/systemd/system/node_exporter.service
[Unit]
Description=node_exporter service

[Service]
User=root
ExecStart=/root/node_exporter/node_exporter \
        --collector.textfile.directory=/root/node_exporter/textfile

TimeoutStopSec=10
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl restart node_exporter.service
systemctl enable node_exporter.service
systemctl status node_exporter.service

修改 prometheus 配置文件

cat prometheus.yml
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["localhost:9090"]

  # 添加 node_exporter 的配置
  - job_name: "node_exporter"
    static_configs:
            - targets: ["localhost:9100"]
systemctl restart prometheus.service

添加数据源

在这里插入图片描述

<think>好的,我现在需要帮用户解决关于夜莺监控V8.0.0-beta.8.2版本中Docker组件内置仪表盘没有模板的问题。首先,我应该先确认用户的问题具体是什么。用户提到内置仪表盘的Docker组件没有模板,可能是指他们在使用该版本时,无法找到预期的Docker监控仪表盘,或者仪表盘没有正确显示数据。 接下来,我需要回忆一下夜莺监控的基本结构和组件。夜莺通常依赖Prometheus等数据源,而Docker的监控一般通过cAdvisor来收集容器指标,然后由Prometheus抓取。仪表盘可能需要特定的PromQL查询或者指标名称,如果模板不存在,可能是配置问题或者版本差异。 首先,我应该检查用户是否正确配置了数据源。比如,是否已经安装了cAdvisor,并且Prometheus是否正确配置了job来抓取cAdvisor的指标。如果数据源没有问题,那么可能是夜莺版本中的内置仪表盘模板缺失或者未正确导入。 接下来,用户使用的版本是V8.0.0-beta.8.2,这是一个beta版本,可能存在一些不稳定因素。我需要确认这个版本是否确实移除了Docker的内置仪表盘,或者是否有文档提到相关变更。可能需要查阅官方发布的更新日志或GitHub的issue,看看是否有其他用户遇到类似问题。 如果确认是版本问题,建议用户升级到稳定版,或者从社区获取对应的仪表盘模板手动导入。另外,用户可能需要手动创建仪表盘,配置正确的指标和面板。这时候,我需要提供一些常见的Docker监控指标,比如容器CPU使用率$container_cpu_usage_seconds_total$,内存使用$container_memory_usage_bytes$,网络流量等,并指导用户如何编写PromQL查询。 另外,检查夜莺的仪表盘导入功能是否正常,用户是否有权限访问内置模板。有时候权限问题或者UI缓存可能导致模板不显示,尝试清除缓存或者重新登录。 最后,如果以上步骤无法解决,建议用户联系夜莺的社区支持,或者在GitHub上提交issue,提供详细的版本信息和配置情况,以便开发团队进一步排查问题。</think>### 夜莺监控 V8.0.0-beta.8.2 内置 Docker 仪表盘缺失模板问题分析 #### 1. **问题定位** - **现象描述**:Docker 组件的内置仪表盘未显示模板(无预置监控图表)。 - **可能原因**: 1. Beta 版本功能未完善,内置模板暂未集成。 2. 数据源配置缺失(如 Prometheus 未采集 Docker 相关指标)。 3. 仪表盘模板未正确导入或权限限制。 #### 2. **逐步排查与解决** **步骤 1:验证数据源配置** - **检查 cAdvisor 和 Prometheus**: - 确保已部署 cAdvisor 并暴露指标接口(默认端口 8080)。 - 确认 Prometheus 配置中包含以下抓取任务: ```yaml - job_name: 'docker' static_configs: - targets: ['cadvisor-host:8080'] ``` - **验证指标是否存在**: 在 Prometheus 或夜莺的 `Explore` 页面查询 Docker 基础指标,例如: - 容器 CPU 使用率:`rate(container_cpu_usage_seconds_total{name=~".+"}[1m])` - 容器内存使用:`container_memory_usage_bytes{name=~".+"}` **步骤 2:手动导入仪表盘模板** - **从社区获取模板**: 访问夜莺官方 GitHub 仓库或社区论坛(如 Awesome-N9e),搜索 Docker 监控的 JSON 模板文件。 - **导入操作**: 1. 进入夜莺 Web 控制台 → 仪表盘 → 点击「导入」按钮。 2. 上传 JSON 文件并根据提示绑定数据源(如 Prometheus)。 **步骤 3:临时替代方案(手动创建)** - **关键指标配置示例**: | 监控项 | PromQL 查询 | |----------------|-----------------------------------------------------------------------------| | 容器 CPU 使用率 | `sum(rate(container_cpu_usage_seconds_total{image!=""}[1m])) by (name)` | | 容器内存占用 | `sum(container_memory_usage_bytes{image!=""}) by (name)` | | 网络流量 | `rate(container_network_receive_bytes_total{name=~".+"}[1m])` | - **告警规则建议**: ```yaml # 容器内存超限告警 - alert: DockerContainerMemoryHigh expr: container_memory_usage_bytes / container_spec_memory_limit_bytes > 0.8 for: 5m labels: severity: warning annotations: summary: "容器内存使用超限: {{ $labels.name }}" ``` #### 3. **版本兼容性说明** - **Beta 版本限制**:V8.0.0-beta.8.2 可能尚未完成所有内置仪表盘的适配,建议关注[官方更新日志](https://github.com/didi/nightingale/releases)。 - **升级建议**:如需生产环境使用,推荐回退至稳定版本(如 V7.x)或等待后续正式版发布。 #### 4. **后续跟进** - 提交 GitHub Issue 反馈问题,附上环境信息和日志。 - 监控夜莺社区公告,及时获取模板更新或补丁。 通过以上步骤,可快速恢复 Docker 监控能力。如仍遇问题,建议提供 `/api/v1/series` 接口的指标列表供进一步分析。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值