You are here: Home / Debian GNU/Linux / Servers / MySQL / Install Pinba MySQL engine on Debian

Install Pinba MySQL engine on Debian

by Pierre-Yves Landuré last modified Jan 12, 2019 06:47

Pinba is a MySQL engine engineered to collect statistical data. Its main usage is to collect performance informations on PHP applications.

This howto is tested on :

  • Debian 7.0 Wheezy

Prerequisites

This howto needs :

This howto recommends :

Installation

Environment preparation

Install the needed software :

command apt-get install build-essential protobuf-compiler libmysqlclient-dev \
libjudydebian1 libevent-dev libjudy-dev git libevent-2.0-5 libtool \
libevent-core-2.0-5 libevent-extra-2.0-5 libevent-openssl-2.0-5 \
libevent-pthreads-2.0-5 libprotobuf-dev libprotobuf-lite7 libprotobuf7

Software installation

Download the sources :

command git clone 'https://github.com/tony2001/pinba_engine' '/tmp/pinba_engine'

Fetch the MySQL sources :

command pushd '/tmp'
command apt-get source mysql-server
command popd
MYSQL_SOURCES="$(command find '/tmp' -maxdepth 1 -type d -name 'mysql-*')"
command cp '/usr/include/mysql/mysql_version.h' "${MYSQL_SOURCES}/include"
command cp '/usr/include/mysql/my_config.h' "${MYSQL_SOURCES}/include"

Detect installed MySQL configuration options :

OPTIONS="$(VISUAL="$(command which 'cat')" command mysqlbug \
| command grep 'Configured with' \
| command sed -e 's/.*configure -v //')"

Go to the sources folder :

command pushd '/tmp/pinba_engine'

Generate the configuration script :

./buildconf.sh

Configure the sources :

command bash -c "./configure ${OPTIONS} \
--with-mysql='${MYSQL_SOURCES}' \
--with-judy \
--with-protobuf \
--with-event \
--libdir='/usr/lib/mysql/plugin/'"

Build the software :

command make

Install the software :

command make install

Exit the sources folder :

command popd

Enabling the engine

Setup the MySQL server to use Pinba engine :

command mysql --execute="INSTALL PLUGIN pinba SONAME 'libpinba_engine.so';" --user=root

Create a database for Pinba :

command mysql --execute="CREATE DATABASE pinba DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci;" --user=root

Initialize the database contents :

command mysql --user=root 'pinba' < '/tmp/pinba_engine/default_tables.sql'

Delete the sources :

command rm -r '/tmp/pinba_engine' "${MYSQL_SOURCES}"

Engine configuration

Create the configuration file for the Pinba engine :

command wget 'https://raw.github.com/biapy/howto.biapy.com/master/mysql/pinba.cnf' \
  --quiet --no-check-certificate --output-document='/etc/mysql/conf.d/pinba.cnf'
/etc/init.d/mysql restart

You can adjust the Pinba setup to your needs by editing 'pinba.cnf' file. The MySQL server needs a restart after each change:

command vim '/etc/mysql/conf.d/pinba.cnf'

If the PHP server providing Pinba the statistical data is on another host than the MySQL server, open Pinba port on the local network (dangerous, make sure be behing a firewall):

# command sed -i \
    -e 's/^pinba_address/#pinba_address/' \
  '/etc/mysql/conf.d/pinba.cnf'
/etc/init.d/mysql restart

Thanks