Merge lp:~tplavcic/percona-server/bld-212-5.6-tokudb into lp:percona-server/5.6

Proposed by Tomislav Plavcic
Status: Superseded
Proposed branch: lp:~tplavcic/percona-server/bld-212-5.6-tokudb
Merge into: lp:percona-server/5.6
Diff against target: 440 lines (+319/-23)
6 files modified
build-ps/debian/percona-server-tokudb-5.6.files (+1/-0)
build-ps/debian/percona-server-tokudb-5.6.postinst (+4/-9)
build-ps/percona-server.spec (+10/-14)
scripts/CMakeLists.txt (+1/-0)
scripts/mysqld_safe.sh (+59/-0)
scripts/ps_tokudb_admin.sh (+244/-0)
To merge this branch: bzr merge lp:~tplavcic/percona-server/bld-212-5.6-tokudb
Reviewer Review Type Date Requested Status
Laurynas Biveinis Pending
Review via email: mp+246589@code.launchpad.net

This proposal supersedes a proposal from 2015-01-15.

This proposal has been superseded by a proposal from 2015-01-28.

Description of the change

This change is for BLD-212 (simplify TokuDB installation).
It adds ps_tokudb_admin script which can install/uninstall TokuDB plugin and disable transparent huge pages.
Mysqld_safe was changed to read thp-setting option from my.cnf

Extensive testing was done in BLD-212 so here I only show how install/uninstall works on centos7.
Test packages are available here:
http://jenkins.percona.com/job/percona-server-5.6-RELEASE/96/

INSTALL
-------
[vagrant@t-centos7-64 ~]$ sudo ps_tokudb_admin -e -u root
Checking transparent huge pages status on the system...
>> Transparent huge pages are enabled (should be disabled).

Checking if thp-setting=never option is already set in config file...
>> Option thp-setting=never is not set in the config file.
>> (needed only if THP is not disabled permanently on the system)

Checking TokuDB plugin status...
>> TokuDB plugin is not installed.

Disabling transparent huge pages for the current session...
>> Successfuly disabled transparent huge pages for this session.

Adding thp-setting=never option into /etc/my.cnf
>> Successfuly added thp-setting=never option into /etc/my.cnf

Installing TokuDB engine...
>> Successfuly installed TokuDB plugin.

mysql> show plugins;
...
| TokuDB | ACTIVE | STORAGE ENGINE | ha_tokudb.so | GPL |
| TokuDB_file_map | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_fractal_tree_info | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_fractal_tree_block_map | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_trx | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_locks | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_lock_waits | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
+-------------------------------+----------+--------------------+--------------+---------+

UNINSTALL
---------
[vagrant@t-centos7-64 ~]$ sudo ps_tokudb_admin -d -u root
Checking transparent huge pages status on the system...
>> Transparent huge pages are currently disabled on the system.

Checking if thp-setting=never option is already set in config file...
>> Option thp-setting=never is set in the config file.

Checking TokuDB plugin status...
>> TokuDB plugin is installed.

Removing thp-setting=never option from /etc/my.cnf
>> Successfuly removed thp-setting=never option from /etc/my.cnf

Uninstalling TokuDB plugin...
>> Successfuly uninstalled TokuDB plugin.

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

It needs a blueprint?

review: Needs Information
Revision history for this message
Tomislav Plavcic (tplavcic) wrote : Posted in a previous version of this proposal

Created some blueprint - please check.

Revision history for this message
Roel Van de Paar (roel11) wrote : Posted in a previous version of this proposal

The script does not allow specification of host/socket/port. Thus, it assumes that PS is installed in a standard way (yum/apt), on a standard port, etc.

If the customer has both MS and PS on one box, on different ports, the wrong one may be auto-selected depending on which one is running on the default port, etc.

review: Needs Information
Revision history for this message
Roel Van de Paar (roel11) wrote : Posted in a previous version of this proposal

Also, I am not sure about removing the INSTALL PLUGIN information from postinst. It may still make sense for many DBA's to quickly hop in a CLI and execute this, rather then using a new tool.

Revision history for this message
David Bennett (dbpercona) wrote :

Regarding the INSTALL PLUGIN postinst message, perhaps we could add a manual installation instructions under /usr/share/doc/{percona-server-tokudb-5.6} that gave complete instructions including the setting of THP. The manual instructions text file could be referenced in the postinst message.

This way the postinst message would remain concise and the DBA would have access to the full instructions which we could update if needed.

Revision history for this message
David Bennett (dbpercona) wrote :

Regarding the manual installation text file, Tomislav points out that there is a link to the manual instructions referenced in the postinst message:

 * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_intro.html for more details

This will be easier to maintain and provide us with a single point of maintenance.

Revision history for this message
Roel Van de Paar (roel11) wrote :

@David/@Tomislav - manual link sounds great/fine.

Revision history for this message
Roel Van de Paar (roel11) wrote :

However, the way it stands now;

+ echo -e " * Run the following script to enable the TokuDB storage engine in Percona Server:\n"
+ echo -e "\tps_tokudb_admin --enable -u <mysql_admin_user> -p <mysql_admin_pass>\n"
+ echo -e " * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_intro.html for more details\n\n"

It looks like tokudb_intro.html will have more details on tps_tokudb_admin (it does not). Maybe instead it should be pointed at http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_installation.html and on that page (before we release this) info on tps_tokudb_admin.sh should be added.

Btw, the above should read" ps_tokudb_admin.sh" (.sh) + potentially list connect details? How about;

+ echo -e "\tps_tokudb_admin --enable -u <mysql_admin_user> -p <mysql_admin_pass> {-S <socket>} {-h <host> -P <port>} \n"

Revision history for this message
Roel Van de Paar (roel11) wrote :

On second thoughts, both pages are of interest. So, how about this final update;

+ echo -e " * Run the following script to enable the TokuDB storage engine in Percona Server:\n"
+ echo -e "\tps_tokudb_admin.sh --enable -u <mysql_admin_user> -p <mysql_admin_pass> {-S <socket>} {-h <host> -P <port>}\n"
+ echo -e " * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_installation.html for more installation details\n\n"
+ echo -e " * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_intro.html for an Introduction to TokuDB\n\n"

Revision history for this message
Roel Van de Paar (roel11) wrote :

(There is a second newline in between the URL's should it look fairly clean/uncluttered)

Revision history for this message
Tomislav Plavcic (tplavcic) wrote :

Roel/David:
- I've changed postinst to what Roel suggested (with two links) - it should look ok
- host, port, socket are added as parameters
- and usage info is added in mysqld_safe for --thp-setting
Info about the new build with this changes is in BLD-212 - when we confirm it is ok I'll resubmit merge proposal.

Revision history for this message
Roel Van de Paar (roel11) wrote :

I previously checked out the host etc. option addition, and - whilst not having tested it - the code looked good.

Revision history for this message
Roel Van de Paar (roel11) wrote :

Script should still be tested with new options + user/pwd etc.

Revision history for this message
Roel Van de Paar (roel11) wrote :

Btw, official release is on 28th

Revision history for this message
Tomislav Plavcic (tplavcic) wrote :

Changed postinst messages, script running parameters and usage info in mysqld_safe so resubmitting MP.
Testing has been done in BLD-212.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'build-ps/debian/percona-server-tokudb-5.6.files'
--- build-ps/debian/percona-server-tokudb-5.6.files 2014-09-27 13:49:22 +0000
+++ build-ps/debian/percona-server-tokudb-5.6.files 2015-01-23 07:50:01 +0000
@@ -1,3 +1,4 @@
1usr/lib/mysql/plugin/ha_tokudb.so1usr/lib/mysql/plugin/ha_tokudb.so
2usr/lib/mysql/plugin/debug/ha_tokudb.so2usr/lib/mysql/plugin/debug/ha_tokudb.so
3usr/bin/tokuftdump3usr/bin/tokuftdump
4usr/bin/ps_tokudb_admin
45
=== modified file 'build-ps/debian/percona-server-tokudb-5.6.postinst'
--- build-ps/debian/percona-server-tokudb-5.6.postinst 2014-05-20 21:04:08 +0000
+++ build-ps/debian/percona-server-tokudb-5.6.postinst 2015-01-23 07:50:01 +0000
@@ -3,15 +3,10 @@
3# Some postinstall info about TokuDB3# Some postinstall info about TokuDB
4if [ -z "$2" ]; then4if [ -z "$2" ]; then
5 echo -e "\n\n * This release of Percona Server is distributed with TokuDB storage engine."5 echo -e "\n\n * This release of Percona Server is distributed with TokuDB storage engine."
6 echo -e " * Run the following commands to enable the TokuDB storage engine in Percona Server:\n"6 echo -e " * Run the following script to enable the TokuDB storage engine in Percona Server:\n"
7 echo -e "\tmysql -e \"INSTALL PLUGIN tokudb SONAME 'ha_tokudb.so';\""7 echo -e "\tps_tokudb_admin --enable -u <mysql_admin_user> -p[mysql_admin_pass] [-S <socket>] [-h <host> -P <port>]\n"
8 echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_file_map SONAME 'ha_tokudb.so';\""8 echo -e " * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_installation.html for more installation details\n"
9 echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_fractal_tree_info SONAME 'ha_tokudb.so';\""9 echo -e " * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_intro.html for an introduction to TokuDB\n\n"
10 echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME 'ha_tokudb.so';\""
11 echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_trx SONAME 'ha_tokudb.so';\""
12 echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_locks SONAME 'ha_tokudb.so';\""
13 echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_lock_waits SONAME 'ha_tokudb.so';\""
14 echo -e "\n * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_intro.html for more details\n\n"
15fi10fi
1611
17#DEBHELPER#12#DEBHELPER#
1813
=== modified file 'build-ps/percona-server.spec'
--- build-ps/percona-server.spec 2015-01-13 14:38:41 +0000
+++ build-ps/percona-server.spec 2015-01-23 07:50:01 +0000
@@ -651,6 +651,10 @@
651%if 0%{?systemd}651%if 0%{?systemd}
652rm -rf $RBR%{_sysconfdir}/init.d/mysql652rm -rf $RBR%{_sysconfdir}/init.d/mysql
653%endif653%endif
654# Not needed if TokuDB package is not created
655%if ! %{with tokudb}
656rm -rf $RBR%{_bindir}/ps_tokudb_admin
657%endif
654658
655##############################################################################659##############################################################################
656# Post processing actions, i.e. when installed660# Post processing actions, i.e. when installed
@@ -1094,20 +1098,11 @@
1094%post -n Percona-Server-tokudb%{product_suffix}1098%post -n Percona-Server-tokudb%{product_suffix}
10951099
1096if [ $1 -eq 1 ] ; then1100if [ $1 -eq 1 ] ; then
1097 echo ""1101 echo -e "\n\n * This release of Percona Server is distributed with TokuDB storage engine."
1098 echo "* This release of Percona Server is distributed with TokuDB storage engine."1102 echo -e " * Run the following script to enable the TokuDB storage engine in Percona Server:\n"
1099 echo "* Run the following commands to enable the TokuDB storage engine in Percona Server:"1103 echo -e "\tps_tokudb_admin --enable -u <mysql_admin_user> -p[mysql_admin_pass] [-S <socket>] [-h <host> -P <port>]\n"
1100 echo ""1104 echo -e " * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_installation.html for more installation details\n"
1101 echo "mysql -e \"INSTALL PLUGIN tokudb SONAME 'ha_tokudb.so';\""1105 echo -e " * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_intro.html for an introduction to TokuDB\n\n"
1102 echo "mysql -e \"INSTALL PLUGIN tokudb_file_map SONAME 'ha_tokudb.so';\""
1103 echo "mysql -e \"INSTALL PLUGIN tokudb_fractal_tree_info SONAME 'ha_tokudb.so';\""
1104 echo "mysql -e \"INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME 'ha_tokudb.so';\""
1105 echo "mysql -e \"INSTALL PLUGIN tokudb_trx SONAME 'ha_tokudb.so';\""
1106 echo "mysql -e \"INSTALL PLUGIN tokudb_locks SONAME 'ha_tokudb.so';\""
1107 echo "mysql -e \"INSTALL PLUGIN tokudb_lock_waits SONAME 'ha_tokudb.so';\""
1108 echo ""
1109 echo "* See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_intro.html for more details"
1110 echo ""
1111fi1106fi
1112# ----------------------------------------------------------------------------1107# ----------------------------------------------------------------------------
1113%endif1108%endif
@@ -1375,6 +1370,7 @@
1375%{_bindir}/tokuftdump1370%{_bindir}/tokuftdump
1376%{_libdir}/mysql/plugin/ha_tokudb.so1371%{_libdir}/mysql/plugin/ha_tokudb.so
1377%attr(755, root, root) %{_libdir}/mysql/plugin/debug/ha_tokudb.so1372%attr(755, root, root) %{_libdir}/mysql/plugin/debug/ha_tokudb.so
1373%attr(755, root, root) %{_bindir}/ps_tokudb_admin
1378%endif1374%endif
13791375
1380# ----------------------------------------------------------------------------1376# ----------------------------------------------------------------------------
13811377
=== modified file 'scripts/CMakeLists.txt'
--- scripts/CMakeLists.txt 2014-12-16 06:00:17 +0000
+++ scripts/CMakeLists.txt 2015-01-23 07:50:01 +0000
@@ -339,6 +339,7 @@
339 mysqldumpslow339 mysqldumpslow
340 mysqld_multi340 mysqld_multi
341 mysqld_safe341 mysqld_safe
342 ps_tokudb_admin
342 )343 )
343 FOREACH(file ${BIN_SCRIPTS})344 FOREACH(file ${BIN_SCRIPTS})
344 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh)345 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh)
345346
=== modified file 'scripts/mysqld_safe.sh'
--- scripts/mysqld_safe.sh 2014-12-01 07:53:48 +0000
+++ scripts/mysqld_safe.sh 2015-01-23 07:50:01 +0000
@@ -20,6 +20,8 @@
20load_jemalloc=120load_jemalloc=1
21flush_caches=021flush_caches=0
22numa_interleave=022numa_interleave=0
23# Change (disable) transparent huge pages (TokuDB requirement)
24thp_setting=
2325
24# Initial logging status: error log is not open, and not using syslog26# Initial logging status: error log is not open, and not using syslog
25logging=init27logging=init
@@ -66,6 +68,14 @@
66esac68esac
6769
68usage () {70usage () {
71 thp_usage=""
72 if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then
73 thp_usage=$(cat <<'EOF'
74 --thp-setting=SETTING Change transparent huge pages setting
75 on the system before starting mysqld
76EOF
77);
78 fi
69 cat <<EOF79 cat <<EOF
70Usage: $0 [OPTIONS]80Usage: $0 [OPTIONS]
71 --no-defaults Don't read the system defaults file81 --no-defaults Don't read the system defaults file
@@ -89,6 +99,7 @@
89 starting the server99 starting the server
90 --numa-interleave Run mysqld with its memory interleaved100 --numa-interleave Run mysqld with its memory interleaved
91 on all NUMA nodes101 on all NUMA nodes
102${thp_usage}
92103
93All other options are passed to the mysqld program.104All other options are passed to the mysqld program.
94105
@@ -233,6 +244,7 @@
233 --open-files-limit=*) open_files="$val" ;;244 --open-files-limit=*) open_files="$val" ;;
234 --open_files_limit=*) open_files="$val" ;;245 --open_files_limit=*) open_files="$val" ;;
235 --skip-kill-mysqld*) KILL_MYSQLD=0 ;;246 --skip-kill-mysqld*) KILL_MYSQLD=0 ;;
247 --thp-setting=*) thp_setting="$val" ;;
236 --syslog) want_syslog=1 ;;248 --syslog) want_syslog=1 ;;
237 --skip-syslog) want_syslog=0 ;;249 --skip-syslog) want_syslog=0 ;;
238 --syslog-tag=*) syslog_tag="$val" ;;250 --syslog-tag=*) syslog_tag="$val" ;;
@@ -799,6 +811,53 @@
799 exit 1811 exit 1
800fi812fi
801813
814# If thp-setting is specified, check to see if thp is supported
815# on this kernel and clear the value if it isn't
816if [ -n "$thp_setting" ] && [ ! -f /sys/kernel/mm/transparent_hugepage/enabled ]
817then
818 log_notice "Transparent huge pages is not supported on this system, ignoring thp-setting."
819 thp_setting=
820fi
821
822# Change transparent huge pages setting if thp-setting option specified
823if [ -n "$thp_setting" ]
824then
825 if [ $(id -u) -ne 0 ]; then
826 log_error "mysqld_safe must be run as root for setting transparent huge pages!"
827 exit 1
828 elif [ $thp_setting != "always" -a $thp_setting != "madvise" -a $thp_setting != "never" ]; then
829 log_error "Invalid value for thp-setting=$thp_setting in config file. Valid values are: always, madvise or never"
830 exit 1
831 else
832 if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then
833 CONTENT_THP=$(cat /sys/kernel/mm/transparent_hugepage/enabled)
834 STATUS_THP=0
835 set +e
836 STATUS_THP=$(echo $CONTENT_THP | grep -cv "\[${thp_setting}\]")
837 set -e
838 fi
839 if [ $STATUS_THP -eq 0 ]; then
840 log_notice "Transparent huge pages are already set to: ${thp_setting}."
841 else
842 if [ -f /sys/kernel/mm/transparent_hugepage/defrag ]; then
843 echo $thp_setting > /sys/kernel/mm/transparent_hugepage/defrag
844 if [ $? -ne 0 ]; then
845 log_error "Error setting transparent huge pages to: ${thp_setting}."
846 exit 1
847 fi
848 fi
849 if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then
850 echo $thp_setting > /sys/kernel/mm/transparent_hugepage/enabled
851 if [ $? -ne 0 ]; then
852 log_error "Error setting transparent huge pages to: ${thp_setting}."
853 exit 1
854 fi
855 fi
856 log_notice "Successfuly set transparent huge pages to: ${thp_setting}."
857 fi
858 fi
859fi
860
802#861#
803# Uncomment the following lines if you want all tables to be automatically862# Uncomment the following lines if you want all tables to be automatically
804# checked and repaired during startup. You should add sensible key_buffer863# checked and repaired during startup. You should add sensible key_buffer
805864
=== added file 'scripts/ps_tokudb_admin.sh'
--- scripts/ps_tokudb_admin.sh 1970-01-01 00:00:00 +0000
+++ scripts/ps_tokudb_admin.sh 2015-01-23 07:50:01 +0000
@@ -0,0 +1,244 @@
1#!/bin/bash
2#
3# Script for installing TokuDB plugin in Percona Server
4#
5set -u
6
7# Examine parameters
8# default user
9USER="root"
10# default pass
11PASSWORD=""
12SOCKET=""
13HOST=""
14PORT=""
15STATUS_THP_SYSTEM=0
16STATUS_THP_MYCNF=0
17STATUS_PLUGIN=0
18ENABLE=0
19DISABLE=0
20MYCNF_LOCATION=
21MYSQLD_SAFE_STATUS=0
22
23# Check if we have a functional getopt(1)
24if ! getopt --test
25 then
26 go_out="$(getopt --options=u:p::S:h:P:ed \
27 --longoptions=user:,password::,socket:,host:,port:,enable,disable,help \
28 --name="$(basename "$0")" -- "$@")"
29 test $? -eq 0 || exit 1
30 eval set -- $go_out
31fi
32
33for arg
34do
35 case "$arg" in
36 -- ) shift; break;;
37 -u | --user )
38 USER="$2"
39 shift 2
40 ;;
41 -p | --password )
42 case "$2" in
43 "")
44 read -s -p "Enter password:" INPUT_PASS
45 PASSWORD="-p$INPUT_PASS"
46 printf "\n\n"
47 ;;
48 *)
49 PASSWORD="-p$2"
50 ;;
51 esac
52 shift 2
53 ;;
54 -S | --socket )
55 SOCKET="-S $2"
56 shift 2
57 ;;
58 -h | --host )
59 HOST="-h $2"
60 shift 2
61 ;;
62 -P | --port )
63 PORT="-P $2"
64 shift 2
65 ;;
66 -e | --enable )
67 shift
68 ENABLE=1
69 ;;
70 -d | --disable )
71 shift
72 DISABLE=1
73 ;;
74 --help )
75 printf "This script is used for installing and uninstalling TokuDB plugin for Percona Server 5.6.\n"
76 printf "If transparent huge pages are enabled on the system it adds thp-setting=never option to my.cnf\n"
77 printf "to disable it on runtime.\n\n"
78 printf "Valid options are:\n"
79 printf " --user=user_name, -u user_name\t mysql admin username\n"
80 printf " --password[=password], -p[password]\t mysql admin password (on empty will prompt to enter)\n"
81 printf " --socket=path, -S path\t\t the socket file to use for connection\n"
82 printf " --host=host_name, -h host_name\t connect to given host\n"
83 printf " --port=port_num, -P port_num\t\t port number to use for connection\n"
84 printf " --enable, -e\t\t\t\t enable TokuDB plugin and disable transparent huge pages in my.cnf\n"
85 printf " --disable, d\t\t\t\t disable TokuDB plugin and remove thp-setting=never option in my.cnf\n"
86 printf " --help\t\t\t\t show this help\n\n"
87 printf "For TokuDB requirements and manual steps for installation please visit this webpage:\n"
88 printf "http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_installation.html\n\n"
89 exit 0
90 ;;
91 esac
92done
93
94# Make sure only root can run this script
95if [ $(id -u) -ne 0 ]; then
96 echo "This script must be run as root!" 1>&2
97 exit 1
98fi
99
100if [ $ENABLE = 1 -a $DISABLE = 1 ]; then
101 printf "Only --enable OR --disable can be specified - not both!\n"
102 exit 1
103elif [ $ENABLE = 0 -a $DISABLE = 0 ]; then
104 printf "You should specify --enable or --disable option. Use --help for printing options.\n"
105 exit 1
106fi
107
108# Check transparent huge pages status on the system
109printf "Checking transparent huge pages status on the system...\n"
110if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then
111 CONTENT_TRANSHP=$(</sys/kernel/mm/transparent_hugepage/enabled)
112 STATUS_THP_SYSTEM=$(echo $CONTENT_TRANSHP | grep -cv '\[never\]')
113fi
114if [ $STATUS_THP_SYSTEM = 0 ]; then
115 printf ">> Transparent huge pages are currently disabled on the system.\n\n"
116else
117 printf ">> Transparent huge pages are enabled (should be disabled).\n\n"
118fi
119
120# Check thp-setting=never option in my.cnf
121printf "Checking if thp-setting=never option is already set in config file...\n"
122STATUS_THP_MYCNF=$(my_print_defaults server mysqld mysqld_safe|grep -c thp-setting=never)
123if [ $STATUS_THP_MYCNF = 0 ]; then
124 printf ">> Option thp-setting=never is not set in the config file.\n"
125 printf ">> (needed only if THP is not disabled permanently on the system)\n\n"
126else
127 printf ">> Option thp-setting=never is set in the config file.\n\n"
128fi
129
130# Check location of my.cnf
131if [ -f /etc/my.cnf ]; then
132 MYCNF_LOCATION=/etc/my.cnf
133elif [ -f /etc/mysql/my.cnf ]; then
134 MYCNF_LOCATION=/etc/mysql/my.cnf
135elif [ -f /usr/etc/my.cnf ]; then
136 MYCNF_LOCATION=/usr/etc/my.cnf
137else
138 if [ -d /etc/mysql ]; then
139 MYCNF_LOCATION=/etc/mysql/my.cnf
140 else
141 MYCNF_LOCATION=/etc/my.cnf
142 fi
143 echo -n "" >> ${MYCNF_LOCATION}
144fi
145
146# Check TokuDB plugin status
147printf "Checking TokuDB plugin status...\n"
148LIST_ENGINE=$(mysql -e "show plugins;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null)
149if [ $? -ne 0 ]; then
150 printf ">> Error checking TokuDB plugin status! Please check username, password and other options...\n";
151 exit 1
152fi
153STATUS_PLUGIN=$(echo "$LIST_ENGINE" | grep -c "TokuDB")
154if [ $STATUS_PLUGIN = 0 ]; then
155 printf ">> TokuDB plugin is not installed.\n\n"
156elif [ $STATUS_PLUGIN = 7 ]; then
157 printf ">> TokuDB plugin is installed.\n\n"
158else
159 printf ">> TokuDB plugin is partially installed. Please cleanup manually.\n\n"
160 exit 1
161fi
162
163# Disable transparent huge pages in the current session so
164# that the plugin can be installed without restarting PS
165if [ $ENABLE = 1 -a $STATUS_THP_SYSTEM = 1 ]; then
166 printf "Disabling transparent huge pages for the current session...\n"
167 if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
168 echo never > /sys/kernel/mm/transparent_hugepage/defrag
169 fi
170 if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
171 echo never > /sys/kernel/mm/transparent_hugepage/enabled
172 fi
173 if [ $? -eq 0 ]; then
174 printf ">> Successfuly disabled transparent huge pages for this session.\n\n"
175 else
176 printf ">> Error disabling transparent huge pages for this session.\n\n"
177 exit 1
178 fi
179fi
180
181# Add option to disable transparent huge pages into my.cnf
182if [ $ENABLE = 1 -a $STATUS_THP_MYCNF = 0 ]; then
183 printf "Adding thp-setting=never option into $MYCNF_LOCATION\n"
184 MYSQLD_SAFE_STATUS=$(grep -c "^\[mysqld_safe\]$" $MYCNF_LOCATION)
185 if [ $MYSQLD_SAFE_STATUS = 0 ]; then
186 echo -e "\n[mysqld_safe]\nthp-setting=never" >> $MYCNF_LOCATION
187 else
188 sed -i '/^\[mysqld_safe\]$/a thp-setting=never' $MYCNF_LOCATION
189 fi
190 if [ $? -eq 0 ]; then
191 printf ">> Successfuly added thp-setting=never option into $MYCNF_LOCATION\n\n";
192 else
193 printf ">> Error adding thp-setting=never option into $MYCNF_LOCATION\n\n";
194 exit 1
195 fi
196fi
197
198# Remove option for disabling transparent huge pages from my.cnf
199if [ $DISABLE = 1 -a $STATUS_THP_MYCNF = 1 ]; then
200 printf "Removing thp-setting=never option from $MYCNF_LOCATION\n"
201 sed -i '/^thp-setting=never$/d' $MYCNF_LOCATION
202 if [ $? -eq 0 ]; then
203 printf ">> Successfuly removed thp-setting=never option from $MYCNF_LOCATION\n\n";
204 else
205 printf ">> Error removing thp-setting=never option from $MYCNF_LOCATION\n\n";
206 exit 1
207 fi
208fi
209
210# Installing TokuDB plugin
211if [ $ENABLE = 1 -a $STATUS_PLUGIN = 0 ]; then
212 printf "Installing TokuDB engine...\n"
213 mysql -e "INSTALL PLUGIN tokudb SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
214 mysql -e "INSTALL PLUGIN tokudb_file_map SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
215 mysql -e "INSTALL PLUGIN tokudb_fractal_tree_info SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
216 mysql -e "INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
217 mysql -e "INSTALL PLUGIN tokudb_trx SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
218 mysql -e "INSTALL PLUGIN tokudb_locks SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
219 mysql -e "INSTALL PLUGIN tokudb_lock_waits SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null
220 if [ $? -eq 0 ]; then
221 printf ">> Successfuly installed TokuDB plugin.\n\n"
222 else
223 printf ">> Error installing TokuDB plugin. Please check error log.\n\n"
224 exit 1
225 fi
226fi
227
228# Uninstalling TokuDB plugin
229if [ $DISABLE = 1 -a $STATUS_PLUGIN = 7 ]; then
230 printf "Uninstalling TokuDB plugin...\n"
231 mysql -e "UNINSTALL PLUGIN tokudb;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
232 mysql -e "UNINSTALL PLUGIN tokudb_file_map;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
233 mysql -e "UNINSTALL PLUGIN tokudb_fractal_tree_info;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
234 mysql -e "UNINSTALL PLUGIN tokudb_fractal_tree_block_map;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
235 mysql -e "UNINSTALL PLUGIN tokudb_trx;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
236 mysql -e "UNINSTALL PLUGIN tokudb_locks;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
237 mysql -e "UNINSTALL PLUGIN tokudb_lock_waits;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null
238 if [ $? -eq 0 ]; then
239 printf ">> Successfuly uninstalled TokuDB plugin.\n\n"
240 else
241 printf ">> Error uninstalling TokuDB plugin. Please check error log.\n\n"
242 exit 1
243 fi
244fi

Subscribers

People subscribed via source and target branches