Skip to content

Instantly share code, notes, and snippets.

View dontstopbelieveing's full-sized avatar

dontstopbelieveing

View GitHub Profile
@dontstopbelieveing
dontstopbelieveing / gather_xx_.sh
Last active October 4, 2019 00:17
Collecting metrics
#Slave Lag
#!/usr/bin/bash
log_dir=/logs/
#Slave lag
mysql --login-path=mysqlconn -e "show slave status \G" | grep Seconds| awk '{ print $2 }' | while IFS= read -r line; do printf '%s\t%s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$line"; done | tee -a $log_dir/slave_lag
#Processlist
mysql --login-path=mysqlconn -e "show slave status \G" | grep Seconds| awk '{ print $2 }' | while IFS= read -r line; do printf '%s\t%s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$line"; done | tee -a $log_dir/slave_lag
#!/usr/bin/bash
#export PATH=$PATH:/x/home/mysql/product/mysql/bin/mysql
#mysql --login-path=mysqlconn --batch --skip-column-names -e "select * from information_schema.processlist where user not in ('root','repl','system user') and host like '10.72.12.201%'" | while IFS= read -r line; do printf '%s %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$line"; done | tee -a $log_dir/connection_metrics.log
mysql --login-path=mysqlconn --batch --skip-column-names -e "select now(),count(*) from information_schema.processlist where user not in ('root','repl','system user');" | tee -a /tmp/connection_metrics.log
select * from (SELECT a.manifest_label,a.cos,x.status FROM manifest_approval a, manifest_approval_history h, manifest_approval_action x where manifest_label in ('commercesetupnodeweb-1.2.0_20190924210218860', 'commercesetupnodeweb-1.2.0_20190925124406157', 'commercesetupnodeweb-1.1.3_2019092415463768', 'commercesetupnodeweb-1.1.3_20190924144432630', 'commercesetupnodeweb-1.1.3_20190923164432256', 'commercesetupnodeweb-1.1.3_20190923154136989', 'commercesetupnodeweb-1.1.3_20190922225234618', 'commercesetupnodeweb-1.1.3_20190922233835112', 'commercesetupnodeweb-1.1.2_20190922145056771', 'commercesetupnodeweb-1.1.2_20190921220059754', 'commercesetupnodeweb-1.1.2_20190920220652189', 'commercesetupnodeweb-1.1.2_20190918124024272', 'commercesetupnodeweb-1.1.2_20190917132435888', 'commercesetupnodeweb-1.1.2_20190916164942679', 'commercesetupnodeweb-1.1.2_20190916165027142', 'commercesetupnodeweb-1.1.2_20190916134019187', 'commercesetupnodeweb-1.1.1_2019091310434924', 'commercesetupnodeweb-1.1.1_2019091216405973', 'c
@dontstopbelieveing
dontstopbelieveing / orchestrator.conf.json
Created August 28, 2019 23:12
Orchestrator configuration file
{
"Debug": false,
"EnableSyslog": false,
"ListenAddress": ":3000",
"MySQLTopologyUser": "orc_client_user",
"MySQLTopologyPassword": "orc_client_password",
"MySQLTopologyCredentialsConfigFile": "/etc/orchestrator-topology.cnf",
"MySQLTopologySSLPrivateKeyFile": "",
"MySQLTopologySSLCertFile": "",
"MySQLTopologySSLCAFile": "",
@dontstopbelieveing
dontstopbelieveing / generatetsdata.py
Created December 19, 2018 19:31
Populating invoice table
#!/usr/bin/python
import random
from datetime import datetime
import MySQLdb as mysql
host =
user =
password =
db =
@dontstopbelieveing
dontstopbelieveing / sysbench-insert.lua
Created December 12, 2018 20:20
insert script for sysbench 1.0
./sysbench --test=tests/db/oltp.lua \
--mysql-host=$host \
--mysql-port=3306 \
--mysql-user=reinvent \
--mysql-password=reinvent \
--mysql-db=$db \
--mysql-table-engine=innodb \
--oltp-test-mode=complex \
--oltp-read-only=on \
--oltp-table-size=1000000 \
@dontstopbelieveing
dontstopbelieveing / BufferPool.sql
Last active December 11, 2018 17:26
MySQL Helpful Queries
-- In absence of sys schema
SELECT table_name,
ROUND(SUM(IF(compressed_size = 0, 16384, compressed_size)) / 1073741824, 2) AS allocated_GB,
ROUND(SUM(data_size) / 1073741824, 2) AS data_GB,
COUNT(page_number) AS pages,
COUNT(IF(is_hashed = 'YES', 1, NULL)) AS pages_hashed,
COUNT(IF(is_old = 'YES', 1, NULL)) AS pages_old,
ROUND(SUM(number_records)/COUNT(DISTINCT index_name)) AS rows_cached
FROM information_schema.innodb_buffer_page
WHERE table_name = "`db_name`.`table_name`"
@dontstopbelieveing
dontstopbelieveing / online_store.sql
Last active May 22, 2023 15:04
Using JSON with MySQL 5.7–compatible Amazon Aurora
--Creating the database
DROP DATABASE online_store;
CREATE DATABASE online_store;
--Creating supporting tables
USE online_store;
CREATE TABLE brands (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL
);