关于夜莺不再过多赘述了,直接进入正文。
正文
单机版架构
来自官方
本文环境
系统版本:
- CentOS:7.9
- Redis:3.2
- mariadb:5.5
- Prometheus:2.32.1
- Telegraf:1.21
安装基础软件(可选,如果有无需安装)
yum -y install vim wget
安装 Prometheus
这里可以查询官网 Prometheus 版本,截止发文前为止版本为2.32.1
mkdir -p /opt/prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.32.1/prometheus-2.32.1.linux-amd64.tar.gz
tar xf prometheus-2.32.1.linux-amd64.tar.gz
cp -far prometheus-2.32.1.linux-amd64/* /opt/prometheus/
设置守护进程
Prometheus 在启动的时候要注意开启 --enable-feature=remote-write-receiver
cat </etc/systemd/system/prometheus.service
[Unit]
Description="prometheus"
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
ExecStart=/opt/prometheus/prometheus --config.file=/opt/prometheus/prometheus.yml --storage.tsdb.path=/opt/prometheus/data --web.enable-lifecycle --enable-feature=remote-write-receiver --query.lookback-delta=2m
Restart=on-failure
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=prometheus
[Install]
WantedBy=multi-user.target
EOF
启动 Prometheus
systemctl daemon-reload
systemctl enable prometheus
systemctl restart prometheus
systemctl status prometheus
数据库部分
1.安装数据库
yum -y install mariadb-server
2.启动数据库
systemctl start mariadb && systemctl enable mariadb
3.设置数据库密码
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('xiaoyu123');"
Redis 部分
1.安装redis
需要安装EPEL源方可安装redis
yum -y install epel-release
yum -y install redis
2.启动 redis
systemctl start redis && systemctl enable redis
安装夜莺组件
1.创建相关目录
mkdir -p /opt/n9e && cd /opt/n9e
2.下载夜莺,以官网最新版为主
wget https://github.com/didi/nightingale/releases/download/v5.2.1/n9e-5.2.1.tar.gz
3.解压文件
tar zxvf n9e-5.2.1.tar.gz
4.导入架构文件
mysql -uroot -pxiaoyu123 < docker/initsql/a-n9e.sql
修改配置文件
1.修改server配置文件
vim /opt/n9e/etc/server.conf
2.修改webapi配置文件
vim /opt/n9e/etc/webapi.conf
编辑 service 文件
1.n9e-server
cat </etc/systemd/system/n9e-server.service
[Unit]
Description="n9e-server"
After=network.target
[Service]
Type=simple
ExecStart=/opt/n9e/n9e server
WorkingDirectory=/opt/n9e
Restart=on-failure
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=n9e-server
[Install]
WantedBy=multi-user.target
EOF
2.n9e-webapi
cat </etc/systemd/system/n9e-webapi.service
[Unit]
Description="n9e-webapi"
After=network.target
[Service]
Type=simple
ExecStart=/opt/n9e/n9e webapi
WorkingDirectory=/opt/n9e
Restart=on-failure
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=n9e-server
[Install]
WantedBy=multi-user.target
EOF
启动夜莺组件
systemctl daemon-reload
systemctl enable n9e-server n9e-webapi
systemctl restart n9e-server n9e-webapi
systemctl status n9e-server
systemctl status n9e-webapi
访问前端
默认访问地址为:http://your ip address:18000
默认用户名密码为:root/root.2000
登录页
语句查询
图形
写在最后
目前V5版本已经设置 telegraf 为主要采集器,prometheus 的采集器也可以使用,相对于夜莺成为了一个分析器,最终传递到 grafana 进行展示,遗憾的是夜莺目前只支持折线图,大家感兴趣的不妨可以尝试一下,下期会就使用再进行探讨。