设为首页 收藏本站
查看: 780|回复: 0

[经验分享] MySQL主从架构由5.5版本升级到5.6方案

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-8-30 09:38:02 | 显示全部楼层 |阅读模式
主从架构[一主多从]升级步骤

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》主
   特别注意配置文件的正确性
   磁盘空间足够存放两份旧数据的大小
   旧数据不动,以防升级失败,可以回退到旧版本



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-265051-1-1.html 上篇帖子: PHP对Mysql操作的自定义函数 下篇帖子: mysql变量修改及生效 版本升级
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表