installation of Redis:
Tar zxvf redis-2.6.4.tar.gz
CD redis-2.6.4
just make it right.
Make
After execution, the corresponding execution files will be generated in the SRC directory of the current directory , such as:redis-server redis-cli, etc.;
We create the Redis location directory and the corresponding data store directory, configuration file directory, etc. in the /usr/local/ directory :
Mkdir/usr/local/redis/{conf,run,db}–pv
cd/root/redis-2.8.17
CP redis.conf/usr/local/redis/conf/
CD src/
CP Redis-benchmark Redis-check-aofredis-check-dump redis-server redis-cli mkreleasehdr.sh/usr/local/redis/
to this The Redis installation is complete.
Let's try booting up and see if the appropriate port is already started:
/usr/local/redis/redis-server /usr/local/redis/conf/redis.conf
at this point, all configurations are default, you can see that Redis is running in the foreground, or you can have Redis run in the background, here to modify the Redis configuration file, mainly redis.conf this file.
This configuration file describes the following:
daemonize Yes #--- the default value of No, which is used to customize whether the Redis service is running in daemon mode. ---
Pidfile/usr/local/webserver/redis/run/redis.pid # The default value,/var/run/redis.pid, specifies the process number file path for the Redis service, which you need to configure when running in daemon mode;
Port 6379 # Default value 6379, specifying the ports for the Redis service
# bind 127.0.0.1 # bind IP, default is native all network device;
Timeout 0 # The client disconnects after n seconds of inactivity, and by default 0 means that it is continuously open.
LogLevel Notice # # # # Set the log level on the service side with the following options:
Debug: Record detailed information for development or commissioning;
Verbose: Provide a lot of useful information, but not as detailed as debug , the default is this option;
Notice: Moderate reminders, more for the product environment;
Warning: Only important warning messages are displayed;
LogFile StdOut # # Specifies the output path of the log, the default value of stdout, indicating output to the screen, the Guardian mode is output to /dev/null;
If you want to output the log to syslog , you can start syslog-enabled Yes, which defaults to no.
# syslog-enabled No
Databases # # # Specifies the number of databases, by default , and the database used by default is DB0.
----The following snapshot-related settings :------
# Save <seconds><changes> # # Specify how long to refresh the snapshot to disk, this option has two attribute values and only fires when two attribute values are met; You can set multiple levels, such as the default parameter file:
Save 1: triggered at least once when the key value is changed forevery cubic seconds ( minutes );
Save: Every second (5 minutes ) is triggered at least ten times the key value is changed;
Save 10000: Triggered at least 10000 key changes per second;
Save 900 1
Save 300 10
Save 60 10000
rdbcompression Yes # # default Yes, when the dump database uses LZF to compress string objects, if the CPU resources are more tense, you can set the No, choose not to compress;
Rdbchecksum Yes
# The filename where to dump the DB database file name
Dbfilename Dump.rdb # # Default value dump.rdb,dump to file name in filesystem
DIR/USR/LOCAL/WEBSERVER/REDIS/DB # # Default value ./, that is, thecurrent directory,dump out of the data file storage path;
----The following replication-related settings, replication is not enabled by default, so the following table parameters are commented on in the default parameter file ----
# slaveof <masterip><masterport> # # Specify the primary IP and port for creating a mirror service
# Masterauth <master-password> # # If the master is configured with a password, it should also be set up here;
Slave-serve-stale-data Yes # # default value Yes. When slave loses a connection to the master side, or the copy is still being processed, the slave will have the following two performances:
When the value of this parameter is Yes ,slave continues to respond to client requests, although the data is not synchronized or even has no data ( appearing in the case of initial synchronization );
when the value of this parameter is no ,slave returns the error message "SYNC with Master in Progreee";
slave-read-only Yes # # default from Redis is read-only mode
# # # # # # # # # Repl-ping-slave-period, specify the period of slave to ping master periodically ;
# Repl-timeout The default value , specify the time-out. Note This parameter includes the time to bulk transfer data and ping the response.
------The following security-related settings ------
# Requirepass Foobared # # # # # # # # # Specify a password to connect to the client via a password;
# Rename-command CONFIGB840FC02D524045429941CC15F59E41CB7BE6C52 # # # redefine the command, such as renaming the CONFIG command to a very complex name:
# Rename-command CONFIG "" cancels this command;
-----The following settings for resource throttling ------
# maxclients 10000 # # Specifies the maximum number of concurrent connections for a client, by default there is no limit until Redis cannot create a new process, and setting the parameter value to 0 also means no limit if the parameter specifies a value. When the concurrent connection reaches the specified value,redis closes all new connections and returns the error message ' max number of clients reached ';
# maxmemory <bytes> # # # Set redis maximum available memory. When the maximum memory is reached,Redis attempts to delete the key values according to the set recycle policy. If the key value cannot be deleted, or if the retention policy is set to not clear, Redis will return an error message to the memory-issuing request. This parameter is useful when Redis is cached as a first-level LRU .
# maxmemory-policy Volatile-lru # # # # Default value volatile-lru, specify the purge policy, in the following ways:
VOLATILE-LRU, remove the key with Anexpire set using a LRU algorithm
ALLKEYS-LRU, remove any keyaccordingly to the LRU algorithm
Volatile-random, remove a random keywith an expire set
Allkeys->random, remove a randomkey, any key
Volatile-ttl, remove the key with Thenearest expire time (minor TTL)
Noeviction, don ' t expire at all, Justreturn a error on write operations
# maxmemory-samples 3 # # # # # # # # # default 3,LRU and minimum TTL policies are not rigorous policies, but approximate estimates, so you can choose to sample values for inspection.
-----The following configuration for APPEND----
Only mode setting, Redis asynchronously dumps data to disk by default, which in extreme cases may result in the loss of some data ( such as a sudden server outage ). If the data is important and you do not want to lose it, you can enable write-through mode, in which Redis synchronizes all the received writes to the appendonly.aof file, which is in the Redis when the service starts rebuilds all data in memory. Note that this pattern has a very large impact on performance.
AppendOnly No # # # Default value No, specifies whether write mode is enabled;
# appendfilename Appendonly.aof # # # write-down default file name appendonly.aof
Appendfsync: Call Fsync () mode to let the operating system write data to disk, data synchronization mode, there are the following modes:
Always: Called every time, such as security, but the slowest speed;
Everysec: Synchronization per second, which is also the default mode;
No: Do not call Fsync, the operating system determines when synchronization, such as fast mode;
No-appendfsync-on-rewrite: Default value no. When the AOF fsync policy is set to always or everysec, the background save process performs a large number of I/O operations. In some Linux configurations , Redis may block too many Fsync () calls.
Auto-aof-rewrite-percentage: Default value 100
Auto-aof-rewrite-min-size: Default value 64MB
# Appendfsync Always
Appendfsync everysec
# Appendfsync No
-----The following settings related to Advanced configuration ----
Hash-max-zipmap-entries: By default ,when the number of elements of a map reaches the maximum, but the length of the largest element does not reach the set threshold, its HASH Coding takes a special approach ( more efficient use of memory ). This parameter is used in combination with the following parameters to set these two thresholds. Set the number of elements;
Hash-max-zipmap-value: The default value of twosets the maximum length of the value of the element in the map;
List-max-ziplist-entries: The default value is, like hash, a list array that satisfies the criteria also takes a special way to save space.
List-max-ziplist-value: Default value 64
Set-max-intset-entries: The default value is, when data in a set type is a numeric type, and the number of integral elements in set does not exceed the specified value, a special encoding is used.
Zset-max-ziplist-entries: The default value is $ A, similar to hash and list .
Zset-max-ziplist-value: Default value 64
Activerehashing: The default is yes tocontrol whether the hash is automatically rebuilt . the activerehashing uses 1 microseconds of CPU time per microsecond to reorganize the Redis hash table. Rebuilding is done by a lazy way, the more you write a hash table, the more steps you need to perform rehashing, and if the server is currently idle, then rehashing The operation is always performed. If the requirement for real-time is high and it is difficult to accept the 2 microsecond latency that Redis occasionally has , you can set activerehashing to no, otherwise the recommended setting is Yesto save memory space.
Redis installation under Linux