https://www.percona.com/blog/2016/05/03/best-practices-for-configuring-optimal-mysql-memory-usage/
2022 m. vasario 15 d., antradienis
mysql memory calculator
#!/bin/sh# you might want to add some user authentication here
mysql -e "show variables; show status" | awk ' { VAR[$1]=$2 } END { MAX_CONN = VAR["max_connections"] MAX_USED_CONN = VAR["Max_used_connections"] BASE_MEM=VAR["key_buffer_size"] + VAR["query_cache_size"] + VAR["innodb_buffer_pool_size"] + VAR["innodb_additional_mem_pool_size"] + VAR["innodb_log_buffer_size"] MEM_PER_CONN=VAR["read_buffer_size"] + VAR["read_rnd_buffer_size"] + VAR["sort_buffer_size"] + VAR["join_buffer_size"] + VAR["binlog_cache_size"] + VAR["thread_stack"] + VAR["tmp_table_size"] MEM_TOTAL_MIN=BASE_MEM + MEM_PER_CONN*MAX_USED_CONN MEM_TOTAL_MAX=BASE_MEM + MEM_PER_CONN*MAX_CONN printf "+------------------------------------------+--------------------+\n" printf "| %40s | %15.3f MB |\n", "key_buffer_size", VAR["key_buffer_size"]/1048576 printf "| %40s | %15.3f MB |\n", "query_cache_size", VAR["query_cache_size"]/1048576 printf "| %40s | %15.3f MB |\n", "innodb_buffer_pool_size", VAR["innodb_buffer_pool_size"]/1048576 printf "| %40s | %15.3f MB |\n", "innodb_additional_mem_pool_size", VAR["innodb_additional_mem_pool_size"]/1048576 printf "| %40s | %15.3f MB |\n", "innodb_log_buffer_size", VAR["innodb_log_buffer_size"]/1048576 printf "+------------------------------------------+--------------------+\n" printf "| %40s | %15.3f MB |\n", "BASE MEMORY", BASE_MEM/1048576 printf "+------------------------------------------+--------------------+\n" printf "| %40s | %15.3f MB |\n", "sort_buffer_size", VAR["sort_buffer_size"]/1048576 printf "| %40s | %15.3f MB |\n", "read_buffer_size", VAR["read_buffer_size"]/1048576 printf "| %40s | %15.3f MB |\n", "read_rnd_buffer_size", VAR["read_rnd_buffer_size"]/1048576 printf "| %40s | %15.3f MB |\n", "join_buffer_size", VAR["join_buffer_size"]/1048576 printf "| %40s | %15.3f MB |\n", "thread_stack", VAR["thread_stack"]/1048576 printf "| %40s | %15.3f MB |\n", "binlog_cache_size", VAR["binlog_cache_size"]/1048576 printf "| %40s | %15.3f MB |\n", "tmp_table_size", VAR["tmp_table_size"]/1048576 printf "+------------------------------------------+--------------------+\n" printf "| %40s | %15.3f MB |\n", "MEMORY PER CONNECTION", MEM_PER_CONN/1048576 printf "+------------------------------------------+--------------------+\n" printf "| %40s | %18d |\n", "Max_used_connections", MAX_USED_CONN printf "| %40s | %18d |\n", "max_connections", MAX_CONN printf "+------------------------------------------+--------------------+\n" printf "| %40s | %15.3f MB |\n", "TOTAL (MIN)", MEM_TOTAL_MIN/1048576 printf "| %40s | %15.3f MB |\n", "TOTAL (MAX)", MEM_TOTAL_MAX/1048576 printf "+------------------------------------------+--------------------+\n" }'
2021 m. gruodžio 22 d., trečiadienis
mysql dump import pagreitintuvas
#!/bin/bash
DATA="/db.sql.gz"
SIZE="$(du $DATA | awk '{ print $1 }')K"
DBNAME="test"
DBPASS="Apasdasdasdfnti"
DBUSER="root"
{
#echo "Dropping/creating database ${DBNAME}" >&2
#echo "DROP DATABASE IF EXISTS ${DBNAME};"
#echo "CREATE DATABASE ${DBNAME};"
echo "use ${DBNAME};"
echo "Setting speed settings" >&2
echo "SET FOREIGN_KEY_CHECKS = 0;"
echo "SET UNIQUE_CHECKS = 0;"
echo "SET AUTOCOMMIT = 0;"
echo "Loading data (this will take a while)" >&2
cat $DATA | gzip -d
echo "Resetting speed settings" >&2
echo "SET FOREIGN_KEY_CHECKS = 1;"
echo "SET UNIQUE_CHECKS = 1;"
echo "COMMIT;"
echo "Done." >&2
} | pv -ps $SIZE | mysql --password=$DBPASS --user=$DBUSER
#paprastas 1 eilutes pvz
# pv /home/dnsb/dbtest.sql.gz | gunzip | mysql --password=Apdasdadti --user=root dbname
# pv dump.sql.gz | zcat | mysql -u user -ppasswd database
#nblogask itas pvz https://github.com/servercollective/import-large-mysql-dump/blob/master/import.sh
#ddl="$ddl set global net_buffer_length=1000000; "
#ddl="$ddl set global max_allowed_packet=1000000000; "
2021 m. liepos 20 d., antradienis
Asmens kodų regex pagal ES šalis
https://ipsec.pl/european-personal-data-regexp-patterns.html
LT pvz: [3-6][0-9]{2}[0,1][0-9][0-9]{2}[0-9]{4}
patikslintas: [3-6][0-9]{2}(1[0-2]|0[1-9])[0-3][0-9][0-9]{4}
(šaltinis):
[^0-9] [0-5][0-9]{2} (1[0-2]|0[1-9]) [0-3][0-9] [0-9]{4}...
2021 m. liepos 1 d., ketvirtadienis
inode usage paieskos
greitas top direktoriju radikjlis, randantis net giliai esancias direkmtorijas
{ find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n; } 2>/dev/null
vienos direktorijos inode counteris:
find . -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn
greitas trynimas senesniu nei 20d failu
find /opt/remi/php54/root/var/lib/php/session/ -atime +20 | xargs -r rm
2020 m. spalio 8 d., ketvirtadienis
php and web sockets
http://socketo.me/ igalina paleisti php serveri klausanti kakzoki tai porta, kad galetume apdoroti websocket susijungimus, uzklausas