当前位置: 首页 > article >正文

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

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.kler.cn/a/303588.html

相关文章:

  • 如何在 Ubuntu 上 部署 OceanBase
  • go反射深入学习
  • 基于Spring Boot的在线性格测试系统设计与实现(源码+定制+开发)智能性格测试与用户个性分析平台、在线心理测评系统的开发、性格测试与个性数据管理系统
  • Redisson的可重入锁
  • opc da 服务器数据 转 IEC61850项目案例
  • 华为路由策略配置
  • 「漏洞复现」紫光电子档案管理系统 selectFileRemote SQL注入漏洞
  • TestCraft - GPT支持的测试想法生成器和自动化测试生成器
  • 前端使用COS上传文件
  • 为什么要进行MySQL增量备份?
  • 【数据结构和算法实践-树-LeetCode112-路径总和】
  • 力扣: 四数相加II
  • Linux安装管理多版本JDK
  • CSS Clip-Path:重塑元素边界的艺术
  • mysql慢sql问题修复
  • 计算机毕业设计 自习室座位预约系统的设计与实现 Java+SpringBoot+Vue 前后端分离 文档报告 代码讲解 安装调试
  • qt操作excel(QAxObject详细介绍)
  • 论文解读《LaMP: When Large Language Models Meet Personalization》
  • 浏览器插件利器--allWebPluginV2.0.0.20-alpha版发布
  • 首批通过!华为云CodeArts Snap智能开发助手通过可信AI智能编码工具评估,获当前最高等级
  • 气膜体育馆:为学校打造智能化运动空间—轻空间
  • 响应式网站真的就只是多了一个媒体查询吗?
  • CSS学习17--CSS3 过渡、2D变形、3D变形、动画
  • linux 内核代码学习(九)--Linux内核启动和文件系统
  • MySQL 子查询
  • 计算几何学习