广告
返回顶部
首页 > 资讯 > 数据库 >我写的一键安装MySQL脚本——暴力版
  • 475
分享到

我写的一键安装MySQL脚本——暴力版

2024-04-02 19:04:59 475人浏览 独家记忆
摘要

[root@xd-10-189 songlisha]# cat install_Mysql.sh  #!/bin/bash mysql_src=/songlisha

[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

我写的一键安装MySQL脚本——暴力版

您可能感兴趣的文档:

--结束END--

本文标题: 我写的一键安装MySQL脚本——暴力版

本文链接: https://www.lsjlt.com/news/43521.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作