If it is a professional dBA, many parameters will be added when the instance is started to make the system run very stably, so that a parameter may be added after redis at startup, you can specify the path of the configuration file to start the database by reading the startup configuration file like MySQL. After the source code is compiled, there is a redis. conf file in the redis-2.2.12 directory, this file is the configuration file of redis, the method to start redis with the configuration file is as follows:
[Root @ localhost redis-2.2.12] # src/redis-server redis. conf
Redis supports many parameters, but all have default values.
Daemonize:
By default, redis is not running in the background. If you need to run in the background, change the value of this item to yes.
Pidfile
When redis is running in the background, redis puts the PID file in/var/run/redis. PID by default. You can configure it to another address. When running multiple redis services, you must specify different PID files and ports.
Bind
Specify that redis only receives requests from this IP address. If this parameter is not set, all requests will be processed. It is best to set this parameter in the production environment.
Port
Listening port. The default value is 6379.
Timeout
Set the timeout time for client connection, in seconds. When the client does not send any commands during this period, close the connection.
Loglevel
Log levels are classified into four levels: Debug, verbose, notice, and warning. Notice is generally enabled in the production environment.
Logfile
Configure the log file address. The standard output is used by default, that is, printed in the window of the command line terminal.
Databases
Set the number of databases. You can use the select <dbid> command to switch between databases. The default database is 0.
Save
Set the frequency of redis database images.
If (when 10000 keys change within 60 seconds ){
Back up images
} Else if (10 keys changed in 300 seconds ){
Back up images
} Else if (one keys changed in 900 seconds ){
Back up images
}
Rdbcompression
Whether to perform compression during image backup
Dbfilename
File Name of the backup image file
Dir
Path of the database image backup file. The path and file name must be configured separately because redis
During row backup, the current database status is first written to a temporary file. When the backup is complete, the temporary file is replaced with the file specified above, the temporary files and the backup files configured above are stored in the specified path.
Slaveof
Set this database as the slave database of another database
Masterauth
Specify
Requirepass
Set the password to be used before other settings are made after the client connects. Warning because redis is quite fast, an external user can try a K password in one second on a better server, this means you need to specify a very powerful password to prevent brute-force cracking.
Maxclients
Limit the number of customers connected at the same time. When the number of connections exceeds this value, redis will no longer receive other connection requests, and the client will receive an error message when trying to connect.
Maxmemory
Set the maximum memory available for redis. When the memory is full, if you still receive the SET command, redis will first try to remove the key with expire information, regardless of whether the key expires. During deletion, the key will be deleted according to the expiration time, and the key to be expired will be deleted first. If all keys with expire information are deleted, an error is returned. In this way, redis will not receive write requests, but only get requests. Maxmemory settings are suitable for using redis as a cache similar to memcached.
Appendonly
By default, redis asynchronously backs up database images to disks in the background. However, this backup is time-consuming and cannot be performed frequently, if a fault occurs, such as power limit or power limit, it may cause a wide range of data loss. Therefore, redis provides another more efficient method for database backup and disaster recovery. After the append only mode is enabled, redis will append each write operation request received to appendonly. in the aof file, when redis is restarted, the previous state will be restored from the file. However, this will cause the appendonly. aof file to be too large, so redis also supports the bgrewriteaof command to reorganize appendonly. Aof. Therefore, we recommend that you disable the image and enable appendonly. aof in the production environment. You can also rewrite appendonly. aof every day when there is less access.
Appendfsync
Set the synchronization frequency of the appendonly. aof file. Always indicates that the write operation is synchronized every time, while everysec indicates that the write operation is accumulated and synchronized every second. This needs to be configured according to the actual business scenario
VM-Enabled
Whether to enable virtual memory support. Because redis is a memory database and cannot receive new write requests when the memory is full, redis 2.0 provides virtual memory support. However, in redis, all keys are stored in the memory. When the memory is insufficient, only the value is placed in the SWAp zone. This ensures that although the virtual memory is used, the performance is basically not affected. At the same time, you must note that you should set VM-max-memory to enough to put down all your keys.
VM-Swap-File
Set the swap file path for the virtual memory
VM-max-memory
Set the maximum physical memory size that redis will use after enabling virtual memory. The default value is 0. redis will put all of its swap files into swap files to use as little physical memory as possible. In the production environment, you need to set this value according to the actual situation, it is best not to use the default 0
VM-page-size
Set the page size of the virtual memory. If your value is relatively large, for example, you need to place all the articles such as blogs and news in the value, set it to a larger value, if you want to store small content, set it to a smaller value.
VM-pages
Set the total number of pages for the swap file. Note that the page table information is stored in the physical memory, and each 8 pages occupies one byte in Ram. Total virtual memory size = VM-page-size * VM-pages
VM-max-threads
Sets the number of threads simultaneously used by VM Io. Because the data is encoded and decoded during memory exchange, I/O devices cannot support many concurrent reads and writes on the hardware, however, if the value of the vlaue you saved is relatively large, you can set this value to a greater value to improve the performance.
Glueoutputbuf
Put the small output cache together so that multiple responses can be sent to the client in a TCP packet. I am not very clear about the specific principle and actual effect. So according to the annotations, you can set it to yes if you are not sure.
Hash-max-zipmap-entries
Hash data structure is introduced in redis 2.0. When the hash contains more than the specified number of elements and the maximum number of elements does not exceed the critical value, hash will be stored in a special encoding method (greatly reducing memory usage, the two thresholds can be set here.
Activerehashing
After it is enabled, redis uses a CPU time of 1 ms every 100 milliseconds to re-hash the hash table of redis, which can reduce the memory usage. In your application scenario, if you have strict real-time requirements and cannot accept redis's 2 ms latency for requests from time to time, set this parameter to No. If you do not have such strict real-time requirements, you can set it to yes to release the memory as quickly as possible.