当前位置:网站首页>Tidb source code series: immersive compilation of tidb
Tidb source code series: immersive compilation of tidb
2022-06-13 07:37:00 【Fish is not fish】
1. background
I just finished studying recently PCTP, Yes TiDB Have a rough understanding of all kinds of reading and writing , But to study something more detailed ,
It must be inseparable from learning the source code , If you want to learn the source code, you can refer to the official TiDB Source series article , But the official article
All are 18 Annual hair , There may be some lag , So you can refer to this and combine the source code to learn .TiDB Source code series interpretation articles : Official source code interpretation blog address
However, learning source code is certainly the most effective way to learn by compiling and debugging source code , After these days of study , And ask the development boss ,
Successfully compiled TiDB, So share it with small partners who are interested in the source code .
2. The preparation of the instruments
Goland A white whore (30 God )TiDB The latest source code tar Pack one Mac a
3. Source download
1. First go github Download source code : Source code download address
2. Choose the version you want to see : Here I take the latest 5.4.0 Version as an example .
3. decompression tar package
#1. Open the terminal
#2. Unzip to the corresponding directory tar package
tar -xzvf tidb-5.4.0.tar.gz
# After decompression, you will get a folder
4. Compile software download configuration
because TiDB It is used. go language-written , So we use goland Compile .
1. Download a 30 Tianbai whoring version , Those who have the ability can buy the paid version directly ( Support genuine )
Download address :goland Download address
Choose a suitable computer system to download :
2. After installation, select the corresponding open project .
3. Find what you just unzipped TiDB Source folder , open 
4. There may be a lot of errors after opening ( Here's the picture ), But it's not a big problem , Basically because there is no installation go Correlation module As a result of .
The required gomodule You can see in the following file in the code , You can see that it's all red now , The description is missing the corresponding mod.
5. open goland Set up , Then download the latest version of goroot, The required... Will be installed module.
Then choose the latest version to download .
Then we will start to download the related dependencies :
During the test, I found that only a part of it will be downloaded , So the rest of the missing can click on the picture from github sync.
When the download is complete, it will all turn green , So far, we have configured the environment .
5. The build process
Go through the above steps , Basically everything is ready , Then we can compile it ourselves TiDB database .
1. But there will be another problem Where to start ?
Here we still need to use the official source code series I started talking about : How to learn TiDB Source code
As a non professional developer , You can only learn with the help of tips on the official website .
From my address above , You can see TiDB What does the source file correspond to , And where to start .
2. From the above, we can know from the official blog tidb-server/main.go function
First main.go Inside var Is the startup parameter of our system , You can modify the corresponding parameters to start 
Then find below main Green button next to function , You can choose debug Mode or run directly , So here I'm going to choose Debug Pattern , You can see more information .
After clicking, you need to wait for a while , The bottom of the screen will show compiling…
After compiling , Everyone can be in debug Column to see the corresponding information :
You can see [INFO] [server.go:246] ["server is running MySQL protocol"] [addr=0.0.0.0:4000] That means the startup was successful .
3. Visit to see if it really runs successfully .
You can see TiDB The service is already running ,
Use MySQL Command line access TiDB, You can see that O K, So far, the compilation is complete .
6. Last
After successful operation , You can break points through different functions later , Then look at your SQL Which functions in which code will be called . The location of the function can refer to the source code analysis of the official blog for breakpoint testing .
边栏推荐
- RT thread simulator lvgl control: button button event
- redis-0. Introduction to redis and NiO principle (random talk)
- Considerations for using redis transactions
- 不同系统添加证书
- redis-1. Install redis with pictures and texts
- [splashsplash] repeat the script that outputs splashsurf
- 10. process communication
- TCP协议的三次握手过程和四次挥手过程以及为什么要这样? ------一二熊猫
- 【硬记】脏读、不可重复读、幻读场景核心区别
- A solution to the problem that there is always a newline character when C merges multiple RichTextBox contents
猜你喜欢

A solution to the problem that there is always a newline character when C merges multiple RichTextBox contents

11.29 Li Kou swipes questions every day

Classification of databases

Redis underlying data structure -- listpack

Redis Cluster - the underlying principle of cluster execution commands

2021-10-08

IDS persistence ---rdb

Export chrome plug-ins and import local plug-ins to chrome

RT thread simulator lvgl control: button button event

Paper notes: multi label learning bp-mll
随机推荐
How to solve the 404 problem
MySQL summary
思路清晰的软光栅小引擎和四元数结合案例
Simple understanding of basic language of C language
Redis learning journey - transaction
oracle问题,字段里面的数据被逗号隔开,取逗号两边数据
Redis learning journey master-slave replication
An example of CSRF attack defense in web application scenarios
powerdisgner逆向生成oracle数据模型
[MySQL change master error] slave is not configured or failed to initialize properly
The management practice of leading enterprises has proved that what is the core of sustainable development of enterprises?
A. Vacations (DP greed
First graphical interface (modified version)
C Advanced Programming - features
RT thread simulator lvgl control: slider control
Redis underlying data structure - underlying principle of hash table
GCC compilation process, function library related compilation process
Redis learning journey --redis Conf details
P1434 [show2002] skiing (memory search
Considerations for using redis transactions