Configuration of Redis

Source: Internet
Author: User
Tags password protection

Configuration of Redis Configuration Method
  1. Through the redis.conf file
  2. The redis.conf configuration can be overridden by command-line arguments
  3. The config set command dynamically modifies a subset of Redis configurations without restarting Redis.

    redis>  CONFIG SET LogLevel warningokredis>  CONFIG GET loglevel1)  " loglevel   2)  " Warning"   

Redis supports 16 databases by default, which can be modified by configuring the parameter databases. After the Redis client connection succeeds, the No. 0 database is selected by default, but you can use the Select command to replace the database, such as:

Redis> SELECT 1OKredis [1]> GET foo (nil)
redis.conf Configuration Item Description
Configuration Items Description
Daemonize No Redis defaults to not run as a daemon, can be modified by this configuration item, and the daemon is enabled with Yes
Pidfile/var/run/redis.pid When Redis is running as a daemon, Redis writes the PID to the/var/run/redis.pid file by default and can be specified by pidfile
Port 6379 Specify the Redis listening port, the default port is 6379, the author in his own blog post explains why 6379 is chosen as the default port, because 6379 Merz the corresponding number on the phone keypad, and Merz taken from Italy showgirl Alessia Merz name
Bind 127.0.0.1 The host address of the binding
Timeout 300 When the client closes the connection after a period of inactivity, if 0 is specified, the feature is turned off
LogLevel verbose Specify logging level, Redis supports four levels in total: Debug, verbose, notice, warning, default = verbose
LogFile stdout logging mode, default to standard output, if Redis is configured to run as Daemon, and here is configured for logging as standard output, the log will be sent to/dev/null
Databases 16 Set the number of databases, the default database is 0, you can use the Select command to specify the database ID on the connection
Save Specify how many times the update operation will synchronize the data to the data file and can be combined with multiple conditions
Rdbcompression Yes Specifies whether to compress data when stored to a local database, by default Yes,redis with LZF compression, which can be turned off if you want to save CPU time, but will cause the database file to become huge
Dbfilename Dump.rdb Specifies the local database file name, the default value is Dump.rdb
Dir./ Specify local Database storage directory
Slaveof Set the IP address and port of the master service when this machine is a Slav service, and it will automatically synchronize data from master when Redis boots
Masterauth When the master service has password protection set, the Slav service connects the password of master
Requirepass foobared Set the Redis connection password, if the connection password is configured, the client needs to provide a password via the auth command when connecting to Redis, which is turned off by default
MaxClients 128 Set the maximum number of client connections at the same time, the default is unlimited, Redis can open at the same number of client connections for the Redis process can open the maximum number of file descriptors, if set maxclients 0, indicating no restrictions. When the number of client connections reaches the limit, Redis closes the new connection and returns the max number of clients reached error message to the client
MaxMemory Specify the Redis maximum memory limit, Redis will load the data into memory when it is started, Redis will try to clear the expired or expiring key first, when this method is processed, still reach the maximum memory setting, will no longer write operation, but still can read operation. Redis new VM mechanism will store key memory, value will be stored in swap area
AppendOnly No Specifies whether logging occurs after each update operation, which, by default, writes data to disk asynchronously, which, if not turned on, may cause data loss over time for a power outage. Because the Redis itself synchronizes data files in sync with the save conditions above, some data will only exist in memory for a period of time. Default is No
Appendfilename appendonly.aof Specifies the update log file name, which defaults to appendonly.aof
Appendfsync everysec|no|always Specify the update log condition (No: Indicates that the operating system is synchronizing the data cache to disk (fast), always: Represents a manual call to Fsync () after each update operation to write data to disk (slow, secure), Everysec: Indicates synchronization once per second (tradeoff, default))
Vm-enabled No Specifies whether the virtual memory mechanism is enabled, the default value is the NO,VM mechanism to store data paging, and Redis will have less access to the page that is cold data swap to disk, access to a number of pages automatically swapped out into memory by the disk (in the following article I will carefully analyze the Redis VM mechanism)
Vm-swap-file/tmp/redis.swap Virtual memory file path, default value of/tmp/redis.swap, not available for multiple Redis instance shares
Vm-max-memory 0 All data larger than Vm-max-memory is stored in virtual memory, regardless of how small the vm-max-memory setting is, all index data is in memory (Redis's index data is keys), that is, when Vm-max-memory is set to 0, In fact, all value is present on disk. The default value is 0
Vm-page-size 32 The Redis swap file is divided into a number of page, an object can be saved on more than one page, but a page can not be shared by multiple objects, Vm-page-size is based on the size of the stored data to set, the author suggests that if you store many small objects, The page size is best set to 32 or 64bytes, and if you store large objects, you can use a larger page, and if you are unsure, use the default values
Vm-pages 134217728 Sets the number of pages in the swap file, which consumes 1byte of memory per 8 pages on disk because the page table (a bitmap that indicates that the page is idle or used) is in memory
Vm-max-threads 4 Set the number of threads to access the swap file, preferably without exceeding the machine's number of cores, if set to 0, all operations on the swap file are serial and may cause a long delay. The default value is 4
Glueoutputbuf Yes Sets whether to merge smaller packages into a single package when answering to the client, which is turned on by default
Hash-max-zipmap-entries Hash-max-zipmap-value 512 Specifies that a special hashing algorithm is used when more than a certain number or maximum element exceeds a critical value
activerehashing Yes Specifies whether to activate the reset hash, which is turned on by default (described later in the introduction of the Redis hashing algorithm)
Include/path/to/local.conf Specifies that other configuration files can be used to use the same profile between multiple Redis instances on the same host, while each instance has its own specific configuration file

If you find an error, please tap, welcome message exchange, thank you

Configuration of Redis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.