当前位置:网站首页>Technology sharing | MySQL shell customized deployment MySQL instance
Technology sharing | MySQL shell customized deployment MySQL instance
2022-07-28 16:58:00 【ActionTech】
author : Yang Taotao
Senior database expert , Specialized research MySQL More than ten years . Good at MySQL、PostgreSQL、MongoDB And other open source database related backup recovery 、SQL tuning 、 Monitoring operation and maintenance 、 High availability architecture design, etc . At present, I work in akerson , For major operators and bank financial enterprises MySQL Related technical support 、MySQL Related courses, training, etc .
In this paper, the source : Original contribution
* Produced by aikesheng open source community , Original content is not allowed to be used without authorization , For reprint, please contact the editor and indicate the source .
Previously written and used MySQL Shell Of DBA Components to build 、 Operation and maintenance MySQL InnoDB Cluster . Today, let's continue on DBA Extended introduction of components , Discuss how to use it to customize the deployment MySQL example .
One 、 How to deploy multiple versions MySQL example :
By default DBA When a component deploys multiple instances , Using the built-in MySQL edition , That is, in the environment variable $PATH Search in the included path mysqld To confirm the specific instance version . For example, on my machine , Default MySQL Version is 8.0 , So the instance version after direct deployment is also 8.0.
[email protected]:~# mysqlsh --py
MySQL Shell 8.0.29
...
MySQL Py > dba.deploy_sandbox_instance(3350);
A new MySQL sandbox instance will be created on this host in
/root/mysql-sandboxes/3350
...
Instance localhost:3350 successfully deployed and started.
Use shell.connect('[email protected]:3350') to connect to the instance.
For example, the above port is 3350 After the deployment is completed , Create a new connection , After success, the client will receive the specific version :Server version: 8.0.29 MySQL Community Server - GPL.
MySQL Py > \c [email protected]:3350
...
Your MySQL connection id is 12
Server version: 8.0.29 MySQL Community Server - GPL
If you want to deploy multiple different versions at the same time MySQL example , Just put the corresponding version of mysqld Path into $ PATH that will do . It should be noted that , New path and old $ PATH Splicing sequence : The new path comes first , The old $ PATH After ! After deployment , Remember to put it again $PATH Content restore .
For example, on my machine MySQL 5.7 The directory of the version installation package is :/root/opt/mysql/5.7.34 , Then add subdirectories of this directory bin To environment variable $PATH that will do :
[email protected]:~# export PATH=/root/opt/mysql/5.7.34/bin:$PATH
Re enter MySQL Shell Environmental Science , And above MySQL 8.0 The same deployment method : You can see , The newly deployed instance version is 5.7.34-log MySQL Community Server (GPL).
MySQL Py > dba.deploy_sandbox_instance(3351)
A new MySQL sandbox instance will be created on this host in
/root/mysql-sandboxes/3351
...
Instance localhost:3351 successfully deployed and started.
Use shell.connect('[email protected]:3351') to connect to the instance.
MySQL Py > \c [email protected]:3351
...
Your MySQL connection id is 7
Server version: 5.7.34-log MySQL Community Server (GPL)
Two 、 How to change the basic directory of a deployment instance :
The default deployment instance file is ~/mysql-sandboxes Next , Divide by instance port , One subdirectory per port . For example, the two previously deployed MySQL example , Corresponding to the directory /root/mysql-sandboxes/3350、/root/mysql-sandboxes/3351 .
There are two ways to change the basic directory of the deployment instance :
1. call dba.deploy_sandbox_instance when , Explicitly specify the deployment directory :
- sandboxDir: path where the new instance will be deployed.
For example, deploy a new instance 3352, Specify the basic directory as :/tmp/mysql-sandbox.
MySQL Py > dba.deploy_sandbox_instance(3352,{"sandboxDir":"/tmp/mysql-sandbox"})
A new MySQL sandbox instance will be created on this host in
/tmp/mysql-sandbox/3352
...
Instance localhost:3352 successfully deployed and started.
Use shell.connect('[email protected]:3352') to connect to the instance.
The biggest disadvantage of this method is that it is not universal for the deployment of subsequent new instances , You need to specify... For each new instance sandboxDir Option . If you don't explicitly specify , Then continue to use the default directory :~/mysql-sandboxes. For example, the following deployment example 3353, Still use the default directory .
MySQL Py > dba.deploy_sandbox_instance(3353)
A new MySQL sandbox instance will be created on this host in
/root/mysql-sandboxes/3353
The next way is directly in MySQL Shell Of Shell Specify the basic deployment directory in the component , It works for the overall situation .
2. Set explicitly shell Component's options Dictionary properties , modify KEY be known as sandboxDir The value of is the specified directory :
- sandboxDir: default path where the new sandbox instances for InnoDB cluster will be deployed
Set up sandboxDir by /tmp/mysql-sandbox : --persist For permanent effect , similar MySQL Inside set persist Grammatical effect .
MySQL Py > \option --persist sandboxDir /tmp/mysql-sandbox
Re enter MySQL Shell Environmental Science , Deploy two new instances , The corresponding ports are 3353 and 3354: Both instances are deployed in the directory /tmp/mysql-sandbox Next .
MySQL Py > for i in range(3353,3355):
-> dba.deploy_sandbox_instance(i)
->
A new MySQL sandbox instance will be created on this host in
/tmp/mysql-sandbox/3353
...
A new MySQL sandbox instance will be created on this host in
/tmp/mysql-sandbox/3354
...
3、 ... and 、 How to change the instance parameters of a new deployment :
No specific parameters are set for the above deployed instances , Only the default values are used . No matter what scenario the deployed instance is used in , Some parameters still need to change with the scene . There are two ways to change parameters :
1. Configure parameters while deploying instances : Suitable for changing a few parameters .
For example, deploy a new instance 3355, Specify the following parameters respectively :
server-id=1000
tmp_table_size=64M
read_buffer_size=1M
Add these parameters to mysqldOptions The array can be .
MySQL Py > dba.deploy_sandbox_instance(3355,{"mysqldOptions":["server_id=1000","tmp_table_size=64M","read_buffer_size=1M"]})
A new MySQL sandbox instance will be created on this host in
/tmp/mysql-sandbox/3355
...
Instance localhost:3355 successfully deployed and started.
Use shell.connect('[email protected]:3355') to connect to the instance.
confirm my.cnf Successfully changed :
[email protected]:/tmp/mysql-sandbox/3355# grep "server_id\|tmp_table_size\|read_buffer_size" my.cnf
server_id = 1000
tmp_table_size = 64M
read_buffer_size = 1M
2. Configure the parameters after deploying the instance : Suitable for changing a large number of parameters .
Directly change the corresponding my.cnf , After that, restart .
summary :
Use MySQL Shell Of DBA Components can be deployed easily MySQL example , But it is not recommended to produce , Because of entering MySQL Shell After environment , These instances can be maintained at will , Increased risk .
边栏推荐
- Ruoyi集成flyway后启动报错的解决方法
- 快速掌握 Kotlin 集合函数
- Binary representation of negative integers and floating point numbers
- IM即时通讯软件开发网络请求成功率的优化
- Efficiency comparison of three methods for obtaining timestamp
- Applet: scroll view slides to the bottom by default
- Semtech推出物联网地理定位解决方案LoRa Edge,首款芯片LR1110现已上市
- 向高通支付18亿美元专利费之后,传华为向联发科订购了1.2亿颗芯片!官方回应
- 关于Bug处理的一些看法
- How to set ticdc synchronization data to only synchronize the specified library?
猜你喜欢

概率论与数理统计第一章

阿里云 MSE 支持 Go 语言流量防护

在AD中添加差分对及连线

HTAP是有代价的

Debugging methods of USB products (fx3, ccg3pa)

Introduction and implementation of stack (detailed explanation)

【深度学习】:《PyTorch入门到项目实战》第四天:从0到1实现logistic回归(附源码)

微软:Edge 浏览器已内置磁盘缓存压缩技术,可节省空间占用且不降低系统性能

【深度学习】:《PyTorch入门到项目实战》第七天之模型评估和选择(上):欠拟合和过拟合(含源码)

有趣的 Kotlin 0x08:What am I
随机推荐
Applet: scroll view slides to the bottom by default
Detailed record of steps to configure web server (many references)
小程序:scroll-view默认滑倒最下面
Re13:读论文 Gender and Racial Stereotype Detection in Legal Opinion Word Embeddings
Each account corresponds to all passwords, and then each password corresponds to all accounts. How to write the brute force cracking code
Microsoft question 100 - do it every day - question 16
MySQL安装教程
获取时间戳的三种方法的效率比较
Design direction of daily development plan
leetcode9. 回文数
Semtech推出物联网地理定位解决方案LoRa Edge,首款芯片LR1110现已上市
大学生参加六星教育PHP培训,找到了薪水远超同龄人的工作
Signal shielding and processing
Efficiency comparison of three methods for obtaining timestamp
Leetcode learn to insert and sort unordered linked lists (detailed explanation)
parseJson
Redis source code optimization -- binding core
Nowcode- learn to delete duplicate elements in the linked list (detailed explanation)
egg(十九):使用egg-redis性能优化,缓存数据提升响应效率
HTAP是有代价的