Skip to content

Instantly share code, notes, and snippets.

@alastori
Created May 13, 2016 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alastori/551ff337836e225ccf763d590cda1d33 to your computer and use it in GitHub Desktop.
Save alastori/551ff337836e225ccf763d590cda1d33 to your computer and use it in GitHub Desktop.
Bash script to install MySQL Enterprise Monitor Agent 3.x in Enterprise Linux 7.x
#!/bin/bash
#Bash script to install MySQL Enterprise Monitor Agent 3.x in Enterprise Linux 7.x
#Copy the MEM Agent executable binary (mysqlmonitoragent*.bin) into the $PACKAGES_DIR and run this script as root
#You can find the binaries in http://support.oracle.com (preferable) or http://edelivery.oracle.com
#Modify these variables as you wish
DIR_TO_INSTALL=/home/vagrant/mysql/enterprise/agent #/opt/mysql/enterprise/agent
PACKAGES_DIR=/home/vagrant/packages #This folder already contains the Executable Binaries
MEM_SERVICE_HOST=vmmysqltools
MEM_SERVICE_PORT=18443
MEM_AGENT_USR=agent
MEM_AGENT_PWD=agent
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306
MYSQL_ROOT_USR=root
MYSQL_ROOT_PWD=Root#123
MEM_LIMITED_USR=memlimited
MEM_LIMITED_PWD=Limited#123
MEM_GENERAL_USR=memgeneral
MEM_GENERAL_PWD=General#123
set -e # stop script execution on any error
#Next lines install MEM Agent
echo "Installing MySQL Enterprise Monitor Agent from $PACKAGES_DIR..."
MEM_AGENT_INSTALLER=$(ls -d $PACKAGES_DIR/mysqlmonitoragent-3* | head -1)
cd $PACKAGES_DIR
$MEM_AGENT_INSTALLER --mode unattended \
--installdir $DIR_TO_INSTALL \
--managerhost $MEM_SERVICE_HOST --managerport $MEM_SERVICE_PORT \
--checkmysqlhost yes --mysql-identity-source default \
--agentuser $MEM_AGENT_USR --agentpassword $MEM_AGENT_PWD \
--mysqlhost $MYSQL_HOST --mysqlport $MYSQL_PORT \
--mysqluser $MYSQL_ROOT_USR --mysqlpassword $MYSQL_ROOT_PWD \
--agent_autocreate yes \
--limiteduser $MEM_LIMITED_USR --limitedpassword $MEM_LIMITED_PWD \
--generaluser $MEM_GENERAL_USR --generalpassword $MEM_GENERAL_PWD
echo "MEM Agent installed."
cat $DIR_TO_INSTALL/install.log | grep "exit code"
echo "Starting MySQL Agent..."
#should also be available in /etc/init.d
$DIR_TO_INSTALL/etc/init.d/mysql-monitor-agent start
tail $DIR_TO_INSTALL/logs/mysql-monitor-agent.log
$DIR_TO_INSTALL/etc/init.d/mysql-monitor-agent status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment