Tuesday, February 23, 2016

Building XtraBackup for Mac OSX

source https://twindb.com/building-xtrabackup-for-mac-os/


The above source was missing some steps which I thought I'd add as a reminder for future installations for anyone missing the same dependencies as I did.


port install libgcrypt libev


If you get the following error as I did on make

percona-xtrabackup-2.4.1/sql/mysqld.cc:6409:10: error: use of undeclared identifier 'yaSSL_ASN1_TIME_to_string'
return yaSSL_ASN1_TIME_to_string(time, buf, len);
^
[ 98%] Building CXX object sql/CMakeFiles/sql.dir/protocol_callback.cc.o
1 error generated.
make[2]: *** [sql/CMakeFiles/sql.dir/mysqld.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [sql/CMakeFiles/sql.dir/all] Error 2
make: *** [all] Error 2

then you can edit ./sql/mysqld.cc and on line 6404 change

#ifdef HAVE_YASSL

to


#ifdef HAVE_YASSL2


and run make again, done!

Monday, June 9, 2014

My custom optimized build of PHP 5.5 & PHP 5.4

Everyone has their own requirements of what they need enabled or not, this is my setup that I've used over the last couple of years. I have had the option of both PHP 5.4 and 5.5, but my personal preference is to go with the latest 5.5 releases.



apt-get install autoconf libxml2-dev libcurl3-dev libmysqlclient-dev libbz2-dev libsnmp9-dev libjpeg-dev libpng-dev libfreetype6-dev libmcrypt-dev libc-client-dev snmp


export PHP_VER=5.4.29
export PHP_PREFIX=php5.4


-- for php 5.3 - 5.4
wget "http://nl.php.net/distributions/php-$PHP_VER.tar.gz" -O php-$PHP_VER.tar.gz
tar xfz "php-$PHP_VER.tar.gz"
cd "php-$PHP_VER"


export PHP_VER=5.5.13
export PHP_PREFIX=php5.5

cd /app/sources/
rm php* -fr

-- for php 5.5
wget "http://dk1.php.net/get/php-$PHP_VER.tar.bz2/from/www.php.net/mirror" -O php-$PHP_VER.tar.bz2
tar xjf "php-$PHP_VER.tar.bz2"
cd "php-$PHP_VER"



### compile
touch ac*;
./buildconf --force
./configure \
--enable-fpm \
--enable-opcache \
--prefix=/app/${PHP_PREFIX} \
--disable-all \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-snmp \
--with-zlib \
--with-openssl \
--with-snmp \
--with-gd \
--with-freetype-dir=/usr \
--enable-gd-native-ttf \
--with-jpeg-dir=/usr/lib32 \
--with-png-dir=/usr/lib32 \
--with-gettext \
--enable-pdo \
--enable-inline-optimization \
--enable-mbstring \
--enable-filter \
--enable-session \
--enable-json \
--enable-hash \
--disable-debug \
--without-sqlite3 \
--enable-bcmath \
--enable-ctype \
--enable-libxml \
--enable-simplexml \
--enable-xml \
--enable-xmlwriter \
--enable-xmlreader \
--enable-sockets \
--enable-dom \
--with-mcrypt \
--with-imap \
--with-imap-ssl \
--with-kerberos \
--enable-ftp \
--enable-zip \
--enable-xmlwriter \
--with-curl \
--enable-hash \
--with-iconv \
--enable-soap \


make -j4
make install


#### CHANGES

### PHP 5.4 -> 5.5
<< --enable-opcache ln -s /app/${PHP_PREFIX}/bin/php /usr/bin/php ln -s /app/${PHP_PREFIX}/bin/pear /usr/bin/pear ln -s /app/${PHP_PREFIX}/bin/pecl /usr/bin/pecl cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm update-rc.d -f php-fpm defaults




Most things should be self-explained, but note that if you go with PHP 5.4 that you should add --enable-opcache to the compile to use 'now' standard opcache of PHP.



Happy pasting!

Thursday, June 5, 2014

How to compile Percona XtraDB Cluster 5.6 on Ubuntu 14.04 Trusty Tahr

Getting a new server with the latest LTS started out like great news, but soon turned out to be a "couple" of hours wasted on google'n without success.

#percona on freenode is sadly still very very idle and of no help, and after reading different sources such as
http://www.percona.com/doc/percona-xtradb-cluster/5.5/installation/compiling_xtradb_cluster.html
http://www.percona.com/doc/percona-xtradb-cluster/5.6/installation/compiling_xtradb_cluster.html
https://mariadb.com/kb/en/building-the-galera-wsrep-package-on-ubuntu-and-debian/

I managed to get it all working and wanted to share the success.


Note: There might be more packages that need to be installed that I already had when installing another application, if you get an error along the way, leave a comment and I'll help out and update the blog as we go along.

apt-get install bzr openssl cmake libncurses5-dev bison xinetd socat build-essential flex bison automake autoconf bzr libtool libaio-dev zlib1g-dev libboost-dev

Next, we'll go on with the compile & install. Note if you are (for some reason) compiling on a 32bit machine use ./BUILD/compile-pentium else use ./BUILD/compile-pentium64 as the paste below does.
mkdir /app/sources -p
cd /app/sources
rm -fr percona
mkdir percona
cd percona

bzr checkout --lightweight lp:percona-xtradb-cluster/5.6
./BUILD/compile-pentium64
make install

# only needed for clusterchek (haproxy)
cp scripts/clustercheck /usr/bin/
cp scripts/mysqlchk /etc/xinetd.d/

# standard debian packages
cp build-ps/debian/additions/debian-start /etc/mysql/
cp build/debian/percona-xtradb-cluster-server-5.6.mysql.init /etc/init.d/mysql
chmod +x /etc/init.d/mysql

# make the debian scripts work with our compiled folders
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysqld_safe /usr/bin/mysqld_safe
ln -s /usr/local/mysql/bin/mysqld /usr/sbin/mysqld
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/mysqladmin

groupadd mysql
useradd -r -g mysql mysql

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

The symlinks are added to make the installment as close as possible to the default MySQL for Ubuntu. That way we don't need to update the standard scripts of init.d, xinet.d, clustercheck and others.


Last thing that we are missing is the galera module, you know - the one we point in our config file: wsrep_provider=/usr/lib/libgalera_smm.so
So after compiling it from source as specified by a document I found on MariaDB, I found that it was very time consuming while the result was the same as using the galera-module from Perconas sources which was luckely in the repo.

(remember to add perconas repo before doing the next step http://www.percona.com/doc/percona-server/5.6/installation/apt_repo.html)

apt-get install percona-xtradb-cluster-galera-3.x

That's it! Now you have a fresh MySQL installment ready to be tested with your own my.cnf file.
Remember to restart xined if you will use tools such as HaProxy to monitor the clusterstatus.



Happy Pasting!



Monday, November 26, 2012

MySQL Delete dupes

My favorite way of deleting dupes (taken from the honorable #mysql on freenode)


If you have a unique ID and the name may contain duplicates then

DELETE t1 FROM table1 AS t1 JOIN table1 AS t2 ON t1.id>t2.id AND t1.name=t2.name;

If you have other fields that need to be taken into consideration extend the join as needed. If it fails on a myisam table see http://bugs.mysql.com/bug.php?id=28837

Tuesday, August 21, 2012

phpMyAdmin - The plain HTTP request was sent to HTTPS port

So I tried getting phpMyAdmin to work with https again, turns out there was a solution posted back in 2008 on this blog.

His solution didn't quite work out for me, so I thought I'd update it with my working solution.

His version states add fastcgi_param HTTPS on which is correct, just at the wrong place.
location ~ \.php$ {
fastcgi_param HTTPS on;
fastcgi_pass 127.0.0.1:xxxx;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
}


What I need to do is the following:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:xxxx;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_param HTTPS on;
}



Why? Simply cause in the conf/fastcgi_params file I had this:
fastcgi_param HTTPS $ssl_protocol;

Which doesn't seem to be good enough for good ol' phpMyAdmin, so we need to overwrite it after we include the conf file.


Fin.

Sunday, February 19, 2012

Enabling Pure-ftpd TLS


Tell pure-ftpd to accept tls connections
echo 1 > /etc/pure-ftpd/conf/TLS


Setup your certificate

mkdir -p /etc/ssl/private

openssl req -x509 -nodes -newkey rsa:1024 -keyout \
/etc/ssl/private/pure-ftpd.pem \
-out /etc/ssl/private/pure-ftpd.pem

chmod 600 /etc/ssl/private/*.pem


Restart pure-ftpd

/etc/init.d/pure-ftpd restart



Enjoy.

Friday, January 6, 2012

Remove unused kernels in Ubuntu

Update @20:th Aug 2015

The old dpkg trick was unstable and wanted to delete tons of unwanted things more than 50% of the time, so I found another useful command which has a higher success rate of doing what we want.



aptitude purge ~ilinux-image-\[0-9\]\(\!`uname -r`\)


source: http://www.upubuntu.com/2011/11/how-to-remove-unused-old-kernels-on.html









Run the following command to see what the command will remove:


dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get --dry-run remove



And finally to actually remove the kernels use:



dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get -y purge



source: http://tuxtweaks.com/2010/10/remove-old-kernels-in-ubuntu-with-one-command/