前言
夜鶯(Nightingale)是滴滴基礎平台聯合滴滴雲研發和開源的企業級監控解決方案。旨在滿足雲原生時代企業級的監控需求。Nightingale在產品完成度、系統高可用、以及用戶體驗方面,達到了企業級的要求,可滿足不同規模用戶的場景,小到幾台服務,大到數十萬都可以完美支撐。兼顧雲原生和裸金屬,支持應用監控和系統監控,插件機制靈活,插件豐富完善,具有高度的靈活性和可擴展性。
Nightingale 在 Open-Falcon 的基礎上,結合滴滴內部的最佳實踐,在性能、可維護性、易用性方面做了大量的改進,作為集團統一的監控解決方案,支撐了滴滴內部數十億監控指標,覆蓋了從系統、容器、到應用等各層面的監控需求,周活躍用戶數千。
我們簡單快捷,直接使用all-in-one來安裝部署夜鶯的這套監控系統~
步驟
下載n9e-1.3.0-438ec4a.el7.x86_64.rpm-bundle.tar.gz並進行解壓和安裝
wget https://dl.cactifans.com/n9e/1.3.0/n9e-1.3.0-438ec4a.el7.x86_64.rpm-bundle.tar.gz && tar -zxvf n9e-1.3.0-438ec4a.el7.x86_64.rpm-bundle.tar.gz && yum install n9e-* -y
安裝相應的nginx和mysql
推薦使用oneinstack直接一鍵安裝~
wget -c http://mirrors.linuxeye.com/oneinstack-full.tar.gz && tar xzf oneinstack-full.tar.gz && ./oneinstack/install.sh --nginx_option 1 --db_option 2 --dbinstallmethod 1 --dbrootpwd oneinstack --memcached --reboot
mysql 導入表結構並創建相應的用戶
mysql -uroot -p </usr/local/n9e/sql/n9e_hbs.sql
mysql -uroot -p </usr/local/n9e/sql/n9e_mon.sql
mysql -uroot -p </usr/local/n9e/sql/n9e_uic.sql
安全考慮,建議為 n9e 獨立建立 mysql 用戶,在 mysql 里創建 n9e 用戶並授權
mysql>create user n9e@127.0.0.1 identified by '你的密碼';
mysql>grant all on n9e_hbs.* to n9e@127.0.0.1;
mysql>grant all on n9e_mon.* to n9e@127.0.0.1;
mysql>grant all on n9e_uic.* to n9e@127.0.0.1;
mysql> flush privileges;
修改配置文件mysql.yml
中的密碼,通過sed或者手動都可以
vi /usr/local/n9e/etc/mysql.yml
---
uic:
addr: "n9e:你的密碼@tcp(127.0.0.1:3306)/n9e_uic?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
修改Nginx的配置文件
cat /usr/local/n9e/etc/nginx.conf
#放到http中
proxy_connect_timeout 500ms;
proxy_send_timeout 1000ms;
proxy_read_timeout 3000ms;
proxy_buffers 64 8k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 64k;
proxy_redirect off;
proxy_next_upstream error invalid_header timeout http_502 http_504;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-Port $remote_port;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# server內容
upstream n9e.monapi {
server 127.0.0.1:5800;
keepalive 10;
}
upstream n9e.index {
server 127.0.0.1:5830;
keepalive 10;
}
upstream n9e.transfer {
server 127.0.0.1:5810;
keepalive 10;
}
server {
listen 52000; #監聽端口改成自己對外的接口
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
location / {
root /usr/local/n9e/pub;
}
location /api/portal {
proxy_pass http://n9e.monapi;
}
location /api/index {
proxy_pass http://n9e.index;
}
location /api/transfer {
proxy_pass http://n9e.transfer;
}
}
nginx的完整配置
cat /usr/local/nginx/conf/nginx.conf
user www www;
worker_processes auto;
error_log /data/wwwlogs/error_nginx.log crit;
pid /var/run/nginx.pid;
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 51200;
multi_accept on;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 1024m;
client_body_buffer_size 10m;
sendfile on;
tcp_nopush on;
keepalive_timeout 120;
server_tokens off;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
fastcgi_intercept_errors on;
proxy_connect_timeout 500ms;
proxy_send_timeout 1000ms;
proxy_read_timeout 3000ms;
proxy_buffers 64 8k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 64k;
proxy_redirect off;
proxy_next_upstream error invalid_header timeout http_502 http_504;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-Port $remote_port;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#Gzip Compression
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 6;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
text/javascript application/javascript application/x-javascript
text/x-json application/json application/x-web-app-manifest+json
text/css text/plain text/x-component
font/opentype application/x-font-ttf application/vnd.ms-fontobject
image/x-icon;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
##Brotli Compression
#brotli on;
#brotli_comp_level 6;
#brotli_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
##If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency.
#open_file_cache max=1000 inactive=20s;
#open_file_cache_valid 30s;
#open_file_cache_min_uses 2;
#open_file_cache_errors on;
######################## default ############################
server {
listen 80;
server_name _;
access_log /data/wwwlogs/access_nginx.log combined;
root /data/wwwroot/default;
index index.html index.htm index.php;
#error_page 404 /404.html;
#error_page 502 /502.html;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
location ~ [^/]\.php(/|$) {
#fastcgi_pass remote_php_ip:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
location ~ ^/(\.user.ini|\.ht|\.git|\.svn|\.project|LICENSE|README.md) {
deny all;
}
}
######################## nightingale ############################
upstream n9e.monapi {
server 127.0.0.1:5800;
keepalive 10;
}
upstream n9e.index {
server 127.0.0.1:5830;
keepalive 10;
}
upstream n9e.transfer {
server 127.0.0.1:5810;
keepalive 10;
}
server {
listen 52000;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
location / {
root /usr/local/n9e/pub;
}
location /api/portal {
proxy_pass http://n9e.monapi;
}
location /api/index {
proxy_pass http://n9e.index;
}
location /api/transfer {
proxy_pass http://n9e.transfer;
}
}
########################## vhost #############################
include vhost/*.conf;
}
驗證配置是否正確
nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
重新載入nginx
service nginx reload
啟動所有組件服務
systemctl enable --now n9e-collector n9e-tsdb n9e-transfer n9e-monapi n9e-judge n9e-index
查看服務狀態
cd /usr/local/n9e/
#查看有哪些命令
./control -h
Usage: ./control {start|stop|restart|status|build|pack} <module>
#查看所有服務狀態(一共6個) | 全部啟動后就可以進行下一步, 若某一個沒啟動可到/usr/local/n9e/logs中去查看相關服務的日志
./control status
root 18322 0.1 0.1 996288 25792 ? Sl May08 2:27 /usr/local/n9e/n9e-index
root 18351 0.1 0.1 1069996 22916 ? Sl May08 2:50 /usr/local/n9e/n9e-judge
root 18381 0.2 0.1 1152172 28780 ? Sl May08 5:28 /usr/local/n9e/n9e-collector
n9e 66032 0.1 0.1 1408048 28484 ? Ssl May08 2:53 /usr/local/n9e/n9e-tsdb
n9e 66116 0.6 0.1 1061668 23156 ? Ssl May08 13:21 /usr/local/n9e/n9e-transfer
n9e 66131 0.6 0.1 1070460 29588 ? Ssl May08 13:13 /usr/local/n9e/n9e-monapi
#啟動(單個模塊/所有模塊 )
./control start collector
./control start all
訪問
使用瀏覽器打開http://公網ip 即可訪問,默認賬號 root 密碼 root