码迷,mamicode.com
首页 > 系统相关 > 详细

shell脚本实例

时间:2019-07-15 14:43:59      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:sum   libaio   orm   dir   evel   ima   soft   max   ted   

本文主要用于记录学习生产、测试环境shell脚本实例

【1】源码安装mysql shell脚本

#!/bin/sh
#editor huangbo
#yum -y install libaio libaio-devel

mysqlpath=/data/soft
tar -xvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz -C ${mysqlpath}
ln -s ${mysqlpath}/mysql-5.7.21-linux-glibc2.12-x86_64 /usr/local/mysql

cd ${mysqlpath}
ln -s mysql-5.7.21-linux-glibc2.12-x86_64 mysql
mkdir -p ${mysqlpath}/mysql/data

id mysql
if [ $? -ne 0 ];then
    echo ‘user mysql is existed!‘
else
    useradd mysql
fi
chown -R root:mysql ${mysqlpath}/mysql
chown -R mysql:mysql ${mysqlpath}/mysql/data
cat >> /etc/my.cnf <<EOF
[client]
default-character-set=utf8mb4

[mysql]
default-character-set=utf8mb4

[mysqld]
########basic settings########
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect=‘SET NAMES utf8mb4‘
server-id = 11 
port = 3306
user = mysql
bind_address = 0.0.0.0 
autocommit = 1
character_set_server=utf8mb4
skip_name_resolve = 1
skip-ssl
max_connections = 1000
max_connect_errors = 1000
datadir = ${mysqlpath}/mysql/data
transaction_isolation = READ-COMMITTED
explicit_defaults_for_timestamp = 1
join_buffer_size = 134217728
tmp_table_size = 67108864
tmpdir = /tmp
max_allowed_packet = 16777216
sql_mode = "NO_ENGINE_SUBSTITUTION"
interactive_timeout = 1800
wait_timeout = 1800
read_buffer_size = 16777216
read_rnd_buffer_size = 33554432
sort_buffer_size = 33554432
lower_case_table_names = 1

########log settings########
log_error = error.log
slow_query_log = 1
slow_query_log_file = slow.log
log_queries_not_using_indexes = 1
log_slow_admin_statements = 1
log_slow_slave_statements = 1
log_throttle_queries_not_using_indexes = 10
expire_logs_days = 90
long_query_time = 2
min_examined_row_limit = 100

########replication settings########
master_info_repository = TABLE
relay_log_info_repository = TABLE
log_bin = bin.log
sync_binlog = 1
gtid_mode = on
enforce_gtid_consistency = 1
log_slave_updates
binlog_format = row 
relay_log = relay.log
relay_log_recovery = 1
binlog_gtid_simple_recovery = 1
slave_skip_errors = ddl_exist_errors
binlog_checksum=none

########innodb settings########
#innodb_page_size = 8192
innodb_buffer_pool_size = 1024M
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_lru_scan_depth = 2000
innodb_lock_wait_timeout = 5
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_method = O_DIRECT
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_log_group_home_dir = ${mysqlpath}/mysql/data
innodb_undo_directory = ${mysqlpath}/mysql/data
innodb_undo_logs = 128
innodb_undo_tablespaces = 3
innodb_flush_neighbors = 1
innodb_log_file_size = 4G
innodb_log_buffer_size = 16777216
innodb_purge_threads = 4
innodb_thread_concurrency = 64
innodb_print_all_deadlocks = 1
innodb_strict_mode = 1
innodb_sort_buffer_size = 67108864 

#######MGR##########
#transaction_write_set_extraction=XXHASH64
#loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
#loose-group_replication_start_on_boot=off
#loose-group_replication_local_address= "10.253.124.77:33060"
#loose-group_replication_group_seeds= "10.253.124.77:33060,10.253.124.78:33060,10.253.124.79:33060,10.253.124.80:33060,10.253.124.81:33060,10.253.124.82:33060"
#loose-group_replication_bootstrap_group= off
#loose-group_replication_single_primary_mode=FALSE
#loose-group_replication_enforce_update_everywhere_checks= TRUE 

#####Master-slave semi sync#########
plugin_dir=${mysqlpath}/mysql/lib/plugin
plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"
rpl_semi_sync_master_enabled = 1 
rpl_semi_sync_master_timeout = 1000

[mysqld-5.7]
innodb_buffer_pool_dump_pct = 40
innodb_page_cleaners = 4
innodb_undo_log_truncate = 1
innodb_max_undo_log_size = 2G
innodb_purge_rseg_truncate_frequency = 128
binlog_gtid_simple_recovery=1
log_timestamps=system
show_compatibility_56=on
EOF

cd ${mysqlpath}/mysql/
./bin/mysqld --defaults-file=/etc/my.cnf --datadir=${mysqlpath}/mysql/data --basedir=${mysqlpath}/mysql --user=mysql --initialize-insecure

cd ${mysqlpath}/mysql/
cp support-files/mysql.server /etc/init.d/mysqld
mv /usr/bin/mysql /usr/bin/mysql.bak
ln -s ${mysqlpath}/mysql/bin/mysql /usr/bin/mysql

chkconfig mysqld on
service mysqld start

${mysqlpath}/mysql/bin/mysql -uroot -e"set password=‘123qqq...‘;
update mysql.user set host=‘%‘ where user=‘root‘;
flush privileges;"

shell脚本实例

标签:sum   libaio   orm   dir   evel   ima   soft   max   ted   

原文地址:https://blog.51cto.com/14052552/2420245

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!