溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

我寫(xiě)的一鍵安裝MySQL腳本——暴力版

發(fā)布時(shí)間:2020-07-24 20:17:02 來(lái)源:網(wǎng)絡(luò) 閱讀:431 作者:莎吧啦 欄目:MySQL數(shù)據(jù)庫(kù)
[root@xd-10-189 songlisha]# cat install_mysql.sh 
#!/bin/bash

mysql_src=/songlisha/home/admin/mysql_data
install_scr=/songlisha/usr/local

rm -rf $install_scr/mysql
rm -rf $mysql_src
rm -rf /etc/my.cnf

groupadd mysql
useradd -g mysql mysql
mkdir -p $mysql_src/{binlog,innodb_log,innodb_ts,log,mydata,relaylog,sock,tmpdir}
chown -R mysql.mysql $mysql_src
tar zxvf $install_scr/mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz -C $install_scr
mv $install_scr/mysql-5.6.34-linux-glibc2.5-x86_64 $install_scr/mysql

cat >> /etc/my.cnf <<EOF
[client]
port            = 3306
socket          = /songlisha/home/admin/mysql_data/sock/mysql3306.sock

[mysql]
prompt='\u@\h [\d]> '
no-auto-rehash
default_character_set = utf8

[mysqld]
user = mysql
basedir = /songlisha/usr/local/mysql
datadir = /songlisha/home/admin/mysql_data 
port = 3306
socket = /songlisha/home/admin/mysql_data/sock/my3307.sock
event_scheduler = 0
max_allowed_packet=64M
#skip-grant-tables


#timeout
interactive_timeout = 300
wait_timeout = 100000

#character set
character-set-server = utf8

open_files_limit = 65535
max_connections = 100
max_connect_errors = 100000

skip-name-resolve = 1
#logs
log-output=file
slow_query_log = 1
slow_query_log_file = /songlisha/home/admin/mysql_data/log/slow.log
log-error = /songlisha/home/admin/mysql_data/log/error.log
log_warnings = 2
pid-file = mysql.pid
#log-slow-admin-statements = 1
#log-queries-not-using-indexes = 1
log-slow-slave-statements = 1
long_query_time = 0.3

#binlog
binlog_format = row
server-id = 1273307
log-bin = /songlisha/home/admin/mysql_data/binlog/mybin.log
binlog_cache_size = 4M
max_binlog_size = 1G
max_binlog_cache_size = 2G
sync_binlog = 0
expire_logs_days = 7

#relay log
skip_slave_start = 1
max_relay_log_size = 1G
relay_log_purge = 1
relay_log_recovery = 1
log_slave_updates
#slave-skip-errors=1032,1053,1062
tmpdir = /songlisha/home/admin/mysql_data/tmpdir

explicit_defaults_for_timestamp=1
#buffers & cache
table_open_cache = 2048
table_definition_cache = 2048
table_open_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 256
query_cache_size = 0
query_cache_type = 0
query_cache_limit = 256K
query_cache_min_res_unit = 512
thread_stack = 192K
tmp_table_size = 96M
key_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 32M

#myisam
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 1G
myisam_repair_threads = 1

#innodb
innodb_data_home_dir=/songlisha/home/admin/mysql_data/innodb_ts
innodb_log_group_home_dir=/songlisha/home/admin/mysql_data/innodb_log
innodb_buffer_pool_size = 1G
innodb_buffer_pool_instances = 1
innodb_data_file_path = ibdata1:10G:autoextend
innodb_flush_log_at_trx_commit = 2
innodb_log_file_size = 500M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 70
innodb_file_per_table = 1
innodb_rollback_on_timeout
innodb_status_file = 1
transaction_isolation = READ-COMMITTED
innodb_log_buffer_size = 16M
innodb_lock_wait_timeout = 10
innodb_sync_spin_loops = 40
innodb_support_xa = 0
innodb_thread_concurrency = 0
innodb_thread_sleep_delay = 500
#innodb_file_io_threads    = 4
innodb_concurrency_tickets = 1000
log_bin_trust_function_creators = 1
innodb_flush_method = O_DIRECT
innodb_read_io_threads = 16
innodb_write_io_threads = 16
innodb_io_capacity = 2000
innodb_file_format = Barracuda
innodb_purge_threads=1
innodb_purge_batch_size = 32
innodb_old_blocks_pct=75
innodb_change_buffering=all
innodb_stats_on_metadata=OFF

[mysqld_safe]
open_file_limit = 65535
EOF

$install_scr/mysql/scripts/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf --datadir=/songlisha/home/admin/mysql_data --basedir=/songlisha/usr/local/mysql
cp $install_scr/mysql/support-files/mysql.server /etc/init.d/mysqld
service mysqld start
chkconfig mysqld on
echo "export PATH="\$PATH:/songlisha/usr/local/mysql/bin"" >> /etc/profile
export PATH="/songlisha/usr/local/mysql/bin:$PATH"
source /etc/profile

exit 0

我寫(xiě)的一鍵安裝MySQL腳本——暴力版

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI