前言
最近关注到国内的开源的云原生监控分分析软件--夜莺监控( Nightingale ),非常感兴趣,有幸加入了由大佬组建的分享群来探讨夜莺的使用,以下在本博客记录使用夜莺的全部过程
一、夜莺的架构介绍
以下以夜莺新版本V6.X做介绍
服务端主模块--n9e;可以部署多个 n9e 实例组成集群,n9e 依赖 2 个存储,数据库、Redis,可以使用 MySQL 或 Postgres,自己按需选用。
n9e 提供的是 HTTP 接口,前面负载均衡可以是 4 层的,也可以是 7 层的。一般就选用 Nginx 就可以了。
n9e 这个模块接收到数据之后,需要转发给后端的时序库,时序库可以Prometheus或者VictoriaMetrics(推荐)
mysql用来存放用户配置信息,如告警规则,用户信息,监控大盘等。
如果集群部署的话可以在LB端使用Nginx
相关配置是:
[Pushgw]
LabelRewrite = true[[Pushgw.Writers]]
Url = "http://127.0.0.1:9090/api/v1/write"
数据采集agent,可以是Categraf、Telegraf、 Grafana-agent、Datadog-agent,exporter,推荐新部署直接使用Categraf,原来已使用Prometheus通过exporter采集的可以直接将Prometheus数据源接入n9e。
项目github地址 https://github.com/ccfos/nightingale
官网地址 https://flashcat.cloud/download/
二、部署夜莺server
1、环境准备
在CentOS 7.9进行部署,操作系统安装略,夜莺需要的组件 n9e、Redis、mysql、Victoria-Metrics、Categraf
2、安装Redis,并设置开机自启
#yum install epel-release -y
#yum install -y redis
#systemctl enable redis
#systemctl start redis
3、安装mysql,自启动并设置初始密码,对数据库进行初始化操作,夜莺配置文件的初始密码为1234,可自行修改
yum -y install mariadb*
systemctl enable mariadb
systemctl start mariadb
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('1234');"
mysql_secure_installation
4、安装Victoria-Metrics时序库
去github 下载最新版本 https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.90.0
下载单机社区版
将压缩包放着服务器上解压安装,可以放到systemd中启动
nohup ./victoria-metrics-prod &>vm.log &
systemd示例配置
[Unit]
Description="n9e"
After=network.target
[Service]
Type=simple
ExecStart=/opt/n9e/n9e
WorkingDirectory=/opt/n9e
Restart=on-failure
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=n9e
[Install]
WantedBy=multi-user.target
进程正常
5、安装n9e
国内主站下载 https://flashcat.cloud/download/nightingale/
也可到github https://github.com/ccfos/nightingale/releases
解压后设置mysql,启动n9e,检查进程和日志;可以放到systemd中启动
#mkdir -p /opt/n9e && cd /opt/n9e
#tarball=n9e-v6.0.0-ga.3-linux-amd64.tar.gz
#urlpath=https://download.flashcat.cloud/${tarball}
#wget $urlpath || exit 1
#tar zxvf ${tarball}
#mysql -uroot -p1234 < n9e.sql
#nohup ./n9e &> n9e.log &
#ps -aux | grep n9e
#cat n9e.log
可编辑config.toml修改mysql密码
#vi n9e/etc/config.toml
如果启动成功,server 默认会监听在 17000 端口,记得关闭防火墙或者开放17000端口
我的环境 http://10.10.160.10:17000启动成功
三、安装Categraf
主站 https://flashcat.cloud/download/categraf/
Gethub https://github.com/flashcatcloud/categraf/releases/
解压修改配置文件
#vi config.toml
找到[heartbeat] enable = true
启动categraf
nohup ./categraf &> stdout.log &
ps -aux | grep categraf
发现报错 提示缺少libpcap
yum install libpcap-devel
yum -y install mlocate
updatedb
#重新创建软链接
locate libpcap
cd /usr/lib64/
ls -al /usr/lib64/libpcap.so.*
ln -s libpcap.so.1.5.3 libpcap.so.0.8
重新启动categraf
nohup ./categraf &> stdout.log &
ps -aux | grep categraf
#采集测试
./categraf --test --debug
至此,夜莺整体组件部署完毕