夜鶯監控v5.5 —— 單機版部署
部署參考https://n9e.gitee.io/quickstart/standalone/,做了些許改動
一、 版本號
伺服器系統:CentOS 7.9
MySQL: 5.7.37
Redis: 3.2.12
Prometheus: 2.34.0
Nightingale:5.5.0
二、 安裝 MySQL
1、 系統安裝後,初始自帶資料庫,將其刪除
yum -y remove mysql* mariadb*
2、 yum安裝
yum -y install mysql57-community-release-el7-10.noarch.rpm
sed -i "s/gpgcheck=1/gpgcheck=0/g" /etc/yum.repos.d/mysql-community.repo
yum -y install mysql-community-server
3、 啟動服務、開機自啟
systemctl start mysqld.service
systemctl enable mysqld.service
4、 檢視資料庫root賬戶初始密碼
grep "password" /var/log/mysqld.log
5、 修改資料庫root賬戶密碼
mysqladmin -uroot -p${sql_password} password ${new_sql_passwd}
sql_password 是mysql root賬號的初始密碼,由第4步獲得
new_sql_passwd 是root賬號的新密碼,需要自行定義,此處需要注意下密碼安全級別
三、 安裝 Redis
1、 yum安裝
yum -y install redis
2、 修改密碼
sed -i "s/^# requirepass.*/requirepass ${new_sql_passwd}/" /etc/redis.conf
預設密碼為空,這樣不太好,建議修改為自定義的密碼,尤其是當埠對外開放的時候
3、 啟動服務、開機自啟
systemctl start redis
systemctl enable redis
四、 安裝 Prometheus
1、 下載、解壓
wget https://github.com/prometheus/prometheus/releases/download/v2.34.0/prometheus-2.34.0.linux-amd64.tar.gz
tar zxf prometheus-2.34.0.linux-amd64.tar.gz
mv prometheus-2.34.0.linux-amd64 /usr/local/prometheus
2、 配置 service
cat > /usr/lib/systemd/system/prometheus.service << EOF
[Unit] Description="prometheus" Documentation=https://prometheus.io/ After=network.target [Service] Type=simple ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/usr/local/prometheus/data --web.enable-lifecycle --enable-feature=remote-write-receiver --query.lookback-delta=2m --web.enable-admin-api Restart=on-failure SuccessExitStatus=0 LimitNOFILE=65536 StandardOutput=syslog StandardError=syslog SyslogIdentifier=prometheus [Install] WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus
新增一項 “--web.enable-admin-api”,因為後續使用過程中涉及到刪除指標資料,不新增也可以
五、 安裝 Nightingale
1、 下載
mkdir /usr/local/n9e && cd /usr/local/n9e
wget https://github.com/didi/nightingale/releases/download/v5.5.0/n9e-5.5.0.tar.gz
tar zxf n9e-5.5.0.tar.gz
mysql -uroot -p${new_sql_passwd}< docker/initsql/a-n9e.sql
2、 修改配置檔案
etc/server.conf 的第119行和第145行,對應的修改為redis和mysql的root賬號密碼
etc/webapi.conf 的第142行和第168行,對應的修改為redis和mysql的root賬號密碼
行數僅供參考
3、 配置 service
cat > /usr/lib/systemd/system/n9e-server.service << EOF [Unit] Description="n9e-server" After=network.target [Service] Type=simple ExecStart=/usr/local/n9e/n9e server WorkingDirectory=/usr/local/n9e Restart=on-failure SuccessExitStatus=0 LimitNOFILE=65536 StandardOutput=syslog StandardError=syslog SyslogIdentifier=n9e-server [Install] WantedBy=multi-user.target EOF cat > /usr/lib/systemd/system/n9e-webapi.service << EOF [Unit] Description="n9e-webapi" After=network.target [Service] Type=simple ExecStart=/usr/local/n9e/n9e webapi WorkingDirectory=/usr/local/n9e Restart=on-failure SuccessExitStatus=0 LimitNOFILE=65536 StandardOutput=syslog StandardError=syslog SyslogIdentifier=n9e-webapi [Install] WantedBy=multi-user.target EOF systemctl daemon-reload
systemctl start n9e-server
systemctl enable n9e-server systemctl start n9e-webapi
systemctl enable n9e-webapi
4、 訪問web
預設使用者 root, 初始密碼 root.2020