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
1=== modified file 'build-ps/debian/percona-server-tokudb-5.6.files'
2--- build-ps/debian/percona-server-tokudb-5.6.files 2014-09-27 13:49:22 +0000
3+++ build-ps/debian/percona-server-tokudb-5.6.files 2015-01-23 07:50:01 +0000
4@@ -1,3 +1,4 @@
5 usr/lib/mysql/plugin/ha_tokudb.so
6 usr/lib/mysql/plugin/debug/ha_tokudb.so
7 usr/bin/tokuftdump
8+usr/bin/ps_tokudb_admin
9
10=== modified file 'build-ps/debian/percona-server-tokudb-5.6.postinst'
11--- build-ps/debian/percona-server-tokudb-5.6.postinst 2014-05-20 21:04:08 +0000
12+++ build-ps/debian/percona-server-tokudb-5.6.postinst 2015-01-23 07:50:01 +0000
13@@ -3,15 +3,10 @@
14 # Some postinstall info about TokuDB
15 if [ -z "$2" ]; then
16 echo -e "\n\n * This release of Percona Server is distributed with TokuDB storage engine."
17- echo -e " * Run the following commands to enable the TokuDB storage engine in Percona Server:\n"
18- echo -e "\tmysql -e \"INSTALL PLUGIN tokudb SONAME 'ha_tokudb.so';\""
19- echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_file_map SONAME 'ha_tokudb.so';\""
20- echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_fractal_tree_info SONAME 'ha_tokudb.so';\""
21- echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME 'ha_tokudb.so';\""
22- echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_trx SONAME 'ha_tokudb.so';\""
23- echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_locks SONAME 'ha_tokudb.so';\""
24- echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_lock_waits SONAME 'ha_tokudb.so';\""
25- echo -e "\n * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_intro.html for more details\n\n"
26+ echo -e " * Run the following script to enable the TokuDB storage engine in Percona Server:\n"
27+ echo -e "\tps_tokudb_admin --enable -u <mysql_admin_user> -p[mysql_admin_pass] [-S <socket>] [-h <host> -P <port>]\n"
28+ echo -e " * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_installation.html for more installation details\n"
29+ echo -e " * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_intro.html for an introduction to TokuDB\n\n"
30 fi
31
32 #DEBHELPER#
33
34=== modified file 'build-ps/percona-server.spec'
35--- build-ps/percona-server.spec 2015-01-13 14:38:41 +0000
36+++ build-ps/percona-server.spec 2015-01-23 07:50:01 +0000
37@@ -651,6 +651,10 @@
38 %if 0%{?systemd}
39 rm -rf $RBR%{_sysconfdir}/init.d/mysql
40 %endif
41+# Not needed if TokuDB package is not created
42+%if ! %{with tokudb}
43+rm -rf $RBR%{_bindir}/ps_tokudb_admin
44+%endif
45
46 ##############################################################################
47 # Post processing actions, i.e. when installed
48@@ -1094,20 +1098,11 @@
49 %post -n Percona-Server-tokudb%{product_suffix}
50
51 if [ $1 -eq 1 ] ; then
52- echo ""
53- echo "* This release of Percona Server is distributed with TokuDB storage engine."
54- echo "* Run the following commands to enable the TokuDB storage engine in Percona Server:"
55- echo ""
56- echo "mysql -e \"INSTALL PLUGIN tokudb SONAME 'ha_tokudb.so';\""
57- echo "mysql -e \"INSTALL PLUGIN tokudb_file_map SONAME 'ha_tokudb.so';\""
58- echo "mysql -e \"INSTALL PLUGIN tokudb_fractal_tree_info SONAME 'ha_tokudb.so';\""
59- echo "mysql -e \"INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME 'ha_tokudb.so';\""
60- echo "mysql -e \"INSTALL PLUGIN tokudb_trx SONAME 'ha_tokudb.so';\""
61- echo "mysql -e \"INSTALL PLUGIN tokudb_locks SONAME 'ha_tokudb.so';\""
62- echo "mysql -e \"INSTALL PLUGIN tokudb_lock_waits SONAME 'ha_tokudb.so';\""
63- echo ""
64- echo "* See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_intro.html for more details"
65- echo ""
66+ echo -e "\n\n * This release of Percona Server is distributed with TokuDB storage engine."
67+ echo -e " * Run the following script to enable the TokuDB storage engine in Percona Server:\n"
68+ echo -e "\tps_tokudb_admin --enable -u <mysql_admin_user> -p[mysql_admin_pass] [-S <socket>] [-h <host> -P <port>]\n"
69+ echo -e " * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_installation.html for more installation details\n"
70+ echo -e " * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_intro.html for an introduction to TokuDB\n\n"
71 fi
72 # ----------------------------------------------------------------------------
73 %endif
74@@ -1375,6 +1370,7 @@
75 %{_bindir}/tokuftdump
76 %{_libdir}/mysql/plugin/ha_tokudb.so
77 %attr(755, root, root) %{_libdir}/mysql/plugin/debug/ha_tokudb.so
78+%attr(755, root, root) %{_bindir}/ps_tokudb_admin
79 %endif
80
81 # ----------------------------------------------------------------------------
82
83=== modified file 'scripts/CMakeLists.txt'
84--- scripts/CMakeLists.txt 2014-12-16 06:00:17 +0000
85+++ scripts/CMakeLists.txt 2015-01-23 07:50:01 +0000
86@@ -339,6 +339,7 @@
87 mysqldumpslow
88 mysqld_multi
89 mysqld_safe
90+ ps_tokudb_admin
91 )
92 FOREACH(file ${BIN_SCRIPTS})
93 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh)
94
95=== modified file 'scripts/mysqld_safe.sh'
96--- scripts/mysqld_safe.sh 2014-12-01 07:53:48 +0000
97+++ scripts/mysqld_safe.sh 2015-01-23 07:50:01 +0000
98@@ -20,6 +20,8 @@
99 load_jemalloc=1
100 flush_caches=0
101 numa_interleave=0
102+# Change (disable) transparent huge pages (TokuDB requirement)
103+thp_setting=
104
105 # Initial logging status: error log is not open, and not using syslog
106 logging=init
107@@ -66,6 +68,14 @@
108 esac
109
110 usage () {
111+ thp_usage=""
112+ if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then
113+ thp_usage=$(cat <<'EOF'
114+ --thp-setting=SETTING Change transparent huge pages setting
115+ on the system before starting mysqld
116+EOF
117+);
118+ fi
119 cat <<EOF
120 Usage: $0 [OPTIONS]
121 --no-defaults Don't read the system defaults file
122@@ -89,6 +99,7 @@
123 starting the server
124 --numa-interleave Run mysqld with its memory interleaved
125 on all NUMA nodes
126+${thp_usage}
127
128 All other options are passed to the mysqld program.
129
130@@ -233,6 +244,7 @@
131 --open-files-limit=*) open_files="$val" ;;
132 --open_files_limit=*) open_files="$val" ;;
133 --skip-kill-mysqld*) KILL_MYSQLD=0 ;;
134+ --thp-setting=*) thp_setting="$val" ;;
135 --syslog) want_syslog=1 ;;
136 --skip-syslog) want_syslog=0 ;;
137 --syslog-tag=*) syslog_tag="$val" ;;
138@@ -799,6 +811,53 @@
139 exit 1
140 fi
141
142+# If thp-setting is specified, check to see if thp is supported
143+# on this kernel and clear the value if it isn't
144+if [ -n "$thp_setting" ] && [ ! -f /sys/kernel/mm/transparent_hugepage/enabled ]
145+then
146+ log_notice "Transparent huge pages is not supported on this system, ignoring thp-setting."
147+ thp_setting=
148+fi
149+
150+# Change transparent huge pages setting if thp-setting option specified
151+if [ -n "$thp_setting" ]
152+then
153+ if [ $(id -u) -ne 0 ]; then
154+ log_error "mysqld_safe must be run as root for setting transparent huge pages!"
155+ exit 1
156+ elif [ $thp_setting != "always" -a $thp_setting != "madvise" -a $thp_setting != "never" ]; then
157+ log_error "Invalid value for thp-setting=$thp_setting in config file. Valid values are: always, madvise or never"
158+ exit 1
159+ else
160+ if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then
161+ CONTENT_THP=$(cat /sys/kernel/mm/transparent_hugepage/enabled)
162+ STATUS_THP=0
163+ set +e
164+ STATUS_THP=$(echo $CONTENT_THP | grep -cv "\[${thp_setting}\]")
165+ set -e
166+ fi
167+ if [ $STATUS_THP -eq 0 ]; then
168+ log_notice "Transparent huge pages are already set to: ${thp_setting}."
169+ else
170+ if [ -f /sys/kernel/mm/transparent_hugepage/defrag ]; then
171+ echo $thp_setting > /sys/kernel/mm/transparent_hugepage/defrag
172+ if [ $? -ne 0 ]; then
173+ log_error "Error setting transparent huge pages to: ${thp_setting}."
174+ exit 1
175+ fi
176+ fi
177+ if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then
178+ echo $thp_setting > /sys/kernel/mm/transparent_hugepage/enabled
179+ if [ $? -ne 0 ]; then
180+ log_error "Error setting transparent huge pages to: ${thp_setting}."
181+ exit 1
182+ fi
183+ fi
184+ log_notice "Successfuly set transparent huge pages to: ${thp_setting}."
185+ fi
186+ fi
187+fi
188+
189 #
190 # Uncomment the following lines if you want all tables to be automatically
191 # checked and repaired during startup. You should add sensible key_buffer
192
193=== added file 'scripts/ps_tokudb_admin.sh'
194--- scripts/ps_tokudb_admin.sh 1970-01-01 00:00:00 +0000
195+++ scripts/ps_tokudb_admin.sh 2015-01-23 07:50:01 +0000
196@@ -0,0 +1,244 @@
197+#!/bin/bash
198+#
199+# Script for installing TokuDB plugin in Percona Server
200+#
201+set -u
202+
203+# Examine parameters
204+# default user
205+USER="root"
206+# default pass
207+PASSWORD=""
208+SOCKET=""
209+HOST=""
210+PORT=""
211+STATUS_THP_SYSTEM=0
212+STATUS_THP_MYCNF=0
213+STATUS_PLUGIN=0
214+ENABLE=0
215+DISABLE=0
216+MYCNF_LOCATION=
217+MYSQLD_SAFE_STATUS=0
218+
219+# Check if we have a functional getopt(1)
220+if ! getopt --test
221+ then
222+ go_out="$(getopt --options=u:p::S:h:P:ed \
223+ --longoptions=user:,password::,socket:,host:,port:,enable,disable,help \
224+ --name="$(basename "$0")" -- "$@")"
225+ test $? -eq 0 || exit 1
226+ eval set -- $go_out
227+fi
228+
229+for arg
230+do
231+ case "$arg" in
232+ -- ) shift; break;;
233+ -u | --user )
234+ USER="$2"
235+ shift 2
236+ ;;
237+ -p | --password )
238+ case "$2" in
239+ "")
240+ read -s -p "Enter password:" INPUT_PASS
241+ PASSWORD="-p$INPUT_PASS"
242+ printf "\n\n"
243+ ;;
244+ *)
245+ PASSWORD="-p$2"
246+ ;;
247+ esac
248+ shift 2
249+ ;;
250+ -S | --socket )
251+ SOCKET="-S $2"
252+ shift 2
253+ ;;
254+ -h | --host )
255+ HOST="-h $2"
256+ shift 2
257+ ;;
258+ -P | --port )
259+ PORT="-P $2"
260+ shift 2
261+ ;;
262+ -e | --enable )
263+ shift
264+ ENABLE=1
265+ ;;
266+ -d | --disable )
267+ shift
268+ DISABLE=1
269+ ;;
270+ --help )
271+ printf "This script is used for installing and uninstalling TokuDB plugin for Percona Server 5.6.\n"
272+ printf "If transparent huge pages are enabled on the system it adds thp-setting=never option to my.cnf\n"
273+ printf "to disable it on runtime.\n\n"
274+ printf "Valid options are:\n"
275+ printf " --user=user_name, -u user_name\t mysql admin username\n"
276+ printf " --password[=password], -p[password]\t mysql admin password (on empty will prompt to enter)\n"
277+ printf " --socket=path, -S path\t\t the socket file to use for connection\n"
278+ printf " --host=host_name, -h host_name\t connect to given host\n"
279+ printf " --port=port_num, -P port_num\t\t port number to use for connection\n"
280+ printf " --enable, -e\t\t\t\t enable TokuDB plugin and disable transparent huge pages in my.cnf\n"
281+ printf " --disable, d\t\t\t\t disable TokuDB plugin and remove thp-setting=never option in my.cnf\n"
282+ printf " --help\t\t\t\t show this help\n\n"
283+ printf "For TokuDB requirements and manual steps for installation please visit this webpage:\n"
284+ printf "http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_installation.html\n\n"
285+ exit 0
286+ ;;
287+ esac
288+done
289+
290+# Make sure only root can run this script
291+if [ $(id -u) -ne 0 ]; then
292+ echo "This script must be run as root!" 1>&2
293+ exit 1
294+fi
295+
296+if [ $ENABLE = 1 -a $DISABLE = 1 ]; then
297+ printf "Only --enable OR --disable can be specified - not both!\n"
298+ exit 1
299+elif [ $ENABLE = 0 -a $DISABLE = 0 ]; then
300+ printf "You should specify --enable or --disable option. Use --help for printing options.\n"
301+ exit 1
302+fi
303+
304+# Check transparent huge pages status on the system
305+printf "Checking transparent huge pages status on the system...\n"
306+if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then
307+ CONTENT_TRANSHP=$(</sys/kernel/mm/transparent_hugepage/enabled)
308+ STATUS_THP_SYSTEM=$(echo $CONTENT_TRANSHP | grep -cv '\[never\]')
309+fi
310+if [ $STATUS_THP_SYSTEM = 0 ]; then
311+ printf ">> Transparent huge pages are currently disabled on the system.\n\n"
312+else
313+ printf ">> Transparent huge pages are enabled (should be disabled).\n\n"
314+fi
315+
316+# Check thp-setting=never option in my.cnf
317+printf "Checking if thp-setting=never option is already set in config file...\n"
318+STATUS_THP_MYCNF=$(my_print_defaults server mysqld mysqld_safe|grep -c thp-setting=never)
319+if [ $STATUS_THP_MYCNF = 0 ]; then
320+ printf ">> Option thp-setting=never is not set in the config file.\n"
321+ printf ">> (needed only if THP is not disabled permanently on the system)\n\n"
322+else
323+ printf ">> Option thp-setting=never is set in the config file.\n\n"
324+fi
325+
326+# Check location of my.cnf
327+if [ -f /etc/my.cnf ]; then
328+ MYCNF_LOCATION=/etc/my.cnf
329+elif [ -f /etc/mysql/my.cnf ]; then
330+ MYCNF_LOCATION=/etc/mysql/my.cnf
331+elif [ -f /usr/etc/my.cnf ]; then
332+ MYCNF_LOCATION=/usr/etc/my.cnf
333+else
334+ if [ -d /etc/mysql ]; then
335+ MYCNF_LOCATION=/etc/mysql/my.cnf
336+ else
337+ MYCNF_LOCATION=/etc/my.cnf
338+ fi
339+ echo -n "" >> ${MYCNF_LOCATION}
340+fi
341+
342+# Check TokuDB plugin status
343+printf "Checking TokuDB plugin status...\n"
344+LIST_ENGINE=$(mysql -e "show plugins;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null)
345+if [ $? -ne 0 ]; then
346+ printf ">> Error checking TokuDB plugin status! Please check username, password and other options...\n";
347+ exit 1
348+fi
349+STATUS_PLUGIN=$(echo "$LIST_ENGINE" | grep -c "TokuDB")
350+if [ $STATUS_PLUGIN = 0 ]; then
351+ printf ">> TokuDB plugin is not installed.\n\n"
352+elif [ $STATUS_PLUGIN = 7 ]; then
353+ printf ">> TokuDB plugin is installed.\n\n"
354+else
355+ printf ">> TokuDB plugin is partially installed. Please cleanup manually.\n\n"
356+ exit 1
357+fi
358+
359+# Disable transparent huge pages in the current session so
360+# that the plugin can be installed without restarting PS
361+if [ $ENABLE = 1 -a $STATUS_THP_SYSTEM = 1 ]; then
362+ printf "Disabling transparent huge pages for the current session...\n"
363+ if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
364+ echo never > /sys/kernel/mm/transparent_hugepage/defrag
365+ fi
366+ if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
367+ echo never > /sys/kernel/mm/transparent_hugepage/enabled
368+ fi
369+ if [ $? -eq 0 ]; then
370+ printf ">> Successfuly disabled transparent huge pages for this session.\n\n"
371+ else
372+ printf ">> Error disabling transparent huge pages for this session.\n\n"
373+ exit 1
374+ fi
375+fi
376+
377+# Add option to disable transparent huge pages into my.cnf
378+if [ $ENABLE = 1 -a $STATUS_THP_MYCNF = 0 ]; then
379+ printf "Adding thp-setting=never option into $MYCNF_LOCATION\n"
380+ MYSQLD_SAFE_STATUS=$(grep -c "^\[mysqld_safe\]$" $MYCNF_LOCATION)
381+ if [ $MYSQLD_SAFE_STATUS = 0 ]; then
382+ echo -e "\n[mysqld_safe]\nthp-setting=never" >> $MYCNF_LOCATION
383+ else
384+ sed -i '/^\[mysqld_safe\]$/a thp-setting=never' $MYCNF_LOCATION
385+ fi
386+ if [ $? -eq 0 ]; then
387+ printf ">> Successfuly added thp-setting=never option into $MYCNF_LOCATION\n\n";
388+ else
389+ printf ">> Error adding thp-setting=never option into $MYCNF_LOCATION\n\n";
390+ exit 1
391+ fi
392+fi
393+
394+# Remove option for disabling transparent huge pages from my.cnf
395+if [ $DISABLE = 1 -a $STATUS_THP_MYCNF = 1 ]; then
396+ printf "Removing thp-setting=never option from $MYCNF_LOCATION\n"
397+ sed -i '/^thp-setting=never$/d' $MYCNF_LOCATION
398+ if [ $? -eq 0 ]; then
399+ printf ">> Successfuly removed thp-setting=never option from $MYCNF_LOCATION\n\n";
400+ else
401+ printf ">> Error removing thp-setting=never option from $MYCNF_LOCATION\n\n";
402+ exit 1
403+ fi
404+fi
405+
406+# Installing TokuDB plugin
407+if [ $ENABLE = 1 -a $STATUS_PLUGIN = 0 ]; then
408+ printf "Installing TokuDB engine...\n"
409+ mysql -e "INSTALL PLUGIN tokudb SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
410+ mysql -e "INSTALL PLUGIN tokudb_file_map SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
411+ mysql -e "INSTALL PLUGIN tokudb_fractal_tree_info SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
412+ mysql -e "INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
413+ mysql -e "INSTALL PLUGIN tokudb_trx SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
414+ mysql -e "INSTALL PLUGIN tokudb_locks SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
415+ mysql -e "INSTALL PLUGIN tokudb_lock_waits SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null
416+ if [ $? -eq 0 ]; then
417+ printf ">> Successfuly installed TokuDB plugin.\n\n"
418+ else
419+ printf ">> Error installing TokuDB plugin. Please check error log.\n\n"
420+ exit 1
421+ fi
422+fi
423+
424+# Uninstalling TokuDB plugin
425+if [ $DISABLE = 1 -a $STATUS_PLUGIN = 7 ]; then
426+ printf "Uninstalling TokuDB plugin...\n"
427+ mysql -e "UNINSTALL PLUGIN tokudb;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
428+ mysql -e "UNINSTALL PLUGIN tokudb_file_map;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
429+ mysql -e "UNINSTALL PLUGIN tokudb_fractal_tree_info;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
430+ mysql -e "UNINSTALL PLUGIN tokudb_fractal_tree_block_map;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
431+ mysql -e "UNINSTALL PLUGIN tokudb_trx;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
432+ mysql -e "UNINSTALL PLUGIN tokudb_locks;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null &&
433+ mysql -e "UNINSTALL PLUGIN tokudb_lock_waits;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null
434+ if [ $? -eq 0 ]; then
435+ printf ">> Successfuly uninstalled TokuDB plugin.\n\n"
436+ else
437+ printf ">> Error uninstalling TokuDB plugin. Please check error log.\n\n"
438+ exit 1
439+ fi
440+fi

Subscribers

People subscribed via source and target branches