Ko te tuhi i roto i te reo Rust, e tohuhia ana e te mahi nui me te iti o te kohi RAM ka whakaritea ki ona analogues. I tua atu, ka nui te aro ki nga mahi e pa ana ki te tika, ina koa, te kaha ki te penapena i nga kaupapa kaore i tukuna ki te papaa i runga i te kōpae me te huri i nga konae.
Ma te hoahoanga, he pouara takahanga a Vector ka whiwhi karere mai i tetahi, neke atu ranei pūtake, ka taea te tono mo enei karere huringa, me te tuku atu ki tetahi, ki etahi atu ranei wairere.
He whakakapinga a Vector mo te filebeat me te logstash, ka taea e ia te mahi i roto i nga mahi e rua (whiwhi me te tuku i nga raarangi), etahi atu korero mo aua mea pae.
Mena i roto i te Logstash ka hangaia te mekameka hei whakaurunga → tātari → putanga ka noho ki Vector puna → hurihuri → totohu
Ka kitea nga tauira i roto i nga tuhinga.
Ko tenei tohutohu he tohutohu hou mai i Vyacheslav Rakhinsky. Kei roto i nga tohutohu taketake te tukatuka geoip. I te wa e whakamatautau ana i te geoip mai i te whatunga o roto, i puta he hapa te 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
Mena ka hiahia tetahi ki te tukatuka geoip, tirohia nga tohutohu taketake mai i Vyacheslav Rakhinsky.
Ka whirihorahia e matou te huinga o Nginx (Rautaki uru) → Vector (Kaihoko | Filebeat) → Vector (Server | Logstash) → wehe i Clickhouse me te wehe i Elasticsearch. Ka whakauruhia e matou nga kaitoro e 4. Ahakoa ka taea e koe te karo me nga kaitoro e 3.
He penei te kaupapa.
Monokia a Selinux i runga i o tūmau katoa
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
reboot
Ka whakauruhia e matou he emulator tūmau HTTP + taputapu ki runga i nga tūmau katoa
Ka whakamahia e ClickHouse te huinga tohutohu SSE 4.2, no reira ki te kore e tohua, ko te tautoko mo taua mea i roto i te tukatuka i whakamahia hei whakaritenga punaha taapiri. Anei te whakahau kia tirohia mena kei te tautoko te tukatuka o naianei i te SSE 4.2:
Te whirihora i te Elasticsearch mo te aratau node kotahi 1 shard, 0 tauira. Ko te mea pea ka mau koe i te kahui o te maha o nga kaitoro kaore koe e hiahia ki te mahi i tenei.
Mo nga taurangi a meake nei, whakahōuhia te tauira taunoa:
I muri i te waihanga i nga ripanga, ka taea e koe te whakahaere Vector
systemctl enable vector
systemctl start vector
Ka taea te tiro i nga raarangi vector penei:
journalctl -f -u vector
Me whai whakaurunga penei i roto i nga raarangi
INFO vector::topology::builder: Healthcheck: Passed.
INFO vector::topology::builder: Healthcheck: Passed.
I runga i te kiritaki (Tumautuku Tukutuku) - tūmau tuatahi
I runga i te tūmau me te nginx, me whakakore koe i te ipv6, na te mea ko te ripanga raarangi i te clickhouse te whakamahi i te mara upstream_addr IPv4, na te mea kaore au e whakamahi ipv6 i roto i te whatunga. Ki te kore te ipv6 e whakaweto, ka puta he hapa:
DB::Exception: Invalid IPv4 value.: (while read the value of key upstream_addr)
Tena pea nga kaipānui, taapirihia te tautoko ipv6.
Waihangahia te konae /etc/sysctl.d/98-disable-ipv6.conf
Tuatahi, me whirihora i te whakatakotoranga rangitaki i Nginx i roto i te konae /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;
}
Kia kore ai e pakaru to whirihoranga o naianei, ka taea e Nginx te maha o nga tohutohu uru_log
access_log /var/log/nginx/access.log main; # Стандартный лог
access_log /var/log/nginx/access.json.log vector; # Новый лог в формате json
Kaua e wareware ki te taapiri i tetahi ture ki te hurihuri mo nga raarangi hou (mehemea kaore te konae rangitaki e mutu ki te .log)
Na ka whirihora i te whakakapinga Filebeat i te /etc/vector/vector.toml config. Ko te wāhitau IP 172.26.10.108 te wāhitau IP o te tūmau rangitaki (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"
Kaua e wareware ki te taapiri i te kaiwhakamahi vector ki te roopu e hiahiatia ana kia taea e ia te panui i nga konae rangitaki. Hei tauira, ko te nginx in centos te hanga i nga raarangi me nga mana roopu adm.
usermod -a -G adm vector
Me timata te ratonga vector
systemctl enable vector
systemctl start vector
Ka taea te tiro i nga raarangi vector penei:
journalctl -f -u vector
Me whai urunga penei i roto i nga raarangi
INFO vector::topology::builder: Healthcheck: Passed.
Whakamātautau ahotea
Ka mahia nga whakamatautau ma te whakamahi i te tohu tohu a Apache.
I tāutahia te mōkihi httpd-tools ki ngā tūmau katoa
Ka timata taatau ki te whakamatautau ma te whakamahi i te tohu tohu Apache mai i nga kaitoro rereke e 4 i te mata. Tuatahi, ka whakarewahia e matou te multixer kapeka mata, katahi ka timata taatau ki te whakamatau ma te whakamahi i te tohu tohu a Apache. Me pehea te mahi me te mata ka kitea e koe i roto Tuhinga.
Mai i te tūmau tuatahi
while true; do ab -H "User-Agent: 1server" -c 100 -n 10 -t 10 http://vhost1/; sleep 1; done
Mai i te tūmau tuatahi
while true; do ab -H "User-Agent: 2server" -c 100 -n 10 -t 10 http://vhost2/; sleep 1; done
Mai i te tūmau tuatahi
while true; do ab -H "User-Agent: 3server" -c 100 -n 10 -t 10 http://vhost3/; sleep 1; done
Mai i te tūmau tuatahi
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;
Kia kite tatou i te nui o nga rakau i mau ki Clickhouse.
Ko te rahi o te ripanga rangitaki ko 857.19 MB.
Ko te rahi o nga raraunga rite i roto i te taurangi i Elasticsearch ko 4,5GB.
Mena kaore koe e tohu i nga raraunga i roto i te vector i roto i nga taapiri, ka tango a Clickhouse i te 4500/857.19 = 5.24 nga wa iti ake i te Elasticsearch.
I roto i te vector, ka whakamahia taunoa te mara kōpeketanga.