问题探索
一条SQL的生命周期
mysql插件化架构
mysql8.0取消查询缓存
网络IO模型
其他
mysql8.0.24源码编译安装
主要是参考这篇文章,操作过程中根据报错进行fix,特别是修改my.cnf配置文件。
编译安装问题
- OpenSSL 版本不兼容
不兼容1.1版本,需要openssl1.0.2,通过yum install openssl-devel。 - 磁盘空间不足
60g磁盘满了,导致make 终止,/data目录删掉即可。
fatal error: error writing to /tmp/ccFtecZv.s: No space left on device
- 内存不足
需要开启swap分区
g++: internal compiler error: Killed (program cc1plus)
- 太吃内存,make巨慢
没找到解决方案… - 缺少依赖组件
可能是缺少ncurses-devel
yum install ncurses-devel libaio bison zlib-devel openssl openssl-devel patch
mysqld启动问题
- 磁盘空间不足
注意my.cnf配置文件,特别innodb参数配置,可能因系统内存或磁盘容量导致启动失败
查看系统磁盘: df -h
[InnoDB] Error number 28 means ‘No space left on device’
vscode本地调试mysql8.0.24
先在云服务器上执行以下命令:
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
launch.json配置文件如下:
|
|
源码结构
安装tree工具,执行tree -d -L 1命令:
|-- build
|-- client
|-- cmake
|-- components
|-- Docs
|-- doxygen_resources
|-- extra
|-- include
|-- libbinlogevents
|-- libbinlogstandalone
|-- libmysql
|-- libservices
|-- man
|-- mysql-test
|-- mysys
|-- packaging
|-- plugin
|-- router
|-- scripts
|-- share
|-- source_downloads
|-- sql
|-- sql-common
|-- storage
|-- strings
|-- support-files
|-- testclients
|-- unittest
|-- utilities
`-- vio
语雀代码画时序图: https://www.bookstack.cn/read/yuque/34.md
Mysql线程的基本设置
mysql> show variables like 'thread%';
+-------------------+---------------------------+
| Variable_name | Value |
+-------------------+---------------------------+
| thread_cache_size | 1536 |
| thread_handling | one-thread-per-connection |
| thread_stack | 524288 |
+-------------------+---------------------------+
3 rows in set (0.05 sec)
mysql> show global status like 'Thread%';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Threads_cached | 0 |
| Threads_connected | 1 |
| Threads_created | 1 |
| Threads_running | 1 |
+-------------------+-------+
4 rows in set (0.07 sec)
远程连接
root忘记密码
--- mysqld模块下增加skip-grant-tables配置,免密登录后执行以下命令:
update user set authentication_string = '' where user ='root';
--- 注释掉skip-grant-tables配置,重新登录,设置新密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123456';
允许外部访问
use mysql;
update user set host='%' where user ='root';
FLUSH PRIVILEGES;