Redis is an advanced Key-value database. It is similar to memcached, but the data can be persisted and the supported data types are rich. There are strings, lists, collections, and ordered collections. Supports the addition, intersection and complement (difference) of the compute sets on the server side, and supports a variety of sorting functions. So Redis can also be viewed as a data structure server.
All redis data is stored in memory and then periodically asynchronously saved to disk (this is called "semi-persistent mode"), and each data change can be written to a append only file (AOF) (this is called "Full persistence mode").
1. :
$ wget http://redis.googlecode.com/files/redis-2.6.13.tar.gz
2. Unzip
$ tar xzf redis-2.6.13.tar.gz
3. Compile
$ CD redis-2.6.13
$ 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, they function as follows:
Redis-server:redis Server Daemon Startup program
Redis-cli:redis command-line operation tool. You can also use Telnet to manipulate it based on its plain text protocol.
Redis-benchmark:redis Performance Testing tool to test Redis's read and write performance under current system
REDIS-CHECK-AOF: Data Repair
Redis-check-dump: Check the Export tool
4. Modify the system configuration file, execute the command
A) echo Vm.overcommit_memory=1 >>/etc/sysctl.conf
b) 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
5. Modifying a Redis configuration file
A) $ CD redis-2.6.13
b) VI redis.conf
c) Modify Daemonize Yes---to enable 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 per second, do not call Fsync wait for the system to synchronize itself)
6. Start Redis
A) $ cd/usr/local/bin
b)./redis-server/etc/redis.conf
7. Check whether the start is successful
A) $ ps-ef | grep Redis