Redis is a key-value storage system. Similar to memcached, memcached supports more storage value types, including string, list, set, and zset) and hash (hash type ). These data types support push/pop, Add/Remove, Intersection Set and difference set, and more abundant operations, and these operations are atomic. On this basis, redis supports sorting in different ways. Like memcached, data is cached in the memory to ensure efficiency. The difference is that redis periodically writes the updated data to the disk or writes the modification operation to the append record file, and on this basis implements master-slave (master-slave) synchronization.
Redis is a high-performance Key-value database. The emergence of redis largely compensates for the shortage of key/value storage such as memcached, and can play a good complementary role in relational databases in some cases. It provides clients such as Java, C/C ++, C #, PHP, JavaScript, Perl, object-C, Python, Ruby, and Erlang for ease of use.
I am using centos5.4, and the GCC and other environments have been configured.
1. Install TCL because redis depends on TCL.
Yum-y install TCL
2. Install redis
Download redis.2.8.13.tar.gz
Music redis-2.8.13.tar.gz/tmp
CD/tmp/
Ls
Tar-zxvf redis-2.8.13.tar.gz
CD redis-2.8.13
Make & make install
You can check readme during installation. This is a good habit.
./Runtest test found no problem
MV redis. CONF/etc/redis. conf
Running and disabling 3redis
Run redis-server/etc/redis. conf
Disable redis-Pencil Shutdown
4redis configuration file details
Daemonize yes # Run redis in daemon mode later
Pidfile "/var/run/redis. PID" # Run on apsaradb for redis later. The default PID file path is/var/run/redis. PID.
Port 6379 # default port
Bind 127.0.0.1 # All IP addresses of the local machine are bound by default. To ensure security, you can only listen to intranet IP addresses.
Timeout 300 # client timeout settings, in seconds
Loglevel verbose # Set the log level. Four levels are supported: Debug, notice, verbose, and warning.
Logfile stdout # log record method. The default value is standard output. Logs does not write files and is output to an empty device/DEB/null.
Logfile "/usr/local/redis/var/redis. log" # You can specify the log file path
Databases 16 # Number of enabled databases
Save 900 1
Save 300 10
Save 60 10000
Create a local database snapshot in the format of save **
1 write operation in 900 seconds
10 write operations performed within 300 seconds
10000 write operations performed within 60 seconds
Rdbcompression yes # enable lzf compression or set it to no
Dbfilename dump. RDB # Name of the local snapshot Database
Dir "/usr/local/redis/var/" # local snapshot database storage directory
Requirepass Zhanghe # Set the redis database connection password
Maxclients 10000 # maximum number of client connections at the same time, 0 is unlimited
Maxmemory 1024 MB # set the maximum memory used by redis. The value must be smaller than the physical memory.
Appendonly yes # Enable logging, equivalent to MySQL BINLOG
Appendfilename "appendonly. aof" # log file name. Note: it is not a directory path.
Appendfsync everysec # executes synchronization every second. Two other parameters always and no are generally set to everysec, which is equivalent to writing MySQL transaction logs.
5. Verification
Redis-cli-A Zhanghe note-A is followed by the password of the redis database. If the password is incorrect, the password can be entered, but the operation is not allowed. The verification fails.
Redis-cli-A redis
Wagner. 0.0.1: 6379>
Wagner. 0.0.1: 6379>
127.0.0.1: 6379> 127.0.0.1: 6379> s127.0.0.1: 6379> se127.0.0.1: 6379> set127.0.0.1: 6379> set 127.0.0.1: 6379> set s127.0.0.1: 6379> set ss127.0.0.1: 6379> set SS 127.0.0.1: 6379> set SS z127.0.0.1: 6379> set SS zh127.0.0.1: 6379> set SS zha127.0.0.1: 6379> set SS zhan127.0.0.1: 6379> set SS zhang127.0.0.1: 6379> set SS zhangh127.0.0.1: 6379> set SS Zhanghe
OK
127.0.0.1: 6379> 127.0.0.1: 6379> g127.0.0.1: 6379> ge127.0.0.1: 6379> get127.0.0.1: 6379> Get 127.0.0.1: 6379> Get s127.0.0.1: 6379> Get Ss
"Zhanghe"
So far, the configuration is complete
This article is from the "Zhanghe" blog, please be sure to keep this source http://9206668.blog.51cto.com/9196668/1533341