Redis is a high-performance key-value database. The emergence of redis largely compensates for the shortage of keyvalue storage such as memcached, and can play a good complementary role in relational databases in some cases. It provides Python, Ruby, Erlang, and PHP clients for ease of use. The installation and testing steps are as follows:
1. Install redis:
[root@localhost ~]# cd /usr/local/src/[root@localhost src]# wget http://redis.googlecode.com/files/redis-2.2.12.tar.gz[root@localhost src]# tar zxf redis-2.2.12.tar.gz[root@localhost src]# cd redis-2.2.12[root@localhost redis-2.2.12]# make PREFIX=/usr/local/redis install
2. Configure redis:
[Root @ localhost redis-2.2.12] # mkdir-p/usr/local/redis/etc [root @ localhost redis-2.2.12] # mkdir-p/usr/local/redis/var [root @ localhost redis-2.2.12] # cd/usr/local/redis/etc [root @ localhost etc] # vi redis. conf (re-create the conf file and copy the following configuration)
daemonize yespidfile /usr/local/redis/redis.pidport 6379bind 127.0.0.1timeout 300loglevel verboselogfile stdoutdatabases 16save 900 1save 300 10save 60 10000rdbcompression yesdbfilename dump.rdbdir /usr/local/redis/var/slave-serve-stale-data yesmaxclients 12800appendonly noappendfsync everysecno-appendfsync-on-rewrite noslowlog-log-slower-than 10000slowlog-max-len 1024vm-enabled novm-swap-file /tmp/redis.swapvm-max-memory 0vm-page-size 32vm-pages 134217728vm-max-threads 4hash-max-zipmap-entries 512hash-max-zipmap-value 64list-max-ziplist-entries 512list-max-ziplist-value 64set-max-intset-entries 512activerehashing yes
3. Start and close redis:
[root@localhost ~]# /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf[root@localhost ~]# ps -ef|grep redisroot 3891 1 0 18:11 ? 00:00:00 /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf[root@localhost redis-2.2.12]# /usr/local/redis/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown
If you use the default ports 127.0.0.1 and 6379, You can omit the preceding parameters when executing the command.
4. Test redis:
[root@localhost ~]# telnet 127.0.0.1 6379Trying 127.0.0.1...Connected to localhost (127.0.0.1).Escape character is '^]'.^]telnet> quitConnection closed.
5. Description of the file execution function in the/usr/local/redis/bin directory:
Redis-server: daemon Startup Program of the Redis server
Redis-cli: Redis command line operation tool. Of course, you can also use telnet to operate based on its plain text protocol.
Redis-benchmark: Redis performance testing tool to test the read/write performance of Redis in your system and your configuration
-------------------------- Satisfied split line -----------------------------------
Instance:
1) log on and enter the following data:
[root@localhost ~]# /usr/local/redis/bin/redis-cli -h 127.0.0.1 -p 6379redis 127.0.0.1:6379> set name csdnOKredis 127.0.0.1:6379> get name"csdn"redis 127.0.0.1:6379> quit
2) view redis statistics:
[root@localhost ~]# /usr/local/redis/bin/redis-cli -h 127.0.0.1 -p 6379 info
3) test performance:
Send 10 requests to the redis server, each with 50 concurrent clients,-n and-c
[root@localhost ~]# /usr/local/redis/bin/redis-benchmark -h 127.0.0.1 -p 6379 -n 10 -c 50