રસ્ટ ભાષામાં લખાયેલું હોવાથી, તે તેના એનાલોગની તુલનામાં ઉચ્ચ પ્રદર્શન અને ઓછી RAM વપરાશ દ્વારા વર્ગીકૃત થયેલ છે. વધુમાં, ચોકસાઈથી સંબંધિત કાર્યો પર ખૂબ ધ્યાન આપવામાં આવે છે, ખાસ કરીને, ડિસ્ક પરના બફરમાં ન મોકલેલ ઇવેન્ટ્સને સાચવવાની અને ફાઇલોને ફેરવવાની ક્ષમતા.
આર્કિટેક્ચરલ રીતે, વેક્ટર એ ઇવેન્ટ રાઉટર છે જે એક અથવા વધુ લોકો તરફથી સંદેશા મેળવે છે સ્ત્રોતો, વૈકલ્પિક રીતે આ સંદેશાઓ પર અરજી કરવી પરિવર્તનો, અને તેમને એક અથવા વધુને મોકલવા ડ્રેઇન્સ.
વેક્ટર એ ફાઇલબીટ અને લોગસ્ટૅશનું રિપ્લેસમેન્ટ છે, તે બંને ભૂમિકાઓમાં કાર્ય કરી શકે છે (લોગ પ્રાપ્ત કરો અને મોકલો), તેના પર વધુ વિગતો સાઇટ.
જો Logstash માં સાંકળ ઇનપુટ → ફિલ્ટર → આઉટપુટ તરીકે બનેલ હોય તો વેક્ટરમાં તે છે સૂત્રો → પરિવર્તન → સિંક
ઉદાહરણો દસ્તાવેજીકરણમાં મળી શકે છે.
આ સૂચના એમાંથી સુધારેલી સૂચના છે વ્યાચેસ્લાવ રાખિન્સકી. મૂળ સૂચનાઓમાં જીઓપ પ્રોસેસિંગ શામેલ છે. આંતરિક નેટવર્કમાંથી geoip નું પરીક્ષણ કરતી વખતે, વેક્ટરે ભૂલ આપી.
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
જો કોઈને geoip પર પ્રક્રિયા કરવાની જરૂર હોય, તો પછી મૂળ સૂચનાઓનો સંદર્ભ લો વ્યાચેસ્લાવ રાખિન્સકી.
અમે Nginx (એક્સેસ લૉગ્સ) → વેક્ટર (ક્લાયન્ટ | ફાઇલબીટ) → વેક્ટર (સર્વર | લોગસ્ટેશ) → ક્લિકહાઉસમાં અલગથી અને ઇલાસ્ટિકસર્ચમાં અલગથી રૂપરેખાંકિત કરીશું. અમે 4 સર્વર ઇન્સ્ટોલ કરીશું. જો કે તમે તેને 3 સર્વર સાથે બાયપાસ કરી શકો છો.
સ્કીમ કંઈક આવી છે.
તમારા બધા સર્વર પર સેલિનક્સને અક્ષમ કરો
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
reboot
ક્લિકહાઉસ SSE 4.2 સૂચના સમૂહનો ઉપયોગ કરે છે, તેથી જ્યાં સુધી અન્યથા ઉલ્લેખિત ન હોય, વપરાયેલ પ્રોસેસરમાં તેના માટે સપોર્ટ એ વધારાની સિસ્ટમ આવશ્યકતા બની જાય છે. વર્તમાન પ્રોસેસર SSE 4.2 ને સપોર્ટ કરે છે કે કેમ તે તપાસવા માટે અહીં આદેશ છે:
સિંગલ-નોડ મોડ 1 શાર્ડ, 0 પ્રતિકૃતિ માટે સ્થિતિસ્થાપક શોધને ગોઠવી રહ્યું છે. મોટે ભાગે તમારી પાસે મોટી સંખ્યામાં સર્વર્સનું ક્લસ્ટર હશે અને તમારે આ કરવાની જરૂર નથી.
INFO vector::topology::builder: Healthcheck: Passed.
INFO vector::topology::builder: Healthcheck: Passed.
ક્લાયંટ (વેબ સર્વર) પર - 1 લી સર્વર
nginx સાથે સર્વર પર, તમારે ipv6 ને અક્ષમ કરવાની જરૂર છે, કારણ કે ક્લિકહાઉસમાં લોગ ટેબલ ફીલ્ડનો ઉપયોગ કરે છે upstream_addr IPv4, કારણ કે હું નેટવર્કની અંદર ipv6 નો ઉપયોગ કરતો નથી. જો ipv6 બંધ નથી, તો ત્યાં ભૂલો હશે:
DB::Exception: Invalid IPv4 value.: (while read the value of key upstream_addr)
પ્રથમ, આપણે Nginx માં લોગ ફોર્મેટને /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;
}
તમારા વર્તમાન રૂપરેખાંકનને ન તોડવા માટે, Nginx તમને ઘણા ઍક્સેસ_લોગ નિર્દેશો ધરાવવાની મંજૂરી આપે છે
access_log /var/log/nginx/access.log main; # Стандартный лог
access_log /var/log/nginx/access.json.log vector; # Новый лог в формате json
નવા લોગ માટે લોગરોટેટ કરવા માટે નિયમ ઉમેરવાનું ભૂલશો નહીં (જો લોગ ફાઈલ .log સાથે સમાપ્ત થતી નથી)
અને /etc/vector/vector.toml રૂપરેખામાં ફાઇલબીટ રિપ્લેસમેન્ટને ગોઠવો. IP સરનામું 172.26.10.108 એ લોગ સર્વરનું IP સરનામું છે (વેક્ટર-સર્વર)
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"
વેક્ટર વપરાશકર્તાને જરૂરી જૂથમાં ઉમેરવાનું ભૂલશો નહીં જેથી તે લોગ ફાઇલો વાંચી શકે. ઉદાહરણ તરીકે, centos માં nginx એ એડમ જૂથ અધિકારો સાથે લોગ બનાવે છે.
usermod -a -G adm vector
ચાલો વેક્ટર સેવા શરૂ કરીએ
systemctl enable vector
systemctl start vector
વેક્ટર લોગ આ રીતે જોઈ શકાય છે:
journalctl -f -u vector
લોગમાં આના જેવી એન્ટ્રી હોવી જોઈએ
INFO vector::topology::builder: Healthcheck: Passed.
તણાવ પરીક્ષણ
અપાચે બેન્ચમાર્કનો ઉપયોગ કરીને પરીક્ષણ હાથ ધરવામાં આવે છે.
httpd-tools પેકેજ બધા સર્વરો પર સ્થાપિત થયેલ હતું
અમે સ્ક્રીનમાં 4 અલગ-અલગ સર્વર પરથી Apache બેન્ચમાર્કનો ઉપયોગ કરીને પરીક્ષણ શરૂ કરીએ છીએ. પ્રથમ, અમે સ્ક્રીન ટર્મિનલ મલ્ટિપ્લેક્સર લોન્ચ કરીએ છીએ, અને પછી અમે અપાચે બેન્ચમાર્કનો ઉપયોગ કરીને પરીક્ષણ શરૂ કરીએ છીએ. તમે શોધી શકો છો તે સ્ક્રીન સાથે કેવી રીતે કામ કરવું લેખ.
1 લી સર્વરથી
while true; do ab -H "User-Agent: 1server" -c 100 -n 10 -t 10 http://vhost1/; sleep 1; done
2 લી સર્વરથી
while true; do ab -H "User-Agent: 2server" -c 100 -n 10 -t 10 http://vhost2/; sleep 1; done
3 લી સર્વરથી
while true; do ab -H "User-Agent: 3server" -c 100 -n 10 -t 10 http://vhost3/; sleep 1; done
4 લી સર્વરથી
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;
ચાલો જાણીએ કે ક્લિકહાઉસમાં કેટલા લોગ લેવામાં આવ્યા.
લોગ ટેબલનું કદ 857.19 MB છે.
Elasticsearch માં અનુક્રમણિકામાં સમાન ડેટાનું કદ 4,5GB છે.
જો તમે પેરામીટર્સમાં વેક્ટરમાં ડેટાનો ઉલ્લેખ કરતા નથી, તો ક્લિકહાઉસ 4500/857.19 = 5.24 ગણો ઇલાસ્ટિકસર્ચ કરતાં ઓછો લે છે.
વેક્ટરમાં, કમ્પ્રેશન ફીલ્ડનો ઉપયોગ મૂળભૂત રીતે થાય છે.