I. Introduction to Redis
1.1 RedisIntroduction
Redis is an open source API that is written in ANSI C , supports the web, can be persisted in memory, Key-value databases, and provides multiple languages .
1.2 RedisBasic Concepts
Redisis aKey-valueStorage System. and theMemcachedSimilarly, it supports the storage ofValuetypes are relatively more, includingStringstring),ListLinked list),SetCollection),Zset (SortedSet--ordered Collection)and theHash(hash type). These data types all supportPush/pop,Add/removeand take the intersection of the set and the difference set and richer operations, and these operations are atomic. On this basis,Redissupports sorting in a variety of different ways. With theMemcached, the data is cached in memory in order to ensure efficiency. The difference isRedisperiodically writes the updated data to the disk or writes the modification to the appended record file, and on this basis implements theMaster-slave (Master)synchronization.
Redis is a high-performance key-value database. redis memcached this kind key/value java c/c++ C# javascript perl< Span style= "font-family: ' The song Body '; >, object-c python ruby< Span style= "font-family: ' The song Body '; >, erlang etc client, easy to use.
Redis supports master-slave synchronization. Data can be synchronized from the primary server to any number of slave servers, from the server to the primary server that is associated with other slave servers. This enables Redis to perform single-layer tree replication. You can write to the data intentionally or unintentionally. Because of the full implementation of the Publish / subscribe mechanism, you can subscribe to a channel and receive a complete message release record from the master server when the tree is synchronized anywhere from the database. Synchronization is helpful for the scalability and data redundancy of read operations.
two. Redisinstallation
1.Unzip
$ tar zxf redis-3.0.3.tar.gz
2.compiling
$CD redis-3.0.3
$make; Make install
$CP redis.conf/etc/
Parameter description:
When the make install command finishes executing, the executable is generated in the/usr/local/bin directory, respectively , Redis-server,redis-cli, Redis-benchmark, redis-check-aof ,redis-check-dump, and their functions are as follows:
Redis-server:daemon boot program for Redis server
REDIS-CLI:Redis Command-line Operations tool. You can also use telnet to manipulate it based on its plain text protocol.
Redis-benchmark:redis Performance test tool to test Redis Read and write performance under current system
Redis-check-aof: Data repair
Redis-check-dump: Check the export tool
3.Modify the System configuration file
$echo Vm.overcommit_memory=1 >>/etc/sysctl.conf
$sysctl Vm.overcommit_memory=1 or perform echo vm.overcommit_memory=1>>/proc/sys/vm/overcommit_memory
Use numeric meanings:
0, indicates that the kernel will check for sufficient available memory to be used by the process, and if sufficient memory is available, the memory request is allowed; otherwise, the memory request fails and the error is returned to the application process.
1, which means that the kernel allows all physical memory to be allocated regardless of the current memory state.
2, which indicates that the kernel allows allocating more memory than the sum of all physical memory and swap space
4.ModifyRedisconfiguration file
$vim/etc/redis.conf
Modify daemonize Yes--- for the process to run in the background
Parameter description:
Daemonize: Whether to run daemon mode later
Pidfile:pid File location
Port: Port number for listening
Timeout: Request Time-out
LogLevel:log information level
LogFile:log file location
Databases: Number of open databases
Save *: How often the snapshot is saved, the first * indicates how long, and the third * indicates how many times the write operation is performed. Snapshots are automatically saved when a certain number of writes are performed within a certain amount of time. You can set multiple conditions.
Rdbcompression: Whether to use compression
Dbfilename: Data Snapshot file name (only file name, excluding directory)
Dir: Save directory for Data snapshot (this is the directory)
AppendOnly: If the appendonlylog is turned on, each write will record a log, which will improve the data anti-risk ability, but affect the efficiency.
Appendfsync:appendonlylog How to sync to disk (three options, each write is forced to call Fsync, Fsync isenabled once per second , do not call Fsync wait for the system to synchronize itself)
5.StartRedis
$CD/usr/local/bin
$./redis-server/etc/redis.conf
6.Check whether the start is successful
$ps –ef | grep Redis
This article from "I Am 喳喳" blog, reprint please contact the author!
Redis installation Configuration