Skip to content

Commit 21721ee

Browse files
committed
Add compile_percona_server.sh
Signed-off-by: Jack Cherng <[email protected]>
1 parent f8f7986 commit 21721ee

File tree

2 files changed

+196
-0
lines changed

2 files changed

+196
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env bash
2+
3+
#---------------------------------------------------#
4+
# This script compiles the latest Percona server. #
5+
# #
6+
# Author: Jack Cherng <[email protected]> #
7+
#---------------------------------------------------#
8+
9+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
10+
THREAD_CNT=$(getconf _NPROCESSORS_ONLN)
11+
12+
APP_NAME=Percona-Server-8.0.15-5
13+
TAR_FILE_BASENAME=${APP_NAME,,}
14+
TAR_FILE_NAME=${TAR_FILE_BASENAME}.tar.gz
15+
16+
INSTALL_DIR=/usr/local/mysql
17+
18+
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
19+
20+
#-------------------#
21+
# check gcc version #
22+
#-------------------#
23+
24+
GCC_MIN_VERSION=4.9.0
25+
if [ $(version $(gcc -dumpversion)) -lt $(version "${GCC_MIN_VERSION}") ]; then
26+
echo "[*] GCC must be newer than ${GCC_MIN_VERSION}"
27+
exit 1
28+
fi
29+
30+
31+
#--------------#
32+
# install deps #
33+
#--------------#
34+
35+
yum install -y \
36+
scons socat openssl check cmake3 bison \
37+
boost-devel asio-devel libaio-devel ncurses-devel \
38+
readline-devel pam-devel libcurl-devel
39+
40+
41+
#-------#
42+
# begin #
43+
#-------#
44+
45+
pushd "${SCRIPT_DIR}" || exit
46+
47+
48+
#---------------------#
49+
# download the source #
50+
#---------------------#
51+
52+
wget "https://www.percona.com/downloads/Percona-Server-LATEST/${APP_NAME}/source/tarball/${TAR_FILE_NAME}" -O "${TAR_FILE_NAME}"
53+
tar xf "${TAR_FILE_NAME}"
54+
55+
56+
#-----------------#
57+
# compile Percona #
58+
#-----------------#
59+
60+
pushd "${TAR_FILE_BASENAME}" || exit
61+
62+
rm -rf my_build && mkdir -p my_build
63+
pushd my_build || exit
64+
65+
cmake .. \
66+
-DCMAKE_INSTALL_PREFIX:PATH="${INSTALL_DIR}" \
67+
-DDOWNLOAD_BOOST=1 -DWITH_BOOST="$(pwd)/boost" \
68+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
69+
-DBUILD_CONFIG=mysql_release \
70+
-DFEATURE_SET=community
71+
72+
# it's quite possible that we run out of memory, so -j2
73+
make -j2 || exit
74+
make install || exit
75+
76+
popd || exit
77+
78+
popd || exit
79+
80+
81+
#-----#
82+
# end #
83+
#-----#
84+
85+
"${INSTALL_DIR}/bin/mysql" -V || exit
86+
87+
groupadd mysql
88+
useradd -g mysql -s /sbin/nologin -M mysql
89+
90+
mkdir -p /data/mysql
91+
chown mysql.mysql -R /data/mysql
92+
93+
popd || exit
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
[client]
2+
port = 3306
3+
default-character-set = utf8mb4
4+
5+
[mysql]
6+
prompt="MySQL [\d]> "
7+
no-auto-rehash
8+
default-character-set = utf8mb4
9+
10+
[mysqld]
11+
port = 3306
12+
socket = /dev/shm/mysql.sock
13+
mysqlx_socket = /dev/shm/mysqlx.sock
14+
15+
basedir = /usr/local/mysql
16+
datadir = /data/mysql
17+
pid-file = /data/mysql/mysql.pid
18+
lc-messages-dir = /usr/local/mysql/share/english
19+
user = mysql
20+
bind-address = 0.0.0.0
21+
server-id = 1
22+
23+
init-connect = 'SET NAMES utf8mb4'
24+
collation-server = utf8mb4_unicode_ci
25+
character-set-server = utf8mb4
26+
default_authentication_plugin= mysql_native_password
27+
sql-mode = "ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_AUTO_CREATE_USER"
28+
29+
skip-name-resolve
30+
;skip-networking
31+
back_log = 300
32+
33+
max_connections = 996
34+
max_connect_errors = 6000
35+
open_files_limit = 65535
36+
table_open_cache = 256
37+
max_allowed_packet = 500M
38+
binlog_cache_size = 1M
39+
max_heap_table_size = 8M
40+
tmp_table_size = 32M
41+
42+
read_buffer_size = 2M
43+
read_rnd_buffer_size = 8M
44+
sort_buffer_size = 8M
45+
join_buffer_size = 8M
46+
key_buffer_size = 16M
47+
48+
thread_cache_size = 16
49+
50+
query_cache_type = 1
51+
query_cache_size = 16M
52+
query_cache_limit = 2M
53+
54+
ft_min_word_len = 4
55+
56+
log_bin = mysql-bin
57+
binlog_format = mixed
58+
expire_logs_days = 7
59+
60+
log_error = /data/mysql/mysql-error.log
61+
slow_query_log = 1
62+
long_query_time = 1
63+
slow_query_log_file = /data/mysql/mysql-slow.log
64+
65+
performance_schema = 0
66+
explicit_defaults_for_timestamp
67+
68+
;lower_case_table_names = 1
69+
70+
skip-external-locking
71+
72+
default_storage_engine = InnoDB
73+
innodb_file_per_table = 1
74+
innodb_open_files = 500
75+
innodb_buffer_pool_size = 128M
76+
innodb_write_io_threads = 4
77+
innodb_read_io_threads = 4
78+
innodb_thread_concurrency = 0
79+
innodb_purge_threads = 1
80+
innodb_flush_log_at_trx_commit = 2
81+
innodb_log_buffer_size = 2M
82+
innodb_log_file_size = 32M
83+
innodb_log_files_in_group = 3
84+
innodb_max_dirty_pages_pct = 90
85+
innodb_lock_wait_timeout = 120
86+
87+
bulk_insert_buffer_size = 8M
88+
myisam_sort_buffer_size = 16M
89+
myisam_max_sort_file_size = 10G
90+
myisam_repair_threads = 1
91+
92+
interactive_timeout = 28800
93+
wait_timeout = 28800
94+
95+
[mysqldump]
96+
quick
97+
max_allowed_packet = 500M
98+
99+
[myisamchk]
100+
key_buffer_size = 16M
101+
sort_buffer_size = 8M
102+
read_buffer = 4M
103+
write_buffer = 4M

0 commit comments

Comments
 (0)