mirror of https://github.com/midoks/mdserver-web
parent
471e655eb3
commit
476c73fed3
@ -0,0 +1,120 @@ |
||||
#!/bin/bash |
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin |
||||
export PATH |
||||
|
||||
#https://dev.mysql.com/downloads/mysql/5.5.html#downloads |
||||
#https://dev.mysql.com/downloads/file/?id=480541 |
||||
|
||||
curPath=`pwd` |
||||
rootPath=$(dirname "$curPath") |
||||
rootPath=$(dirname "$rootPath") |
||||
serverPath=$(dirname "$rootPath") |
||||
sysName=`uname` |
||||
|
||||
mariadbDir=${serverPath}/source/mariadb |
||||
|
||||
MY_VER=12.1.2 |
||||
|
||||
Install_app() |
||||
{ |
||||
mkdir -p ${mariadbDir} |
||||
echo '正在安装脚本文件...' |
||||
|
||||
if [ "$sysName" != "Darwin" ];then |
||||
mkdir -p /var/log/mariadb |
||||
touch /var/log/mariadb/mariadb.log |
||||
fi |
||||
|
||||
# ----- cpu start ------ |
||||
if [ -z "${cpuCore}" ]; then |
||||
cpuCore="1" |
||||
fi |
||||
|
||||
if [ -f /proc/cpuinfo ];then |
||||
cpuCore=`cat /proc/cpuinfo | grep "processor" | wc -l` |
||||
fi |
||||
|
||||
MEM_INFO=$(free -m|grep Mem|awk '{printf("%.f",($2)/1024)}') |
||||
if [ "${cpuCore}" != "1" ] && [ "${MEM_INFO}" != "0" ];then |
||||
if [ "${cpuCore}" -gt "${MEM_INFO}" ];then |
||||
cpuCore="${MEM_INFO}" |
||||
fi |
||||
else |
||||
cpuCore="1" |
||||
fi |
||||
|
||||
if [ "$cpuCore" -gt "2" ];then |
||||
cpuCore=`echo "$cpuCore" | awk '{printf("%.f",($1)*0.8)}'` |
||||
else |
||||
cpuCore="1" |
||||
fi |
||||
# ----- cpu end ------ |
||||
|
||||
# if [ ! -f ${mariadbDir}/mariadb-${MY_VER}.tar.gz ];then |
||||
# wget --no-check-certificate -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://mirrors.aliyun.com/mariadb/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz |
||||
# fi |
||||
|
||||
# https://downloads.mariadb.org/interstitial/mariadb-10.9.1/source/mariadb-10.9.1.tar.gz |
||||
if [ ! -f ${mariadbDir}/mariadb-${MY_VER}.tar.gz ];then |
||||
wget --no-check-certificate -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://archive.mariadb.org/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz |
||||
fi |
||||
|
||||
if [ ! -d ${mariadbDir}/mariadb-${MY_VER} ];then |
||||
cd ${mariadbDir} && tar -zxvf ${mariadbDir}/mariadb-${MY_VER}.tar.gz |
||||
fi |
||||
|
||||
INSTALL_CMD=cmake |
||||
# check cmake version |
||||
CMAKE_VERSION=`cmake -version | grep version | awk '{print $3}' | awk -F '.' '{print $1}'` |
||||
if [ "$CMAKE_VERSION" -eq "2" ];then |
||||
mkdir -p /var/log/mariadb |
||||
touch /var/log/mariadb/mariadb.log |
||||
INSTALL_CMD=cmake3 |
||||
fi |
||||
|
||||
if [ ! -d $serverPath/mariadb ];then |
||||
cd ${mariadbDir}/mariadb-${MY_VER} && ${INSTALL_CMD} \ |
||||
-DCMAKE_INSTALL_PREFIX=$serverPath/mariadb \ |
||||
-DMYSQL_DATADIR=$serverPath/mariadb/data/ \ |
||||
-DMYSQL_USER=mysql \ |
||||
-DMYSQL_UNIX_ADDR=$serverPath/mariadb/mysql.sock \ |
||||
-DWITH_MYISAM_STORAGE_ENGINE=1 \ |
||||
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ |
||||
-DWITH_MEMORY_STORAGE_ENGINE=1 \ |
||||
-DENABLED_LOCAL_INFILE=1 \ |
||||
-DWITH_PARTITION_STORAGE_ENGINE=1 \ |
||||
-DEXTRA_CHARSETS=all \ |
||||
-DDEFAULT_CHARSET=utf8mb4 \ |
||||
-DDEFAULT_COLLATION=utf8mb4_general_ci \ |
||||
-DCMAKE_C_COMPILER=/usr/bin/gcc \ |
||||
-DCMAKE_CXX_COMPILER=/usr/bin/g++ |
||||
make -j${cpuCore} && make install && make clean |
||||
|
||||
if [ -d $serverPath/mariadb ];then |
||||
echo '12.1' > $serverPath/mariadb/version.pl |
||||
echo '安装完成' |
||||
else |
||||
echo '安装失败' |
||||
echo 'install fail'>&2 |
||||
exit 1 |
||||
fi |
||||
fi |
||||
|
||||
if [ -d ${mariadbDir}/mariadb-${MY_VER} ];then |
||||
rm -rf ${mariadbDir}/mariadb-${MY_VER} |
||||
fi |
||||
|
||||
} |
||||
|
||||
Uninstall_app() |
||||
{ |
||||
rm -rf $serverPath/mariadb |
||||
echo '卸载完成' |
||||
} |
||||
|
||||
action=$1 |
||||
if [ "${1}" == 'install' ];then |
||||
Install_app |
||||
else |
||||
Uninstall_app |
||||
fi |
||||
@ -0,0 +1,116 @@ |
||||
[client] |
||||
user = root |
||||
#password = your_password |
||||
port = 3306 |
||||
socket = {$SERVER_APP_PATH}/mysql.sock |
||||
default-character-set = UTF8MB4 |
||||
|
||||
[mysqld] |
||||
!include {$SERVER_APP_PATH}/etc/mode/classic.cnf |
||||
|
||||
authentication_policy=caching_sha2_password |
||||
pid-file = {$SERVER_APP_PATH}/data/mysql.pid |
||||
user = mysql |
||||
port = 3306 |
||||
socket = {$SERVER_APP_PATH}/mysql.sock |
||||
basedir = {$SERVER_APP_PATH} |
||||
datadir = {$SERVER_APP_PATH}/data |
||||
log-error = {$SERVER_APP_PATH}/data/error.log |
||||
server-id = {$SERVER_ID} |
||||
#sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES |
||||
|
||||
default_storage_engine = InnoDB |
||||
|
||||
key_buffer_size = 8M |
||||
table_open_cache = 32 |
||||
sort_buffer_size = 256K |
||||
net_buffer_length = 4K |
||||
read_buffer_size = 128K |
||||
read_rnd_buffer_size = 256K |
||||
myisam_sort_buffer_size = 4M |
||||
thread_cache_size = 4 |
||||
lower_case_table_names=0 |
||||
tmp_table_size = 8M |
||||
character-set-server = UTF8MB4 |
||||
|
||||
max_connections = 500 |
||||
max_connect_errors = 100 |
||||
open_files_limit = 2560 |
||||
max_allowed_packet = 128M |
||||
|
||||
skip_name_resolve=1 |
||||
#skip-networking |
||||
#skip-external-locking |
||||
#loose-skip-innodb |
||||
#skip-grant-tables |
||||
|
||||
#skip-log-bin |
||||
#disable-log-bin |
||||
#skip-slave-start |
||||
log-bin=mysql-bin |
||||
slow_query_log=1 |
||||
slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log |
||||
long_query_time=10 |
||||
#log_queries_not_using_indexes=1 |
||||
#log_slow_admin_statements=1 |
||||
#log_slow_replica_statements=1 |
||||
binlog_expire_logs_seconds=604800 |
||||
|
||||
relay-log=mdserver |
||||
relay-log-index=mdserver |
||||
|
||||
#多主设置 |
||||
#auto_increment_offset=2 |
||||
#auto_increment_increment=2 |
||||
|
||||
#master |
||||
#sync_binlog=1 |
||||
|
||||
#binlog-do-db |
||||
binlog-ignore-db = test |
||||
binlog-ignore-db = mysql |
||||
binlog-ignore-db = information_schema |
||||
binlog-ignore-db = performance_schema |
||||
|
||||
#slave |
||||
log_replica_updates = 1 |
||||
# Prevent replication from starting automatically with MySQL |
||||
#skip_replica_start = 1 |
||||
#replicate-do-db |
||||
replica_skip_errors=1062,1396 |
||||
replicate-ignore-db = information_schema |
||||
replicate-ignore-db = performance_schema |
||||
replicate-ignore-db = mysql |
||||
replicate-ignore-db = test |
||||
|
||||
|
||||
innodb_data_home_dir = {$SERVER_APP_PATH}/data |
||||
innodb_data_file_path = ibdata1:10M:autoextend |
||||
innodb_log_group_home_dir = {$SERVER_APP_PATH}/data |
||||
innodb_buffer_pool_size = 16M |
||||
#innodb_log_file_size = 5M |
||||
innodb_redo_log_capacity = 4G |
||||
innodb_log_buffer_size = 8M |
||||
innodb_flush_log_at_trx_commit = 1 |
||||
innodb_lock_wait_timeout = 120 |
||||
innodb_max_dirty_pages_pct = 90 |
||||
innodb_read_io_threads = 1 |
||||
innodb_write_io_threads = 1 |
||||
innodb_file_per_table=1 |
||||
|
||||
secure-file-priv={$SERVER_APP_PATH}/tmp |
||||
|
||||
[mysqldump] |
||||
quick |
||||
|
||||
[mysql] |
||||
no-auto-rehash |
||||
|
||||
[myisamchk] |
||||
key_buffer_size = 20M |
||||
sort_buffer_size = 20M |
||||
read_buffer = 2M |
||||
write_buffer = 2M |
||||
|
||||
[mysqlhotcopy] |
||||
interactive-timeout |
||||
@ -0,0 +1,116 @@ |
||||
[client] |
||||
user = root |
||||
#password = your_password |
||||
port = 3306 |
||||
socket = {$SERVER_APP_PATH}/mysql.sock |
||||
default-character-set = UTF8MB4 |
||||
|
||||
[mysqld] |
||||
!include {$SERVER_APP_PATH}/etc/mode/classic.cnf |
||||
|
||||
authentication_policy=caching_sha2_password |
||||
pid-file = {$SERVER_APP_PATH}/data/mysql.pid |
||||
user = mysql |
||||
port = 3306 |
||||
socket = {$SERVER_APP_PATH}/mysql.sock |
||||
basedir = {$SERVER_APP_PATH} |
||||
datadir = {$SERVER_APP_PATH}/data |
||||
log-error = {$SERVER_APP_PATH}/data/error.log |
||||
server-id = {$SERVER_ID} |
||||
#sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES |
||||
|
||||
default_storage_engine = InnoDB |
||||
|
||||
key_buffer_size = 8M |
||||
table_open_cache = 32 |
||||
sort_buffer_size = 256K |
||||
net_buffer_length = 4K |
||||
read_buffer_size = 128K |
||||
read_rnd_buffer_size = 256K |
||||
myisam_sort_buffer_size = 4M |
||||
thread_cache_size = 4 |
||||
lower_case_table_names=0 |
||||
tmp_table_size = 8M |
||||
character-set-server = UTF8MB4 |
||||
|
||||
max_connections = 500 |
||||
max_connect_errors = 100 |
||||
open_files_limit = 2560 |
||||
max_allowed_packet = 128M |
||||
|
||||
skip_name_resolve=1 |
||||
#skip-networking |
||||
#skip-external-locking |
||||
#loose-skip-innodb |
||||
#skip-grant-tables |
||||
|
||||
#skip-log-bin |
||||
#disable-log-bin |
||||
#skip-slave-start |
||||
log-bin=mysql-bin |
||||
slow_query_log=1 |
||||
slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log |
||||
long_query_time=10 |
||||
#log_queries_not_using_indexes=1 |
||||
#log_slow_admin_statements=1 |
||||
#log_slow_replica_statements=1 |
||||
binlog_expire_logs_seconds=604800 |
||||
|
||||
relay-log=mdserver |
||||
relay-log-index=mdserver |
||||
|
||||
#多主设置 |
||||
#auto_increment_offset=2 |
||||
#auto_increment_increment=2 |
||||
|
||||
#master |
||||
#sync_binlog=1 |
||||
|
||||
#binlog-do-db |
||||
binlog-ignore-db = test |
||||
binlog-ignore-db = mysql |
||||
binlog-ignore-db = information_schema |
||||
binlog-ignore-db = performance_schema |
||||
|
||||
#slave |
||||
log_replica_updates = 1 |
||||
# Prevent replication from starting automatically with MySQL |
||||
#skip_replica_start = 1 |
||||
#replicate-do-db |
||||
replica_skip_errors=1062,1396 |
||||
replicate-ignore-db = information_schema |
||||
replicate-ignore-db = performance_schema |
||||
replicate-ignore-db = mysql |
||||
replicate-ignore-db = test |
||||
|
||||
|
||||
innodb_data_home_dir = {$SERVER_APP_PATH}/data |
||||
innodb_data_file_path = ibdata1:10M:autoextend |
||||
innodb_log_group_home_dir = {$SERVER_APP_PATH}/data |
||||
innodb_buffer_pool_size = 16M |
||||
#innodb_log_file_size = 5M |
||||
innodb_redo_log_capacity = 4G |
||||
innodb_log_buffer_size = 8M |
||||
innodb_flush_log_at_trx_commit = 1 |
||||
innodb_lock_wait_timeout = 120 |
||||
innodb_max_dirty_pages_pct = 90 |
||||
innodb_read_io_threads = 1 |
||||
innodb_write_io_threads = 1 |
||||
innodb_file_per_table=1 |
||||
|
||||
secure-file-priv={$SERVER_APP_PATH}/tmp |
||||
|
||||
[mysqldump] |
||||
quick |
||||
|
||||
[mysql] |
||||
no-auto-rehash |
||||
|
||||
[myisamchk] |
||||
key_buffer_size = 20M |
||||
sort_buffer_size = 20M |
||||
read_buffer = 2M |
||||
write_buffer = 2M |
||||
|
||||
[mysqlhotcopy] |
||||
interactive-timeout |
||||
Loading…
Reference in new issue