各個版本下載地址:https://github.com/didi/nightingale/releases
一、安裝
1.安裝編譯
下載我們編譯好的二進制到/home/n9e目錄,如果要更換目錄,要注意修改nginx.conf
mkdir -p /home/n9e
cd /home/n9e
wget http://116.85.64.82/n9e.tar.gz
tar zxvf n9e.tar.gz
redis配置修改,默認配置的6379端口,密碼為空,如果默認配置不對,可以執行如下命令,看到多個配置文件里有redis相關配置,挨個檢查修改下
cd /home/n9e/etc
grep redis -r
下載前端靜態資源文件,放到默認的/home/n9e目錄下,如果要改目錄,需要修改后面提到的nginx.conf
cd /home/n9e
wget http://116.85.64.82/pub.tar.gz
tar zxvf pub.tar.gz
前端的源碼單獨拆了一個repo,地址是: https://github.com/n9e/fe 沒有和nightingale放一塊
2.安裝mysql、redis、nginx
yum install -y mariadb* redis nginx
安裝完成MariaDB,首先啟動MariaDB
systemctl start mariadb
設置開機啟動
systemctl enable mariadb
接下來進行MariaDB的相關簡單配置
mysql_secure_installation
登錄mysql
mysql -uroot -p
開啟redis
systemctl start redis
開啟nginx
systemctl start nginx
3.導入n9e數據庫表結構
mysql -uroot -p </home/n9e/sql/n9e_ams.sql
mysql -uroot -p </home/n9e/sql/n9e_hbs.sql
mysql -uroot -p </home/n9e/sql/n9e_job.sql
mysql -uroot -p </home/n9e/sql/n9e_mon.sql
mysql -uroot -p </home/n9e/sql/n9e_rdb.sql
安全考慮,建議為 n9e 獨立建立 mysql 用戶,在 mysql 里創建 n9e 用戶並授權
mysql>create user n9e@127.0.0.1 identified by '你的密碼';
mysql>grant all on n9e_ams.* to n9e@127.0.0.1;
mysql>grant all on n9e_hbs.* to n9e@127.0.0.1;
mysql>grant all on n9e_job.* to n9e@127.0.0.1;
mysql>grant all on n9e_mon.* to n9e@127.0.0.1;
mysql>grant all on n9e_rdb.* to n9e@127.0.0.1;
mysql> flush privileges;
並修改組件/usr/local/n9e/etc/mysql.yml 文件里的數據庫配置信息
vi /home/n9e/etc/mysql.yml
---
rdb:
addr: "n9e:你的密碼@tcp(127.0.0.1:3306)/n9e_rdb?charset=utf8&parseTime=True&loc=Asia%2FShanghai"
max: 16
idle: 4
debug: false
ams:
addr: "n9e:你的密碼@tcp(127.0.0.1:3306)/n9e_ams?charset=utf8&parseTime=True&loc=Asia%2FShanghai"
max: 16
idle: 4
debug: false
job:
addr: "n9e:你的密碼@tcp(127.0.0.1:3306)/n9e_job?charset=utf8&parseTime=True&loc=Asia%2FShanghai"
max: 16
idle: 4
debug: false
mon:
addr: "n9e:你的密碼@tcp(127.0.0.1:3306)/n9e_mon?charset=utf8&parseTime=True&loc=Asia%2FShanghai"
max: 16
idle: 4
debug: false
hbs:
addr: "n9e:你的密碼@tcp(127.0.0.1:3306)/n9e_hbs?charset=utf8&parseTime=True&loc=Asia%2FShanghai"
max: 16
idle: 4
debug: false
4.修改Nginx的配置文件
cat /home/n9e/etc/nginx.conf
把/home/n9e/etc/nginx.conf的配置信息拷貝到/usr/local/nginx/conf/nginx.conf,即
vi /etc/nginx/nginx.conf
增加配置
######################## nightingale ############################
upstream n9e.rdb {
server 127.0.0.1:8000;
keepalive 60;
}
upstream n9e.ams {
server 127.0.0.1:8002;
keepalive 60;
}
upstream n9e.job {
server 127.0.0.1:8004;
keepalive 60;
}
upstream n9e.monapi {
server 127.0.0.1:8006;
keepalive 60;
}
upstream n9e.transfer {
server 127.0.0.1:8008;
keepalive 60;
}
upstream n9e.index {
server 127.0.0.1:8012;
keepalive 60;
}
server {
listen 6699 default_server;
server_name n9e.example.com;
root /home/n9e/pub;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location =/ {
rewrite / /mon;
}
location / {
try_files $uri /layout/index.html;
}
location ~ .*(.htm|.html|manifest.json)$ {
add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
}
location /api/rdb {
proxy_pass http://n9e.rdb;
}
location /api/ams {
proxy_pass http://n9e.ams;
}
location /api/job {
proxy_pass http://n9e.job;
}
location /api/mon {
proxy_pass http://n9e.monapi;
}
location /api/index {
proxy_pass http://n9e.index;
}
location /api/transfer {
proxy_pass http://n9e.transfer;
}
}
5.驗證配置是否正確
nginx -t
重新載入nginx
service nginx reload
啟動
service nginx start
service nginx status
6.啟動服務
啟動所有
./control start all
查看狀態
./control status
7. 訪問
訪問:http://ip:6699/
賬號密碼:root/root.2020
二、客戶端單獨部署
1.打包agent端需要的文件
tar zcvf agent.tar.gz n9e-agent etc/agent.yml etc/identity.yml etc/address.yml control
2.可以用python起一個httpserver
ss -tlnp| grep 8099
python -mSimpleHTTPServer 8099
3.在客戶端下載這個壓縮包
mkdir -p /home/n9e
cd /home/n9e
4.解壓
address.yml
tar zxvf agent.tar.gz
5.修改配置文件
vi address.yml
:%s/127.0.0.1/你的ip/g
6.啟動agent
./control start agent
7.設置自啟動方式
把服務端的客戶端啟動文件復制到客戶端的/usr/lib/systemd/system/agent.service
cat etc/service/agent.service
vim /usr/lib/systemd/system/agent.service
啟動
systemctl start agent
開機自啟動
systemctl enable agent