1、安装前置依赖
yum -y install mariadb*
systemctl enable mariadb
systemctl restart mariadb
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('1234');"yum install -y redis
systemctl enable redis
systemctl restart redis
2、官网下载所需安装包:这里以V6/prometheus举例
3、安装夜莺v6
1、创建一个你n9e的目录将夜莺解压到该目录下,
2、解压后可以看到n9e.sql是建表语句,导入数据库
mysql -uroot -p1234 < n9e.sql
3、启动n9e,先用nohup测试,systemd托管则需要准备service文件,这里给大家准备好了
nohup ./n9e & > n9e.log &
4、检查端口查看是否在监听,正常监听端口为17000
部署完成
制作service文件,system托管
cat > n9e.service << EOF
[Unit]
Description="n9e.service"
After=network.target[Service]
Type=simple
ExecStart=/path/n9e/n9e server
WorkingDirectory=/path/n9e
Restart=on-failure
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=n9e.service
[Install]
WantedBy=multi-user.target
> EOF
systemctl daemon-reload
systemctl enable n9e
4、prometheus部署
1、下载prometheus二进制文件包,直接解压使用
正常参数启动要添加启动参数--enable-feature=remote-write-receiver
下列已经写到service文件就不用了
2、在systemd托管准备的prometheus.service文件
[Unit]
Description="prometheus"
Documentation=https://prometheus.io/
After=network.target[Service]
Type=simpleExecStart=/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.target3、设置开机自启
systemctl enable prometheus
systemctl restart prometheus
systemctl status prometheus
5、categraf采集器部署
1、启停
v0.3.35以上版本
sudo ./categraf --install添加service文件 --remove --start --stop --statusv0.3.35以下版本
将categraf.service放到system托管2、测试,用:分割多个插件
./categraf --test --inputs mysql:cpu:mem3、重启,修改了采集器的配置,需要重启categraf
kill -HUP `pidof categraf`4、升级
需要先停止之前启动的categraf进程
新版本替换原有的categraf版本,保持categraf和conf目录放在同一个父目录下
执行 sudo ./categraf --start 或者 sudo systemctl start categraf
agent端安装采集器后修改配置参数:
vi config.toml
将17000:这个端口的IP改为master端的IP,并将hostname改为"$ip"