MySQL主从架构由5.5版本升级到5.6方案

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介:

主从架构[一主多从]升级步骤


1. 首先安装最新版本的MySQL  mysql-5.6.26.tar.gz  

   :每台主机分别安装目录:/usr/local/mysql-5.6


yum install libaio-devel 


   编译参数


/usr/local/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6 \

-DMYSQL_DATADIR=/usr/local/mysql-5.6/data \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DENABLE_LOCAL_INFILE=1 \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DEXTRA_CHARSETS=all \

-DMYSQL_TCP_PORT=3306 \

-DWITH_DEBUG=OFF \

-DWITH_READLINE=1 \

-DWITH_EMBEDDED_SERVER=1 \

-DMYSQL_UNIX_ADDR=/tmp/mysql6.sock \

-DWITH_SSL=bundled \

-DENABLE_DTRACE=OFF 




make;make install


软件安装OK



2. 停止其中一个从库:

   将原版本中的数据[data]目录[/usr/local/mysql]拷贝到新版本对应的目录下面[/usr/local/mysql-5.6]

    cp -r /usr/local/mysql/data    /usr/local/mysql-5.6/


3. 变更权限:

   chown -R root .

   chown -R mysql data

   

4. 变更启动脚本

   rm -f /etc/init.d/mysqld

   cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld-5.5

   cp /usr/local/mysql-5.6/support-files/mysql.server  /etc/init.d/mysqld-5.6

   chmod +x  /etc/init.d/mysqld-5.*


5.启动新版本实例

  注意:配置文件必须配置正确,如果配置了旧的参数,会导致实例无法启动

  /etc/init.d/mysqld-5.6 start

  然后观察错误文件,会看到如下报错:

   2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'setup_actors' has the wrong structure

   2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'setup_objects' has the wrong structure

   2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'table_io_waits_summary_by_index_usage' has the wrong structure

   2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'table_io_waits_summary_by_table' has the wrong structure

   2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'table_lock_waits_summary_by_table' has the wrong structure

   2015-08-04 13:16:31 18815 [ERROR] Column count of mysql.threads is wrong. Expected 14, found 3. Created with MySQL 50518, now running 50626. Please use mysql_upgrade to fix this error.

   2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'events_stages_current' has the wrong structure

   2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'events_stages_history' has the wrong structure

   2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'events_stages_history_long' has the wrong structure

   2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_thread_by_event_name' has the wrong structure

   2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_account_by_event_name' has the wrong structure

   2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_user_by_event_name' has the wrong structure

   2015-08-04 13:16:31 18815 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_host_by_event_name' has the wrong structure


6. 运行新版本下的升级脚本进行升级检查,修复mysql库中的主要表

   /usr/local/mysql-5.6/bin/mysql_upgrade -u root -proot

   Warning: Using a password on the command line interface can be insecure.

   Looking for 'mysql' as: /usr/local/mysql_5.6/bin/mysql

   Looking for 'mysqlcheck' as: /usr/local/mysql-5.6/bin/mysqlcheck

   Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql6.sock' 

   Warning: Using a password on the command line interface can be insecure.

   Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql6.sock' 

   Warning: Using a password on the command line interface can be insecure.

   mysql.columns_priv                                 OK

   mysql.db                                           OK

   mysql.event                                        OK

   mysql.func                                         OK

   mysql.general_log                                  OK

   mysql.help_category                                OK

   mysql.help_keyword                                 OK

   mysql.help_relation                                OK

   mysql.help_topic                                   OK

   mysql.host                                         OK

   mysql.innodb_index_stats                           OK

   mysql.innodb_table_stats                           OK

   mysql.ndb_binlog_index                             OK

   mysql.plugin                                       OK

   mysql.proc                                         OK

   mysql.procs_priv                                   OK

   mysql.proxies_priv                                 OK

   mysql.servers                                      OK

   mysql.slave_master_info                            OK

   mysql.slave_relay_log_info                         OK

   mysql.slave_worker_info                            OK

   mysql.slow_log                                     OK

   mysql.tables_priv                                  OK

   mysql.time_zone                                    OK

   mysql.time_zone_leap_second                        OK

   mysql.time_zone_name                               OK

   mysql.time_zone_transition                         OK

   mysql.time_zone_transition_type                    OK

   mysql.user                                         OK

   Running 'mysql_fix_privilege_tables'...

   Warning: Using a password on the command line interface can be insecure.

   Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql6.sock' 

   Warning: Using a password on the command line interface can be insecure.

   Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql6.sock' 

   Warning: Using a password on the command line interface can be insecure.

   babysitter.abc                                     OK

   babysitter.account_tactics_daily_availability      OK

   babysitter.andtlhz_new                             OK


7. 检查完后重启实例

   /etc/init.d/mysqld-5.6 restart






配置文件


   [client]

   #default-character-set   = utf8

   port                    = 3306

   socket                  = /tmp/mysql6.sock

   

   [mysqld]

   

   #skip-grant-tables

   user                    = mysql

   port                    = 3306

   socket                  = /tmp/mysql6.sock

   pid-file                = /usr/local/mysql-5.6/data/mysql-upgrade-master.pid

   #pid-file                = /usr/local/mysql-5.6/data/[主机名].pid

   #pid-file                = /usr/local/mysql-5.6/data/[主机名].pid

   

   ##################

   

   basedir                 = /usr/local/mysql-5.6

   datadir                 = /usr/local/mysql-5.6/data

   

   server-id               = 1

   #server-id               = 2  #从库1配置

   #server-id               = 3  #从库2配置

   

   log_slave_updates       = 1

   log_slave_updates       = 0  #从库配置

   log-bin                 = mysql-bin

   #log-bin                 = mysql-bin   #从库不需要开启binlog

   

   binlog_format           = mixed

   binlog_cache_size       = 64M

   max_binlog_cache_size   = 128M

   expire_logs_days        = 2

   max_binlog_size         = 1G

   binlog-ignore-db        = mysql

   binlog-ignore-db        = test

   binlog-ignore-db        = information_schema

   binlog-ignore-db        = performance_schema

   query_cache_type =0

   

   key_buffer_size         = 384M

   sort_buffer_size        = 2M

   read_buffer_size        = 2M

   read_rnd_buffer_size    = 16M

   join_buffer_size        = 2M

   thread_cache_size       = 8

   query_cache_size        = 32M

   query_cache_limit       = 2M

   query_cache_min_res_unit = 2K

   thread_concurrency      = 32

   

   table_open_cache        = 512

   open_files_limit        = 10240

   back_log                = 600

   max_connections         = 5000

   max_connect_errors      = 6000

   external-locking        = FALSE

   

   max_allowed_packet      = 10M

   default-storage-engine  = MYISAM

   thread_stack            = 192K

   transaction_isolation   = READ-COMMITTED

   tmp_table_size          = 256M

   max_heap_table_size     = 512M

   

   bulk_insert_buffer_size = 64M

   long_query_time         = 2

   slow_query_log

   slow_query_log_file     = /usr/local/mysql-5.6/data/slow_query.log

   skip-name-resolve

   explicit_defaults_for_timestamp = true  #新版本关于时间戳的新特性配置

   

   innodb_buffer_pool_size = 512M

   innodb_data_file_path = ibdata1:256M:autoextend

   innodb_file_io_threads  = 4

   innodb_thread_concurrency = 8

   innodb_flush_log_at_trx_commit = 2

   innodb_log_buffer_size  = 16M

   innodb_log_file_size    = 128M

   innodb_log_files_in_group = 3

   innodb_max_dirty_pages_pct = 90

   innodb_lock_wait_timeout = 120

   innodb_file_per_table   = 1

   innodb_flush_method = O_DIRECT

   

   

   [mysqldump]

   quick

   max_allowed_packet   = 10M

   

   [mysql]

   no-auto-rehash

   safe-updates

   

   [mysqlhotcopy]

   interactive-timeout

   

   [myisamchk]

   key_buffer_size = 256M

   sort_buffer_size = 256M

   read_buffer = 2M

   write_buffer = 2M

   

   ##################

   

   

   以上操作顺序为:从1》从2》主

   特别注意配置文件的正确性

   磁盘空间足够存放两份旧数据的大小

   旧数据不动,以防升级失败,可以回退到旧版本


     本文转自andylhz 51CTO博客,原文链接:http://blog.51cto.com/andylhz2009/1844007,如需转载请自行联系原作者



相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
打赏
0
0
0
0
348
分享
相关文章
阿里二面:10亿级分库分表,如何丝滑扩容、如何双写灰度?阿里P8方案+ 架构图,看完直接上offer!
阿里二面:10亿级分库分表,如何丝滑扩容、如何双写灰度?阿里P8方案+ 架构图,看完直接上offer!
阿里二面:10亿级分库分表,如何丝滑扩容、如何双写灰度?阿里P8方案+ 架构图,看完直接上offer!
【上云基础系列 02-01】通过SLB+1台ECS+ESS弹性伸缩,搭建一个精简版的上云标准弹性架构(含方案及教程)
通常,构建一个弹性架构(即使是一个最基础的入门版),至少需要2台ECS。但是,很多小微企业刚开始上云的时候,为了节省成本不愿意购买更多的服务器。通过 “ALB+ESS弹性伸缩+1台ECS+RDS”方案,在保障低成本的同时,也不牺牲业务架构的弹性设计,更避免了很多人因为节省成本选择了单体架构后频繁改造架构的困局。 方案中的几个设计非常值得小微企业借鉴:(1)通过ALB/RDS的按量付费,节省了初期流量不大时的费用;(2)通过ESS弹性伸缩,不需要提前购买服务器资源,但是当业务增长或减少时却保持了资源弹性自动扩缩容。
2025年阿里云弹性裸金属服务器架构解析与资源配置方案
🚀 核心特性与技术创新:提供100%物理机性能输出,支持NVIDIA A100/V100 GPU直通,无虚拟化层损耗。网络与存储优化,400万PPS吞吐量,ESSD云盘IOPS达100万,RDMA延迟<5μs。全球部署覆盖华北、华东、华南及海外节点,支持跨地域负载均衡。典型应用场景包括AI训练、科学计算等,支持分布式训练和并行计算框架。弹性裸金属服务器+OSS存储+高速网络综合部署,满足高性能计算需求。
【上云基础系列04】基于标准架构的数据库升级
本文回顾了业务上云从基础到进阶的理念,涵盖基础版和全栈版架构。在“入门级:上云标准弹性架构基础版”的基础上,本文针对数据库升级,重点介绍了高可用数据库架构的升级方案,确保数据安全和业务连续性。最后,附有详细的“上云标准弹性架构”演进说明,帮助用户选择合适的架构方案。
基于 Apache RocketMQ 的 ApsaraMQ Serverless 架构升级
基于 Apache RocketMQ 的 ApsaraMQ Serverless 架构升级
AllData数据中台技术架构升级演进
杭州奥零数据科技有限公司成立于2023年,专注于数据中台业务,维护开源项目AllData并提供商业版解决方案。AllData提供数据集成、存储、开发、治理及BI展示等一站式服务,支持AI大模型应用,助力企业高效利用数据价值。
使用Qwen2.5+SpringBoot+SpringAI+SpringWebFlux的基于意图识别的多智能体架构方案
本项目旨在解决智能体的“超级入口”问题,通过开发基于意图识别的多智能体框架,实现用户通过单一交互入口使用所有智能体。项目依托阿里开源的Qwen2.5大模型,利用其强大的FunctionCall能力,精准识别用户意图并调用相应智能体。 核心功能包括: - 意图识别:基于Qwen2.5的大模型方法调用能力,准确识别用户意图。 - 业务调用中心:解耦框架与业务逻辑,集中处理业务方法调用,提升系统灵活性。 - 会话管理:支持连续对话,保存用户会话历史,确保上下文连贯性。 - 流式返回:支持打字机效果的流式返回,增强用户体验。 感谢Qwen2.5系列大模型的支持,使项目得以顺利实施。
1082 8
使用Qwen2.5+SpringBoot+SpringAI+SpringWebFlux的基于意图识别的多智能体架构方案
MySQL版本升级(8.0.31->8.0.37)
本次升级将MySQL从8.0.31升级到8.0.37,采用就地升级方式。具体步骤包括:停止MySQL服务、备份数据目录、下载并解压新版本的RPM包,使用`yum update`命令更新已安装的MySQL组件,最后启动MySQL服务并验证版本。整个过程需确保所有相关RPM包一同升级,避免部分包遗漏导致的问题。官方文档提供了详细指导,确保升级顺利进行。
472 16
Paimon助力数据湖仓架构实时化升级
本次分享由阿里云高级技术专家李劲松介绍Paimon助力数据湖仓架构实时化升级。内容涵盖四个部分:1) 数据架构的存储演进,介绍Data LakeHouse结合的优势;2) Paimon实时数据湖,强调其批流一体和高效处理能力;3) 数据湖的实时流式处理,展示Paimon在时效性提升上的应用;4) 数据湖非结构化处理,介绍Paimon对非结构化数据的支持及AI集成。Paimon通过优化存储格式和引入LSM技术,实现了更高效的实时数据处理和查询性能,广泛应用于阿里巴巴内部及各大公司,未来将进一步支持AI相关功能。

热门文章

最新文章