Rate This Document
Findability
Accuracy
Completeness
Readability

Preparing a Run Script

The GCC FDO component uses a run script to start optimized applications. Therefore, a run script needs to be prepared. The run script contains the startup and test commands.

Its contents depend on the actual environment. For example, in the sysbench and TPC-C tests, the run script must contain the following contents:

  • Commands for starting MySQL
  • Commands for starting the test
  • Custom test execution duration (The recommended execution duration for a sysbench or TPC-C test is 5 to 10 minutes.)

Preparing a Run Script

The following uses the BenchmarkSQL test tool as an example to describe how to create a run script. For details about how to use BenchmarkSQL, see BenchmarkSQL Test Guide.

  1. Optional: Install MySQL by referring to MySQL Porting Guide. If MySQL has been installed, skip this step.
  2. Optional: Load test data by referring to BenchmarkSQL Test Guide. If the database contains the BenchmarkSQL test data, skip this step.

    Steps 1 and 2 are performed to initiate the MySQL data directory, set up a user account, and prepare the BenchmarkSQL test data. The run.sh script can then directly perform the TPC-C test. If you have both the data directory and BenchmarkSQL test data ready, skip steps 1 and 2.

  3. Create a run script file.
    1
    vi /root/run.sh
    
  4. Press i to enter the insert mode and add the following contents to the file:
    1
    2
    3
    4
    pkill mysqld
    /usr/local/mysql-gcc/bin/mysqld --defaults-file=/etc/my.cnf &  # This command is used to start MySQL. /usr/local/mysql-gcc is the MySQL installation path in the MySQL run script. Change the path to the actual one.
    sleep 60 # Wait until the MySQL startup is complete. The waiting time depends on the actual environment.
    cd /home/benchmarksql5.0-for-mysql/run && bash runBenchmark.sh my_mysql.properties  # This is the TPC-C test command. To remotely run this command, you can configure password-free login and run this command through SSH.
    
  5. Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.

(Optional) Configuring Password-free Login to a Remote Server Through SSH

  1. Run the following command on the local server to generate a public key and a private key:

    The system will ask you where to store the generated key pair. Press Enter to use the default directory. If the system prompts you to enter a passphrase, press Enter to use the default value.

    1
    ssh-keygen
    

  2. Ensure that a key pair has been generated in the specified directory.
    1
    ll /root/.ssh/
    

  3. Run the following command to add the contents of the id_rsa.pub public key on the local host to the /root/.ssh/authorized_keys file on the remote server. In this example, the IP address of the remote server is 192.168.53.222. When the system prompts you to enter the password of the root user on the server, enter the password and press Enter.
    1
    ssh-copy-id root@192.168.53.222
    

  4. Run the test command remotely through SSH.
    1
    ssh root@192.168.53.222 "cd benchmarksql-5.0/run && bash runBenchmark.sh my_mysql.properties"
    

Changing the Test Duration

This section describes how to change the test duration in the my_mysql.properties file to 10 minutes. Set the test duration based on the actual requirements.

  1. Open the my_mysql.properties configuration file.
    1
    vi my_mysql.properties
    
  2. Press i to enter the insert mode and change the test duration in the my_mysql.properties file to 10 minutes, that is, change the value of runMins to 10.
    1
    runMins=10
    
  3. Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.