Archive for the ‘MySQL’ Category

Continued: MySQL connection benchmarking

I was asked by a fellow Schematicer to see if there was a performance difference if the fourth parameter of mysql_connect was set to true if it would make any difference. I would assume that it would not make any difference but I went ahead and ran the variation to be sure, the results are below.

Run #1:

11409 fetches, 20 max parallel, 45636 bytes, in 600.011 seconds
4 mean bytes/connection
19.0146 fetches/sec, 76.0586 bytes/sec
msecs/connect: 0.211857 mean, 39.668 max, 0.029 min
msecs/first-response: 1050.65 mean, 2662.53 max, 323.514 min
HTTP response codes: code 200 — 11409

Run #2:

11141 fetches, 20 max parallel, 44564 bytes, in 600.005 seconds
4 mean bytes/connection
18.5682 fetches/sec, 74.2727 bytes/sec
msecs/connect: 0.206869 mean, 30.293 max, 0 min
msecs/first-response: 1076.17 mean, 2317.13 max, 350.16 min
HTTP response codes: code 200 — 11141

Run #3:

11183 fetches, 20 max parallel, 44732 bytes, in 600 seconds
4 mean bytes/connection
18.6383 fetches/sec, 74.5533 bytes/sec
msecs/connect: 0.201182 mean, 24.691 max, 0.03 min
msecs/first-response: 1071.81 mean, 2448.18 max, 366.686 min
HTTP response codes: code 200 — 11183

Results Analysis

  • Average requests per second: 18.7043
  • Average requests completed: 11,244

These results can be compared to the previous post on this topic.

Install of Apache 2.2.3, MySQL 5.0.18 and PHP 5.2.0

After getting our new servers delivered I came to the conclusion very quickly that I would like a way to easily get the same configurations on every box without having to spend the rest of my life doing so. Each box needed to have Apache, MySQL and PHP installed and configured. I decided to write a bash script to do this for me. In the end I am very happy with the way that the script works. It leaves very little work to be done once the script is done running. In the end I have two scripts, one is for a 32bit machine and one is for 64bit machines. Below is the 64bit script. The install will compile PHP with all of the supported modules that we need. The only thing that needs to be done with PHP is the setting the correct config options in the php.ini, this includes putting in APC cache extension.

#!/bin/sh

# Abort on any errors
set -e

# Where do you want all this stuff built?
SRCDIR=/home/support/software/source

# Unpack our large file that contains all needed packages that are not going to be obtained from yum
#rm -Rf ${SRCDIR}
#gzip -d nbs_core_install.gz
#cd nbs_core_install/
#cp -R * ${SRCDIR}/

# Install gcc
yum -y install gcc

# Install cc
yum -y install cc

# Install libtool
yum -y install libtool

# Extract OpenSSH and install openssh and the sshd in the init.d
cd ${SRCDIR}
tar xzf ${SRCDIR}/openssh-4.5p1.tar.gz
cd ${SRCDIR}/openssh-4.5p1
./configure
make
make install
cp -f ${SRCDIR}/sshd.init.d /etc/rc.d/init.d/sshd
chmod 755 /etc/rc.d/init.d/sshd
rm -f /etc/rc.d/rc3.d/S70sshd
cd /etc/rc.d/rc3.d && ln -s /etc/rc.d/init.d/sshd S70sshd
rm -Rf ${SRCDIR}/openssh-4.5p1

# Install libjpeg-devel
yum -y install libjpeg-devel

# Install jpeg.v6b
cd ${SRCDIR}
tar xzf ${SRCDIR}/jpegsrc.v6b.tar.gz
cd ${SRCDIR}/jpeg-6b
cp /usr/share/libtool/config.guess ./
cp /usr/share/libtool/config.sub ./
./configure –enable-shared
make libdir=/usr/lib64
install -d /usr/local/man/man1
make libdir=/usr/lib64 install
rm -Rf ${SRCDIR}/jpeg-6b

# Install libtiff & libtiff-devel
yum -y install libtiff libtiff-devel

# Install Ghostscript (needed for ImageMagick)
yum -y install ghostscript

# Install ImageMagick
yum -y install ImageMagick

# Install libxml2
cd ${SRCDIR}
tar xzf ${SRCDIR}/libxml2-2.6.27.tar.gz
cd ${SRCDIR}/libxml2-2.6.27
./configure –enable-shared
make
make install
make tests
rm -Rf ${SRCDIR}/libxml2-2.6.27

# Install libxslt
cd ${SRCDIR}
tar xzf ${SRCDIR}/libxslt-1.1.19.tar.gz
cd ${SRCDIR}/libxslt-1.1.19
./configure –prefix=/usr
make
make install
rm -Rf ${SRCDIR}/libxslt-1.1.19

# Install zlib
cd ${SRCDIR}
tar xzf ${SRCDIR}/zlib-1.2.3.tar.gz
cd ${SRCDIR}/zlib-1.2.3
./configure –shared –prefix=/usr
make
make install
rm -Rf ${SRCDIR}/zlib-1.2.3

# Install libmcrypt
cd ${SRCDIR}
tar xzf ${SRCDIR}/libmcrypt-2.5.7.tar.gz
cd ${SRCDIR}/libmcrypt-2.5.7
./configure –disable-posix-threads –prefix=/usr
make
make install

# Install libmcrypt lltdl
cd ${SRCDIR}/libmcrypt-2.5.7/libltdl
./configure –prefix=/usr –enable-ltdl-install
make
make install
rm -Rf ${SRCDIR}/libmcrypt-2.5.7

# Install mhash
cd ${SRCDIR}
tar xzf ${SRCDIR}/mhash-0.9.7.1.tar.gz
cd ${SRCDIR}/mhash-0.9.7.1
./configure –prefix=/usr
make
make install
rm -Rf ${SRCDIR}/mhash-0.9.7.1

# Install Freetype
cd ${SRCDIR}
tar xzf ${SRCDIR}/freetype-2.2.1.tar.gz
cd ${SRCDIR}/freetype-2.2.1
./configure
make
make install
rm -Rf ${SRCDIR}/freetype-2.2.1

# Install libidn
cd ${SRCDIR}
tar xzf ${SRCDIR}/libidn-0.6.9.tar.gz
cd ${SRCDIR}/libidn-0.6.9
./configure –with-iconv-prefix=/usr –prefix=/usr
make
make install
rm -Rf ${SRCDIR}/libidn-0.6.9

# Install OpenSSL
cd ${SRCDIR}
tar xzf ${SRCDIR}/openssl-0.9.8d.tar.gz
cd ${SRCDIR}/openssl-0.9.8d
./config
make
make test
make install
rm -Rf ${SRCDIR}/openssl-0.9.8d

# Install cURL
cd ${SRCDIR}
tar xzf ${SRCDIR}/curl-7.15.0.tar.gz
cd ${SRCDIR}/curl-7.15.0
./configure –enable-ipv6 –enable-cookies –enable-crypto-auth –prefix=/usr
make
make install
rm -Rf ${SRCDIR}/curl-7.15.0

# Install c-client (IMAP)
cd ${SRCDIR}
tar xzf ${SRCDIR}/imap-2004g.tar.Z
cd ${SRCDIR}/imap-2004g
make lrh
cp c-client/c-client.a /usr/lib/libc-client.a
cp c-client/*.h /usr/include
rm -Rf ${SRCDIR}/imap-2004g

# Install Apache
cd ${SRCDIR}
tar xzf ${SRCDIR}/httpd-2.2.3.tar.gz
cd ${SRCDIR}/httpd-2.2.3
./configure –enable-rewrite –enable-ssl –enable-deflate –enable-so –enable-proxy –prefix=/usr/local/apache2
make
make install
rm -Rf ${SRCDIR}/httpd-2.2.3

# Install httpd init.d file
cd ${SRCDIR}
rm -f /etc/rc.d/init.d/httpd
cp httpd.init.d /etc/rc.d/init.d/httpd
chmod 755 /etc/rc.d/init.d/httpd
rm -f /etc/rc.d/rc3.d/K*httpd
rm -f /etc/rc.d/rc3.d/S*httpd
cd /etc/rc.d/rc3.d && ln -s /etc/rc.d/init.d/httpd F15sshd

# Install libpng
cd ${SRCDIR}
tar xzf ${SRCDIR}/libpng-1.2.15.tar.gz
cd ${SRCDIR}/libpng-1.2.15
./configure
make
make install
rm -Rf ${SRCDIR}/libpng-1.2.15

# Install MySQL
yum -y install perl-DBI
cd ${SRCDIR}
rpm -i MySQL-server-standard-5.0.18-0.rhel4.x86_64.rpm
rpm -i MySQL-client-standard-5.0.18-0.rhel4.x86_64.rpm
rpm -i MySQL-devel-standard-5.0.18-0.rhel4.x86_64.rpm
rpm -i MySQL-shared-standard-5.0.18-0.rhel4.x86_64.rpm
rpm -i MySQL-standard-debuginfo-5.0.18-0.rhel4.x86_64.rpm
ln -s /usr/lib64/mysql/libmysqlclient.a /usr/lib/libmysqlclient.a

# Install Flex
yum -y install flex

# Install libdv
yum -y install libdv

# Install re2c needed for php pfro compile
cd ${SRCDIR}
tar zxf ${SRCDIR}/re2c-0.11.0.tar.gz
cd ${SRCDIR}/re2c-0.11.0
./configure
make
make install

# Install PHP
cd ${SRCDIR}
tar xzf ${SRCDIR}/php-5.2.0.tar.gz
cd ${SRCDIR}/php-5.2.0
./configure ‘–prefix=/usr’ ‘–exec-prefix=/usr’ ‘–bindir=/usr/bin’ ‘–sbindir=/usr/sbin’ ‘–sysconfdir=/etc’ ‘–datadir=/usr/share’ ‘–includedir=/usr/include’ ‘–libdir=/usr/lib64′ ‘–libexecdir=/usr/libexec’ ‘–localstatedir=/var’ ‘–sharedstatedir=/usr/com’ ‘–mandir=/usr/share/man’ ‘–infodir=/usr/share/info’ ‘–with-mcrypt=/usr’ ‘–with-config-file-path=/etc’ ‘–with-bz2′ ‘–with-curl’ ‘–with-curl-ssl’ ‘–with-exec-dir=/usr/bin’ ‘–with-freetype-dir=/usr’ ‘–with-png-dir=/usr’ ‘–with-gd’ ‘–with-ttf’ ‘–with-gdbm’ ‘–with-gettext’ ‘–with-ncurses’ ‘–with-gmp’ ‘–with-iconv’ ‘–with-jpeg’ ‘–with-openssl’ ‘–with-png’ ‘–with-regex=system’ ‘–with-xsl=/usr’ ‘–with-expat-dir=/usr’ ‘–with-zlib’ ‘–with-layout=GNU’ ‘–with-kerberos=/usr/kerberos’ ‘–with-apxs2=/usr/local/apache2/bin/apxs’ ‘–without-oci8′ ‘–enable-inline-optimization’ ‘–enable-gd-native-ttf’ ‘–enable-exif’ ‘–enable-ftp’ ‘–enable-sockets’ ‘–enable-trans-sid’ ‘–enable-memory-limit’ ‘–disable-rpath’ ‘–disable-debug’ ‘–with-mysql=/usr/local/mysql’ ‘–with-mysqli=/usr/bin/mysql_config’
make
make install
cp php.ini-dist /etc/php.ini
rm -Rf ${SRCDIR}/php-5.2.0

# Install Memcache PHP Extension
cd ${SRCDIR}
tar xzf ${SRCDIR}/memcache-2.1.0.tgz
cd ${SRCDIR}/memcache-2.1.0
phpize
./configure
make
mkdir /usr/local/phpextensions/
cp ${SRCDIR}/memcache-2.1.0/modules/memcache.so /usr/local/phpextensions/
rm -Rf ${SRCDIR}/memcache-2.1.0

# Install APC (php cache)
cd ${SRCDIR}
tar xzf ${SRCDIR}/APC-3.0.12p2.tgz
cd ${SRCDIR}/APC-3.0.12p2
phpize
./configure –enable-apc-mmap=yes –with-apxs2=/usr/local/apache2/bin/apxs
make
cd ${SRCDIR}/APC-3.0.12p2/modules/
cp apc.so /usr/local/phpextensions

# Install libevent-devel
yum -y install libevent-devel

# Install Memcache Daemon
cd ${SRCDIR}
tar xzf ${SRCDIR}/memcached-1.2.1.tar.gz
cd ${SRCDIR}/memcached-1.2.1
./configure
make
make install
rm -Rf ${SRCDIR}/memcached-1.2.1

# Install BRUTIS
cd ${SRCDIR}
cp monitor.php /home/support/
chmod 700 /home/support/monitor.php
cp ${SRCDIR}/crontab_root /var/spool/cron/root

# Install perl-Net-SSLeay
yum -y install perl-Net-SSLeay

# Install Webmin
cd ${SRCDIR}
rpm -U webmin-1.310-1.noarch.rpm

echo
echo
echo ———- INSTALL COMPLETE! ———-
echo
echo

And here is the 32bit script.

#!/bin/sh

# Abort on any errors
set -e

# Where do you want all this stuff built?
SRCDIR=/home/support/software/source

# Install gcc
yum -y install gcc

# Install libtool
yum -y install libtool

# Extract OpenSSH and install openssh and the sshd in the init.d
cd ${SRCDIR}
tar xzf ${SRCDIR}/openssh-4.5p1.tar.gz
cd ${SRCDIR}/openssh-4.5p1
./configure
make
make install
cp -f ${SRCDIR}/sshd.init.d /etc/rc.d/init.d/sshd
chmod 755 /etc/rc.d/init.d/sshd
rm -f /etc/rc.d/rc3.d/S70sshd
cd /etc/rc.d/rc3.d && ln -s /etc/rc.d/init.d/sshd S70sshd
rm -Rf ${SRCDIR}/openssh-4.5p1

# Install libjpeg-devel
yum -y install libjpeg-devel

# Install jpeg.v6b
cd ${SRCDIR}
tar xzf ${SRCDIR}/jpegsrc.v6b.tar.gz
cd ${SRCDIR}/jpeg-6b
cp /usr/share/libtool/config.guess ./
cp /usr/share/libtool/config.sub ./
./configure –enable-shared
make
install -d /usr/local/man/man1
make install
rm -Rf ${SRCDIR}/jpeg-6b

# Install libtiff & libtiff-devel
yum -y install libtiff libtiff-devel

# Install Ghostscript (needed for ImageMagick)
yum -y install ghostscript

# Install ImageMagick
yum -y install ImageMagick

# Install libxml2
cd ${SRCDIR}
tar xzf ${SRCDIR}/libxml2-2.6.27.tar.gz
cd ${SRCDIR}/libxml2-2.6.27
./configure –enable-shared
make
make install
make tests
rm -Rf ${SRCDIR}/libxml2-2.6.27

# Install libxslt
cd ${SRCDIR}
tar xzf ${SRCDIR}/libxslt-1.1.19.tar.gz
cd ${SRCDIR}/libxslt-1.1.19
./configure –prefix=/usr
make
make install
rm -Rf ${SRCDIR}/libxslt-1.1.19

# Install libmcrypt
cd ${SRCDIR}
tar xzf ${SRCDIR}/libmcrypt-2.5.7.tar.gz
cd ${SRCDIR}/libmcrypt-2.5.7
./configure –prefix=/usr
make
make install

# Install Freetype
cd ${SRCDIR}
tar xzf ${SRCDIR}/freetype-2.2.1.tar.gz
cd ${SRCDIR}/freetype-2.2.1
./configure
make
make install
rm -Rf ${SRCDIR}/freetype-2.2.1

# Install OpenSSL
cd ${SRCDIR}
tar xzf ${SRCDIR}/openssl-0.9.8d.tar.gz
cd ${SRCDIR}/openssl-0.9.8d
./config
make
make test
make install
rm -Rf ${SRCDIR}/openssl-0.9.8d

# Install cURL
cd ${SRCDIR}
tar xzf ${SRCDIR}/curl-7.15.0.tar.gz
cd ${SRCDIR}/curl-7.15.0
./configure –enable-ipv6 –enable-cookies –enable-crypto-auth –prefix=/usr
make
make install
rm -Rf ${SRCDIR}/curl-7.15.0

# Install c-client (IMAP)
cd ${SRCDIR}
tar xzf ${SRCDIR}/imap-2004g.tar.Z
cd ${SRCDIR}/imap-2004g
make lrh
cp c-client/c-client.a /usr/lib/libc-client.a
cp c-client/*.h /usr/include
rm -Rf ${SRCDIR}/imap-2004g

# Install Apache
cd ${SRCDIR}
tar xzf ${SRCDIR}/httpd-2.2.3.tar.gz
cd ${SRCDIR}/httpd-2.2.3
./configure –enable-rewrite –enable-ssl –enable-deflate –enable-so –enable-proxy –prefix=/usr/local/apache2
make
make install
rm -Rf ${SRCDIR}/httpd-2.2.3

# Install httpd init.d file
cd ${SRCDIR}
rm -f /etc/rc.d/init.d/httpd
cp httpd.init.d /etc/rc.d/init.d/httpd
chmod 755 /etc/rc.d/init.d/httpd
rm -f /etc/rc.d/rc3.d/K*httpd
rm -f /etc/rc.d/rc3.d/S*httpd
cd /etc/rc.d/rc3.d && ln -s /etc/rc.d/init.d/httpd F15sshd

# Install libpng
cd ${SRCDIR}
tar xzf ${SRCDIR}/libpng-1.2.15.tar.gz
cd ${SRCDIR}/libpng-1.2.15
./configure
make
make install
rm -Rf ${SRCDIR}/libpng-1.2.15

# Install MySQL
yum -y install perl-DBI
cd ${SRCDIR}
rpm -i MySQL-server-standard-5.0.18-0.rhel3.i386.rpm
rpm -i MySQL-client-standard-5.0.18-0.rhel3.i386.rpm
rpm -i MySQL-devel-standard-5.0.18-0.rhel3.i386.rpm
rpm -i MySQL-shared-standard-5.0.18-0.rhel3.i386.rpm

# Install Flex
yum -y install flex

# Install libdv
yum -y install libdv

# Install PHP
cd ${SRCDIR}
tar xzf ${SRCDIR}/php-5.2.0.tar.gz
cd ${SRCDIR}/php-5.2.0
./configure ‘–prefix=/usr’ ‘–exec-prefix=/usr’ ‘–bindir=/usr/bin’ ‘–sbindir=/usr/sbin’ ‘–sysconfdir=/etc’ ‘–datadir=/usr/share’ ‘–includedir=/usr/include’ ‘–libdir=/usr/lib64′ ‘–libexecdir=/usr/libexec’ ‘–localstatedir=/var’ ‘–sharedstatedir=/usr/com’ ‘–mandir=/usr/share/man’ ‘–infodir=/usr/share/info’ ‘–with-mcrypt=/usr’ ‘–with-config-file-path=/etc’ ‘–with-bz2′ ‘–with-curl’ ‘–with-curl-ssl’ ‘–with-exec-dir=/usr/bin’ ‘–with-freetype-dir=/usr’ ‘–with-png-dir=/usr’ ‘–with-gd’ ‘–with-ttf’ ‘–with-gdbm’ ‘–with-gettext’ ‘–with-ncurses’ ‘–with-gmp’ ‘–with-iconv’ ‘–with-jpeg’ ‘–with-openssl’ ‘–with-png’ ‘–with-regex=system’ ‘–with-xsl=/usr’ ‘–with-expat-dir=/usr’ ‘–with-zlib’ ‘–with-layout=GNU’ ‘–with-kerberos=/usr/kerberos’ ‘–with-apxs2=/usr/local/apache2/bin/apxs’ ‘–without-oci8′ ‘–enable-inline-optimization’ ‘–enable-gd-native-ttf’ ‘–enable-exif’ ‘–enable-ftp’ ‘–enable-sockets’ ‘–enable-trans-sid’ ‘–enable-memory-limit’ ‘–disable-rpath’ ‘–disable-debug’ ‘–with-mysql=/usr/local/mysql’ ‘–with-mysqli=/usr/bin/mysql_config’
make
make install
cp php.ini-dist /etc/php.ini
rm -Rf ${SRCDIR}/php-5.2.0

# Install Memcache PHP Extension
cd ${SRCDIR}
tar xzf ${SRCDIR}/memcache-2.1.0.tgz
cd ${SRCDIR}/memcache-2.1.0
phpize
./configure
make
mkdir /usr/local/phpextensions/
cp ${SRCDIR}/memcache-2.1.0/modules/memcache.so /usr/local/phpextensions/
rm -Rf ${SRCDIR}/memcache-2.1.0

# Install APC (php cache)
cd ${SRCDIR}
tar xzf ${SRCDIR}/APC-3.0.12p2.tgz
cd ${SRCDIR}/APC-3.0.12p2
phpize
./configure –enable-apc-mmap=yes –with-apxs2=/usr/local/apache2/bin/apxs
make
cd ${SRCDIR}/APC-3.0.12p2/modules/
cp apc.so /usr/local/phpextensions

# Install libevent-devel
yum -y install libevent-devel

# Install Memcache Daemon
cd ${SRCDIR}
tar xzf ${SRCDIR}/memcached-1.2.1.tar.gz
cd ${SRCDIR}/memcached-1.2.1
./configure
make
make install
rm -Rf ${SRCDIR}/memcached-1.2.1

# Install BRUTIS
cd ${SRCDIR}
cp monitor.php /home/support/
chmod 700 /home/support/monitor.php
cp ${SRCDIR}/crontab_root /var/spool/cron/root

# Install perl-Net-SSLeay
yum -y install perl-Net-SSLeay

# Install Webmin
cd ${SRCDIR}
rpm -U webmin-1.310-1.noarch.rpm

echo
echo
echo ———- INSTALL COMPLETE! ———-
echo
echo

64bit Install of PHP 5.2.0 & MySQL 5.0.18, Awh!!!

This post is meant to be a time saver for anyone else attempting to do a custom compile of PHP 5.2.0 with mysql and mysqli support built in. The systems this setup is being install on are 64bit Pentium machines running Fedora Core 5.
After way too many hours, 30+, of trial and error I found the magic solution, at least in this setup. Basically PHP when doing the configure was looking in the wrong place for the 64bit version of the mysql libraries, mainly libmysqlclient.a. Mysql is installed into /usr/local/mysql and works like a champ. The configure looks for the library in /usr/lib instead of looking in /usr/lib64 as it should considering the –with-libdir=/usr/lib64 was used. To solve this fiasco a simple symbolic link was the answer.

# ln -s /usr/lib64/libmysqlclient.a /usr/lib/mysqlclient.a

After that you should be in good shape for a good compile.