博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL单机上多实例安装
阅读量:6915 次
发布时间:2019-06-27

本文共 3451 字,大约阅读时间需要 11 分钟。

首先安装mysql,不要启动MySQL,先配置vim /etc/my.cnf。

[mysqld_multi]
mysqld = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin
log = /opt/testdb/logs/mysql/mysqld_multi/mysqld_multi.log

[mysqld1]

datadir=/opt/testdb/mysql3306
socket=/opt/testdb/mysql3306/mysql.sock
symbolic-links=0
skip-name-resolve
default-time-zone='+8:00'

port = 3306

secure_file_priv = /opt/testdb/mysql_data
innodb_file_per_table=1
innodb_open_files=1024
skip-external-locking
net_buffer_length = 8K
myisam_sort_buffer_size = 8M
lower_case_table_names = 1

wait_timeout=1800

interactive_timeout = 1800
key_buffer_size = 512M
back_log = 500
max_connections = 3000
max_connect_errors = 6000
table_open_cache = 2048
max_allowed_packet = 32M
join_buffer_size = 2M
thread_cache_size= 128
query_cache_limit = 8M
tmp_table_size = 256M
read_buffer_size=8M
sort_buffer_size=8M
bulk_insert_buffer_size = 64M
innodb_buffer_pool_size = 102400M
innodb_buffer_pool_instances = 8
innodb_log_buffer_size=20M
read_rnd_buffer_size=32M

slow_query_log = 1

slow_query_log_file = /opt/testdb/logs/mysql/3306/mysqld3306_slow.log
long_query_time = 10
log_queries_not_using_indexes = 1
log_output = 'FILE'

innodb_flush_log_at_trx_commit = 2

sync_binlog=8

log-error=/opt/testdb/logs/mysql/3306/mysqld3306.log

pid-file=/var/run/mysql/mysqld3306.pid

server-id=36

binlog_ignore_db=mysql
relay_log = relay-bin
log-bin=/opt/testdb/logs/mysql/3306/mysql_R3306.log

[mysqld2]

datadir=/opt/testdb/mysql3307
socket=/opt/testdb/mysql3307/mysql.sock
symbolic-links=0
skip-name-resolve
default-time-zone='+8:00'

port = 3307

secure_file_priv = /opt/testdb/mysql_data
innodb_file_per_table=1
innodb_open_files=1024
skip-external-locking
net_buffer_length = 8K
myisam_sort_buffer_size = 8M
lower_case_table_names = 1

wait_timeout=1800

interactive_timeout = 1800
key_buffer_size = 512M
back_log = 500
max_connections = 3000
max_connect_errors = 6000
table_open_cache = 2048
max_allowed_packet = 32M
join_buffer_size = 2M
thread_cache_size= 128
query_cache_limit = 8M
tmp_table_size = 256M
read_buffer_size=8M
sort_buffer_size=8M
bulk_insert_buffer_size = 64M
innodb_buffer_pool_size = 20480M
innodb_log_buffer_size=20M
read_rnd_buffer_size=32M

slow_query_log = 1

slow_query_log_file = /opt/testdb/logs/mysql/3307/mysqld3307_slow.log
long_query_time = 10
log_queries_not_using_indexes = 1
log_output = 'FILE'

innodb_flush_log_at_trx_commit = 2

sync_binlog=8

log-error=/opt/testdb/logs/mysql/3307/mysqld3307.log

pid-file=/var/run/mysql/mysqld3307.pid

server-id=37

relay-log = relay-bin
log-slave-updates = 1
binlog_ignore_db=mysql
log-bin=/opt/testdb/logs/mysql/3307/mysql_R3307.log

注意其中innodb_buffer_pool_size配置,这里使用的引擎是Innodb。

在/opt/sdb下新建mysql3306和mysql3307两个文件夹:/opt/testdb/mysql3306, /opt/testdb/mysql3307
分别提权:
chown -R mysql:mysql /opt/testdb/mysql3306
chown -R mysql:mysql /opt/testdb/mysql3307
到mysqld目录下,cd /usr/sbin
初始化,执行
mysqld --initialize --datadir=/opt/testdb/mysql3306 --user=mysql,保存临时密码
同样执行,mysqld --initialize --datadir=/opt/testdb/mysql3307 --user=mysql,保存临时密码
运行MySQL,mysqld_multi start 1-2,同时启动
登陆MySQL,修改密码,mysql -uroot -p -S /opt/testdb/mysql3306/mysql.sock (或者mysql -uroot -p -P3306)
登陆后修改密码:
ALTER USER 'root'@'localhost' identified by '12345678';
FLUSH PRIVILEGES;
添加远程/登陆用户
grant all PRIVILEGES on *.* totestDB@'%' identified by '12345678';
查看MySQL_multi状态,mysqld_multi report
关闭musqld_multi,mysqladmin -h172.16.2.64 -P3306 -uroot -p12345678 shutdown

转载于:https://www.cnblogs.com/AndersonX/p/8707329.html

你可能感兴趣的文章
svn服务器配置以及自动同步到web服务器
查看>>
【CSS进阶】伪元素的妙用2 - 多列均匀布局及title属性效果
查看>>
【VS2013】设定Nuget代理
查看>>
php xls 导出乱码解决方案
查看>>
SwipeBackActivity 的使用
查看>>
逻辑卷、物理卷、卷组 的关系
查看>>
tkinter 弹出窗口 传值回到 主窗口
查看>>
百度面试
查看>>
1211Bug with integer literals in PLSQL
查看>>
Linux 权限管理之目录权限限制
查看>>
再谈矩阵分解在推荐系统中的应用
查看>>
ABAP 面试问题及答案(一):数据库更新及更改 SAP Standard (转)
查看>>
Top 10 JavaScript编辑器,你在用哪个?
查看>>
数据访问层的优化思路
查看>>
饭后最该知道N件事
查看>>
一文教你看懂大数据的技术生态圈 Hadoop,hive,spark
查看>>
关于本地分区索引和索引组织表保证唯一性的限制
查看>>
MaxCompute Studio 2.8.1 新版本发布啦!
查看>>
《区块链原理、设计与应用》一2.5 认识上的误区
查看>>
当所有编程语言都在靠齐的时候
查看>>