Reproduced in: http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/114.html?1455860562
1. Preparing the operating environment
* Set Oom Handler?,zmalloc When allocating memory fails when calling
* Initialize random seeds to generate random numbers
* Initialize the server parameter to the default value
* Create a mapping table for command and handler functions
2. Parsing the command line arguments, Loadserverconfig () parsing the configuration file
* The configuration file overrides the parameters specified by the command line
* Invalid configuration items or unreasonable configuration values will cause Redis to not start properly
3. Initserver () initialization service
* Install signal processing function
* Create shared objects, Redis pre-allocates common objects for sharing to save memory
* Adjust Max open files according to MAXC lients configuration
* Create a global db dictionary with one dict per db
* Monitor network port, install event handler
* If AoF is turned on, open the AoF file
* Create Servercron Timer
4. Loaddatafromdisk () load data from an RDB or aof file
* Failure of the load data (e.g., file format) will cause Redis to not start properly
* Loading process, Redis can still process requests, but most requests will reply-loading error
5. Aemain () Start event loop, receive client request
The event handler function for the listener file descriptor is initialized to Accepttcphandler, and the newly established Connection event handler is set to Readqueryfromclient,readqueryfromclient to read the request from the network connection. Resolves the request parameters and processes them.
Introduction to the Redis startup process