Ny fanoratana amin'ny fiteny Rust dia miavaka amin'ny fampisehoana avo lenta sy ny fanjifana RAM ambany raha oharina amin'ny analogues. Ho fanampin'izany, ny saina be dia be amin'ny asa mifandraika amin'ny fahitsiana, indrindra ny fahafahana mitahiry hetsika tsy alefa amin'ny buffer amin'ny kapila ary manodina rakitra.
Amin'ny Architectural, Vector dia router hetsika izay mandray hafatra avy amin'ny iray na maromaro loharanom-baovao, raha azo atao dia ampiharina amin'ireo hafatra ireo fiovana, ary mandefa azy ireo amin'ny iray na maromaro fantsona ivoahan'ny.
Vector dia fanoloana ny filebeat sy logstash, afaka miasa amin'ny andraikitra roa (mandray sy mandefa logs), antsipiriany bebe kokoa momba azy ireo. tranonkala.
Raha ao amin'ny Logstash ny rojo dia natsangana ho input → filter → output dia ao amin'ny Vector izany loharanom-baovao → manova → milentika
Misy ohatra hita ao amin'ny antontan-taratasy.
Ity torolàlana ity dia torolàlana nohavaozina avy amin'ny Vyacheslav Rakhinsky. Ny torolàlana tany am-boalohany dia misy fanodinana geoip. Rehefa nanandrana geoip avy amin'ny tambajotra anatiny, dia nanome fahadisoana ny vector.
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
Raha misy mila manodina geoip dia jereo ny toromarika voalohany avy amin'ny Vyacheslav Rakhinsky.
ClickHouse dia mampiasa ny SSE 4.2 toromarika napetraka, ka raha tsy misy fepetra manokana, ny fanohanana azy ao amin'ny processeur ampiasaina dia lasa fepetra takiana rafitra fanampiny. Ity ny baiko hanamarinana raha manohana ny SSE 4.2 ny processeur amin'izao fotoana izao:
Aorian'ny famoronana latabatra dia azonao atao ny mihazakazaka Vector
systemctl enable vector
systemctl start vector
Ny logs vector dia azo jerena toy izao:
journalctl -f -u vector
Tokony hisy fidirana toy izany ao amin'ny diary
INFO vector::topology::builder: Healthcheck: Passed.
INFO vector::topology::builder: Healthcheck: Passed.
Amin'ny mpanjifa (Web server) - mpizara voalohany
Ao amin'ny server miaraka amin'ny nginx, mila manaisotra ny ipv6 ianao, satria ny latabatra logs ao amin'ny clickhouse dia mampiasa ny saha. upstream_addr IPv4, satria tsy mampiasa ipv6 ao anaty tambajotra aho. Raha tsy vonoina ny ipv6 dia hisy lesoka:
DB::Exception: Invalid IPv4 value.: (while read the value of key upstream_addr)
Angamba ry mpamaky, ampio ny fanohanana ipv6.
Mamorona ny rakitra /etc/sysctl.d/98-disable-ipv6.conf
Voalohany, mila manamboatra ny format log ao amin'ny Nginx ao amin'ny rakitra /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;
}
Mba tsy handravana ny fandrindranao amin'izao fotoana izao, Nginx dia mamela anao hanana torolalana access_log maromaro
access_log /var/log/nginx/access.log main; # Стандартный лог
access_log /var/log/nginx/access.json.log vector; # Новый лог в формате json
Aza adino ny manisy fitsipika ho logrotate ho an'ny log vaovao (raha tsy mifarana amin'ny .log ny rakitra log)
Ary amboary ny fanoloana Filebeat ao amin'ny /etc/vector/vector.toml config. Ny adiresy IP 172.26.10.108 dia ny adiresy IP an'ny mpizara 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"
Aza adino ny manampy ny mpampiasa vector amin'ny vondrona ilaina mba hahafahany mamaky rakitra log. Ohatra, ny nginx in centos dia mamorona logs miaraka amin'ny zon'ny vondrona adm.
usermod -a -G adm vector
Andao hanomboka ny serivisy vector
systemctl enable vector
systemctl start vector
Ny logs vector dia azo jerena toy izao:
journalctl -f -u vector
Tokony hisy fidirana toy izany ao amin'ny logs
INFO vector::topology::builder: Healthcheck: Passed.
Fitsapana adin-tsaina
Ny fitsapana dia atao amin'ny alàlan'ny benchmark Apache.
Ny fonosana httpd-tools dia napetraka amin'ny mpizara rehetra
Manomboka manao fitiliana amin'ny fampiasana benchmark Apache avy amin'ny mpizara 4 samihafa amin'ny efijery izahay. Voalohany, manomboka ny multiplexer terminal screen isika, ary avy eo dia manomboka manandrana mampiasa ny mari-pamantarana Apache. Ahoana ny fomba fiasa amin'ny efijery azonao jerena ao lahatsoratra.
Avy amin'ny mpizara voalohany
while true; do ab -H "User-Agent: 1server" -c 100 -n 10 -t 10 http://vhost1/; sleep 1; done
Avy amin'ny mpizara voalohany
while true; do ab -H "User-Agent: 2server" -c 100 -n 10 -t 10 http://vhost2/; sleep 1; done
Avy amin'ny mpizara voalohany
while true; do ab -H "User-Agent: 3server" -c 100 -n 10 -t 10 http://vhost3/; sleep 1; done
Avy amin'ny mpizara voalohany
while true; do ab -H "User-Agent: 4server" -c 100 -n 10 -t 10 http://vhost4/; sleep 1; done
Andeha hojerentsika ny angona ao amin'ny Clickhouse
Fantaro ny haben'ny latabatra ao amin'ny Clickhouse
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;
Andao hojerentsika hoe ohatrinona ny logs tao amin'ny Clickhouse.
Ny haben'ny latabatra dia 857.19 MB.
Ny haben'ny angon-drakitra mitovy amin'ny index ao amin'ny Elasticsearch dia 4,5GB.
Raha tsy mamaritra ny angon-drakitra ao amin'ny vector ianao amin'ny paramètre, Clickhouse dia maka 4500/857.19 = 5.24 heny noho ny ao amin'ny Elasticsearch.
Ao amin'ny vector, ny saha famatrarana dia ampiasaina amin'ny alàlan'ny default.