当前位置:网站首页>MySQL architecture (basic)
MySQL architecture (basic)
2022-06-23 23:55:00 【Xiao Wange】
mysql Introduction to various connection modes
socket
Prerequisites must be created and authorized localhost user , Only when the database is started will it be generated socket file
mysql A socket file will be automatically generated when starting , This file can be accessed locally to log in mysql
The file defaults to /tmp/mysql.sock You can specify parameters in the configuration file socket= File path To specify the file location
mysql -uroot -p -S/tmp/mysql.sock #mysql Default to /etc/ look for mysql.sock Users can also in the configuration file [mysql] End assignment socket= The file path is enabled by default
How to confirm that the user is socket Login or TCP/IP The way show processlist; host Column to see how the user logs in
TCP/IP
The premise is that the remote network segment login user must be created and authorized
mysql -utest -p123456 -h10.0.0.51 -P3306 -h Designated host -P Designated port It doesn't make sense to specify alone You need to specify the -h host
mysql be based on ssl Secure links
Check whether the security link function is enabled
show variables like '%ssl%'; have_openssl YES have_ssl YES
mysql_ssl_rsa_setup Generate by command
Under the data directory, the following... Will be generated under the directory .pem file :
ca.pem # Self signed CA certificate , Client connections also need to be provided
client-cert.pem # The certificate file that the client needs to provide to connect to the server
client-key.pem # The private key file that the client needs to provide to connect to the server
private_key.pem # Private key / Private member of the public key pair
public_key.pem # Private key / A common member of a public key pair
server-cert.pem # Server side certificate file
server-key.pem # Server side private key file
Test link ,
mysql -ujialiye -p123 -h10.0.0.51 --ssl-cert=/data/mysql/data_3306/client-cert.pem --ssl-key=/data/mysql/data_3306/client-key.pem
mysql The configuration file
mysql Configure file startup sequence
mysqld --help --verbose |grep my.cnf
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in defaultConfiguration file read order The default from the /ect/my.cnf Read back There is a duplicate configuration file addition relationship If the configuration file is the same, the last configuration shall prevail
If you start multiple instances, you can add --defaults-file= Profile path To specify the startup configuration file separately
Profile description
[mysqld] Label item mysqld The parameters under this tag will be read when running [mysql] Label item mysql The command will read the parameters under the tag [mysqld_safe] Label item mysql Safe start is the parameter of the call [sever] Label item Will cover all server End operation is a parameter of mysqld, mysqld_safe Will call the parameters inside [client] Label item All client programs will be overwritten mysql,mysqldump
mysql Start the closing process
start-up
stay mysql There is a support-files Catalog There's one down there mysql.server file You can use this file Back plus start stop restart Or join systemd management Script call relationship mysql.server----> bin/mysqld_safe----->bin/mysqld Each method can start the database mysqld & Parameters can be added for startup The log will be printed to the screen unless the configuration file specifies that the startup function is not turned off When debugging, I will use mysqld_safe & Parameters can be added for startup Log files , It will automatically monitor mysqld The status of the program , If something goes wrong, it will restart automatically systemd start-up No parameters can be added
close
Enter the database shutdown Use it outside mysqlamin -uroot -p123 -S/tmp/mysql.sock shutdown System management systemd stop
ps stay 8.0 Updates can be made in mysql in restart
mysql Multiple instances
Multiple examples :
Share server resources , Start multiple instances
Generally used in distributed architecture , Choose a commonly used structure
Other nodes may be used for other replicas
If the budget is relatively small, you can 3 One server does 9 An example ,3 Lord 6 Replica
You can also install different versions on one machine mysql Used to simulate , upgrade , test Debugging and other functions
Multi version installation instructions
Different profile assignments
The data directory is different , Different ports socket Different documents
Create different data directories to grant authorization mysql User permissions
mkdir /data/mysql/data_3307
create profile
vim /data/mysql/my.cnf [mysqld] user=mysql basedir=/usr/local/mysql datadir=/data/mysql/data_3307 socket=/tmp/mysql3307.sock log_error=/data/mysql/data_3307/error.log default_authentication_plugin=mysql_native_password server_id=7 log_bin=/data/mysql/binlog_3307 port=3307
initialization
mysqld --defaults-file=/data/mysql/my.cnf --initialize-insecure
Start database
mysqld_safe --defaults-file=/data/mysql/my.cnf
mysql Tool log description
error log mysql Start to close the entire lifecycle , Except for reporting errors , Warnings are also provided , Information and a series of information
genernal log General journal The whole database operation class will be recorded
bin log Binary log 1 Data recovery 2 Be the master and subordinate
slow log Slow log Record slow query statement
error log Open by default
What problems can I see in the error log Start up failure , Master slave fault , Deadlock , The database is rammed ,
By default, there is a in the data directory hostname.err
Control parameter
log_error=/ Error log location It is better to set before initialization
The log file should be separated from the data file
How to view all parameters about logs
show variables like '%log_error%';
show variables You can view all parameters
log_error_verbosity=3 # This parameter can record the log level
How to adjust online set global log_error_verbosity=3
binlog
Function data recovery
Copy
Record mysql Changes that occur ( Additions and deletions ) Class will be recorded binlog
8.0 Start by default binlog The default is in the data directory
server_id= One is greater than 0 The number of 5.7 Then force
log_bin= route / File name prefix
slowlog Slow log Record during database operation , Slow execution sql
Configuration parameters slow_query_log=on Whether to turn on slow log
long_query_time= Catch the slow execution based on time sql Slow query time The default is seconds
slow_query_log_file= route Slow log storage path
log_queries_not_using_indexe=1 Record queries without index
log_throttle_queries_not_using_indexes=1000; Only the nearest 1000 There is no index
The slow log also records lock information
general_log General journal Text format Record mysql All operation statements during the run
Can do problem diagnosis and debugging
Parameters
general_log= switch
general_log_file= Log storage location and name
mysql Upgrade process
Upgrade risk The upgrade cannot be completed , The application is not connected , There's no problem with the database , Application mismatch A lot of tests have to be done
边栏推荐
- 工作中一些常用的工具函数
- List<? extends T>和List<?super T>区别
- Six necessary open source projects for private activities
- 高仿斗鱼 APP
- extern、struct等关键字
- CPU取指到发出控制、微程序控制原理详细过程
- Cvpr2019/ image translation: transgaga: geometry aware unsupervised image to image translation
- Total number of combinations ii[each element can only be solved by + once]
- Notepad++实用功能分享(正则行尾行首替换常用方法、文本比对功能等)
- 2.摄像机标定
猜你喜欢

The lower left corner of vs QT VTK displays the synchronized minor coordinate axis

高仿斗鱼 APP

Golang type assertion

SQL Server 中 GO 的用法
![Restore IP address [standard backtracking + standard pruning]](/img/e6/5f9d2a5af973b6c7051ed434a4b93d.png)
Restore IP address [standard backtracking + standard pruning]

开口式霍尔电流传感器助力直流配电改造

6月25日PMP考试敏捷怎么考?替你分忧解难
![[proteus simulation] example of T6963C driving pg12864 (with Chinese and English display)](/img/e7/d36750c729b76f18418589356706f1.png)
[proteus simulation] example of T6963C driving pg12864 (with Chinese and English display)

ACM. Hj89 24 point operation ●●●
![Total number of combinations ii[each element can only be solved by + once]](/img/06/a40e28a1882a4278883202bc9c72d3.png)
Total number of combinations ii[each element can only be solved by + once]
随机推荐
电子元器件行业B2B交易管理系统:提升数据化驱动能力,促进企业销售业绩增长
三款很酷很骚气的底部导航
Dot and cross product
不容错过 | 华为内部资料--成功的项目管理PPT(123页)
2018/gan:self attention generating adversarial networks
Math. Max() method obtains the maximum value in the array and returns Nan problem analysis
Complete open source project poetry bar app
[things about gbase] gbase 8s high availability technology and case analysis (issue 02)
Three cool and coquettish bottom navigation
逆向工具IDA、GDB使用
入参参数为Object,但传递过去却成了[object object] 是因为需要转为JSON格式
Gbase observation: extended analytical database
并发和并行有什么区别?
Revit API:明细表 ViewSchedule
Golang type assertion
Some common tool functions in work
Docker Deployment redis
A cartoon reading app highly imitating Tencent comics
【Proteus仿真】T6963C驱动PG12864示例(带中英文显示)
WPF效果之Expander+ListBox