前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【快猫星云】Nightingale 监控详解(二)

【快猫星云】Nightingale 监控详解(二)

作者头像
用户6792968
发布2023-04-27 14:53:05
4930
发布2023-04-27 14:53:05
举报
文章被收录于专栏:fred 随笔

环境部署

  1. Prometheus 数据源环境部署
代码语言:javascript
复制
#下载prom,下载链接:https://prometheus.io/download/
#如果下载慢,可以使用国内源地址:https://mirrors.tuna.tsinghua.edu.cn/github-release/prometheus/prometheus/LatestRelease/

mkdir /opt/prometheus
wget  https://github.com/prometheus/prometheus/releases/download/v2.43.0/prometheus-2.43.0.linux-amd64.tar.gz
tar xf prometheus-2.43.0.linux-amd64.tar.gz
mv prometheus-2.43.0.linux-amd64/* /opt/prometheus/

#将 prom 注册为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
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=prometheus


[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable prometheus
systemctl start prometheus
  1. 数据库环境部署
代码语言:javascript
复制
# MySQL 下载链接:https://downloads.mysql.com/archives/community/
#下载 MySQL 并初始化数据库

wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.40-linux-glibc2.12-x86_64.tar.gz
tar xf mysql-5.7.40-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.40-linux-glibc2.12-x86_64 /opt/mysql
mkdir -p /opt/mysql/{data,log}
cd /opt/mysql/bin/
useradd mysql -s /sbin/nologin -M -r
chown -R mysql.mysql /opt/mysql
./mysqld --initialize-insecure --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data

#添加 MySQL 配置文件

cat << EOF >> /etc/my.cnf
[mysqld]
user=mysql
basedir=/opt/mysql
datadir=/opt/mysql/data
socket=/opt/mysql/mysql.sock
symbolic-links=0
character-set-server = utf8mb4
open_files_limit= 65535
max_connections = 256
max_user_connections = 64
max_connect_errors = 10000
log_timestamps = SYSTEM
slow_query_log = 1
slow_query_log_file = /opt/mysql/log/slow.log
server-id=1
long_query_time = 0.1
log-bin = /opt/mysql/log/mysql-bin
max_binlog_cache_size = 512M
max_binlog_size = 1G
expire_logs_days = 7
skip_name_resolve = 1

[mysqld_safe]
log-error=/opt/mysql/log/err.log
pid-file=/opt/mysql/mysqld.pid

EOF

#注册 MySQL 为服务

cat << EOF >> /etc/systemd/system/mysqld.service
[Unit]
Description=MYSQL server
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=forking
TimeoutSec=0
PermissionsStartOnly=true
ExecStart=/opt/mysql/bin/mysqld --defaults-file=/etc/my.cnf --daemonize $OPTIONS
ExecReload=/bin/kill -HUP -$MAINPID     #这里-HUP可以是改成-s HUP,就变成强制杀进程,有需要可以改,下面也一样
ExecStop=/bin/kill -QUIT $MAINPID		#-s QUIT是强制杀进程
KillMode=process
LimitNOFILE=65535
Restart=on-failure
RestartSec=10
RestartPreventExitStatus=1
PrivateTmp=false
EOF
systemctl daemon-reload
systemctl enable mysqld
systemctl start mysqld

#设置 MySQL 密码为:n9etest

./mysqladmin -u root password "n9etest" -S ../mysql.sock
./mysql -uroot -p -S ../mysql.sock -e "grant all on *.* to root@'%' identified by 'n9etest'"

#redis下载地址:https://redis.io/download/

mkdir -p /opt/redis
wget https://github.com/redis/redis/archive/7.0.10.tar.gz
tar xf 7.0.10.tar.gz
cd redis-7.0.10/
make PREFIX=/opt/redis install
cd /opt/redis/
cp -a /opt/redis-7.0.10/redis.conf /opt/redis/bin/
cd bin

#修改redis配置文件

sed -i /protected-mode/s/yes/no/g redis.conf
sed -i /bind/s/127.0.0.1/0.0.0.0/g redis.conf
sed -i  /daemonize/s/no/yes/g redis.conf
sed -i  "/requirepass foobared/a\requirpass n9etest" redis.conf 

#将 redis 注册为服务

cat << EOF >> /etc/systemd/system/redis.service
[Unit]
Description=Redis data structure server
Documentation=https://redis.io/documentation
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/opt/redis/bin/redis-server   /opt/redis/bin/redis.conf
LimitNOFILE=10032
NoNewPrivileges=yes
Type=forking
PrivateTmp=true
UMask=0077

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl start redis
systemctl enable redis
  1. 安装n9e
代码语言:javascript
复制
#下载链接:https://github.com/didi/nightingale/releases

mkdir /opt/n9e
wget https://github.com/ccfos/nightingale/releases/download/v6.0.0-ga.4.1/n9e-v6.0.0-ga.4.1-linux-amd64.tar.gz
tar xf n9e-v6.0.0-ga.4.1-linux-amd64.tar.gz  -C .opt.n9e
cd /opt/n9e
/opt/mysql/bin/mysql -uroot -p -S /opt/mysql/mysql.sock < n9e.sql

#修改配置文件

sed -i  /DSN/s/1234/n9etest/g config.toml
sed -i  "/Address/a\Password = “n9etest”" config.toml

#注册为服务

cat << EOF >> /etc/systemd/system/n9e.service
[Unit]
Description="n9e"
Documentation=https://github.com/ccfos/nightingale
After=network.target
After=redis.target
After=mysqld.target

[Service]
Type=simple

ExecStart=/opt/n9e/n9e  --configs /opt/n9e/etc

Restart=on-failure
SuccessExitStatus=0
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=n9e


[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl start n9e
systemctl enable n9e
  1. 安装 categraf 采集器
代码语言:javascript
复制
#n9e默认推荐使用 categraf 作为采集器收集数据
#下载地址:https://flashcat.cloud/download/categraf/
#配置文件详解:https://flashcat.cloud/docs/content/flashcat-monitor/categraf/3-configuration/

wget https://download.flashcat.cloud/categraf-v0.2.39-linux-amd64-with-cgo-plugin.tar.gz
tar xf categraf-v0.2.39-linux-amd64-with-cgo-plugin.tar.gz 
mv categraf-v0.2.39-linux-amd64-with-cgo-plugin /opt/categraf/
cd /opt/categraf/conf
cp -a categraf.service /etc/systemd/system/
systemctl daemon-reload
systemctl start categraf
systemctl enable categraf

注:这里启动可能会出现报错

实际系统内的libpcap版本会比要求的高一些,重新指一下软链接即可

代码语言:javascript
复制
cd /lib64/
ln -s libpcap.so.1.5.3  libpcap.so.0.8

再次启动就可以了

至此,所有基础服务部署完成

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-04-17,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 MySQL
腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档