Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql innodb cluster building

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Build according to the document. Https://dev.mysql.com/doc/refman/8.0/en/mysql-innodb-cluster-production-deployment.html

Environmental preparation:

1 download and install the required software (my own version of the software-all Linux Generic versions in mysql Community)

Mysql-server (mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz)

Mysql-router (mysql-router-8.0.17-linux-glibc2.12-x86_64.tar.xz)

Mysql-shell (mysql-shell-8.0.17-linux-glibc2.12-x86-64bit.tar.gz)

Installation (take mysql server as an example, other similar, the following are Mysql_tar operating system user operations):

Cd / home/mysql_tar

Tar-xvf mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz

Ln-s mysql-8.0.17-linux-glibc2.12-x86_64 mysql_install (easy to upgrade)

... mysql-router...

.... mysql_shell...

Edit the environment variable:

Vim / home/mysql_tar/.bash_profile

# FOR MYSQL

MYSQL_HOME=/home/mysql_tar/mysql_install

PATH=$PATH:$MYSQL_HOME/bin

Export MYSQL_HOME

# MYSQL SHELL

MYSQL_SHELL_HOME=/home/mysql_tar/mysql_shell

PATH=$PATH:$MYSQL_SHELL_HOME/bin

Export MYSQL_SHELL_HOME

# MYSQL_ROUTER

MYSQL_ROUTER=/home/mysql_tar/mysql_router

PATH=$PATH:$MYSQL_ROUTER/bin

Export MYSQL_ROUTER

Export PATH

Prepare the mysql profile my.cnf

Vim / etc/my.cnf

Default-authentication-plugin=mysql_native_password

Lower_case_table_names=1

Datadir=/data_test

Socket=/data_test/mysql.sock

Log-error=/data_test/mysqld.log

Pid-file=/data_test/mysqld.pid

Create a data directory file / data_test (both users and user groups are mysql_tar) to initialize mysql

Cd / home/mysql_tar/mysql_install/bin (environment variable is set correctly, this step is optional)

. / mysqld-- initialize-- user=mysql_tar (initializes mysql system tablespaces and other important files. If initialize misspells, it will not report errors, but will only prompt that the data directory cannot be found.) start Mysql

Mysqld_safe-- user=mysql_tar & Connect to Mysql and change the root account password:

. / mysql-u root-S / data_test/mysql.sock-p (you can also log in via TCP/IP, here via sockets)

Mysql > alter user root@localhost identified by 'mjj'; log in to mysql through mysqlsh, check the environment, and create a cluster

/ home/mysql_tar/mysql_shell/bin/mysqlsh

MySQL SQL >\ connect root@mysql_host_a (bold is my order)

Creating a session to 'root@mysql_host_a'

Please provide the password for 'root@mysql_host_a': *

Save password for 'root@mysql_host_a'? [y] es/ [N] o / ne [v] er (default No): ~ ~

MySQL mysql_host_a:33060+ ssl JS > dba.checkInstanceConfiguration ()

Validating local MySQL instance listening at port 3306 for use in an InnoDB cluster...**

This instance reports its own address as mysql_host_a:3306

Clients and other cluster members will communicate with it through this address by default. If this is not correct, the report_host MySQL system variable should be changed.

Checking whether existing tables comply with Group Replication requirements...

No incompatible tables detected

Checking instance configuration...

NOTE: Some configuration options need to be fixed:

+-+

| | Variable | Current Value | Required Value | Note | |

+-+

| | binlog_checksum | CRC32 | NONE | Update the server variable | |

| | enforce_gtid_consistency | OFF | ON | Update read-only variable and restart the server | |

| | gtid_mode | OFF | ON | Update read-only variable and restart the server | |

| | server_id | 1 | | Update read-only variable and restart the server |

+-+

Some variables need to be changed, but cannot be done dynamically on the server.

NOTE: Please use the dba.configureInstance () command to repair these issues.

{

"config_errors": [

{

"action": "server_update"

"current": "CRC32"

"option": "binlog_checksum"

"required": "NONE"

}

{

"action": "server_update+restart"

"current": "OFF"

"option": "enforce_gtid_consistency"

"required": "ON"

}

{

"action": "server_update+restart"

"current": "OFF"

"option": "gtid_mode"

"required": "ON"

}

{

"action": "server_update+restart"

"current": "1"

"option": "server_id"

"required":

}

]

"status": "error"

}

MySQL mysql_host_a:33060+ ssl JS >\ exit

Bye!

Add the following parameters to / etc/my.cnf according to the error:

# for innodb cluster

Binlog_checksum=none

Enforce_gtid_consistency=on

Gtid_mode=on

Server_id=1234

Create a cluster

MySQL mysql_host_a:33060+ ssl JS > var cluster = dba.createCluster ('mjjcluster')

A new InnoDB cluster will be created on instance 'mysql_host_a:3306'.

Validating instance at mysql_host_a:3306...

This instance reports its own address as mysql_host_a:3306

Instance configuration is suitable.

Creating InnoDB cluster' mjjcluster' on 'mysql_host_a:3306'...

Adding Seed Instance...

Cluster successfully created. Use Cluster.addInstance () to add MySQL instances.

At least 3 instances are needed for the cluster to be able to withstand up to

One server failure.

10 you can view the cluster status through the cluster.status (); command

MySQL mysql_host_a:33060+ ssl JS > cluster.status ()

{

"clusterName": "mjjcluster"

"defaultReplicaSet": {

"name": "default"

"primary": "mysql_host_a:3306"

"ssl": "REQUIRED"

"status": "OK_NO_TOLERANCE"

"statusText": "Cluster is NOT tolerant to any failures."

"topology": {

"mysql_host_a:3306": {

"address": "mysql_host_a:3306"

"mode": "Rhampw"

"readReplicas": {}

"role": "HA"

"status": "ONLINE"

"version": "8.0.17"

}

}

"topologyMode": "Single-Primary"

}

"groupInformationSourceMember": "mysql_host_a:3306"

}

11, other machines also install software and prepare the environment (dba.checkInstanceConfiguration () pass, the steps are similar to the master node)

Join the node:

MySQL mysql_host_a:33060+ ssl JS > cluster.addInstance ('root@mysql_host_b:3306'); (the host name of my other machine is mysql_host_b)

Cluster.addInstance: Connection 'root@mysql_host_b:3306' is not valid: unable to resolve the IPv4 address. (ArgumentError)

MySQL mysql_host_a:33060+ ssl JS > cluster.addInstance ('root@mysql_host_b:3306')

Please provide the password for 'root@mysql_host_b:3306': * *

Save password for 'root@mysql_host_b:3306'? [y] es/ [N] o / ne [v] er (default No):

NOTE: The target instance 'mysql_host_b:3306' has not been pre-provisioned (GTID set

Is empty). The Shell is unable to decide whether incremental distributed state

Recovery can correctly provision it.

The safest and most convenient way to provision a new instance is through

Automatic clone provisioning, which will completely overwrite the state of

'mysql_host_b:3306' with a physical snapshot from an existing cluster member.

To use this method by default, set the 'recoveryMethod' option to' clone'.

The incremental distributed state recovery may be safely used if you are sure

All updates ever executed in the cluster were done with GTIDs enabled, there

Are no purged transactions and the new instance contains the same GTID set as

The cluster or a subset of it. To use this method by default, set the

'recoveryMethod' option to 'incremental'.

Please select a recovery method [C] lone/ [I] ncremental recovery/ [A] bort (default Clone):

Validating instance at mysql_host_b:3306...

This instance reports its own address as mysql_host_b:3306

Instance configuration is suitable.

A new instance will be added to the InnoDB cluster. Depending on the amount of

Data on the cluster this might take from a few seconds to several hours.

Adding instance to the cluster...

Monitoring recovery process of the new cluster member. Press ^ C to stop monitoring and let it continue in background.

Clone based state recovery is now in progress.

NOTE: A server restart is expected to happen as part of the clone process. If the

Server does not support the RESTART command or does not come back after a

While, you may need to manually start it back.

Waiting for clone to finish...

NOTE: mysql_host_b:3306 is being cloned from mysql_host_a:3306

Stage DROP DATA: Completed

Clone Transfer

FILE COPY # 100% Completed

PAGE COPY # 100% Completed

REDO COPY # 100% Completed

NOTE: mysql_host_b:3306 is shutting down...

Waiting for server restart... Readymysql_host_b:3306 has restarted, waiting for clone to finish...

* * Stage RESTART: CompletedClone process has finished: 58.50 MB transferred in about 1 second (~ inf TB/s)

State recovery already finished for 'mysql_host_b:3306'

The instance 'mysql_host_b:3306' was successfully added to the cluster.

. . . It's done. That's all for the basic steps.

Main methods:

Dba.configureInstance ()

Dba.createCluster ()

Cluster.addInstance ()-cluster=dba.getCluster () gets the cluster variable

Cluster.removeInstance ()

Cluster.rejoinInstance ()

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report