Ni kikọ ni ede Rust, o jẹ ijuwe nipasẹ iṣẹ giga ati agbara Ramu kekere ni akawe si awọn afọwọṣe rẹ. Ni afikun, akiyesi pupọ ni a san si awọn iṣẹ ti o ni ibatan si atunṣe, ni pataki, agbara lati ṣafipamọ awọn iṣẹlẹ ti a ko firanṣẹ si ifipamọ lori disiki ati yiyi awọn faili.
Ni ayaworan, Vector jẹ olulana iṣẹlẹ ti o gba awọn ifiranṣẹ lati ọkan tabi diẹ sii awọn orisun, optionally nbere lori awọn wọnyi awọn ifiranṣẹ awọn iyipada, ati fifiranṣẹ wọn si ọkan tabi diẹ ẹ sii drains.
Vector jẹ aropo fun filebeat ati logstash, o le ṣe ni awọn ipa mejeeji (gba ati firanṣẹ awọn akọọlẹ), awọn alaye diẹ sii lori wọn Aaye.
Ti o ba wa ni Logstash pq ti wa ni itumọ bi titẹ sii → àlẹmọ → iṣelọpọ lẹhinna ni Vector o jẹ awọn orisun → awọn iyipada → rii
Awọn apẹẹrẹ le wa ninu iwe-ipamọ.
Ilana yii jẹ itọnisọna atunṣe lati Vyacheslav Rakhinsky. Awọn itọnisọna atilẹba ni sisẹ geoip ninu. Nigbati o ba ṣe idanwo geoip lati inu nẹtiwọọki inu, fekito fun aṣiṣe kan.
Aug 05 06:25:31.889 DEBUG transform{name=nginx_parse_rename_fields type=rename_fields}: vector::transforms::rename_fields: Field did not exist field=«geoip.country_name» rate_limit_secs=30
Ti ẹnikẹni ba nilo lati ṣe ilana geoip, lẹhinna tọka si awọn itọnisọna atilẹba lati Vyacheslav Rakhinsky.
A yoo tunto apapo Nginx (Awọn igbasilẹ Wiwọle) → Vector (Onibara | Filebeat) → Vector (Olupin | Logstash) → lọtọ ni Clickhouse ati lọtọ ni Elasticsearch. A yoo fi sori ẹrọ 4 olupin. Botilẹjẹpe o le fori rẹ pẹlu awọn olupin 3.
Ilana naa jẹ nkan bi eyi.
Pa Selinux kuro lori gbogbo awọn olupin rẹ
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
reboot
A fi emulator olupin HTTP sori ẹrọ + awọn ohun elo lori gbogbo awọn olupin
ClickHouse nlo eto itọnisọna SSE 4.2, nitorinaa ayafi ti bibẹẹkọ pato, atilẹyin fun rẹ ninu ero isise ti a lo di ibeere eto afikun. Eyi ni aṣẹ lati ṣayẹwo boya ero isise lọwọlọwọ ṣe atilẹyin SSE 4.2:
INFO vector::topology::builder: Healthcheck: Passed.
INFO vector::topology::builder: Healthcheck: Passed.
Lori alabara (olupin wẹẹbu) - olupin 1st
Lori olupin pẹlu nginx, o nilo lati mu ipv6 kuro, niwọn igba ti tabili awọn akọọlẹ ni ile tẹ nlo aaye naa upstream_addr IPv4, niwon Emi ko lo ipv6 inu nẹtiwọki. Ti a ko ba pa ipv6, awọn aṣiṣe yoo wa:
DB::Exception: Invalid IPv4 value.: (while read the value of key upstream_addr)
Ni akọkọ, a nilo lati tunto ọna kika log ni Nginx ninu faili /etc/nginx/nginx.conf
user nginx;
# you must set worker processes based on your CPU cores, nginx does not benefit from setting more than that
worker_processes auto; #some last versions calculate it automatically
# number of file descriptors used for nginx
# the limit for the maximum FDs on the server is usually set by the OS.
# if you don't set FD's then OS settings will be used which is by default 2000
worker_rlimit_nofile 100000;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
# provides the configuration file context in which the directives that affect connection processing are specified.
events {
# determines how much clients will be served per worker
# max clients = worker_connections * worker_processes
# max clients is also limited by the number of socket connections available on the system (~64k)
worker_connections 4000;
# optimized to serve many clients with each thread, essential for linux -- for testing environment
use epoll;
# accept as many connections as possible, may flood worker connections if set too low -- for testing environment
multi_accept on;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format vector escape=json
'{'
'"node_name":"nginx-vector",'
'"timestamp":"$time_iso8601",'
'"server_name":"$server_name",'
'"request_full": "$request",'
'"request_user_agent":"$http_user_agent",'
'"request_http_host":"$http_host",'
'"request_uri":"$request_uri",'
'"request_scheme": "$scheme",'
'"request_method":"$request_method",'
'"request_length":"$request_length",'
'"request_time": "$request_time",'
'"request_referrer":"$http_referer",'
'"response_status": "$status",'
'"response_body_bytes_sent":"$body_bytes_sent",'
'"response_content_type":"$sent_http_content_type",'
'"remote_addr": "$remote_addr",'
'"remote_port": "$remote_port",'
'"remote_user": "$remote_user",'
'"upstream_addr": "$upstream_addr",'
'"upstream_bytes_received": "$upstream_bytes_received",'
'"upstream_bytes_sent": "$upstream_bytes_sent",'
'"upstream_cache_status":"$upstream_cache_status",'
'"upstream_connect_time":"$upstream_connect_time",'
'"upstream_header_time":"$upstream_header_time",'
'"upstream_response_length":"$upstream_response_length",'
'"upstream_response_time":"$upstream_response_time",'
'"upstream_status": "$upstream_status",'
'"upstream_content_type":"$upstream_http_content_type"'
'}';
access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/access.json.log vector; # Новый лог в формате json
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
Ni ibere ki o má ba fọ iṣeto rẹ lọwọlọwọ, Nginx gba ọ laaye lati ni ọpọlọpọ awọn itọnisọna wiwọle_log
access_log /var/log/nginx/access.log main; # Стандартный лог
access_log /var/log/nginx/access.json.log vector; # Новый лог в формате json
Maṣe gbagbe lati ṣafikun ofin kan si logrotate fun awọn akọọlẹ tuntun (ti faili log ko ba pari pẹlu .log)
Ati tunto rirọpo Filebeat ni atunto /etc/vector/vector.toml. Adirẹsi IP 172.26.10.108 jẹ adiresi IP ti olupin log (Vector-Server)
data_dir = "/var/lib/vector"
[sources.nginx_file]
type = "file"
include = [ "/var/log/nginx/access.json.log" ]
start_at_beginning = false
fingerprinting.strategy = "device_and_inode"
[sinks.nginx_output_vector]
type = "vector"
inputs = [ "nginx_file" ]
address = "172.26.10.108:9876"
Maṣe gbagbe lati ṣafikun olumulo fekito si ẹgbẹ ti o nilo ki o le ka awọn faili log. Fun apẹẹrẹ, nginx ni centos ṣẹda awọn akọọlẹ pẹlu awọn ẹtọ ẹgbẹ adm.
usermod -a -G adm vector
Jẹ ká bẹrẹ iṣẹ fekito
systemctl enable vector
systemctl start vector
Awọn akọọlẹ Vector le ṣee wo bi eleyi:
journalctl -f -u vector
O yẹ ki o jẹ titẹ sii bi eyi ninu awọn akọọlẹ
INFO vector::topology::builder: Healthcheck: Passed.
Idanwo Wahala
A ṣe idanwo ni lilo ala Apache.
Awọn ohun elo httpd-irinṣẹ ti fi sori ẹrọ lori gbogbo awọn olupin
A bẹrẹ idanwo ni lilo ala Apache lati awọn olupin oriṣiriṣi mẹrin ni iboju. Ni akọkọ, a ṣe ifilọlẹ multixer ebute iboju, lẹhinna a bẹrẹ idanwo ni lilo ala Apache. Bii o ṣe le ṣiṣẹ pẹlu iboju o le wa ninu article.
Lati olupin 1st
while true; do ab -H "User-Agent: 1server" -c 100 -n 10 -t 10 http://vhost1/; sleep 1; done
Lati olupin 2st
while true; do ab -H "User-Agent: 2server" -c 100 -n 10 -t 10 http://vhost2/; sleep 1; done
Lati olupin 3st
while true; do ab -H "User-Agent: 3server" -c 100 -n 10 -t 10 http://vhost3/; sleep 1; done
Lati olupin 4st
while true; do ab -H "User-Agent: 4server" -c 100 -n 10 -t 10 http://vhost4/; sleep 1; done
select concat(database, '.', table) as table,
formatReadableSize(sum(bytes)) as size,
sum(rows) as rows,
max(modification_time) as latest_modification,
sum(bytes) as bytes_size,
any(engine) as engine,
formatReadableSize(sum(primary_key_bytes_in_memory)) as primary_keys_size
from system.parts
where active
group by database, table
order by bytes_size desc;
Jẹ ki a wa iye awọn akọọlẹ ti o gba ni Clickhouse.
Iwọn tabili awọn akọọlẹ jẹ 857.19 MB.
Iwọn data kanna ni atọka ni Elasticsearch jẹ 4,5GB.
Ti o ko ba pato data ninu fekito ninu awọn paramita, Clickhouse gba 4500/857.19 = 5.24 igba kere ju ni Elasticsearch.