夜莺监控v5版本

夜莺监控v5

v5

  • 夜莺监控v5
    • 1.单机夜莺
    • 2.脚本内容
    • 3.安装完成
    • 4.部署客户端
    • 5.安装客户端代码内容

1.单机夜莺

官网提供了一键部署的脚本 前题是root权限和centos系统

# 安装脚本做了3件事情
# 1. 安装promethues作为存储,夜莺支持对接多种存储,我们选择单机版Prometheus来快速开始
# 2. 安装mysql,root默认密码为1234
# 3. 安装n9e-server
curl -s http://116.85.64.82/install_n9e_server.sh|bash

# 进程如果启动了,理论上会监听2个端口,一个http端口一个rpc端口
# 通过下面命令可以查看端口是否在监听,如果端口都在监听,就说明启动成功
ss -tlnp|grep n9e-server

2.脚本内容

脚本的内容 如果没有外网根据脚本自行调节

#!/bin/bash

# 1.安装promethues作为存储,夜莺支持对接多种存储,我们选择单机版Prometheus来快速开始
#yum install wget -y &>/dev/null  
mkdir -p /opt/prometheus
wget https://s3-gz01.didistatic.com/n9e-pub/prome/prometheus-2.28.0.linux-amd64.tar.gz -O prometheus-2.28.0.linux-amd64.tar.gz
tar xf prometheus-2.28.0.linux-amd64.tar.gz
cp -far prometheus-2.28.0.linux-amd64/*  /opt/prometheus/

# service 
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
RestartSecs=5s
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=prometheus


[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable prometheus
systemctl restart prometheus
systemctl status prometheus

# 2.安装mysql,root默认密码为1234
yum -y install mariadb*
# 假设机器的/home分区是个SSD的大分区,datadir设置为/home/mysql
# mkdir -p /home/mysql
# chown mysql:mysql /home/mysql
# sed -i '/^datadir/s/^.*$/datadir=\/home\/mysql/g' /etc/my.cnf
# 启动mysql进程
systemctl start mariadb.service
# 将mysql设置为开机自启动
systemctl enable mariadb.service
# 设置mysql root密码
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('1234');"

# 3.安装n9e-server
mkdir -p /opt/n9e
cd /opt/n9e
wget 116.85.64.82/n9e-server-5.0.0-rc3.tar.gz
tar zxvf n9e-server-5.0.0-rc3.tar.gz
mysql -uroot -p1234 < /opt/n9e/server/sql/n9e.sql

cp /opt/n9e/server/etc/service/n9e-server.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable n9e-server
systemctl restart n9e-server
systemctl status n9e-server

3.安装完成

安装成功之后,就可以用浏览器访问服务端的端口(在服务端的yml配置中可以看到http的监听端口,默认是8000)进入系统了,系统启动的时候会默认初始化一个`root`账号,密码是`root.2020` 登录之后没啥数据,毕竟我们还没有部署采集程序,下一小节开始部署客户端采集程序。

4.部署客户端

# 一键安装n9e-agentd
curl -s http://116.85.64.82/install_n9e_agentd.sh|bash

# 通过下面命令查看n9e-agentd的进程,如果进程存在,说明启动成功
# 如果启动失败,可通过 journalctl -u n9e-agentd -f 查看日志
ps -ef|grep n9e-agentd|grep -v grep

修改/opt/n9e/agentd/etc/agentd.yaml中的服务端连接地址(搜索endpoint关键字),然后重启n9e-agentd即可,重启命令 systemctl restart n9e-agentd  

5.安装客户端代码内容

#!/bin/bash

# install n9e-agentd
#yum install wget -y &>/dev/null  
mkdir -p /opt/n9e
cd /opt/n9e
wget 116.85.64.82/n9e-agentd-344a75d.tar.gz
tar zxvf n9e-agentd-344a75d.tar.gz

cp /opt/n9e/agentd/systemd/n9e-agentd.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable n9e-agentd
systemctl restart n9e-agentd
systemctl status n9e-agentd

你可能感兴趣的:(夜莺监控,监控类,linux,centos,mysql)