sysbench压测
#!/bin/bash export HOST1=10.111.37.198 export HOST2=10.111.36.163 export PORT=3306 export USER=lr export PASSWORD=LIUrong123@ export SYSBENCH=/usr/share/sysbench/bin/sysbench export LUA=/usr/share/sysbench/share/sysbench/oltp_read_write.lua export THREADS=128 export TABLE_SIZE=100000 export TABLE_NUM=100 export TIME=3600 function get_master() { export out=$(mysql -h$HOST1 -P$PORT -u$USER -p$PASSWORD -e 'show slave statusG;') if [[ -z $out ]]; then MASTER_IP=$HOST1 else MASTER_IP=$HOST2 fi echo $MASTER_IP } function sysbench_init() { $SYSBENCH --threads=$THREADS --time=$TIME --events=999999999 --test=$LUA --table_size=$TABLE_SIZE --tables=$TABLE_NUM --db-driver=mysql --mysql_storage_engine=innodb --mysql-host=$MASTER_IP --mysql-port=$PORT --mysql-user=$USER --mysql-password=$PASSWORD prepare } function sysbench_run() { $SYSBENCH --threads=$THREADS --time=$TIME --events=999999999 --test=$LUA --table_size=$TABLE_SIZE --tables=$TABLE_NUM --db-driver=mysql --mysql_storage_engine=innodb --mysql-host=$MASTER_IP --mysql-port=$PORT --mysql-user=$USER --mysql-password=$PASSWORD run } function sysbench_clean() { $SYSBENCH --threads=$THREADS --time=$TIME --events=999999999 --test=$LUA --table_size=$TABLE_SIZE --tables=$TABLE_NUM --db-driver=mysql --mysql_storage_engine=innodb --mysql-host=$MASTER_IP --mysql-port=$PORT --mysql-user=$USER --mysql-password=$PASSWORD cleanup } get_master sysbench_init sysbench_run #sysbench_clean