Sar-sql Wiki

Wiki page tracking and documenting work on the sar-sql script. Please consider it as a work in progress or very rough draft.

Step by Step Installation

You will need to have root like privileges in the database server in order to complete these tasks.

  1. Create sarsql user with the following commands. Replace user, localhost, the database name and the password has value to fit your particular installation requirements. If your taking snapshots from a server set as _read only_ you will need to add SUPER to the 1st GRANT statement.

GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'user'@'localhost' IDENTIFIED BY PASSWORD '*0000000000000000000000';
GRANT ALL PRIVILEGES ON `sarsql`.* TO 'user'@'localhost';
  1. Create the sarsql schema in the database:

  1. Create a secure configuration file with the user credentials (in Linux: 0600) :

cat .sarsql.conf

# User credentials
  1. Create a wrapper script to define parameters, log file and command invocation. You may use the example below adjusting the directories to match your server:

# Wrapper to run sar-sql for a master and slave

# Default dir

# Pickup variables
RUSER=`grep user $RDIR/.sarsql.conf | cut -d "=" -f 2`
RPWD=`grep password $RDIR/.sarsql.conf | cut -d "=" -f 2`
RSNAPSHOT='--status --process --slave --master'
CMDLINE="$RSNAPSHOT --user $RUSER --pass $RPWD --database sarsql"

# echo "./ $CMDLINE" >> ../log/sarsql.log 2>&1
# exit 1

# Execute the command
cd $RDIR
PATH=$SARDIR:$PATH $CMDLINE >> sarsql.log 2>&1
# $CMDLINE 2>&1 | tee sarsql.log
  1. Run the wrapper at least once to initialize the tables and/or test the parameters
  2. Schedule the wrapper in cron. Use crontab or my favorite: add a file to /etc/cron.d/ with the proper entry as shown below. Make sure you change it to match your environment:

cat mysql_sarsql

# Take mysql status snapshots every 5min
*/5 * * * * mysql /opt/sarsql/

sarsql (last edited 2010-01-08 23:48:32 by gnarvaja)