• mariadb galera cluster 同步操作


    集群掉电,同事着急直接启动一台作为服务。

    预防外一,先把这个1节点作为主节点,单独作为一个集群 leader。

    SET GLOBAL wsrep_provider_options='pc.bootstrap=YES';

    同步第2个节点,同步过程中1节点无法访问。查看进程等待。

    select user,host,time,command,state from information_schema.processlist where state != '' order by 1;
    +----------------------+----------------------+--------+---------+------------------------------------------------+
    | user                 | host                 | time   | command | state                                          |
    +----------------------+----------------------+--------+---------+------------------------------------------------+
    | eXX             | XX   |    942 | Query   | Waiting for global read lock                   |
    | eXX           | XX   |    803 | Query   | Waiting for global read lock                   |
    | eXXXX                |X XX  |      3 | Query   | Opening tables                                 |
    | eXXXX              | XX  |     10 | Query   | Opening tables                                 |
    | eXXXX             | XX  |     16 | Query   | Opening tables                                 |
    ········

    可以看到,有全局读锁

    Waiting for global read lock

    检查同步

    MariaDB [(none)]> show status like 'wsrep_clu%';
    +----------------------------+--------------------------------------+
    | Variable_name              | Value                                |
    +----------------------------+--------------------------------------+
    | wsrep_cluster_weight       | 2                                    |
    | wsrep_cluster_capabilities |                                      |
    | wsrep_cluster_conf_id      | 18446744073709551615                 |
    | wsrep_cluster_size         | 2                                    |
    | wsrep_cluster_state_uuid   | c86db238-d520-11ea-8d9e-ee07c79bb5a5 |
    | wsrep_cluster_status       | Primary                              |
    +----------------------------+--------------------------------------+


    MariaDB [(none)]> show variables like '%wsrep_clu%';
    +-----------------------+---------------------------------------------------------+
    | Variable_name         | Value                                                   |
    +-----------------------+---------------------------------------------------------+
    | wsrep_cluster_address | gcomm://172.3.3.41:4567,172.3.3.43:4567,172.3.3.42:4567 |
    | wsrep_cluster_name    | my_wsrep_cluster                                        |
    +-----------------------+---------------------------------------------------------+
    2 rows in set (0.001 sec)

    报错:

    一、

    Aug 15 22:05:46 Mariadb42 mysqld[49007]: 2020-08-15 22:05:46 0 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name.  Please run mysql_upgrade
    Aug 15 22:05:46 Mariadb42 mysqld[49007]: 2020-08-15 22:05:46 0 [ERROR] InnoDB: Column last_update in table `mysql`.`innodb_table_stats` is INT UNSIGNED NOT NULL but should be BINARY(4) NOT NULL (type mismatch).

    由于集群中版本不同,需要升级数据库的相关表结构。

    mysql_upgrade -u root -p --force

    二、

    Jun 13 15:05:28 localhost.localdomain sh[41841]: 2020-06-13 15:05:28 0 [Note] InnoDB: Completed initialization of buffer pool
    Jun 13 15:05:28 localhost.localdomain sh[41841]: 2020-06-13 15:05:28 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See
    Jun 13 15:05:28 localhost.localdomain sh[41841]: 2020-06-13 15:05:28 0 [ERROR] InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10.2.2.
    Jun 13 15:05:28 localhost.localdomain sh[41841]: 2020-06-13 15:05:28 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
    Jun 13 15:05:28 localhost.localdomain sh[41841]: 2020-06-13 15:05:28 0 [Note] InnoDB: Starting shutdown...
    Jun 13 15:05:28 localhost.localdomain sh[41841]: 2020-06-13 15:05:28 0 [ERROR] Plugin 'InnoDB' init function returned error.
    Jun 13 15:05:28 localhost.localdomain sh[41841]: 2020-06-13 15:05:28 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
    Jun 13 15:05:28 localhost.localdomain sh[41841]: 2020-06-13 15:05:28 0 [Note] Plugin 'FEEDBACK' is disabled.
    Jun 13 15:05:28 localhost.localdomain sh[41841]: 2020-06-13 15:05:28 0 [ERROR] Unknown/unsupported storage engine: InnoDB
    Jun 13 15:05:28 localhost.localdomain sh[41841]: 2020-06-13 15:05:28 0 [ERROR] Aborting'

    意思是”不支持在崩溃后进行升级。redo日志是用MariaDB 10.2.2之前创建的。”
    翻译成人话就是:由于redo log文件是早期版本(10.2.2之前)创建的,我不认识它。

    此处注意,因为公司用的是不同版本的mariadb 做的多主集群,需要将ib_logfile* 日志删除后,自启动(注释掉:#wsrep_on )使其建立自己版本的 ib_logfile0,ib_logfile1 后进行同步,有时无法同步成功,删除grastate.dat, galera.cache, ib_logfile*, ibdata* 后进行同步即可。

  • 相关阅读:
    DataTable转Json就是这么简单(Json.Net DLL (Newtonsoft))
    Mysql查询数据库 整理
    Mysq基础l数据库管理、表管理、增删改数据整理
    zTree基础
    ECharts基础
    layui基础总结
    Bootstrap基础
    JQuery进阶
    JQuery基础总结
    Javascript鼠标键盘事件
  • 原文地址:https://www.cnblogs.com/Leo-Cjh/p/13510663.html
Copyright © 2020-2023  润新知