Support #335
Installing a Percona Node and Galera Replication On A FreeNAS Jail
80%
Description
While increasing availability of the web services provided, I have created a jail for compiling and installing Percona package, with . Once ssh access has been enabled, log in and install the percona client and server:
ssh db.example.com su
Currently there is no Galera in the ports tree, however since percona provides its software source code, I can download the source from them and compile in replication. First update the pkg list:
pkg update
And resolve some dependencies for building wsrep:
pkg install bash bison gcc48 libexecinfo lsof sudo rsync openssl boost-libs cmake flex libcheck scons autoconf automake gmake help2man libtool bzr subversion libevent
Because /bin/bash
is often used as interpreter for scripts, you should link bash to that path:
sudo ln -s /usr/local/bin/bash /bin/bash
Galera is written with the modern version of C++ standard, and its code is not fully compatible with default g++ 4.2.1 compiler. You should have at least g++ 4.7, but g++ 4.8 is highly recommended. Also, you should specify version of libstdc++ library, which is used for program execution through LD_LIBRARY_PATH environment variable. You should assign the following environment variables.
bash LD_LIBRARY_PATH=/usr/local/lib/gcc48 CC=gcc48 CXX=g++48 export LD_LIBRARY_PATH CC CXX
It is recommended to add them to your login shell script (.shrc, .cshrc, .bashrc
).
Download and compile Percona Server with wsrep 5.5:
mkdir /usr/local/src cd /usr/local/src wget http://www.percona.com/redir/downloads/Percona-XtraDB-Cluster/LATEST/source/Percona-XtraDB-Cluster-5.5.34.tar.gz tar xzf Percona-XtraDB-Cluster-5.5.34.tar.gz cd Percona-XtraDB-Cluster-5.5.34 ./BUILD/compile-pentium-wsrep make install
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 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 your PATH variable to open the MySQL console with mysql.
PATH=$PATH:/usr/local/mysql/bin
Note you may need to setting a the PATH variable at the top of
/etc/rc.conf
, similar to the following:
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin:/usr/local/mysql/bin
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"
Now, we can create the database by executing the setup script. Finally, we will start the Percona Server.
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
NOTE: I needed to replace the pidof command with the pgrep command on FreeBSD, I just commented out the previous command and set a new command in the pid variable:
#! Try to find appropriate mysqld process
#! mysqld_pid=`pidof $libexecdir/mysqld`#! FreeBSD fix to try to find appropriate mysqld process
mysqld_pid=`pgrep -d' ' $libexecdir/mysqld`
Now initialize the database system tables:
cd /usr/local/mysql /usr/local/mysql/scripts/mysql_install_db
Run the MySQL secure script to harden your environment.
/usr/local/mysql/bin/mysql_secure_installation
Add MySQL to your system configuration to start it on your system start.
vi /etc/rc.conf
mysql_enable="YES"
Now test start the service:
service mysql start
SUCCESS! MySQL (Percona XtraDB Cluster) running (20263)
And stop the service:
service mysql stop
Download and compile Galera 2.x:
cd /usr/local/src wget http://www.percona.com/redir/downloads/Percona-XtraDB-Cluster/LATEST/source/percona-xtradb-cluster-galera.tar.gz tar xzf percona-xtradb-cluster-galera.tar.gz cd percona-xtradb-db-cluster-galera scons
And manually install the Galera plugin:
cp garb/garbd /usr/local/mysql/bin/ cp libgalera_smm.so /usr/local/mysql/lib/mysql/plugin/
Copy an example mysql configuration to the /etc
directory:
cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf
And make the following changes to /etc/my.cnf:
[mysqld] # Percona XtraDB Cluster binlog_format=ROW wsrep_provider=/usr/local/mysql/lib/mysql/plugin/libgalera_smm.so wsrep_cluster_address=gcomm:// log_slave_updates wsrep_slave_threads=2 wsrep_cluster_name=unique_cluster_name wsrep_sst_method=rsync wsrep_node_name=node2 innodb_locks_unsafe_for_binlog=1 innodb_autoinc_lock_mode=2 [mysqld_safe] wsrep_urls=gcomm://
Resources¶
- http://bin63.com/how-to-install-percona-server-with-xtradb-on-freebsd
- http://www.codership.com/wiki/doku.php?id=compile_galera
- http://serverfault.com/questions/426021/how-to-install-percona-xtradb-cluster-on-x86-server
- http://www.percona.com/downloads/Percona-XtraDB-Cluster/LATEST/source/
- http://www.fromdual.ch/building-galera-replication-from-scratch