夜莺是新一代国产智能监控系统。对云原生场景、传统物理机虚拟机场景,都有很好的支持,10分钟完成搭建,1小时熟悉使用,经受了滴滴生产环境海量数据的验证,希望打造国产监控的标杆之作,目前是v5.0版本,从这个版本开始,与 Prometheus、VictoriaMetrics、Grafana、Telegraf 等生态做了协同集成,力争打造国内最好用的开源运维监控系统。
如果仅仅是为了快速测试,Docker 部署方式是最快的,不过很多朋友未必有 Docker 环境,另外为了减少引入更多技术栈,增强生产环境稳定性,有些朋友可能也不愿意用 Docker,那本篇就来讲解如何快速部署单机版,单机版的配套时序库是使用 Prometheus。如果要监控的机器有几千台,服务有几百个,单机版的容量无法满足,可以上集群版,集群版的时序库建议使用VictoriaMetrics,也可以使用M3DB,不过M3DB的架构更复杂,很多朋友无法搞定,选择简单的 VictoriaMetrics,对大部分公司来讲,足够用了。我们先来看一下服务端架构:
dnf -y install vim git wget
mkdir /opt/prometheus
wget https://s3.jcloud.sjtu.edu.cn/899a892efef34b1b944a19981040f55b-oss01/github-release/prometheus/prometheus/releases/download/v2.33.0/prometheus-2.33.0.linux-amd64.tar.gz
tar xf prometheus-2.33.0.linux-amd64.tar.gz
cp -far prometheus-2.33.0.linux-amd64/* /opt/prometheus/
cat <<EOF >/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
systemctl enable prometheus
systemctl restart prometheus
dnf -y install mariadb-server
密码自己设置即可,本文为 xiaoyu123
systemctl start mariadb
systemctl enable mariadb
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('xiaoyu123');"
dnf -y install redis
systemctl start redis
systemctl enable redis
mkdir -p /opt/n9e && cd /opt/n9e
wget https://github.com/didi/nightingale/releases/download/v5.3.1/n9e-5.3.1.tar.gz
tar zxvf n9e-5.3.1.tar.gz
mysql -uroot -pxiaoyu123 < docker/initsql/a-n9e.sql
由于默认的配置文件的数据库密码为 1234
,所以需要调整。
vim etc/server.conf
vim etc/webapi.conf
默认已经自带,仅仅需要调整参数,主要是调整启动文件路径和工作目录。
vim etc/service/n9e-server.service
cp etc/service/n9e-server.service /usr/lib/systemd/system/
systemctl start n9e-server
systemctl enable n9e-server
vim etc/service/n9e-webapi.service
cp etc/service/n9e-webapi.service /usr/lib/systemd/system
systemctl start n9e-webapi
systemctl enable n9e-webapi
默认用户名密码为 root/root.2020
mkdir -p /opt/vm && cd /opt/vm
wget https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.72.0/victoria-metrics-amd64-v1.72.0.tar.gz
tar zxvf victoria-metrics-amd64-v1.72.0.tar.gz
默认单机版端口号为8428.
mkdir /data
./victoria-metrics-prod -storageDataPath /data
cat <<EOF >/etc/systemd/system/victoria.service
[Unit]
Description="VictoriaMetrics"
Documentation=https://docs.victoriametrics.com/
After=network.target
[Service]
Type=simple
ExecStart=/opt/vm/victoria-metrics-prod -storageDataPath /data
Restart=on-failure
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=VictoriaMetrics
[Install]
WantedBy=multi-user.target
EOF
systemctl start victoria
systemctl enable victoria
curl http://127.0.0.1:8428/metrics
n9e-server 通过 remote write 接口写入时序库,vm 作为时序库的一个选择,其 remote write 接口地址为:http://192.168.0.153:8428/api/v1/write ,把这个地址配置到 server.conf 当中即可,配置完了重启 n9e-server。
vim /opt/n9e/etc/server.conf
vim /opt/n9e/etc/webapi.conf
vim /opt/prometheus/prometheus.yml
整体安装过程相对比较简单,下一篇将带来如何利用 telegraf 和 exporter 进行监控任务。