Merge lp:~tplavcic/percona-server/bld-212-5.6-tokudb into lp:percona-server/5.6
- bld-212-5.6-tokudb
- Merge into 5.6
Status: | Merged |
---|---|
Merged at revision: | 732 |
Proposed branch: | lp:~tplavcic/percona-server/bld-212-5.6-tokudb |
Merge into: | lp:percona-server/5.6 |
Diff against target: |
462 lines (+341/-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 (+266/-0) |
To merge this branch: | bzr merge lp:~tplavcic/percona-server/bld-212-5.6-tokudb |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
David Bennett (community) | Approve | ||
Laurynas Biveinis (community) | Approve | ||
Review via email: mp+247802@code.launchpad.net |
This proposal supersedes a proposal from 2015-01-15.
Commit message
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://
INSTALL
-------
[vagrant@
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_
| TokuDB_
| 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@
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.
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal | # |
Tomislav Plavcic (tplavcic) wrote : Posted in a previous version of this proposal | # |
Created some blueprint - please check.
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.
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.
David Bennett (dbpercona) wrote : Posted in a previous version of this proposal | # |
Regarding the INSTALL PLUGIN postinst message, perhaps we could add a manual installation instructions under /usr/share/
This way the postinst message would remain concise and the DBA would have access to the full instructions which we could update if needed.
David Bennett (dbpercona) wrote : Posted in a previous version of this proposal | # |
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://
This will be easier to maintain and provide us with a single point of maintenance.
Roel Van de Paar (roel11) wrote : Posted in a previous version of this proposal | # |
@David/@Tomislav - manual link sounds great/fine.
Roel Van de Paar (roel11) wrote : Posted in a previous version of this proposal | # |
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_
+ echo -e " * See http://
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://
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"
Roel Van de Paar (roel11) wrote : Posted in a previous version of this proposal | # |
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_
+ echo -e " * See http://
+ echo -e " * See http://
Roel Van de Paar (roel11) wrote : Posted in a previous version of this proposal | # |
(There is a second newline in between the URL's should it look fairly clean/uncluttered)
Tomislav Plavcic (tplavcic) wrote : Posted in a previous version of this proposal | # |
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.
Roel Van de Paar (roel11) wrote : Posted in a previous version of this proposal | # |
I previously checked out the host etc. option addition, and - whilst not having tested it - the code looked good.
Roel Van de Paar (roel11) wrote : Posted in a previous version of this proposal | # |
Script should still be tested with new options + user/pwd etc.
Roel Van de Paar (roel11) wrote : Posted in a previous version of this proposal | # |
Btw, official release is on 28th
Tomislav Plavcic (tplavcic) wrote : Posted in a previous version of this proposal | # |
Changed postinst messages, script running parameters and usage info in mysqld_safe so resubmitting MP.
Testing has been done in BLD-212.
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
Looks good to me, but this should be reviewed by someone more involved with the task, e.g. David.
David Bennett (dbpercona) wrote : | # |
There is an issue in Jira BLD-246:
https:/
PZ discovered that is Percona Server is installed and running without jemalloc prior to the installation of TokuDB (along with jemalloc dependency) then ps_tokudb_admin fails to load the plugin.
The solution that PZ recommend is the safest way to handle it. Have ps_tokudb_admin check to see if mysqld is running without jemalloc underneath. If that condition is true, then stop prior to installation of the plug-in with a message indicating a restart is required.
During restart, the updated mysqld_safe will detect and load the underlying jemalloc automatically and the ps_tokudb_admin --enable can proceed.
There is a command in the Jira issue that will check for jemalloc running underneath mysqld:
grep -c jemalloc /proc/$(cat {path}/
If this returns 0 then the process needs to stop with the restart notification.
David Bennett (dbpercona) wrote : | # |
We need to address Jira BLD-246 then it's good.
Roel Van de Paar (roel11) wrote : | # |
Some ideas on extracting the path (if there are none yet); from ps output, or via mysqladmin, or is there are a better/more reliable way?
David Bennett (dbpercona) wrote : | # |
BLD-246 tested and closed looks good.
Preview Diff
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-29 14:13:34 +0000 | |||
4 | @@ -1,3 +1,4 @@ | |||
5 | 1 | usr/lib/mysql/plugin/ha_tokudb.so | 1 | usr/lib/mysql/plugin/ha_tokudb.so |
6 | 2 | usr/lib/mysql/plugin/debug/ha_tokudb.so | 2 | usr/lib/mysql/plugin/debug/ha_tokudb.so |
7 | 3 | usr/bin/tokuftdump | 3 | usr/bin/tokuftdump |
8 | 4 | usr/bin/ps_tokudb_admin | ||
9 | 4 | 5 | ||
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-29 14:13:34 +0000 | |||
13 | @@ -3,15 +3,10 @@ | |||
14 | 3 | # Some postinstall info about TokuDB | 3 | # Some postinstall info about TokuDB |
15 | 4 | if [ -z "$2" ]; then | 4 | if [ -z "$2" ]; then |
16 | 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." |
26 | 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" |
27 | 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" |
28 | 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" |
29 | 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" |
21 | 10 | echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME 'ha_tokudb.so';\"" | ||
22 | 11 | echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_trx SONAME 'ha_tokudb.so';\"" | ||
23 | 12 | echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_locks SONAME 'ha_tokudb.so';\"" | ||
24 | 13 | echo -e "\tmysql -e \"INSTALL PLUGIN tokudb_lock_waits SONAME 'ha_tokudb.so';\"" | ||
25 | 14 | echo -e "\n * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_intro.html for more details\n\n" | ||
30 | 15 | fi | 10 | fi |
31 | 16 | 11 | ||
32 | 17 | #DEBHELPER# | 12 | #DEBHELPER# |
33 | 18 | 13 | ||
34 | === modified file 'build-ps/percona-server.spec' | |||
35 | --- build-ps/percona-server.spec 2015-01-19 10:11:09 +0000 | |||
36 | +++ build-ps/percona-server.spec 2015-01-29 14:13:34 +0000 | |||
37 | @@ -651,6 +651,10 @@ | |||
38 | 651 | %if 0%{?systemd} | 651 | %if 0%{?systemd} |
39 | 652 | rm -rf $RBR%{_sysconfdir}/init.d/mysql | 652 | rm -rf $RBR%{_sysconfdir}/init.d/mysql |
40 | 653 | %endif | 653 | %endif |
41 | 654 | # Not needed if TokuDB package is not created | ||
42 | 655 | %if ! %{with tokudb} | ||
43 | 656 | rm -rf $RBR%{_bindir}/ps_tokudb_admin | ||
44 | 657 | %endif | ||
45 | 654 | 658 | ||
46 | 655 | ############################################################################## | 659 | ############################################################################## |
47 | 656 | # Post processing actions, i.e. when installed | 660 | # Post processing actions, i.e. when installed |
48 | @@ -1097,20 +1101,11 @@ | |||
49 | 1097 | %post -n Percona-Server-tokudb%{product_suffix} | 1101 | %post -n Percona-Server-tokudb%{product_suffix} |
50 | 1098 | 1102 | ||
51 | 1099 | if [ $1 -eq 1 ] ; then | 1103 | if [ $1 -eq 1 ] ; then |
66 | 1100 | echo "" | 1104 | echo -e "\n\n * This release of Percona Server is distributed with TokuDB storage engine." |
67 | 1101 | echo "* This release of Percona Server is distributed with TokuDB storage engine." | 1105 | echo -e " * Run the following script to enable the TokuDB storage engine in Percona Server:\n" |
68 | 1102 | echo "* Run the following commands to enable the TokuDB storage engine in Percona Server:" | 1106 | echo -e "\tps_tokudb_admin --enable -u <mysql_admin_user> -p[mysql_admin_pass] [-S <socket>] [-h <host> -P <port>]\n" |
69 | 1103 | echo "" | 1107 | echo -e " * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_installation.html for more installation details\n" |
70 | 1104 | echo "mysql -e \"INSTALL PLUGIN tokudb SONAME 'ha_tokudb.so';\"" | 1108 | echo -e " * See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_intro.html for an introduction to TokuDB\n\n" |
57 | 1105 | echo "mysql -e \"INSTALL PLUGIN tokudb_file_map SONAME 'ha_tokudb.so';\"" | ||
58 | 1106 | echo "mysql -e \"INSTALL PLUGIN tokudb_fractal_tree_info SONAME 'ha_tokudb.so';\"" | ||
59 | 1107 | echo "mysql -e \"INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME 'ha_tokudb.so';\"" | ||
60 | 1108 | echo "mysql -e \"INSTALL PLUGIN tokudb_trx SONAME 'ha_tokudb.so';\"" | ||
61 | 1109 | echo "mysql -e \"INSTALL PLUGIN tokudb_locks SONAME 'ha_tokudb.so';\"" | ||
62 | 1110 | echo "mysql -e \"INSTALL PLUGIN tokudb_lock_waits SONAME 'ha_tokudb.so';\"" | ||
63 | 1111 | echo "" | ||
64 | 1112 | echo "* See http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_intro.html for more details" | ||
65 | 1113 | echo "" | ||
71 | 1114 | fi | 1109 | fi |
72 | 1115 | # If upgrade is in question and the server was started before upgrade we need to start it | 1110 | # If upgrade is in question and the server was started before upgrade we need to start it |
73 | 1116 | # after upgrading TokuDB package and not before because TokuDB will fail on init | 1111 | # after upgrading TokuDB package and not before because TokuDB will fail on init |
74 | @@ -1412,6 +1407,7 @@ | |||
75 | 1412 | %{_bindir}/tokuftdump | 1407 | %{_bindir}/tokuftdump |
76 | 1413 | %{_libdir}/mysql/plugin/ha_tokudb.so | 1408 | %{_libdir}/mysql/plugin/ha_tokudb.so |
77 | 1414 | %attr(755, root, root) %{_libdir}/mysql/plugin/debug/ha_tokudb.so | 1409 | %attr(755, root, root) %{_libdir}/mysql/plugin/debug/ha_tokudb.so |
78 | 1410 | %attr(755, root, root) %{_bindir}/ps_tokudb_admin | ||
79 | 1415 | %endif | 1411 | %endif |
80 | 1416 | 1412 | ||
81 | 1417 | # ---------------------------------------------------------------------------- | 1413 | # ---------------------------------------------------------------------------- |
82 | 1418 | 1414 | ||
83 | === modified file 'scripts/CMakeLists.txt' | |||
84 | --- scripts/CMakeLists.txt 2014-12-16 06:00:17 +0000 | |||
85 | +++ scripts/CMakeLists.txt 2015-01-29 14:13:34 +0000 | |||
86 | @@ -339,6 +339,7 @@ | |||
87 | 339 | mysqldumpslow | 339 | mysqldumpslow |
88 | 340 | mysqld_multi | 340 | mysqld_multi |
89 | 341 | mysqld_safe | 341 | mysqld_safe |
90 | 342 | ps_tokudb_admin | ||
91 | 342 | ) | 343 | ) |
92 | 343 | FOREACH(file ${BIN_SCRIPTS}) | 344 | FOREACH(file ${BIN_SCRIPTS}) |
93 | 344 | IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh) | 345 | IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh) |
94 | 345 | 346 | ||
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-29 14:13:34 +0000 | |||
98 | @@ -20,6 +20,8 @@ | |||
99 | 20 | load_jemalloc=1 | 20 | load_jemalloc=1 |
100 | 21 | flush_caches=0 | 21 | flush_caches=0 |
101 | 22 | numa_interleave=0 | 22 | numa_interleave=0 |
102 | 23 | # Change (disable) transparent huge pages (TokuDB requirement) | ||
103 | 24 | thp_setting= | ||
104 | 23 | 25 | ||
105 | 24 | # Initial logging status: error log is not open, and not using syslog | 26 | # Initial logging status: error log is not open, and not using syslog |
106 | 25 | logging=init | 27 | logging=init |
107 | @@ -66,6 +68,14 @@ | |||
108 | 66 | esac | 68 | esac |
109 | 67 | 69 | ||
110 | 68 | usage () { | 70 | usage () { |
111 | 71 | thp_usage="" | ||
112 | 72 | if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then | ||
113 | 73 | thp_usage=$(cat <<'EOF' | ||
114 | 74 | --thp-setting=SETTING Change transparent huge pages setting | ||
115 | 75 | on the system before starting mysqld | ||
116 | 76 | EOF | ||
117 | 77 | ); | ||
118 | 78 | fi | ||
119 | 69 | cat <<EOF | 79 | cat <<EOF |
120 | 70 | Usage: $0 [OPTIONS] | 80 | Usage: $0 [OPTIONS] |
121 | 71 | --no-defaults Don't read the system defaults file | 81 | --no-defaults Don't read the system defaults file |
122 | @@ -89,6 +99,7 @@ | |||
123 | 89 | starting the server | 99 | starting the server |
124 | 90 | --numa-interleave Run mysqld with its memory interleaved | 100 | --numa-interleave Run mysqld with its memory interleaved |
125 | 91 | on all NUMA nodes | 101 | on all NUMA nodes |
126 | 102 | ${thp_usage} | ||
127 | 92 | 103 | ||
128 | 93 | All other options are passed to the mysqld program. | 104 | All other options are passed to the mysqld program. |
129 | 94 | 105 | ||
130 | @@ -233,6 +244,7 @@ | |||
131 | 233 | --open-files-limit=*) open_files="$val" ;; | 244 | --open-files-limit=*) open_files="$val" ;; |
132 | 234 | --open_files_limit=*) open_files="$val" ;; | 245 | --open_files_limit=*) open_files="$val" ;; |
133 | 235 | --skip-kill-mysqld*) KILL_MYSQLD=0 ;; | 246 | --skip-kill-mysqld*) KILL_MYSQLD=0 ;; |
134 | 247 | --thp-setting=*) thp_setting="$val" ;; | ||
135 | 236 | --syslog) want_syslog=1 ;; | 248 | --syslog) want_syslog=1 ;; |
136 | 237 | --skip-syslog) want_syslog=0 ;; | 249 | --skip-syslog) want_syslog=0 ;; |
137 | 238 | --syslog-tag=*) syslog_tag="$val" ;; | 250 | --syslog-tag=*) syslog_tag="$val" ;; |
138 | @@ -799,6 +811,53 @@ | |||
139 | 799 | exit 1 | 811 | exit 1 |
140 | 800 | fi | 812 | fi |
141 | 801 | 813 | ||
142 | 814 | # If thp-setting is specified, check to see if thp is supported | ||
143 | 815 | # on this kernel and clear the value if it isn't | ||
144 | 816 | if [ -n "$thp_setting" ] && [ ! -f /sys/kernel/mm/transparent_hugepage/enabled ] | ||
145 | 817 | then | ||
146 | 818 | log_notice "Transparent huge pages is not supported on this system, ignoring thp-setting." | ||
147 | 819 | thp_setting= | ||
148 | 820 | fi | ||
149 | 821 | |||
150 | 822 | # Change transparent huge pages setting if thp-setting option specified | ||
151 | 823 | if [ -n "$thp_setting" ] | ||
152 | 824 | then | ||
153 | 825 | if [ $(id -u) -ne 0 ]; then | ||
154 | 826 | log_error "mysqld_safe must be run as root for setting transparent huge pages!" | ||
155 | 827 | exit 1 | ||
156 | 828 | elif [ $thp_setting != "always" -a $thp_setting != "madvise" -a $thp_setting != "never" ]; then | ||
157 | 829 | log_error "Invalid value for thp-setting=$thp_setting in config file. Valid values are: always, madvise or never" | ||
158 | 830 | exit 1 | ||
159 | 831 | else | ||
160 | 832 | if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then | ||
161 | 833 | CONTENT_THP=$(cat /sys/kernel/mm/transparent_hugepage/enabled) | ||
162 | 834 | STATUS_THP=0 | ||
163 | 835 | set +e | ||
164 | 836 | STATUS_THP=$(echo $CONTENT_THP | grep -cv "\[${thp_setting}\]") | ||
165 | 837 | set -e | ||
166 | 838 | fi | ||
167 | 839 | if [ $STATUS_THP -eq 0 ]; then | ||
168 | 840 | log_notice "Transparent huge pages are already set to: ${thp_setting}." | ||
169 | 841 | else | ||
170 | 842 | if [ -f /sys/kernel/mm/transparent_hugepage/defrag ]; then | ||
171 | 843 | echo $thp_setting > /sys/kernel/mm/transparent_hugepage/defrag | ||
172 | 844 | if [ $? -ne 0 ]; then | ||
173 | 845 | log_error "Error setting transparent huge pages to: ${thp_setting}." | ||
174 | 846 | exit 1 | ||
175 | 847 | fi | ||
176 | 848 | fi | ||
177 | 849 | if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then | ||
178 | 850 | echo $thp_setting > /sys/kernel/mm/transparent_hugepage/enabled | ||
179 | 851 | if [ $? -ne 0 ]; then | ||
180 | 852 | log_error "Error setting transparent huge pages to: ${thp_setting}." | ||
181 | 853 | exit 1 | ||
182 | 854 | fi | ||
183 | 855 | fi | ||
184 | 856 | log_notice "Successfuly set transparent huge pages to: ${thp_setting}." | ||
185 | 857 | fi | ||
186 | 858 | fi | ||
187 | 859 | fi | ||
188 | 860 | |||
189 | 802 | # | 861 | # |
190 | 803 | # Uncomment the following lines if you want all tables to be automatically | 862 | # Uncomment the following lines if you want all tables to be automatically |
191 | 804 | # checked and repaired during startup. You should add sensible key_buffer | 863 | # checked and repaired during startup. You should add sensible key_buffer |
192 | 805 | 864 | ||
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-29 14:13:34 +0000 | |||
196 | @@ -0,0 +1,266 @@ | |||
197 | 1 | #!/bin/bash | ||
198 | 2 | # | ||
199 | 3 | # Script for installing TokuDB plugin in Percona Server | ||
200 | 4 | # | ||
201 | 5 | set -u | ||
202 | 6 | |||
203 | 7 | # Examine parameters | ||
204 | 8 | # default user | ||
205 | 9 | USER="root" | ||
206 | 10 | # default pass | ||
207 | 11 | PASSWORD="" | ||
208 | 12 | SOCKET="" | ||
209 | 13 | HOST="" | ||
210 | 14 | PORT="" | ||
211 | 15 | STATUS_THP_SYSTEM=0 | ||
212 | 16 | STATUS_THP_MYCNF=0 | ||
213 | 17 | STATUS_PLUGIN=0 | ||
214 | 18 | ENABLE=0 | ||
215 | 19 | DISABLE=0 | ||
216 | 20 | MYCNF_LOCATION= | ||
217 | 21 | MYSQLD_SAFE_STATUS=0 | ||
218 | 22 | |||
219 | 23 | # Check if we have a functional getopt(1) | ||
220 | 24 | if ! getopt --test | ||
221 | 25 | then | ||
222 | 26 | go_out="$(getopt --options=u:p::S:h:P:ed \ | ||
223 | 27 | --longoptions=user:,password::,socket:,host:,port:,enable,disable,help \ | ||
224 | 28 | --name="$(basename "$0")" -- "$@")" | ||
225 | 29 | test $? -eq 0 || exit 1 | ||
226 | 30 | eval set -- $go_out | ||
227 | 31 | fi | ||
228 | 32 | |||
229 | 33 | for arg | ||
230 | 34 | do | ||
231 | 35 | case "$arg" in | ||
232 | 36 | -- ) shift; break;; | ||
233 | 37 | -u | --user ) | ||
234 | 38 | USER="$2" | ||
235 | 39 | shift 2 | ||
236 | 40 | ;; | ||
237 | 41 | -p | --password ) | ||
238 | 42 | case "$2" in | ||
239 | 43 | "") | ||
240 | 44 | read -s -p "Enter password:" INPUT_PASS | ||
241 | 45 | if [ -z "$INPUT_PASS" ]; then | ||
242 | 46 | PASSWORD="" | ||
243 | 47 | printf "\nContinuing without password...\n"; | ||
244 | 48 | else | ||
245 | 49 | PASSWORD="-p$INPUT_PASS" | ||
246 | 50 | fi | ||
247 | 51 | printf "\n\n" | ||
248 | 52 | ;; | ||
249 | 53 | *) | ||
250 | 54 | PASSWORD="-p$2" | ||
251 | 55 | ;; | ||
252 | 56 | esac | ||
253 | 57 | shift 2 | ||
254 | 58 | ;; | ||
255 | 59 | -S | --socket ) | ||
256 | 60 | SOCKET="-S $2" | ||
257 | 61 | shift 2 | ||
258 | 62 | ;; | ||
259 | 63 | -h | --host ) | ||
260 | 64 | HOST="-h $2" | ||
261 | 65 | shift 2 | ||
262 | 66 | ;; | ||
263 | 67 | -P | --port ) | ||
264 | 68 | PORT="-P $2" | ||
265 | 69 | shift 2 | ||
266 | 70 | ;; | ||
267 | 71 | -e | --enable ) | ||
268 | 72 | shift | ||
269 | 73 | ENABLE=1 | ||
270 | 74 | ;; | ||
271 | 75 | -d | --disable ) | ||
272 | 76 | shift | ||
273 | 77 | DISABLE=1 | ||
274 | 78 | ;; | ||
275 | 79 | --help ) | ||
276 | 80 | printf "This script is used for installing and uninstalling TokuDB plugin for Percona Server 5.6.\n" | ||
277 | 81 | printf "If transparent huge pages are enabled on the system it adds thp-setting=never option to my.cnf\n" | ||
278 | 82 | printf "to disable it on runtime.\n\n" | ||
279 | 83 | printf "Valid options are:\n" | ||
280 | 84 | printf " --user=user_name, -u user_name\t mysql admin username\n" | ||
281 | 85 | printf " --password[=password], -p[password]\t mysql admin password (on empty will prompt to enter)\n" | ||
282 | 86 | printf " --socket=path, -S path\t\t the socket file to use for connection\n" | ||
283 | 87 | printf " --host=host_name, -h host_name\t connect to given host\n" | ||
284 | 88 | printf " --port=port_num, -P port_num\t\t port number to use for connection\n" | ||
285 | 89 | printf " --enable, -e\t\t\t\t enable TokuDB plugin and disable transparent huge pages in my.cnf\n" | ||
286 | 90 | printf " --disable, d\t\t\t\t disable TokuDB plugin and remove thp-setting=never option in my.cnf\n" | ||
287 | 91 | printf " --help\t\t\t\t show this help\n\n" | ||
288 | 92 | printf "For TokuDB requirements and manual steps for installation please visit this webpage:\n" | ||
289 | 93 | printf "http://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_installation.html\n\n" | ||
290 | 94 | exit 0 | ||
291 | 95 | ;; | ||
292 | 96 | esac | ||
293 | 97 | done | ||
294 | 98 | |||
295 | 99 | # Make sure only root can run this script | ||
296 | 100 | if [ $(id -u) -ne 0 ]; then | ||
297 | 101 | echo "This script must be run as root!" 1>&2 | ||
298 | 102 | exit 1 | ||
299 | 103 | fi | ||
300 | 104 | |||
301 | 105 | if [ $ENABLE = 1 -a $DISABLE = 1 ]; then | ||
302 | 106 | printf "Only --enable OR --disable can be specified - not both!\n" | ||
303 | 107 | exit 1 | ||
304 | 108 | elif [ $ENABLE = 0 -a $DISABLE = 0 ]; then | ||
305 | 109 | printf "You should specify --enable or --disable option. Use --help for printing options.\n" | ||
306 | 110 | exit 1 | ||
307 | 111 | fi | ||
308 | 112 | |||
309 | 113 | # Check if server is running with jemalloc - if not warn that restart is needed | ||
310 | 114 | printf "Checking if Percona server is running with jemalloc enabled...\n" | ||
311 | 115 | PID_LOCATION=$(mysql -e "show variables like 'pid_file';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null|grep pid_file|awk '{print $2}') | ||
312 | 116 | if [ $? -ne 0 ] || [ "${PID_LOCATION}" == "" ]; then | ||
313 | 117 | printf ">> Error checking pid file location! Please check username, password and other options...\n"; | ||
314 | 118 | exit 1 | ||
315 | 119 | fi | ||
316 | 120 | PID_NUM=$(cat ${PID_LOCATION}) | ||
317 | 121 | JEMALLOC_STATUS=$(grep -c jemalloc /proc/${PID_NUM}/environ) | ||
318 | 122 | if [ $JEMALLOC_STATUS = 0 ]; then | ||
319 | 123 | printf ">> Percona server is not running with jemalloc, please restart server to enable it and then run this script...\n\n"; | ||
320 | 124 | exit 1 | ||
321 | 125 | else | ||
322 | 126 | printf ">> Percona server is running with jemalloc enabled.\n\n"; | ||
323 | 127 | fi | ||
324 | 128 | |||
325 | 129 | # Check transparent huge pages status on the system | ||
326 | 130 | printf "Checking transparent huge pages status on the system...\n" | ||
327 | 131 | if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then | ||
328 | 132 | CONTENT_TRANSHP=$(</sys/kernel/mm/transparent_hugepage/enabled) | ||
329 | 133 | STATUS_THP_SYSTEM=$(echo $CONTENT_TRANSHP | grep -cv '\[never\]') | ||
330 | 134 | fi | ||
331 | 135 | if [ $STATUS_THP_SYSTEM = 0 ]; then | ||
332 | 136 | printf ">> Transparent huge pages are currently disabled on the system.\n\n" | ||
333 | 137 | else | ||
334 | 138 | printf ">> Transparent huge pages are enabled (should be disabled).\n\n" | ||
335 | 139 | fi | ||
336 | 140 | |||
337 | 141 | # Check thp-setting=never option in my.cnf | ||
338 | 142 | printf "Checking if thp-setting=never option is already set in config file...\n" | ||
339 | 143 | STATUS_THP_MYCNF=$(my_print_defaults server mysqld mysqld_safe|grep -c thp-setting=never) | ||
340 | 144 | if [ $STATUS_THP_MYCNF = 0 ]; then | ||
341 | 145 | printf ">> Option thp-setting=never is not set in the config file.\n" | ||
342 | 146 | printf ">> (needed only if THP is not disabled permanently on the system)\n\n" | ||
343 | 147 | else | ||
344 | 148 | printf ">> Option thp-setting=never is set in the config file.\n\n" | ||
345 | 149 | fi | ||
346 | 150 | |||
347 | 151 | # Check location of my.cnf | ||
348 | 152 | if [ -f /etc/my.cnf ]; then | ||
349 | 153 | MYCNF_LOCATION=/etc/my.cnf | ||
350 | 154 | elif [ -f /etc/mysql/my.cnf ]; then | ||
351 | 155 | MYCNF_LOCATION=/etc/mysql/my.cnf | ||
352 | 156 | elif [ -f /usr/etc/my.cnf ]; then | ||
353 | 157 | MYCNF_LOCATION=/usr/etc/my.cnf | ||
354 | 158 | else | ||
355 | 159 | if [ -d /etc/mysql ]; then | ||
356 | 160 | MYCNF_LOCATION=/etc/mysql/my.cnf | ||
357 | 161 | else | ||
358 | 162 | MYCNF_LOCATION=/etc/my.cnf | ||
359 | 163 | fi | ||
360 | 164 | echo -n "" >> ${MYCNF_LOCATION} | ||
361 | 165 | fi | ||
362 | 166 | |||
363 | 167 | # Check TokuDB plugin status | ||
364 | 168 | printf "Checking TokuDB plugin status...\n" | ||
365 | 169 | LIST_ENGINE=$(mysql -e "show plugins;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null) | ||
366 | 170 | if [ $? -ne 0 ]; then | ||
367 | 171 | printf ">> Error checking TokuDB plugin status! Please check username, password and other options...\n"; | ||
368 | 172 | exit 1 | ||
369 | 173 | fi | ||
370 | 174 | STATUS_PLUGIN=$(echo "$LIST_ENGINE" | grep -c "TokuDB") | ||
371 | 175 | if [ $STATUS_PLUGIN = 0 ]; then | ||
372 | 176 | printf ">> TokuDB plugin is not installed.\n\n" | ||
373 | 177 | elif [ $STATUS_PLUGIN = 7 ]; then | ||
374 | 178 | printf ">> TokuDB plugin is installed.\n\n" | ||
375 | 179 | exit 0 | ||
376 | 180 | else | ||
377 | 181 | printf ">> TokuDB plugin is partially installed. Please cleanup manually.\n\n" | ||
378 | 182 | exit 1 | ||
379 | 183 | fi | ||
380 | 184 | |||
381 | 185 | # Disable transparent huge pages in the current session so | ||
382 | 186 | # that the plugin can be installed without restarting PS | ||
383 | 187 | if [ $ENABLE = 1 -a $STATUS_THP_SYSTEM = 1 ]; then | ||
384 | 188 | printf "Disabling transparent huge pages for the current session...\n" | ||
385 | 189 | if test -f /sys/kernel/mm/transparent_hugepage/defrag; then | ||
386 | 190 | echo never > /sys/kernel/mm/transparent_hugepage/defrag | ||
387 | 191 | fi | ||
388 | 192 | if test -f /sys/kernel/mm/transparent_hugepage/enabled; then | ||
389 | 193 | echo never > /sys/kernel/mm/transparent_hugepage/enabled | ||
390 | 194 | fi | ||
391 | 195 | if [ $? -eq 0 ]; then | ||
392 | 196 | printf ">> Successfuly disabled transparent huge pages for this session.\n\n" | ||
393 | 197 | else | ||
394 | 198 | printf ">> Error disabling transparent huge pages for this session.\n\n" | ||
395 | 199 | exit 1 | ||
396 | 200 | fi | ||
397 | 201 | fi | ||
398 | 202 | |||
399 | 203 | # Add option to disable transparent huge pages into my.cnf | ||
400 | 204 | if [ $ENABLE = 1 -a $STATUS_THP_MYCNF = 0 ]; then | ||
401 | 205 | printf "Adding thp-setting=never option into $MYCNF_LOCATION\n" | ||
402 | 206 | MYSQLD_SAFE_STATUS=$(grep -c "^\[mysqld_safe\]$" $MYCNF_LOCATION) | ||
403 | 207 | if [ $MYSQLD_SAFE_STATUS = 0 ]; then | ||
404 | 208 | echo -e "\n[mysqld_safe]\nthp-setting=never" >> $MYCNF_LOCATION | ||
405 | 209 | else | ||
406 | 210 | sed -i '/^\[mysqld_safe\]$/a thp-setting=never' $MYCNF_LOCATION | ||
407 | 211 | fi | ||
408 | 212 | if [ $? -eq 0 ]; then | ||
409 | 213 | printf ">> Successfuly added thp-setting=never option into $MYCNF_LOCATION\n\n"; | ||
410 | 214 | else | ||
411 | 215 | printf ">> Error adding thp-setting=never option into $MYCNF_LOCATION\n\n"; | ||
412 | 216 | exit 1 | ||
413 | 217 | fi | ||
414 | 218 | fi | ||
415 | 219 | |||
416 | 220 | # Remove option for disabling transparent huge pages from my.cnf | ||
417 | 221 | if [ $DISABLE = 1 -a $STATUS_THP_MYCNF = 1 ]; then | ||
418 | 222 | printf "Removing thp-setting=never option from $MYCNF_LOCATION\n" | ||
419 | 223 | sed -i '/^thp-setting=never$/d' $MYCNF_LOCATION | ||
420 | 224 | if [ $? -eq 0 ]; then | ||
421 | 225 | printf ">> Successfuly removed thp-setting=never option from $MYCNF_LOCATION\n\n"; | ||
422 | 226 | else | ||
423 | 227 | printf ">> Error removing thp-setting=never option from $MYCNF_LOCATION\n\n"; | ||
424 | 228 | exit 1 | ||
425 | 229 | fi | ||
426 | 230 | fi | ||
427 | 231 | |||
428 | 232 | # Installing TokuDB plugin | ||
429 | 233 | if [ $ENABLE = 1 -a $STATUS_PLUGIN = 0 ]; then | ||
430 | 234 | printf "Installing TokuDB engine...\n" | ||
431 | 235 | mysql -e "INSTALL PLUGIN tokudb SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null && | ||
432 | 236 | mysql -e "INSTALL PLUGIN tokudb_file_map SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null && | ||
433 | 237 | mysql -e "INSTALL PLUGIN tokudb_fractal_tree_info SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null && | ||
434 | 238 | mysql -e "INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null && | ||
435 | 239 | mysql -e "INSTALL PLUGIN tokudb_trx SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null && | ||
436 | 240 | mysql -e "INSTALL PLUGIN tokudb_locks SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null && | ||
437 | 241 | mysql -e "INSTALL PLUGIN tokudb_lock_waits SONAME 'ha_tokudb.so';" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null | ||
438 | 242 | if [ $? -eq 0 ]; then | ||
439 | 243 | printf ">> Successfuly installed TokuDB plugin.\n\n" | ||
440 | 244 | else | ||
441 | 245 | printf ">> Error installing TokuDB plugin. Please check error log.\n\n" | ||
442 | 246 | exit 1 | ||
443 | 247 | fi | ||
444 | 248 | fi | ||
445 | 249 | |||
446 | 250 | # Uninstalling TokuDB plugin | ||
447 | 251 | if [ $DISABLE = 1 -a $STATUS_PLUGIN = 7 ]; then | ||
448 | 252 | printf "Uninstalling TokuDB plugin...\n" | ||
449 | 253 | mysql -e "UNINSTALL PLUGIN tokudb;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null && | ||
450 | 254 | mysql -e "UNINSTALL PLUGIN tokudb_file_map;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null && | ||
451 | 255 | mysql -e "UNINSTALL PLUGIN tokudb_fractal_tree_info;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null && | ||
452 | 256 | mysql -e "UNINSTALL PLUGIN tokudb_fractal_tree_block_map;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null && | ||
453 | 257 | mysql -e "UNINSTALL PLUGIN tokudb_trx;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null && | ||
454 | 258 | mysql -e "UNINSTALL PLUGIN tokudb_locks;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null && | ||
455 | 259 | mysql -e "UNINSTALL PLUGIN tokudb_lock_waits;" -u $USER $PASSWORD $SOCKET $HOST $PORT 2>/dev/null | ||
456 | 260 | if [ $? -eq 0 ]; then | ||
457 | 261 | printf ">> Successfuly uninstalled TokuDB plugin.\n\n" | ||
458 | 262 | else | ||
459 | 263 | printf ">> Error uninstalling TokuDB plugin. Please check error log.\n\n" | ||
460 | 264 | exit 1 | ||
461 | 265 | fi | ||
462 | 266 | fi |
It needs a blueprint?