Skip to content

Instantly share code, notes, and snippets.

@dungmanh88
dungmanh88 / Backup and restore using percona xtrabackup
Created October 4, 2016 16:03
Backup and restore using percona xtrabackup
Backup myisam db:
innobackupex --user=root--password=<passwd> --host=127.0.0.1 --parallel=4 --lock-wait-timeout=180 --lock-wait-threshold=20 --lock-wait-query-type=all --kill-long-queries-timeout=20 --kill-long-query-type=all /data/backup
Backup innodb db:
innobackupex --user=root--password=<passwd> --host=127.0.0.1 --parallel=4 /data/backup
Backup galera:
innobackupex --user=root--password=<passwd> --host=127.0.0.1 --galera-info --parallel=4 /data/backup
Restore:
@dungmanh88
dungmanh88 / Search Gist of an account
Created October 3, 2016 09:17
Search Gist of an account
In search box:
user:username keyword
@dungmanh88
dungmanh88 / Debug docker
Created October 3, 2016 04:01
Debug docker
journalctl -u docker.service | less
systemctl status docker.service -l
docker inspect <container-name>
docker logs -f <container-name>
docker inspect <image-name>
docker history <image-name>
docker network inspect <network-name>
@dungmanh88
dungmanh88 / backup_collection_mongo.sh
Last active January 22, 2024 07:42
Dump multiple collections of a db in mongodb
#!/bin/bash
db=<db>
collection_list="<collection1> <collection2> <collection3>"
host=127.0.0.1
port=<port>
out_prefix=/Temp
for collection in $collection_list; do
echo $collection
out_dir="${out_prefix}/${db}_${collection}/"
@dungmanh88
dungmanh88 / Use chronyd as date time server
Last active October 2, 2016 13:27
Use chronyd as date time server
For chrony client:
yum install chrony
vi /etc/chrony.conf
server NTP_SERVER iburst
systemctl enable chronyd.service
systemctl start chronyd.service
For chrony server:
yum install chrony
@dungmanh88
dungmanh88 / Change hostname on Centos 7
Created October 1, 2016 17:06
Change hostname on Centos 7
hostname <new-hostname>
echo "<new-hostname>" > /etc/hostname
replace old-hostname by new-hostname in /etc/hosts
@dungmanh88
dungmanh88 / Use rdesktop to remote desktop
Created October 1, 2016 15:43
Use rdesktop to remote desktop
rdesktop -u <username> -p"<password>" <ip> -g 90%
@dungmanh88
dungmanh88 / Statistic about data size of all table in a database
Created October 1, 2016 15:37
Statistic about data size of all table in a database
SELECT table_schema as `Database`, table_name AS `Table`, round(((data_length + index_length) / 1024 / 1024), 2) as mb FROM information_schema.TABLES order by mb asc;
@dungmanh88
dungmanh88 / Statistic about data size of all databases
Created October 1, 2016 15:36
Statistic about data size of all databases
select table_schema "DB Name", Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" from information_schema.tables group by table_schema;
@dungmanh88
dungmanh88 / Check if DB has engine MyISAM
Created October 1, 2016 15:35
Check if DB has engine MyISAM
select table_schema, table_name, engine from information_schema.tables where engine != 'InnoDB' and table_schema not in ('mysql', 'performance_schema', 'information_schema');