CentOS Linux System installation Redis process and configuration parameter description _redis

Source: Internet
Author: User
Tags chmod hash redis centos

Installation process:

Copy Code code as follows:

wget http://code.google.com/p/redis/downloads/detail?name=redis-2.0.4.tar.gz
Tar xvzf redis-2.0.4.tar.gz
CD redis-2.0.4
Make
Mkdir/home/redis
CP Redis-server/home/redis
CP Redis-benchmark/home/redis
CP Redis-cli/home/redis
CP Redis.conf/home/redis
Cd/home/redis

sudo commands may be required during installation, and new users in the newly installed Redhat virtual machine may not be able to use the sudo command, and therefore need to manually modify the/etc/sudoers file, as follows:

Copy Code code as follows:

Cd/etc
Su Root # #切换为root用户, enter password at the same time
chmod u+w sudoers # #放开sudoers文件的写权限
# #在root all = The following line adds "your username" all =
: Wq # #保存退出
chmod u-w sudoers # #取消修改权限

Start

Copy Code code as follows:

./redis-server redis.conf

Enter the command interaction mode, two types:

Copy Code code as follows:

1:/REDIS-CLI
2:telnet 127.0.0.1 6379 (IP access port)

Configuration file Parameter Description:

1. Redis is not run as a daemon by default, and can be modified using Yes to enable the daemon process

Copy Code code as follows:

Daemonize No

2. When Redis is running as a daemon, Redis writes the PID to the/var/run/redis.pid file by default, which can be specified by pidfile

Copy Code code as follows:

Pidfile/var/run/redis.pid

3. Specify the Redis listening port, the default port is 6379, the author in his own posting explained why 6379 as the default port, because 6379 on the phone button on the number of Merz, and Merz from the Italian singer Alessia Merz name

Copy Code code as follows:

Port 6379

4. The host address of the binding

Copy Code code as follows:

Bind 127.0.0.1

5. Close the connection when the client is idle for a long time, or 0 if specified, to turn off the feature

Copy Code code as follows:

Timeout 300

6. Specify logging level, Redis supports four levels in total: Debug, verbose, notice, warning, default to verbose

Copy Code code as follows:

LogLevel verbose

7. Logging mode, default to standard output, if the configuration redis for the daemon mode, and this is configured as logging mode for standard output, the log will be sent to/dev/null

Copy Code code as follows:

LogFile stdout

8. Set the number of databases, the default database is 0, you can use the Select command to specify the database ID on the connection

Copy Code code as follows:

Databases 16

9. Specify how long, how many times the update operation, the data synchronized to the data file, can be multiple conditions with

Copy Code code as follows:

Save

There are three conditions available in the Redis default configuration file:

Copy Code code as follows:

Save 900 1
Save 300 10
Save 60 10000

Each represents 1 changes in 900 seconds (15 minutes), 5 changes in 300 seconds (10 minutes), and 60 changes in 10,000 seconds.

10. Specifies whether to compress the data when stored to the local database, the default is Yes,redis with LZF compression, if you want to save CPU time, you can turn off this option, but it will cause the database file to become huge

Copy Code code as follows:

Rdbcompression Yes

11. Specify the local database filename, the default value is Dump.rdb

Copy Code code as follows:

Dbfilename Dump.rdb

12. Specify local Database storage directory

Copy Code code as follows:

Dir./

13. Set the IP address and port of master service when this machine is Slav service, it automatically synchronizes data from master when Redis is started

Copy Code code as follows:

Slaveof

14. When the master service is password protected, the Slav service connects Master's password

Copy Code code as follows:

Masterauth

15. Set the Redis connection password, if the connection password is configured, the client will need to provide the password through auth command when connecting Redis, the default shutdown

Copy Code code as follows:

Requirepass foobared

16. Set the maximum number of client connections at the same time, the default unrestricted, Redis can open the number of client connections Redis process can open the maximum number of file descriptors, if set maxclients 0, which means no restrictions. When the number of client connections reaches a limit, Redis closes the new connection and returns the max number of clients reached error message to the client

Copy Code code as follows:

MaxClients 128

17. Specify Redis maximum memory limit, Redis will load the data into memory at startup, and after reaching maximum memory, Redis will attempt to clear a key that has expired or is about to expire, and when this method is processed, it still reaches the maximum memory setting, no more writes will be made, but the read operation is still available. Redis the new VM mechanism, the key is stored in memory, and value is stored in the swap area

Copy Code code as follows:

MaxMemory

18. Specifies whether to log records after each update operation, redis the data to disk by default and, if not, may result in loss of data for a period of time if the power is not turned on. Because the Redis itself synchronizes data files according to the above save condition, some data will only exist in memory for a period of time. Default is No

Copy Code code as follows:

AppendOnly No

19. Specify update log file name, default to Appendonly.aof

Copy Code code as follows:

Appendfilename appendonly.aof

20. Specify an update log condition with 3 optional values:

No: Indicates that the operating system synchronizes data cache to disk (fast)
Always: Indicates that Fsync () is manually invoked after each update operation () to write data to disk (slow, secure)
Everysec: Indicates sync per second (compromise, default)

Copy Code code as follows:

Appendfsync everysec

21. Specifies whether the virtual memory mechanism is enabled, the default is no, a simple introduction, the VM mechanism to store data paging, by Redis will be less visited the page that cold data swap to disk, Access to many pages from the disk automatically swapped out into memory (in the following article I will carefully analyze the VM mechanism of Redis)

Copy Code code as follows:

Vm-enabled No

22. Virtual memory file path, default value is/tmp/redis.swap, not multiple Redis instance sharing

Copy Code code as follows:

Vm-swap-file/tmp/redis.swap

23. Save all data larger than vm-max-memory into virtual memory, no matter how small the Vm-max-memory settings, all index data is memory storage (Redis index data is the keys), that is to say, when the vm-max-memory is set to 0, In fact, all of the value exists on the disk. The default value is 0

Copy Code code as follows:

Vm-max-memory 0

Redis swap file is divided into a lot of page, an object can be saved on multiple page, but a page can not be shared by multiple objects, Vm-page-size is based on the size of the stored data set, the authors suggest that if you store a lot of small objects, The page size is best set to 32 or 64bytes; If you store a large object, you can use a larger page and, if unsure, use the default value

Copy Code code as follows:

Vm-page-size 32

25. Set the number of pages in the swap file, because the page table (a bitmap that indicates that the page is idle or used) is in memory, which consumes 1byte of memory per 8 pages on disk.

Copy Code code as follows:

Vm-pages 134217728

26. Set the number of threads to access the swap file, preferably do not exceed the machine's core, if set to 0, then all operation of the swap file is serial, may cause a relatively long delay. The default value is 4

Copy Code code as follows:

Vm-max-threads 4

27. Set when replying to the client, whether to merge the smaller packages into one package send, default to open

Copy Code code as follows:

Glueoutputbuf Yes

28. Specifies that a special hashing algorithm is used when more than a certain number or maximum element exceeds a critical value

Copy Code code as follows:

Hash-max-zipmap-entries 64
Hash-max-zipmap-value 512

29. Specifies whether to activate the reset hash, which is turned on by default (described later when introducing the hash algorithm for Redis)

Copy Code code as follows:

activerehashing Yes

30. Specifies that there are other configuration files that can use the same configuration file between multiple Redis instances on the same host, while each instance has its own specific configuration file

Copy Code code as follows:

Include/path/to/local.conf

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.