-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_my_cnf-8.0.sh
executable file
·126 lines (108 loc) · 4.23 KB
/
create_my_cnf-8.0.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: create_my_cnf.sh BASEDIR"
echo "Creates my.cnf file and associated directories necessay if they do not exist."
echo "Assumes that BASEDIR is the location of mysql as a result of a 'make install'."
exit 1
fi
if [ -n "$2" ]; then
SUFFIX="-${2}"
fi
BASEDIR=$1
shift
DATADIR=${DATADIR:-${BASEDIR}/data${SUFFIX}}
ETCDIR=${ETCDIR:-${BASEDIR}/etc${SUFFIX}}
TMPDIR=${TMPDIR:-${BASEDIR}/tmp${SUFFIX}}
VARDIR=${VARDIR:-${BASEDIR}/var${SUFFIX}}
PORT=${PORT:-10002}
SOCKETFILE=${SOCKETFILE:-${VARDIR}/mysql.sock}
PIDFILE=${PIDFILE:-${VARDIR}/mysql.pid}
DEFAULTSFILE=${DEFAULTSFILE:-${ETCDIR}/my.cnf}
SERVERID=${SERVERID:-"1"}
RUNMYSQLD=${BASEDIR}/runmysqld${SUFFIX}.sh
GDBMYSQLD=${BASEDIR}/gdbmysqld${SUFFIX}.sh
RUNMYSQL=${BASEDIR}/runmysql${SUFFIX}.sh
RUNMYSQLADMIN=${BASEDIR}/runmysqladmin${SUFFIX}.sh
if [ ! -d "${BASEDIR}" ]; then
echo "Invalid BASEDIR specified \"${BASEDIR}\""
exit 1
fi
if [ ! -d "${ETCDIR}" ]; then
mkdir ${ETCDIR}
if [ $? -ne 0 ]; then
echo "Creation of ETCDIR \"${ETCDIR}\" failed with $?"
exit 1
fi
echo "Created \"${ETCDIR}\""
fi
if [ ! -d "${TMPDIR}" ]; then
mkdir ${TMPDIR}
if [ $? -ne 0 ]; then
echo "Creation of TMPDIR \"${TMPDIR}\" failed with $?"
exit 1
fi
echo "Created \"${TMPDIR}\""
fi
if [ ! -d "${VARDIR}" ]; then
mkdir ${VARDIR}
if [ $? -ne 0 ]; then
echo "Creation of VARDIR \"${VARDIR}\" failed with $?"
exit 1
fi
echo "Created \"${VARDIR}\""
fi
cat > ${DEFAULTSFILE} <<EOF
[client]
port=${PORT}
socket=${SOCKETFILE}
user=root
[mysqld]
basedir=${BASEDIR}
datadir=${DATADIR}
tmpdir=${TMPDIR}
port=${PORT}
socket=${SOCKETFILE}
pid-file=${PIDFILE}
console
server-id=${SERVERID}
max_connections=1000
#plugin-load=TokuDB=ha_tokudb.so;TokuDB_trx=ha_tokudb.so;TokuDB_locks=ha_tokudb.so;TokuDB_lock_waits=ha_tokudb.so;TokuDB_file_map=ha_tokudb.so;TokuDB_fractal_tree_info=ha_tokudb.so;TokuDB_fractal_tree_block_map=ha_tokudb.so;TokuDB_background_job_status=ha_tokudb.so
#plugin-load=rocksdb=ha_rocksdb.so;rocksdb_cfstats=ha_rocksdb.so;rocksdb_dbstats=ha_rocksdb.so;rocksdb_perf_context=ha_rocksdb.so;rocksdb_perf_context_global=ha_rocksdb.so;rocksdb_cf_options=ha_rocksdb.so;rocksdb_compaction_stats=ha_rocksdb.so;rocksdb_global_info=ha_rocksdb.so;rocksdb_ddl=ha_rocksdb.so;rocksdb_index_file_map=ha_rocksdb.so;rocksdb_locks=ha_rocksdb.so;rocksdb_trx=ha_rocksdb.so
#plugin-load=TokuDB=ha_tokudb.so;TokuDB_trx=ha_tokudb.so;TokuDB_locks=ha_tokudb.so;TokuDB_lock_waits=ha_tokudb.so;TokuDB_file_map=ha_tokudb.so;TokuDB_fractal_tree_info=ha_tokudb.so;TokuDB_fractal_tree_block_map=ha_tokudb.so;TokuDB_background_job_status=ha_tokudb.so;rocksdb=ha_rocksdb.so;rocksdb_cfstats=ha_rocksdb.so;rocksdb_dbstats=ha_rocksdb.so;rocksdb_perf_context=ha_rocksdb.so;rocksdb_perf_context_global=ha_rocksdb.so;rocksdb_cf_options=ha_rocksdb.so;rocksdb_compaction_stats=ha_rocksdb.so;rocksdb_global_info=ha_rocksdb.so;rocksdb_ddl=ha_rocksdb.so;rocksdb_index_file_map=ha_rocksdb.so;rocksdb_locks=ha_rocksdb.so;rocksdb_trx=ha_rocksdb.so
EOF
#for option in $@; do
# echo "${option}" >> ${DEFAULTSFILE}
#done
echo "Wrote out \"${DEFAULTSFILE}\" with contents:"
cat ${DEFAULTSFILE}
LIBASAN=$(find /usr/lib -name 'libasan.so' | sort | head -n 1)
LIBEATMYDATA=$(find /usr/lib -name 'libeatmydata.so' | sort | head -n 1)
LIBHOTBACKUP=$(find $(readlink -f ..) -type f -name 'libHotBackup.so')
LIBJEMALLOC=$(find /usr/lib -name 'libjemalloc.so*' | sort | head -n 1)
if [ -z "${LIBEATMYDATA}" ]; then
echo "****** NO LIBEATMYDATA FOUND ******"
exit 1
fi
PRELOAD="${LIBEATMYDATA}:${LIBJEMALLOC}"
cat > ${GDBMYSQLD} <<EOF
#!/bin/bash
LD_PRELOAD="${PRELOAD}" gdb --args ${BASEDIR}/bin/mysqld --defaults-file=${DEFAULTSFILE} --loose-tokudb-check-jemalloc=no \$@
EOF
chmod +x ${GDBMYSQLD}
cat > ${RUNMYSQLD} <<EOF
#!/bin/bash
LD_PRELOAD="${PRELOAD}" ${BASEDIR}/bin/mysqld --defaults-file=${DEFAULTSFILE} --loose-tokudb-check-jemalloc=no \$@
EOF
chmod +x ${RUNMYSQLD}
cat > ${RUNMYSQL} <<EOF
#!/bin/bash
${BASEDIR}/bin/mysql --defaults-file=${DEFAULTSFILE} --loose-tokudb-check-jemalloc=no \$@
EOF
chmod +x ${RUNMYSQL}
cat > ${RUNMYSQLADMIN} <<EOF
#!/bin/bash
${BASEDIR}/bin/mysqladmin --defaults-file=${DEFAULTSFILE} --loose-tokudb-check-jemalloc=no \$@
EOF
chmod +x ${RUNMYSQLADMIN}
rm -rf ${DATADIR}/*
${RUNMYSQLD} --initialize-insecure