MYSQL Router 8.2.0双开

------承接上一篇文章mysql router读写分离实践。

本套集群已经连接了192.168.85.83~85的主机,但为了更多的承载业务流量尝试启动多个mysqlrouter进程,现在尝试:

64系列的端口,已经打开了,是之前85.83-85的负载管理。

现在我们尝试启动多一个MySQLrouter来管理192.168.28.6~8集群,使用7450端口。

IP地址

角色

操作系统

192.168.85.81

MySQL Router+MASTER

Centos7.7_x64

192.168.85.82

MySQL Router+BACKUP

Centos7.7_x64

192.168.85.80

VIP

192.168.28.6

k8s-master2

Centos7.7_x64

192.168.28.7

k8s-master

Centos7.7_x64

192.168.28.8

k8s-node1

Centos7.7_x64

[root@router01 mysqlrouter7]# mysqlrouter --bootstrap root@192.168.28.6:3306 --directory /etc/mysqlrouter8 --force -c /etc/mysqlrouter/mysqlrouter7.conf --user root

Please enter MySQL password for root:

# Bootstrapping MySQL Router 8.2.0 (MySQL Community - GPL) instance at '/etc/mysqlrouter8'...

- Creating account(s) (only those that are needed, if any)

- Verifying account (using it to run SQL queries that would be run by Router)

- Storing account in keyring

- Adjusting permissions of generated files

- Creating configuration /etc/mysqlrouter8/mysqlrouter.conf

# MySQL Router configured for the InnoDB Cluster 'mycluster'

After this MySQL Router has been started with the generated configuration

$ mysqlrouter -c /etc/mysqlrouter8/mysqlrouter.conf

InnoDB Cluster 'mycluster' can be reached by connecting to:

## MySQL Classic protocol

- Read/Write Connections: localhost:6446

- Read/Only Connections: localhost:6447

- Read/Write Split Connections: localhost:6450

## MySQL X protocol

- Read/Write Connections: localhost:6448

- Read/Only Connections: localhost:6449

[root@router01 mysqlrouter8]# cat /etc/mysqlrouter8/mysqlrouter.conf

# File automatically generated during MySQL Router bootstrap

[DEFAULT]

user=root

logging_folder=/etc/mysqlrouter8/log

runtime_folder=/etc/mysqlrouter8/run

data_folder=/etc/mysqlrouter8/data

keyring_path=/etc/mysqlrouter8/data/keyring

master_key_path=/etc/mysqlrouter8/mysqlrouter.key

connect_timeout=5

read_timeout=30

dynamic_state=/etc/mysqlrouter8/data/state.json

client_ssl_cert=/etc/mysqlrouter8/data/router-cert.pem

client_ssl_key=/etc/mysqlrouter8/data/router-key.pem

client_ssl_mode=PREFERRED

server_ssl_mode=AS_CLIENT

server_ssl_verify=DISABLED

unknown_config_option=error

max_idle_server_connections=74

[logger]

level=INFO

[metadata_cache:bootstrap]

cluster_type=gr

router_id=2

user=mysql_router2_7szuxv9prhkd

metadata_cluster=mycluster

ttl=0.5

auth_cache_ttl=-1

auth_cache_refresh_interval=2

use_gr_notifications=0

[routing:bootstrap_rw]

bind_address=192.168.85.80              ####0.0.0.0修改为192.168.85.80 VIP地址

bind_port=7446                                     ####端口64打头的修改为74打头

destinations=metadata-cache://mycluster/?role=PRIMARY

routing_strategy=first-available

protocol=classic

[routing:bootstrap_ro]

bind_address=192.168.85.80

bind_port=7447

destinations=metadata-cache://mycluster/?role=SECONDARY

routing_strategy=round-robin-with-fallback

protocol=classic

[routing:bootstrap_rw_split]

bind_address=192.168.85.80

bind_port=7450

destinations=metadata-cache://mycluster/?role=PRIMARY_AND_SECONDARY

routing_strategy=round-robin

protocol=classic

connection_sharing=1

client_ssl_mode=PREFERRED

server_ssl_mode=PREFERRED

access_mode=auto

[routing:bootstrap_x_rw]

bind_address=192.168.85.80

bind_port=7448

destinations=metadata-cache://mycluster/?role=PRIMARY

routing_strategy=first-available

protocol=x

[routing:bootstrap_x_ro]

bind_address=192.168.85.80

bind_port=7449

destinations=metadata-cache://mycluster/?role=SECONDARY

routing_strategy=round-robin-with-fallback

protocol=x

[http_server]

port=8444                                       ####http端口8443打头的修改为8444

ssl=1

ssl_cert=/etc/mysqlrouter8/data/router-cert.pem

ssl_key=/etc/mysqlrouter8/data/router-key.pem

[http_auth_realm:default_auth_realm]

backend=default_auth_backend

method=basic

name=default_realm

[rest_router]

require_realm=default_auth_realm

[rest_api]

[http_auth_backend:default_auth_backend]

backend=metadata_cache

[rest_routing]

require_realm=default_auth_realm

[rest_metadata_cache]

require_realm=default_auth_realm

[root@router01 mysqlrouter8]#

[root@router01 mysqlrouter8]# ps -ef|grep router

root 1263 1 2 Dec21 ? 02:28:17 mysqlrouter -c /etc/mysqlrouter/mysqlrouter.conf

#####原来的进程一直在####################

root 86945 85731 0 16:36 pts/2 00:00:00 tailf /etc/mysqlrouter7/log/mysqlrouter.log

root 87819 80935 0 16:42 pts/0 00:00:00 grep --color=auto router

[root@router01 mysqlrouter8]# ls

data log mysqlrouter.conf mysqlrouter.key run start.sh stop.sh

[root@router01 mysqlrouter8]# ./start.sh

[root@router01 mysqlrouter8]# PID 87867 written to '/etc/mysqlrouter8/mysqlrouter.pid'

stopping to log to the console. Continuing to log to filelog

[root@router01 mysqlrouter8]# mysqlsh 192.168.85.80:7450

MySQL Shell 8.2.1

Copyright (c) 2016, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates.

Other names may be trademarks of their respective owners.

Type '\help' or '\?' for help; '\quit' to exit.

Creating a session to 'root@192.168.85.80:7450'

Fetching schema names for auto-completion... Press ^C to stop.

  • Your MySQL connection id is 0

Server version: 8.0.35 MySQL Community Server - GPL

No default schema selected; type \use <schema> to set one.

MySQL 192.168.85.80:7450 ssl JS > var cluster =dba.getCluster();

NOTE: The installed metadata version 2.1.0 is lower than the version required by Shell which is version 2.2.0. It is recommended to upgrade the metadata. See \? dba.upgradeMetadata for additional details.

MySQL 192.168.85.80:7450 ssl JS > cluster.status();

{

"clusterName": "mycluster",

"defaultReplicaSet": {

"name": "default",

"primary": "k8s-master2:3306",

"ssl": "REQUIRED",

"status": "OK",

"statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",

"topology": {

"k8s-master2:3306": {

"address": "k8s-master2:3306",

"memberRole": "PRIMARY",

"mode": "R/W",

"readReplicas": {},

"replicationLag": "applier_queue_applied",

"role": "HA",

"status": "ONLINE",

"version": "8.0.35"

},

"k8s-master:3306": {

"address": "k8s-master:3306",

"memberRole": "SECONDARY",

"mode": "R/O",

"readReplicas": {},

"replicationLag": "applier_queue_applied",

"role": "HA",

"status": "ONLINE",

"version": "8.0.35"

},

"k8s-node1:3306": {

"address": "k8s-node1:3306",

"memberRole": "SECONDARY",

"mode": "R/O",

"readReplicas": {},

"replicationLag": "applier_queue_applied",

"role": "HA",

"status": "ONLINE",

"version": "8.0.35"

}

},

"topologyMode": "Single-Primary"

},

"groupInformationSourceMember": "k8s-master2:3306"

}

MySQL 192.168.85.80:7450 ssl JS >

---------嗯,至此,MySQLrouter双开或多开成功!

         通过测试,我们可以设计为两台mysql router通过keepalive提供高可用保障,然后启用mysql router读写分离多开服务来为更多的mysql集群统一提供数据进出,为数据的信息安全把控提供集中管理。

  • 28
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lq2003

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值