Skip to content

Instantly share code, notes, and snippets.

View v0112358's full-sized avatar

Nguyen Tan Vy v0112358

  • Freelancer
  • Vietnam
View GitHub Profile
@v0112358
v0112358 / mysql-need-to-monitor-metrics
Created December 28, 2018 03:11
MySQL need to monitor metrics
Numbers & types of operations (selects, updates, inserts, rollbacks, etc)
Cache hit rates and sizing recommendations
Query response times
Table scans and index usage
Temporary disk tables
Abnormal connection events
Replication status
@v0112358
v0112358 / s3fs-viettel-cloudstorage.md
Created January 3, 2019 02:23
S3FS + Bizcloud Simple storage + Viettel CloudStorage
  • Bizcloud simple storage
s3fs cdn_simple /bizfly -o use_cache=/tmp/ -o parallel_count=25 -o passwd_file=/root/.passwd-bizfly -o sigv2 -o url=https://ss-hn-1.vccloud.vn
  • Viettel Cloudstorage
s3fs cdn_simple /viettel -o sigv2 -o use_path_request_style -o use_cache=/tmp/ -o parallel_count=25 -o passwd_file=/root/.passwd-viettel -o url=http://s1.cloudstorage.com.vn
@v0112358
v0112358 / remove nf_contrack
Created March 24, 2019 14:07
Remove nf_contrack
rmmod iptable_nat
rmmod nf_nat_ipv4
rmmod nf_nat
rmmod nf_conntrack_ipv4
rmmod nf_conntrack
@v0112358
v0112358 / change_mysql_relay_bin_log_directory.md
Created July 4, 2019 14:55
change_mysql_relay_bin_log_directory.md
  • Change the relay_log variable in the my.cnf to relay_log = /mnt/relay/mysql_relay_bin

  • Stop mysqld

systemctl stop mysqld
  • Move all relay_log to new location:
@v0112358
v0112358 / Install odyssey on CentOS 7.md
Last active January 2, 2020 14:23
Install odyssey on CentOS 7

Odssey

Advanced multi-threaded PostgreSQL connection pooler and request router.

How to build odyssey on CentOS 7

yum install git cmake postgresql11-devel openssl-devel zlib-devel gcc -y
PATH=$PATH:/usr/pgsql-11/bin/
export PATH
LD_LIBRARY_PATH=/usr/pgsql-11/lib/
@v0112358
v0112358 / Ask yourself as an DBA
Created February 6, 2020 08:39
Ask yourself as an DBA
- How many transaction does the database handle per table, per hour?
- Which table has the most inserts?
- Do we delete data from this table?
- Which hour has the highest peak of updates, and on which tables?

1/ On master

CREATE TABLE event_store (
id bigint DEFAULT nextval('public.eid_seq_1'::regclass) NOT NULL,
topic character varying(255),
created_at timestamp(6) without time zone DEFAULT now()
) PARTITION BY RANGE (created_at);
@v0112358
v0112358 / useful-mysql-queries.md
Created March 25, 2020 14:26
useful mysql queries

1/ Check index size

SELECT concat(table_schema,'.',table_name) tables,
concat(round(table_rows/1000000,2),'M') rows,
concat(round(data_length/(1024*1024*1024),2),'G') data_size,
concat(round(index_length/(1024*1024*1024),2),'G') index_size,
concat(round((data_length+index_length)/(1024*1024*1024),2),'G') total_size,
round(index_length/data_length,2) index_data_ratio
FROM information_schema.TABLES
WHERE table_name like "%PRIVILEGES%"
@v0112358
v0112358 / switchover primary-secondary MongoDB with minimal downtime.md
Last active April 1, 2020 14:39
switchover primary-secondary MongoDB with minimal downtime

MongoDB with replica sets before switchover:

mongodb-01: {role: primary, priority: 9, hidden: 0}
mongodb-02: {role: secondary, priority: 1, hidden: 0}
mongodb-03: {role: secondary, priority: 1, hidden: 0}
mongodb-04: {role: secondary, priority: 7, hidden: 0}
mongodb-05: {role: secondary, priority: 1, hidden: 0}

MongoDB with replica sets after switchover:

@v0112358
v0112358 / Upgrade-plugin-for-provider-digitalocean.md
Created May 6, 2020 03:22
Upgrade terraform provider to use digitalocean_vpc resource

The error message:

Error: Invalid resource type

  on vpc-prod-cicd-k8s.tf line 1, in resource "digitalocean_vpc" "vpc_prod_cicd_k8s":
   1: resource "digitalocean_vpc" "vpc_prod_cicd_k8s" {

The provider provider.digitalocean does not support resource type
"digitalocean_vpc".