October 20, 2017

How to Install Percona Server with XtraDB on FreeBSD

Percona Logo

With Percona Server you can replace your existing MySQL with a much faster and more consistently relational database management system. Percona XtraDB is an enhanced version of the InnoDB storage engine, designed to better scale on modern hardware, and including a variety of other features useful in high performance environments. It is fully backwards compatible, and so can be used as a replacement for standard InnoDB. This combination offers breakthrough performance, scalability and features such as self-tuning algorithms for extremely high-performance hardware. The storage engine is licensed under GPLv2, and it is absolutely free to use.

Root access is required to edit the following files and to execute commands. Log in as root (su) or simply prepend sudo to all commands that require root privileges.

Install CMake

CMake is needed to compile Percona Server. Type the following lines into the console to install CMake:

cd /usr/ports/devel/cmake
make install clean; rehash

Install Wget

We used Wget to fetch the sources. Use your favorite content retrieval program or install Wget with the following lines:

cd /usr/ports/ftp/wget
make install clean; rehash

Install Percona Server with XtraDB

Now, we can fetch the sources and build the Percona Server.

mkdir /usr/local/src
cd /usr/local/src
wget http://www.percona.com/redir/downloads/Percona-Server-5.5/Percona-Server-5.5.16-22.0/source/Percona-Server-5.5.16-rel22.0.tar.gz
tar zxvf Percona-Server-5.5.16-rel22.0.tar.gz
cd Percona-Server-5.5.16-rel22.0
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_CONFIG=mysql_release -DFEATURE_SET=community -DWITH_EMBEDDED_SERVER=OFF 
make && make install; rehash

Add a user for the Percona Server

Add a new user to run the Percona Server as mysql.

adduser

Username: mysql
Full name: Percona Server
Uid [1002]: 
Login group [mysql]: 
Login group is mysql. Invite mysql into other groups? []: 
Login class [default]: 
Shell (sh csh tcsh bash rbash git-shell nologin) [sh]: csh
Home directory [/home/mysql]: /usr/local/mysql/data
Home directory permissions (Leave empty for default): 
Use password-based authentication? [no]: no
Lock out the account after creation? [no]: no
Username   : mysql
Password   : 
Full Name  : Percona Server
Uid        : 1002
Class      : 
Groups     : mysql 
Home       : /usr/local/mysql/data
Home Mode  : 
Shell      : /bin/csh
Locked     : no
OK? (yes/no): yes
adduser: INFO: Successfully added (mysql) to the user database.

Change file permissions

Change the permissions of your data directory to the newly created mysql user with the following line:

chown -R mysql:mysql /usr/local/mysql/data

Update the PATH variable

Update your PATH varibale to open the MySQL console with mysql.

setenv PATH ${PATH}:/usr/local/mysql/bin

Configure settings

Configure the setup script and change the basedir, ldata and user.

vi /usr/local/mysql/scripts/mysql_install_db
basedir="/usr/local/mysql"
ldata="/usr/local/mysql/data"
user="mysql"

Prepare start script

Now, we can create the database by executing the setup script. Finally, we will start the Percona Server.

/usr/local/mysql/scripts/mysql_install_db
cp /usr/local/mysql/support-files/mysql.server /usr/local/etc/rc.d/
mv /usr/local/etc/rc.d/mysql.server /usr/local/etc/rc.d/mysql
/usr/local/etc/rc.d/mysql start

MySQL hardening

Run the MySQL secure script to harden your environment.

/usr/local/mysql/bin/mysql_secure_installation

Start MySQL on system start

Add MysQL to your system configuration to start it on your system start.

vi /etc/rc.conf
mysql_enable="YES"

Comments

  1. Wget is not needed, FreeBSD has the “fetch” program in base which works just as well. :)

  2. This post was very helpful in getting Percona XtraDB Cluster compiled and installed in FreeBSD 9.1. If you get errors during make about PAM failures, then add this to your cmake command:

    -DWITHOUT_AUTH_PAM=1 -DWITHOUT_AUTH_PAM_COMPAT=1 -DWITHOUT_DIALOG=1

    thank you

  3. seksan khajornchai says:

    Thank!

  4. Vasile says:

    Hi,

    Installed with success but i have an issue, i don’t know where to put my.cnf config file.

    Maybe someone can help me, please reply.

    Thankz

    • Hi Vasile,
      you can place the my.cnf file in the /etc directory. This is one of the directories where Percona will search for a configuration file upon restart.

      • Vasile says:

        Hi,

        I place my file unti now in /usr/local/etc but i don’t know if my config was loaded or not, i will move it in /etc .

        Thank you

Speak Your Mind