设为首页 加入收藏

TOP

[MySQL]MySQL的自动化安装部署(二)
2015-07-24 10:41:09 来源: 作者: 【 】 浏览:3
Tags:MySQL 自动化 安装 部署
nnodb_buffer_pool_instances=4 innodb_log_files_in_group=4 innodb_log_file_size=1G innodb_log_buffer_size=200M innodb_flush_log_at_trx_commit=1 innodb_additional_mem_pool_size=20M innodb_max_dirty_pages_pct=60 innodb_io_capacity=200 innodb_thread_concurrency=32 innodb_read_io_threads=8 innodb_write_io_threads=8 innodb_open_files=60000 innodb_file_format=Barracuda innodb_file_per_table=1 innodb_flush_method=O_DIRECT innodb_change_buffering=all innodb_adaptive_flushing=1 innodb_old_blocks_time=1000 innodb_stats_on_metadata=0 innodb_read_ahead=0 innodb_use_native_aio=0 innodb_lock_wait_timeout=50 innodb_rollback_on_timeout=0 innodb_purge_threads=1 innodb_strict_mode=1 transaction-isolation=READ-COMMITTED #myisam key_buffer_size=100M myisam_sort_buffer_size=64M concurrent_insert=2 delayed_insert_timeout=300 #replication master-info-file=/data/mysql/log/master.info relay-log=/data/mysql/log/mysql-relay relay_log_info_file=/data/mysql/log/mysql-relay.info relay-log-index=/data/mysql/log/mysql-relay.index slave_load_tmpdir=/data/mysql/tmp slave_type_conversions="ALL_NON_LOSSY" slave_net_timeout=4 skip-slave-start sync_master_info=1000 sync_relay_log_info=1000 #binlog log-bin=/data/mysql/log/mysql-bin server_id=2552763370 binlog_cache_size=32K max_binlog_cache_size=2G max_binlog_size=500M binlog_format=ROW sync_binlog=1000 log-slave-updates=1 expire_logs_days=0 #server default-storage-engine=INNODB character-set-server=gbk lower_case_table_names=1 skip-external-locking open_files_limit=65536 safe-user-create local-infile=1 performance_schema=0 log_slow_admin_statements=1 log_warnings=1 long_query_time=1 slow_query_log=1 general_log=0 query_cache_type=0 query_cache_limit=1M query_cache_min_res_unit=1K table_definition_cache=65536 thread_stack=512K thread_cache_size=256 read_rnd_buffer_size=128K sort_buffer_size=256K join_buffer_size=128K read_buffer_size=128K port=3306 skip-name-resolve skip-ssl max_connections=4500 max_user_connections=4000 max_connect_errors=65536 max_allowed_packet=128M connect_timeout=8 net_read_timeout=30 net_write_timeout=60 back_log=1024 #server id 细心的读者应该会注意在,在my.cnf的末尾在server id上留了空白,在后面的shell脚本会动态加上,这是因为在一个企业内部的所有MySQL的server id必须保持全局一致性,这样在主备复制时才不会导致混乱。 其实如果想把这个脚本写的更通用,完全可以把更多的参数留白,如port、datadir、内存相关参数等,这里我只是以server id为例,抛砖引玉。

3、准备MySQL数据目录模板

你得事先准备一台MySQL,可以根据自己的需求,把通用性的东西放在上面(如账户等),下面是一个最简单的已安装好的MySQL的数据目录结构:
[root@lx25 mysql]# ls -l
total 12
drwxr-xr-x 5 mysql mysql 4096 Jul  2 09:26 data
drwxr-xr-x 2 mysql mysql 4096 Jul  1 18:21 log
drwxr-xr-x 2 mysql mysql 4096 Jul  2 09:26 tmp
[root@lx25 mysql]# cd data
[root@lx25 data]# ls -l
total 6314044
drwx------ 2 mysql mysql       4096 Jul  1 17:17 mysql
drwx------ 2 mysql mysql       4096 Jul  1 17:17 performance_schema
drwx------ 2 mysql mysql       4096 Jul  1 17:17 test
把该目录用tar打包(命名为data.tar),然后以这个为模板解压至新装MySQL实例的数据目录下即可。

4、编写自动化安装部署脚本

在运行这个脚本之前,我们必须得把前面几部制作的rpm包、my.cnf模板和数据目录模板放到一个固定的地方,本例中是放在企业内部的ftp上。 MySQL自动化安装部署脚本(命名为:mysql_install.sh)如下:
#!/bin/sh

#Step 1: Prepare
yum install cmake gcc g++ bison ncurses-devel zlib 

groupadd mysql
useradd -g mysql mysql

#Step 2: G
首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇mysql---左连接、右连接、内连接.. 下一篇[Python]使用MYSQL

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·雾里看花:真正意义 (2025-12-26 10:54:36)
·C++——模板(超详细 (2025-12-26 10:54:34)
·C++ 模板 | 菜鸟教程 (2025-12-26 10:54:30)
·请问c语言刚入门,该 (2025-12-26 10:21:04)
·python 编程怎么定义 (2025-12-26 10:21:01)