首页 > 数据库 > MySQL > 正文

CentOS7.5使用mysql

2024-07-24 12:41:49
字体:
来源:转载
供稿:网友

因使用源码安装的MySQL5.7.28多实例,在导入数据库时会出现问题,所以重新研究使用mysql_multi的方法来管理多实例,经过测试环境验证之后,在各方面使用上特别在备份还原上,没有报MySQL5.7.28多实例的问题,踩了不少坑,这里我将我的部署过程分享下,如果在哪里出问题的,还请多多指正与指导,谢谢!!

参考文章:Centos7.5安装mysql5.7.24二进制包方式部署

https://www.jb51.net/article/151867.htm

本从就直接从2.7章节开始安装mysql多实例,具体部署过程如下:

2.7 安装mysql多实例

2.7.1. 创建软件安装目录(部署路径请根据实际修改)

[root@~]# mkdir -pv /data/mysql/{3306,3307}[root@~]# mkdir -v /data/mysql/3306/{logs,data,binlog}[root@~]# mkdir -v /data/mysql/3307/{logs,data,binlog}

2.7.2. MySQL安装包下载

[root@~]# cd /opt[root@~]# wget -c https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz[root@~]# tar zxvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz[root@~]# mv mysql-5.7.28-linux-glibc2.12-x86_64 /usr/local/mysql[root@~]# chown -R mysql:mysql /usr/local/mysql[root@~]# chown -R mysql:mysql /data

2.7.3. MySQL参数配置

 配置my.cnf参数文件

(1)server_id=3306与server_id=3307数值请根据实际配置,注意配置的id值与局域网内其他各实例所配置的数值不可以冲突;

(2)max_connections=1000配置MySQL数据库的最大连接数,根据实际需要配置,其他参数的优化根据实际需要修改或添

加;

(3)配置文件全部内容如下

[root@~]# vim /etc/my.cnf[mysqld_multi]mysqld = /usr/local/mysql/bin/mysqldmysqladmin = /usr/local/mysql/bin/mysqladminlog = /data/mysql/mysqld_multi.log #user=root#pass=[mysql]prompt="/u@jsshapp /R:/m:/s [/d]> "no-auto-rehash[mysqld3306]user = mysqlport = 3306symbolic-links = 0#basedir = /usr/datadir = /data/mysql/3306/datasocket = /data/mysql/3306/mysql3306.sockpid-file = /data/mysql/3306/mysqld3306.pidserver_id = 3306character_set_server = utf8max_connections = 1000skip_name_resolve = 1open_files_limit = 65536thread_cache_size = 64table_open_cache = 4096table_definition_cache = 1024table_open_cache_instances = 64max_prepared_stmt_count = 1048576explicit_defaults_for_timestamp = truelog_timestamps = systembinlog_format = rowlog_bin = /data/mysql/3306/binlog/mysql-binbinlog_rows_query_log_events = onexpire_logs_days = 7binlog_cache_size = 4Mmax_binlog_cache_size = 2Gmax_binlog_size = 1Gsync_binlog = 1log_bin_trust_function_creators = 1slow_query_log = onslow_query_log_file = /data/mysql/3306/data/slow.loglog-error = /data/mysql/3306/logs/error.loglog_queries_not_using_indexes = onlong_query_time = 1.000000gtid_mode = onenforce_gtid_consistency = ondefault_storage_engine = innodbdefault_tmp_storage_engine = innodbinnodb_data_file_path = ibdata1:12M:autoextend:max:2000Minnodb_temp_data_file_path = ibtmp1:12M:autoextend:max:2000Minnodb_buffer_pool_filename = ib_buffer_poolinnodb_log_files_in_group = 3innodb_log_file_size = 512Minnodb_online_alter_log_max_size = 1024Minnodb_open_files = 4096innodb_page_size = 16kinnodb_thread_concurrency = 0innodb_read_io_threads = 4innodb_write_io_threads = 4innodb_purge_threads = 4innodb_page_cleaners = 4innodb_print_all_deadlocks = oninnodb_lock_wait_timeout = 20innodb_spin_wait_delay = 128innodb_autoinc_lock_mode = 2innodb_io_capacity = 200innodb_io_capacity_max = 2000#innodb_flush_neighbors = innodb_log_buffer_size = 8Minnodb_flush_log_at_timeout = 1innodb_flush_log_at_trx_commit = 2innodb_buffer_pool_size = 1024Minnodb_buffer_pool_instances = 4autocommit = 1innodb_buffer_pool_dump_pct = 25innodb_buffer_pool_dump_at_shutdown = ONinnodb_buffer_pool_load_at_startup = ON[mysqld3307]user = mysqlport = 3307symbolic-links = 0lower_case_table_names = 1#basedir = /usr/datadir = /data/mysql/3307/datasocket = /data/mysql/3307/mysql3307.sockpid-file = /data/mysql/3307/mysqld3307.pidserver_id = 3307character_set_server = utf8max_connections = 1000skip_name_resolve = 1open_files_limit = 65536thread_cache_size = 64table_open_cache = 4096table_definition_cache = 1024table_open_cache_instances = 64max_prepared_stmt_count = 1048576explicit_defaults_for_timestamp = truelog_timestamps = systembinlog_format = rowlog_bin = /data/mysql/3307/binlog/mysql-binbinlog_rows_query_log_events = onexpire_logs_days = 7binlog_cache_size = 4Mmax_binlog_cache_size = 2Gmax_binlog_size = 1Gsync_binlog = 1slow_query_log = onslow_query_log_file = /data/mysql/3307/data/slow.loglog-error = /data/mysql/3307/logs/error.loglog_queries_not_using_indexes = onlong_query_time = 1.000000gtid_mode = onenforce_gtid_consistency = ondefault_storage_engine = innodbdefault_tmp_storage_engine = innodbinnodb_data_file_path = ibdata1:12M:autoextend:max:2000Minnodb_temp_data_file_path = ibtmp1:12M:autoextend:max:2000Minnodb_buffer_pool_filename = ib_buffer_poolinnodb_log_files_in_group = 3innodb_log_file_size = 512Minnodb_online_alter_log_max_size = 1024Minnodb_open_files = 4096innodb_page_size = 16kinnodb_thread_concurrency = 0innodb_read_io_threads = 4innodb_write_io_threads = 4innodb_purge_threads = 4innodb_page_cleaners = 4innodb_print_all_deadlocks = oninnodb_lock_wait_timeout = 20innodb_spin_wait_delay = 128innodb_autoinc_lock_mode = 2innodb_io_capacity = 200innodb_io_capacity_max = 2000#innodb_flush_neighbors = innodb_log_buffer_size = 8Minnodb_flush_log_at_timeout = 1innodb_flush_log_at_trx_commit = 2innodb_buffer_pool_size = 1024Minnodb_buffer_pool_instances = 4autocommit = 1innodb_buffer_pool_dump_pct = 25innodb_buffer_pool_dump_at_shutdown = ONinnodb_buffer_pool_load_at_startup = ON[mysqldump]quickmax_allowed_packet = 32M
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表