Install Percona on Mac OSX Lion
Recently I mentioned my intention to install Percona Server on my MacBook Pro for development purposes. I will admit it was a mild rant because I ran into some issues with installing Percona.
(Un)fortunately for me, the issues with installing were largely due to my ignorance of various build flags and what each purpose was for and I was able to resolve most of them. So without further ado, I present the steps that I used to successfully build Percona Server from bazaar on Mac OSX Lion.
Prepare the environment
This is the software you will need to install*:
*Some of the above might need further things installed. That is beyond the scope of this post.
Actually, I am going to assume you have XCode installed. You need it for the compiling programs like gcc and autoconf. If you don’t have it, click the link above and get it ASAP.
Now then, MySQL 5.5 decided to start utilizing the CMake program to compile source, so that is next on the list. You can get it from the link above. They have a .dmg file for Macs, but I compiled it from the linux source file (.tar.gz), version 2.8.6 in this post.
$ cd ~/sourceFiles derekd$ wget http://www.cmake.org/files/v2.8/cmake-2.8.6.tar.gz derekd$ tar -xzvf cmake-2.8.6.tar.gz derekd$ cd cmake-2.8.6.tar.gz derekd$ ./bootstrap && make && sudo make install
Now, you will need to install Bazaar, as that’s the source control that MySQL/Percona uses. Using the link above will actually get you to some installation instructions that are exactly what I used. At the time of this writing, Bazaar does not have an install file for Mac OSX Lion, so use the one for Snow Leopard.
I want to highlight one issue. Mac OSX Lion defaults to Python version 2.7, but Bazaar needs v2.6 at the time of this writing. So if you don’t have virtual environments set up (outside scope of this article), set your default version of Python to 2.6:
derekd$ defaults write com.apple.versioner.python Version 2.6
So after installing from the .dmg file, you should have everything you need to install Percona Server.
Percona Server with XtraDB
As it turns out, Percona Server installs by taking the version of MySQL it has as its base, and applying Percona patches to the code, prior to compilation. These steps should get you an installed copy of Percona:
derekd$ cd ~/devel derekd$ bzr init-repo ./percona-server derekd$ cd ./percona-server derekd$ bzr branch lp:percona-server/5.5 derekd$ cd 5.5 derekd$ make #this step downloads mysql and applies the percona packages derekd$ cd Percona-Server derekd$ BUILD/autorun.sh derekd$ CFLAGS="-arch x86_64 -Wall -Wextra -Wunused -Wwrite-strings -mtune=native -m64 -DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS -DSAFE_MUTEX -O0 -g3 -gdwarf-2" CXXFLAGS="-arch x86_64 -Wall -Wextra -Wunused -Wwrite-strings -Wno-unused-parameter -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti -mtune=native -m64 -DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS -DSAFE_MUTEX -O0 -g3 -gdwarf-2" ./configure --enable-thread-safe-client --with-mysqld-user=_mysql --enable-shared --with-plugins=max --with-extra-charsets=complex --with-big-tables --with-ssl --with-readline --enable-assembler derekd$ make derekd$ sudo make install
And that should be it. You can follow normal MySQL installation steps after this step.
A word about Configuration options
The above configure script was taken mostly from the BUILD/compile-pentium64-debug-max script. I was forced to remove the –with-debug option on the Mac, because it forced warnings to be handled as errors, and percona has added a couple variables that are only used inside a block that is not applicable on Mac OSX. EG, in sql/sql_prepare.cc:
#ifdef HAVE_CLOCK_GETTIME /* get end cputime */ if (!cputime_error && !(cputime_error= clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp))) end_cpu_nsecs= tp.tv_sec*1000000000.0+tp.tv_nsec; #endif
tp is declared outside the block, and clock_gettime is not implemented on Mac OSX. (src)
I have been able to compile a –with-debug version from bazaar with the following:
derekd$ make clean && rm CMakeCache.txt derekd$ CFLAGS="-arch x86_64 -Wall -Wextra -Wunused -Wwrite-strings -mtune=native -m64 -DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS -DSAFE_MUTEX -O1 -g3 -gdwarf-2" \ CXXFLAGS="-arch x86_64 -Wall -Wextra -Wunused -Wwrite-strings -Wno-unused-parameter -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti -mtune=native -m64 -DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS -DSAFE_MUTEX -O2 -g3 -gdwarf-2" \ ./configure --enable-thread-safe-client --with-mysqld-user=_mysql --enable-shared --with-plugins=max --with-extra-charsets=complex --with-big-tables --with-ssl --with-readline --enable-assembler --with-debug --disable-mysql-maintainer-mode derekd$ make
The issue was that –with-debug enables the -Werror CFLAG. To override this, provide –disable-mysql-maintainer-mode. Thanks to Stewart Smith at Percona for providing this information.
Also, I have tested this build command on Percona Server 5.1 and 5.5, and it works on both servers on my MacBook Pro running Mac OSX 10.7 Lion. Eventually I will convert to the cmake directives, but for now, if it ain’t baroque, don’t fix it.