Skip to content

Instantly share code, notes, and snippets.

View sennajox's full-sized avatar

Sennajox sennajox

  • Shanghai, China
View GitHub Profile
@sennajox
sennajox / run_fio.sh
Last active December 21, 2023 11:00
A script that runs fio test and genearates a simple result for each jobs
#!/bin/bash
if [ $# -lt 2 ]; then
echo "usage:$0 dev output_dir [iodepth]"
echo "example 1: Testing the whole block device. Attention: That will destory the filesystem on the target block device"
echo "./run_fio.sh /dev/sdb fio_test"
echo ""
echo "example 2: Testing a file, but not destory filesystem. Suppose the target device mount on /data"
echo "fallocate -l 1G /data/test.dat"
echo "./run_fio.sh /data/test.dat fio_test"
@sennajox
sennajox / Methods of disk io performance testing
Last active March 5, 2023 11:38
Methods of disk io performance testing
测试磁盘IO性能的几种方法
在磁盘测试中最关心的几个指标分别为:iops(每秒执行的IO次数)、bw(带宽,每秒的吞吐量)、lat(每次IO操作的延迟)。
当每次IO操作的block较小时,如512bytes/4k/8k等,测试的主要是iops。
当每次IO操作的block较大时,如256k/512k/1M等,测试的主要是bw。
1. 最简单的dd
dd是linux自带的磁盘读写工具,可用于测试顺序读写。
一般而言,磁盘读写有两种方式:BufferIO、DirectIO,DirectIO可以更好的了解纯磁盘读写的性能。
1.1 dd测试DirectIO
1. raid
1.1 查看物理卷信息
/opt/MegaRAID/MegaCli/MegaCli64 -pdlist -aall
1.2 查看逻辑卷+物理卷
/opt/MegaRAID/MegaCli/MegaCli64 -ldpdinfo -aall
1.2.1 查看逻辑卷
/opt/MegaRAID/MegaCli/MegaCli64 -ldinfo -lall -aall
@sennajox
sennajox / tbdba-restore-mysqldump.pl
Created November 7, 2013 14:10
A copy of tbdba-restore-mysqldump.pl
#!/usr/bin/perl
# First written by orczhou.com orchzou@gmail.com
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 2 of the License.
# How faster it is:
# $ls -lh backup.sql.gz
# -rw-r--r-- 1 mysql dba 14G Nov 21 04:49 backup.sql.gz
@sennajox
sennajox / sector2file.sh
Last active September 17, 2019 01:52
find the file by sector in filesystem
#!/bin/bash
# sector_list sample as below:
# 0
# 512
# 4087578
# 4087579
# 6324224
#
# You should build a sector_list firstly, and then execute this script to catch the files
@sennajox
sennajox / scan_port.sh
Created August 19, 2014 06:29
Scan port with nmap, use 11211(memcached) and 6379(redis) as example
#!/bin/bash
if [ $# -lt 1 ];then
echo "usage:$0 iplist"
exit 1
fi
iplist=$1
i=0
@sennajox
sennajox / slow_log_dump.py
Last active October 12, 2017 05:59
Convert the slowlog from table into logfile
#!/usr/bin/env python2
"""
Queries the slowlog database table and outputs it in
the normal MySQL slow log text format.
Run this script by:
python /path/to/slow_log_dump.py dbip dbport dbusr dbpwd [start_time] [end_time] > /path/to/slow_log_dump.log
Then you can run the normal mysqldumpslow parser on the output file (slow_log_dump.log)
@sennajox
sennajox / roll.py
Created December 19, 2016 03:27
roll
#!/usr/bin/env python2
# coding=utf8
import sys, os
import random
import time
if __name__ == "__main__":
curtime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
@sennajox
sennajox / run_sysbench.sh
Last active June 2, 2016 03:12
A simple script for testing mysql with sysbench
#!/bin/bash
if [ $# -lt 2 ]; then
echo "usage:$0 test_name {prepare|run|cleanup|gen}"
exit 1
fi
test_name="$1"
cmd="$2"
@sennajox
sennajox / straceall.sh
Created October 22, 2013 18:09
A simple script to strace a group of processes
#!/bin/bash
if [ $# -lt 1 ];then
echo "usage:$0 process_name"
exit 1
fi
process_name="$1"
function straceall()