首页 > 数据库 > MySQL > mariaDB 10.1源码安装
|
[client]
port = 3306
socket = /mariaDB/data/mysql.sock
[mysql]
no-auto-rehash
[mysqld]
server-id = 1
user = mysql
port = 3306
socket = /mariaDB/socket/mysql.sock
basedir = /mariaDB
datadir = /mariaDB/data
default-storage-engine = InnoDB
external-locking = FALSE
skip-name-resolve
#connect options
back_log = 600 #
max_connections = 1000
max_connect_errors = 10 #number which allow to connect server for error password
connect_timeout=20 #The number of seconds that the mysqld server waits for a connect packet
max_allowed_packet = 32M
### Table Cache Settings
table_open_cache = 800 ## Range: 64~ 524288
open_files_limit = 5000
tmp_table_size = 2G #recommend same size as tmp_table_size
max_heap_table_size = 2G #recommend 256 min
### Thread Cache
thread_cache_size = 64
#thread_stack = 192K
### Query Cache
query_cache_size = 64M
query_cache_limit = 4M
### Per-Thread Buffers
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
join_buffer_size = 2M
thread_stack = 512k
##transaction infomation
transaction_isolation = READ-COMMITTED
#slog log
slow_query_log_file=/mariaDB/logs/slow-log.log
slow_query_log=1
long_query_time=4 #set time when executing is more this time,the sql be writen in slow log
log_queries_not_using_indexes=1 #when executing sql,the table have not index for the sql, the sql will be writen in slow log
##bin log
log-bin = /mariaDB/logs/ray-bin.log
binlog_cache_size = 10M
max_binlog_cache_size = 8M
max_binlog_size = 128M
expire_logs_days = 7
binlog_format = ROW
binlog_stmt_cache_size = 10M
key_buffer_size = 256MB
lower_case_table_names = 1
###innodb options
innodb_buffer_pool_instances=8
innodb_file_per_table = on
innodb_thread_concurrency = 8
innodb_read_io_threads = 16 ##2*cpu个数*cpu核数,个人建议与cpu核数相等或2倍
innodb_write_io_threads = 16
##innodb memery
innodb_buffer_pool_size = 512M
innodb_max_dirty_pages_pct = 70
innodb_lock_wait_timeout = 120
##redo log
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_flush_log_at_trx_commit = 1
autocommit=0
#set independent undo
innodb_undo_directory=/mariaDB/data
innodb_undo_logs=128
innodb_undo_tablespaces=4
[mysqldump]
quick
max_allowed_packet = 32M
[mysqld_safe]
log-error=/mariaDB/logs/mysql_ray.err
pid-file=/mariaDB/data/ray.pid
|
|
#!/bin/bash
mysql_port=3306
mysql_username="root"
mysql_password="123456"
function_start_mysql()
{
printf "Starting MySQL...\n"
/bin/sh /mariaDB/bin/mysqld_safe --defaults-file=/mariaDB/my.cnf 2>&1 > /dev/null &
}
function_stop_mysql()
{
printf "Stoping MySQL...\n"
/mariaDB/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /mariaDB/socket/mysql.sock shutdown
}
function_restart_mysql()
{
printf "Restarting MySQL...\n"
function_stop_mysql
function_start_mysql
}
function_kill_mysql()
{
kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')
kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')
}
case $1 in
start)
function_start_mysql;;
stop)
function_stop_mysql;;
kill)
function_kill_mysql;;
restart)
function_stop_mysql
function_start_mysql;;
*)
echo "Usage: /mariaDB/mysqld {start|stop|restart|kill}";;
esac
|
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28572479/viewspace-2137012/ ,如需转载,请注明出处,否则将追究法律责任。