sysbench scripts (6)
来源:互联网 发布:搜索优化翻译 编辑:程序博客网 时间:2024/06/07 03:09
衔接上文,以下是test文件夹下的脚本。
6、server_op.sh脚本
#! /bin/sh############################################################ Copyright (c) 2012, Heng.Wang. All rights reserved.## This program is benifit for sysbench oltp test.############################################################ set -x# Get the key value of input arguments format like '--args=value'.get_key_value(){ echo "$1" | sed 's/^--[a-zA-Z_-]*=//' }# Usage will be helpful when you need to input the valid arguments.usage(){cat <<EOFUsage: $0 [configure-options] -?, --help Show this help message. --mysqldir=<> Set the mysql directory --defaults-file=<> Set the configure file for mysql --host=<> Set the host name. --port=<> Set the port number. --user=<> Set the user name. --password=<> Set the password. --socket=<> Set the socket file. -s,--start Start the mysql server. -d,--shutdown Shutdown the mysql server. Note: this script is intended for internal use by developers.EOF}# Print the default value of the arguments of the script.print_default(){cat <<EOF The default value of the variables: mysqldir $MYSQLDIR defaults-file $CONFIG host $HOST port $PORT user $USER password $PASSWORD socket $SOCKET start FALSE shutdown FALSE EOF}# Parse the input arguments and get the value of the input argument.parse_options(){ while test $# -gt 0 do case "$1" in --mysqldir=*) MYSQLDIR=`get_key_value "$1"`;; --defaults-file=*) CONFIG=`get_key_value "$1"`;; --host=*) HOST=`get_key_value "$1"`;; --port=*) PORT=`get_key_value "$1"`;; --user=*) USER=`get_key_value "$1"`;; --password=*) PASSWORD=`get_key_value "$1"`;; --socket=*) SOCKET=`get_key_value "$1"`;; -s | --start) START=1;; -d | --shutdown) SHUTDOWN=1;; -? | --help) usage print_default exit 0;; *) echo "Unknown option '$1'" exit 1;; esac shift done}#Shutdown the mysql server after the sysbench test.shutdown_mysqld(){ cd $MYSQLDIR ./bin/mysqladmin --host=$HOST --port=$PORT --user=$USER --password=$PASSWORD --socket=$SOCKET shutdown > /dev/null if [ $? -ne 0 ] then echo "Exit with error when shutdown the mysql server procedure!" exit -1 fi sleep 10}#Start the mysql server if the server is not running.start_mysqld(){ cd $MYSQLDIR ./bin/mysqladmin --host=$HOST --port=$PORT --user=$USER --password=$PASSWORD --socket=$SOCKET status > /dev/null if [ $? -ne 0 ] then ./bin/mysqld_safe --defaults-file=$CONFIG > /dev/null & if [ $? -ne 0 ] then echo "Exit with error when start the mysql server procedure!" exit -1 fi sleep 30 fi}############################################################## Define the variables the script used for executing.MYSQLDIR=/opt/Percona-ServerCONFIG=/opt/Percona-Server/etc/my.cnfHOST=localhostPORT=3306USER=rootPASSWORD=SOCKET=/tmp/mysql.sockSTART=0SHUTDOWN=0# Call the parse_options function to parse the input arguments.parse_options "$@"if [ $START -eq 0 ] && [ $SHUTDOWN -eq 0 ]then echo "Please be ensure you operation for mysql server." exit 1fiif [ $START -eq 1 ]then #Start the mysql server start_mysqld echo "The server is successfully started!"fi if [ $SHUTDOWN -eq 1 ]then #Shutdown the mysql server shutdown_mysqld echo "The server is successfully shutdown!"fiexit 0
- sysbench scripts (6)
- Sysbench scripts使用说明文档
- Sysbench scripts源码分析
- sysbench scripts (1)
- sysbench scripts (2)
- sysbench scripts (3)
- sysbench scripts (4)
- sysbench scripts (5)
- sysbench scripts (7)
- sysbench scripts (8)
- sysbench scripts (9)
- sysbench scripts (10)
- sysbench scripts (11)
- sysbench scripts (12)
- sysbench scripts (13)
- sysbench scripts (14)
- sysbench scripts (15)
- sysbench
- sysbench scripts (5)
- EMV 的交易流程
- Java获得客户端IP的方法
- sprintf函数的用法
- jQuery 动态内容添,获取HTML标签和属性
- sysbench scripts (6)
- SQL Server 2008 变量叠加必须初始化
- 【已解决】可执行程序无法在Linux上运行,显示line 1: syntax error: word unexpected (expecting ")
- sysbench scripts (7)
- free
- 中文编码杂谈
- sysbench scripts (8)
- 使用ibatis抛出java.lang.IllegalArgumentException实则抛出:NestedSQLException异常
- sysbench scripts (9)