Support #335
Updated by Daniel Curtis almost 11 years ago
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: <pre> ssh db.example.com su </pre> Currently there is no Galera in the ports tree, however since percona provides its software source code, I can download did manage to find a script that creates an entry in the source from them and compile in replication. ports tree. First update the pkg list: ports tree: <pre> pkg update portsnap fetch portsnap extract </pre> And resolve some dependencies for building wsrep: <pre> pkg install bash bison gcc48 libexecinfo lsof sudo rsync openssl boost-libs cmake flex libcheck scons autoconf automake gmake help2man libtool bzr subversion libevent </pre> Because @/bin/bash@ is often used as interpreter for scripts, you should link bash to that path: <pre> sudo ln -s /usr/local/bin/bash /bin/bash </pre> 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. <pre> bash LD_LIBRARY_PATH=/usr/local/lib/gcc48 CC=gcc48 CXX=g++48 export LD_LIBRARY_PATH CC CXX </pre> It is recommended to add them to your login shell script (@.shrc, .cshrc, .bashrc@). Download and compile Percona Server with wsrep 5.5: <pre> 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 </pre> Add a new user to run the Percona Server as mysql. <pre> adduser </pre> > 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: <pre> chown -R mysql:mysql /usr/local/mysql/data </pre> Update your PATH variable to open the MySQL console with mysql. <pre> PATH=$PATH:/usr/local/mysql/bin </pre> 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 Then download and change the @basedir@, @ldata@ and @user@. <pre> vi /usr/local/mysql/scripts/mysql_install_db </pre> > 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. <pre> 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 </pre> 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: <pre> cd /usr/local/mysql /usr/local/mysql/scripts/mysql_install_db </pre> Run the MySQL secure script to harden your environment. <pre> /usr/local/mysql/bin/mysql_secure_installation </pre> Add MySQL to your system configuration to start it on your system start. <pre> vi /etc/rc.conf </pre> > mysql_enable="YES" Now test start the service: <pre> service mysql start </pre> > SUCCESS! MySQL (Percona XtraDB Cluster) running (20263) And stop the service: <pre> service mysql stop </pre> Download and compile Galera 2.x: <pre> 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 </pre> And manually install the Galera plugin: <pre> cp garb/garbd /usr/local/mysql/bin/ cp libgalera_smm.so /usr/local/mysql/lib/mysql/plugin/ /usr/local/mysql/lib/plugin/ </pre> Copy an example mysql configuration to the @/etc@ directory: <pre> cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf </pre> And make the following changes to /etc/my.cnf: <pre> [mysqld] # Percona XtraDB Cluster binlog_format=ROW wsrep_provider=/usr/lib/mysql/lib/mysql/plugin/libgalera_smm.so 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:// </pre> h2. 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