Skip to content

Instantly share code, notes, and snippets.

@bradfordpythian
Last active February 17, 2017 17:35
Show Gist options
  • Save bradfordpythian/bf453ec7d2e9f31c1f531f16af150233 to your computer and use it in GitHub Desktop.
Save bradfordpythian/bf453ec7d2e9f31c1f531f16af150233 to your computer and use it in GitHub Desktop.
set_target_dir() {
local TARGET_DIR=$1
[ -z "${TARGET_DIR}" ] && echo "INTERNAL ERROR: One parameter required ($#) supplied" && exit 1
if [ ! -d "${TARGET_DIR}" ]
then
sudo mkdir -p ${TARGET_DIR}
RC=$?
[ ${RC} -ne 0 ] && echo "ERROR: Unable to make '${TARGET_DIR}'" && exit ${RC}
sudo chmod 777 ${TARGET_DIR}
RC=$?
[ ${RC} -ne 0 ] && echo "ERROR: Unable to set permissions on '${TARGET_DIR}'" && exit ${RC}
fi
cd ${TARGET_DIR}
RC=$?
[ ${RC} -ne 0 ] && echo "ERROR: Unable to change directory to '${TARGET_DIR}'" && exit ${RC}
return 0
}
get_rpm() {
local RPM=$1
local URL=$2
[ -z "${RPM}" -o -z "${URL}" ] && echo "INTERNAL ERROR: Two parameters required ($#) supplied" && exit 1
[ -f "${RPM}" ] && echo "${RPM} file in place" && return 0
wget --timeout=10 --tries=1 ${URL}${RPM}
RC=$?
[ ${RC} -ne 0 ] && echo "ERROR: Unable to change directory to '${TARGET_DIR}'" && exit ${RC}
return 0
}
install_rpm() {
local RPM=$1
[ -z "${RPM}" ] && echo "INTERNAL ERROR: One parameter required ($#) supplied" && exit 1
[ ! -f "${RPM}" ] && echo "${RPM} file not found" && exit 1
PKG=`echo ${RPM} | sed -e "s/.rpm//"`
EXISTS=`rpm -qa | grep ${PKG} | wc -l`
[ ${EXISTS} -eq 1 ] && echo "${RPM} already installed" && return 0
sudo rpm -ivh ${RPM}
RC=$?
[ ${RC} -ne 0 ] && echo "ERROR: Unable to install rpm '${RPM}'" && exit ${RC}
return 0
}
[ -z "${RPM_TARGET_DIR}" ] && RPM_TARGET_DIR=/opt/software
set_target_dir ${RPM_TARGET_DIR}
# See https://centos.pkgs.org/6/epel-x86_64/jemalloc-3.6.0-1.el6.x86_64.rpm.html
RPM="jemalloc-3.6.0-1.el6.x86_64.rpm"
get_rpm ${RPM} "http://dl.fedoraproject.org/pub/epel/6/x86_64/"
install_rpm ${RPM}
RPM="Percona-Server-tokudb-56-5.6.26-rel74.0.el6.x86_64.rpm"
install_rpm ${RPM}
if [ `sestatus | grep "^Current.*enforcing" | wc -l` -eq 1 ]
then
sudo setenforce permissive
sudo sed -i "s/^SELINUX=enforcing/SELINUX=permissive/" /etc/selinux/config
fi
sudo service mysql restart
sudo ps_tokudb_admin --enable -uroot
mysql -uroot -e "SELECT VERSION(), @@tokudb_version, @@hostname;"
mysql -uroot -e "SHOW ENGINES" | grep -i tokudb
mysql -uroot -e "CREATE SCHEMA IF NOT EXISTS test;USE test; DROP TABLE IF EXISTS t1; CREATE TABLE t1(i1 INT) ENGINE=TokuDB;SHOW CREATE TABLE t1;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment