mycat双主高可用架构部署-MySQL5.7环境部署第一台

server/2024/12/23 1:25:08/
MySQL5.7服务器IP是192.168.31.209及192.168.31.210

1、192.168.31.209:3307实例部署

        a、配置文件

mkdir -p /data/mysql/mysql3307/{data,logs} #创建MySQL数据及日志目录
vi /data/mysql/mysql3307/my3307.cnf #配置文件整理
[client]
#password       = your_password
port            = 3307
socket          = /data/mysql/mysql3307/mysql.sock
default-character-set=utf8
[mysqld]
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
binlog_cache_size=20M
thread_stack = 512K
join_buffer_size=20M
query_cache_type = 1
max_heap_table_size = 2048M
port=3307
socket=/data/mysql/mysql3307/mysql.sock
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql/mysql3307/data
default_storage_engine = InnoDB
performance_schema_max_table_instances = 400
table_definition_cache = 400
key_buffer_size = 1024M
max_allowed_packet=100G
table_open_cache = 4096
sort_buffer_size=4M
net_buffer_length = 4K
read_buffer_size = 4096K
read_rnd_buffer_size = 2048K
myisam_sort_buffer_size = 128M
thread_cache_size = 512
query_cache_size = 384M
tmp_table_size = 2048M
max_connections=1024
max_connect_errors = 100
open_files_limit = 65535
log-bin=mysql-bin
binlog_format=mixed
server_id=2
expire_logs_days=7
slow_query_log=on
slow_query_log_file=/data/mysql/mysql3307/logs/slow.log
long_query_time=0.5
log_queries_not_using_indexes=1
log_error=/data/mysql/mysql3307/logs/error.log
log_bin=/data/mysql/mysql3307/logs/mysql-bin
gtid_mode=on
enforce_gtid_consistency=true
log_slave_updates=1
wait_timeout=60
innodb_buffer_pool_size=8096M
innodb_log_file_size=256M
innodb_log_buffer_size=64M
innodb_flush_log_at_trx_commit=1
innodb_log_files_in_group=2
max_binlog_cache_size=512M
max_binlog_size=2048M
binlog_group_commit_sync_delay=100 #主库
binlog_group_commit_sync_no_delay_count=20 #主库
slave_parallel_type=logical_clock #从库配置
slave_parallel_workers=4 #从库配置
transaction_write_set_extraction=XXHASH64 #从库配置
binlog_transaction_dependency_tracking=writeset #从库配置
slave_preserve_commit_order=1 #从库配置
sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqldump]
quick
max_allowed_packet = 500M
[mysql]
no-auto-rehash
default-character-set=utf8
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 2M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout

        b、初始化及授权

chown -R mysql:mysql /data/mys* #更改数据权限组
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3307/my3307.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/mysql3307/data #初始化数据库
mysqld --defaults-file=/data/mysql/mysql3307/my3307.cnf & #启动3307数据库
grep 'temporary password' /data/mysql/mysql3307/logs/error.log #获取临时密码
firewall-cmd --zone=public --add-port=3307/tcp --permanent #开启3307端口 
firewall-cmd --reload #刷新防火墙
mysql -uroot -p -S /data/mysql/mysql3307/mysql.sock #连接数据库
alter user root@'localhost' identified by '123456'; //第一次修改密码

2、192.168.31.209:3308实例部署

        a、配置文件

mkdir -p /data/mysql/mysql3308/{data,logs} #创建MySQL数据及日志目录
vi /data/mysql/mysql3308/my3308.cnf #配置文件整理
[client]
#password       = your_password
port            = 3308
socket          = /data/mysql/mysql3308/mysql.sock
default-character-set=utf8
[mysqld]
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
binlog_cache_size=20M
thread_stack = 512K
join_buffer_size=20M
query_cache_type = 1
max_heap_table_size = 2048M
port=3308
socket=/data/mysql/mysql3308/mysql.sock
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql/mysql3308/data
default_storage_engine = InnoDB
performance_schema_max_table_instances = 400
table_definition_cache = 400
key_buffer_size = 1024M
max_allowed_packet=100G
table_open_cache = 4096
sort_buffer_size=4M
net_buffer_length = 4K
read_buffer_size = 4096K
read_rnd_buffer_size = 2048K
myisam_sort_buffer_size = 128M
thread_cache_size = 512
query_cache_size = 384M
tmp_table_size = 2048M
max_connections=1024
max_connect_errors = 100
open_files_limit = 65535
log-bin=mysql-bin
binlog_format=mixed
server_id=3
expire_logs_days=7
slow_query_log=on
slow_query_log_file=/data/mysql/mysql3308/logs/slow.log
long_query_time=0.5
log_queries_not_using_indexes=1
log_error=/data/mysql/mysql3308/logs/error.log
log_bin=/data/mysql/mysql3308/logs/mysql-bin
gtid_mode=on
enforce_gtid_consistency=true
log_slave_updates=1
wait_timeout=60
innodb_buffer_pool_size=8096M
innodb_log_file_size=256M
innodb_log_buffer_size=64M
innodb_flush_log_at_trx_commit=1
innodb_log_files_in_group=2
max_binlog_cache_size=512M
max_binlog_size=2048M
binlog_group_commit_sync_delay=100 #主库
binlog_group_commit_sync_no_delay_count=20 #主库
slave_parallel_type=logical_clock #从库配置
slave_parallel_workers=4 #从库配置
transaction_write_set_extraction=XXHASH64 #从库配置
binlog_transaction_dependency_tracking=writeset #从库配置
slave_preserve_commit_order=1 #从库配置
sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqldump]
quick
max_allowed_packet = 500M
[mysql]
no-auto-rehash
default-character-set=utf8
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 2M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout

        b、初始化及授权

chown -R mysql:mysql /data/mys* #更改数据权限组
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3308/my3308.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/mysql3308/data #初始化数据库
mysqld --defaults-file=/data/mysql/mysql3308/my3308.cnf & #启动3308数据库
grep 'temporary password' /data/mysql/mysql3308/logs/error.log #获取临时密码
firewall-cmd --zone=public --add-port=3308/tcp --permanent #开启3308端口 
firewall-cmd --reload #刷新防火墙
mysql -uroot -p -S /data/mysql/mysql3308/mysql.sock #连接数据库
alter user root@'localhost' identified by '123456'; //第一次修改密码

3、192.168.31.209:3309实例部署

        a、配置文件

mkdir -p /data/mysql/mysql3309/{data,logs} #创建MySQL数据及日志目录
vi /data/mysql/mysql3309/my3309.cnf #配置文件整理
[client]
#password       = your_password
port            = 3309
socket          = /data/mysql/mysql3309/mysql.sock
default-character-set=utf8
[mysqld]
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
binlog_cache_size=20M
thread_stack = 512K
join_buffer_size=20M
query_cache_type = 1
max_heap_table_size = 2048M
port=3309
socket=/data/mysql/mysql3309/mysql.sock
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql/mysql3309/data
default_storage_engine = InnoDB
performance_schema_max_table_instances = 400
table_definition_cache = 400
key_buffer_size = 1024M
max_allowed_packet=100G
table_open_cache = 4096
sort_buffer_size=4M
net_buffer_length = 4K
read_buffer_size = 4096K
read_rnd_buffer_size = 2048K
myisam_sort_buffer_size = 128M
thread_cache_size = 512
query_cache_size = 384M
tmp_table_size = 2048M
max_connections=1024
max_connect_errors = 100
open_files_limit = 65535
log-bin=mysql-bin
binlog_format=mixed
server_id=4
expire_logs_days=7
slow_query_log=on
slow_query_log_file=/data/mysql/mysql3309/logs/slow.log
long_query_time=0.5
log_queries_not_using_indexes=1
log_error=/data/mysql/mysql3309/logs/error.log
log_bin=/data/mysql/mysql3309/logs/mysql-bin
gtid_mode=on
enforce_gtid_consistency=true
log_slave_updates=1
wait_timeout=60
innodb_buffer_pool_size=8096M
innodb_log_file_size=256M
innodb_log_buffer_size=64M
innodb_flush_log_at_trx_commit=1
innodb_log_files_in_group=2
max_binlog_cache_size=512M
max_binlog_size=2048M
binlog_group_commit_sync_delay=100 #主库
binlog_group_commit_sync_no_delay_count=20 #主库
slave_parallel_type=logical_clock #从库配置
slave_parallel_workers=4 #从库配置
transaction_write_set_extraction=XXHASH64 #从库配置
binlog_transaction_dependency_tracking=writeset #从库配置
slave_preserve_commit_order=1 #从库配置
sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqldump]
quick
max_allowed_packet = 500M
[mysql]
no-auto-rehash
default-character-set=utf8
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 2M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout

        b、初始化及授权

chown -R mysql:mysql /data/mys* #更改数据权限组
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3309/my3309.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/mysql3309/data #初始化数据库
mysqld --defaults-file=/data/mysql/mysql3309/my3309.cnf & #启动3309数据库
grep 'temporary password' /data/mysql/mysql3309/logs/error.log #获取临时密码
firewall-cmd --zone=public --add-port=3309/tcp --permanent #开启3309端口 
firewall-cmd --reload #刷新防火墙
mysql -uroot -p -S /data/mysql/mysql3309/mysql.sock #连接数据库
alter user root@'localhost' identified by '123456'; //第一次修改密码

第一台mysql服务器已经配置好


http://www.ppmy.cn/server/114261.html

相关文章

综合自动化变电所运行的可靠性

摘 要:自动化技术在变电所中的有效利用,一方面能够通过网络信息平台落实远程变电操控的需要,使变电所的工作质量与效率得到显著提升,并增强变电系统的可控性;另一方面,凭借可靠性检测措施,更便于…

中文分词jieba库的使用与实景应用(一)

知识星球:https://articles.zsxq.com/id_fxvgc803qmr2.html 目录 一.定义: 精确模式(默认模式): 全模式: 搜索引擎模式: paddle 模式(基于深度学习的分词模式)&…

面试—Linux

目录 ps tar netstat 文件处理命令(增删改) 文件操作(查看) 权限管理 文件搜索 网络管理 压缩命令 Vim编辑器 ps ps命令用于显示当前系统的进程状态 包括一些进程ID,终端,运行时间等 常见参数 …

【限流器】golang令牌桶限流源码分析

1.令牌桶限流算法 算法思想:系统以一定速率生成令牌,存放于桶中,在达到容量的最大值后停止生成令牌。用户生成请求后从令牌桶中消费令牌才能执行。否则延迟执行或被限制。 使用场景:平滑流量控制;在一定程度上可以处…

从零开始搭建Prometheus与Grafana监控系统:实战演练

从零开始搭建 Prometheus 与 Grafana 监控系统:实战演练 监控系统是现代 IT 基础设施的重要组成部分,用于监控服务器、应用程序和服务的性能和可用性。Prometheus 和 Grafana 是目前广泛使用的开源监控和可视化工具。本篇文章将从零开始,手把…

云原生架构概念

云原生架构概念 云原生架构(Cloud Native Architechtrue)作为一种现代软件开发的革新力量,正在逐渐改变企业构建、部署和管理应用程序的方式。它的核心优势在于支持微服务架构,使得应用程序能够分解为独立、松耦合的服务&#xf…

Nginx的负载均衡

Nginx 是一个高性能的 HTTP 和反向代理服务器,广泛用于负载均衡。负载均衡的目的是将客户端请求分配到多个后端服务器,以提高应用的可用性和性能。下面详细解释 Nginx 的负载均衡特性,包括其工作原理、配置方法、负载均衡算法等。 工作原理 …

贝锐蒲公英远程视频监控方案:4G入网无需公网IP,跨品牌统一管理

在部署视频监控并实现集中监看时,常常会遇到各种挑战。比如:部分监控点位布线困难、无法接入有线宽带,或是没有固定公网IP,难以实现远程集中监看;已有网络质量差,传输延迟大、丢包率高,远程实时…