E ngotsoe ka puo ea Rust, e tšoauoa ka ts'ebetso e phahameng le tšebeliso e tlase ea RAM ha e bapisoa le li-analogues tsa eona. Ntle le moo, ho lebisoa tlhokomelo e ngata mesebetsing e amanang le ho nepahala, haholo-holo, bokhoni ba ho boloka liketsahalo tse sa romelloang ho buffer ho disk le ho potoloha lifaele.
Ka meralo, Vector ke router ea ketsahalo e amohelang melaetsa ho tsoa ho e le 'ngoe kapa ho feta mehloli, ka boikhethelo ho sebelisa melaetsa ena liphetoho, le ho li romela ho a le mong kapa ho feta li-drain.
Vector ke sebaka sa filebeat le logstash, e ka sebetsa likarolong tse peli (ho amohela le ho romela li-log), lintlha tse ling ho tsona. sebaka.
Haeba ho Logstash ketane e hahiloe joalo ka kenyelletso → sefa → tlhahiso ebe ho Vector ho joalo Mehloli → ea fetoha → siling
Mehlala e ka fumanoa litokomaneng.
Taelo ena ke taelo e nchafalitsoeng e tsoang ho Vyacheslav Rakhinsky. Litaelo tsa mantlha li na le ts'ebetso ea geoip. Ha u leka geoip ho tsoa ho marang-rang a ka hare, vector e fane ka phoso.
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
Haeba mang kapa mang a hloka ho sebetsana le geoip, joale sheba litaelo tsa mantlha tse tsoang ho Vyacheslav Rakhinsky.
Re tla lokisa motsoako oa Nginx (Access logs) → Vector (Client | Filebeat) → Vector (Server | Logstash) → ka thoko ho Clickhouse le ka thoko ho Elasticsearch. Re tla kenya li-server tse 4. Leha o ka e feta ka li-server tse 3.
Morero ke ntho e kang ena.
Tlosa Selinux ho li-server tsohle tsa hau
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
reboot
Re kenya emulator ea seva sa HTTP + lisebelisoa ho li-server tsohle
ClickHouse e sebelisa sete ea litaelo tsa SSE 4.2, kahoo ntle le haeba ho boletsoe ka tsela e 'ngoe, tšehetso ea eona ho processor e sebelisitsoeng e fetoha tlhoko e eketsehileng ea sistimi. Mona ke taelo ea ho lekola hore na processor ea hajoale e tšehetsa SSE 4.2:
E hlophisa Elasticsearch bakeng sa mofuta oa node e le 'ngoe 1 shard, 0 replica. Mohlomong u tla ba le sehlopha sa li-server tse ngata 'me ha ho hlokahale hore u etse sena.
Bakeng sa li-index tsa nako e tlang, ntlafatsa template ea kamehla:
Ho lokela hore ho be le lintho tse kang tsena ka har'a li-logs
INFO vector::topology::builder: Healthcheck: Passed.
INFO vector::topology::builder: Healthcheck: Passed.
Ho moreki (Seva ea Webo) - 1st server
Ho seva e nang le nginx, o hloka ho tima ipv6, kaha tafole ea li-log ho clickhouse e sebelisa tšimo. upstream_addr IPv4, kaha ha ke sebelise ipv6 ka har'a marang-rang. Haeba ipv6 e sa tingoa, ho tla ba le liphoso:
DB::Exception: Invalid IPv4 value.: (while read the value of key upstream_addr)
Taba ea pele, re hloka ho hlophisa sebopeho sa log ho Nginx faeleng /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;
}
E le hore u se ke ua senya tlhophiso ea hau ea hajoale, Nginx e u lumella ho ba le litaelo tse 'maloa tsa access_log
access_log /var/log/nginx/access.log main; # Стандартный лог
access_log /var/log/nginx/access.json.log vector; # Новый лог в формате json
U se ke ua lebala ho kenya molao ho logrotate bakeng sa li-log tse ncha (haeba faele ea log e sa felle ka .log)
Tlosa default.conf ho /etc/nginx/conf.d/
rm -f /etc/nginx/conf.d/default.conf
Kenya moamoheli oa sebele /etc/nginx/conf.d/vhost1.conf
'Me u lokise sebaka sa Filebeat ho /etc/vector/vector.toml config. Aterese ea IP 172.26.10.108 ke aterese ea IP ea seva sa 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"
U se ke ua lebala ho kenya mochine oa vector ho sehlopha se hlokahalang e le hore a tsebe ho bala lifaele tsa log. Mohlala, nginx ka centos e etsa li-log tse nang le litokelo tsa sehlopha sa adm.
usermod -a -G adm vector
Ha re qale tšebeletso ea vector
systemctl enable vector
systemctl start vector
Li-logs tsa Vector li ka bonoa ka tsela ena:
journalctl -f -u vector
Ho lokela hore ho be le keno e kang ena ka har'a li-log
INFO vector::topology::builder: Healthcheck: Passed.
Teko ea Khatello ea Maikutlo
Teko e etsoa ho sebelisoa benchmark ea Apache.
Sephutheloana sa httpd-tools se kentsoe ho li-server tsohle
Re qala ho leka ho sebelisa benchmark ea Apache ho tsoa ho li-server tse 4 tse fapaneng skrineng. Taba ea mantlha, re qala "multiplexer" ea skrineng, ebe re qala ho leka ho sebelisa benchmark ea Apache. Mokhoa oa ho sebetsa ka skrine o ka o fumana ho sehlooho.
Ho tsoa ho seva sa pele
while true; do ab -H "User-Agent: 1server" -c 100 -n 10 -t 10 http://vhost1/; sleep 1; done
Ho tsoa ho seva sa pele
while true; do ab -H "User-Agent: 2server" -c 100 -n 10 -t 10 http://vhost2/; sleep 1; done
Ho tsoa ho seva sa pele
while true; do ab -H "User-Agent: 3server" -c 100 -n 10 -t 10 http://vhost3/; sleep 1; done
Ho tsoa ho seva sa pele
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;
Ha re fumane hore na ho na le lifate tse kae tse kentsoeng Clickhouse.
Boholo ba tafole ea lifate ke 857.19 MB.
Boholo ba data e tšoanang ho index ho Elasticsearch ke 4,5GB.
Haeba u sa hlakise lintlha ka har'a vector ho liparamente, Clickhouse e nka 4500/857.19 = makhetlo a 5.24 ka tlase ho Elasticsearch.
Ho vector, sebaka sa compression se sebelisoa ka ho sa feleng.