Deploy Redis3 in CentOS7

Source: Internet
Author: User
Tags redis version redis cluster install redis

Deploy Redis3 in CentOS7

CentOS7 Redis3 Study Notes

1 Official Redis Website:
Http://www.redis.io/

2 Redis:
Http://download.redis.io/releases/redis-3.0.7.tar.gz
Here we download the redis-3.0.7.tar.gz

3 Redis introduction:
Redis is an open source (BSD licensed), in-memory data structure store, used as database, cache and message broker. it supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries. redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic IC partitioning with Redis Cluster.
This passage comes from the official Redis website. Is this the most convincing !? Pai_^

4. We can connect to the CentOS7 server through SecureCRT or XShell and enter the/usr/local/tools/directory:
Cd/usr/local/tools/
If this directory is not available, create it. This directory is mainly used to store some of the installation packages we downloaded:
Mkdir-p/usr/local/tools/

5 download the redis-3.0.7.tar.gz source code:
Wget http://download.redis.io/releases/redis-3.0.7.tar.gz
You can also click the http://download.redis.io/releases/redis-3.0.7.tar.gz address of the official website to download to the local machine now, and then upload to the/usr/local/tools/directory through SecureFXP;

6 unzip the redis-3.0.7.tar.gz source code:
Tar xzf redis-3.0.7.tar.gz

7. Compile the Redis source code:
Go to the Redis root directory redis-3.0.7:
Cd redis-3.0.7
Execute the compilation command:
Make

8. Start the Redist Server:
Src/redis-server
Shell gives us the following feedback, indicating that the redis service is successfully started:
1206: C 04 May 05:48:48. 344 # Warning: no config file specified, using the default config. in order to specify a config file use. /redis-server/path/to/redis. conf
_._
_.-''__''-._
_.-'''. '_. ''-. _ Redis 3.0.7 (00000000/0) 64 bit
.-''.-'''.'''\/_.,_''-._
(',.-' | ',) Running in standalone mode
| '-. _'-...-'_...-.'-. _ | ''_.-'| Port: 6379
| '-. _'. _/_.-'| PID: 1206
'-._'-._'-./_.-'_.-'
| '-. _.-' |
| '-. _'-. _.-'_.-' | Http://redis.io
'-._'-._'-.__.-'_.-'_.-'
| '-. _.-' |
| '-. _'-. _.-'_.-' |
'-._'-._'-.__.-'_.-'_.-'
'-._'-.__.-'_.-'
'-.__.-'
'-.__.-'

1206: M 04 May 05:48:48. 347 # WARNING: The TCP backlog setting of 511 cannot be enforced because/proc/sys/net/core/somaxconn is set to the lower value of 128.
1206: M 04 May 05:48:48. 347 # Server started, Redis version 3.0.7
1206: M 04 May 05:48:48. 347 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. to fix this issue add'vm. overcommit_memory = 1' to/etc/sysctl. conf and then reboot or run the command 'sysctl vm. overcommit_memory = 1' for this to take effect.
1206: M 04 May 05:48:48. 347 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. this will create latency and memory usage issues with Redis. to fix this issue run the command 'echo never>/sys/kernel/mm/transparent_hugepage/enabled 'as root, and add it to your/etc/rc. local in order to retain the setting after a reboot. redis must be restarted after THP is disabled.
1206: M 04 May 05:48:48. 355 * DB loaded from disk: 0.008 seconds
1206: M 04 May 05:48:48. 355 * The server is now ready to accept connections on port 6379
Note: The default port number of apsaradb for redis is 6379. We can see that the current PID of apsaradb for redis is 1206, which is running on a single machine. redis-server under the src directory indicates the redis server command;

9. It does not have any specific significance to start the redis server. Then we start the redis client to experience the charm of redis:
Src/redis-cli
Redis-cli in src indicates the command for redis to start the client;

10 because redis is developed in C language, let's take a look at the data types supported by redis,
String (String)
APPEND
BITCOUNT
BITOP
DECR
DECRBY
GET
GETBIT
GETRANGE
GETSET
INCR
INCRBY
INCRBYFLOAT
MGET
MSET
MSETNX
PSETEX
SET
SETBIT
SETEX
SETNX
SETRANGE
STRLEN
Hash (Hash table)
HDEL
HEXISTS
HGET
HGETALL
HINCRBY
HINCRBYFLOAT
HKEYS
HLEN
Hmet
HMSET
HSET
HSETNX
HVALS
HSCAN
List)
BLPOP
BRPOP
BRPOPLPUSH
LINDEX
LINSERT
LLEN
LPOP
LPUSH
LPUSHX
LRANGE
LREM
LSET
LTRIM
RPOP
RPOPLPUSH
RPUSH
RPUSHX
Set)
SADD
SCARD
SDIFF
SDIFFSTORE
SINTER
SINTERSTORE
SISMEMBER
SMEMBERS
SMOVE
SPOP
SRANDMEMBER
SREM
SUNION
SUNIONSTORE
SSCAN
SortedSet)
ZADD
ZCARD
ZCOUNT
ZINCRBY
ZRANGE
ZRANGEBYSCORE
ZRANK
ZREM
ZREMRANGEBYRANK
ZREMRANGEBYSCORE
ZREVRANGE
ZREVRANGEBYSCORE
ZREVRANK
ZSCORE
ZUNIONSTORE
ZINTERSTORE
ZSCAN

11. redis document translation website:
Http://doc.redisfans.com/
If you do not understand or forget it, you can view it here;

12 The basic data unit of redis is SDS (simple dynamic string), which is encapsulated on the char [] array in C language and used to store basic data;

13 set and get strings:
We insert a string type data to the redis Server:
127.0.0.1: 6379> set name 'idea'
The result returned by shell is as follows:
OK
Let's take a look at the value with the key name inserted to the redis Server:
127.0.0.1: 6379> get name
The result returned by shell is as follows:
"Idea"

14. Let's make an auto-incrementing sequence:
14.1 set a sequence whose key is orderid and its initial value is 10000:
Incrby orderid 10000
14.2 perform incremental operations one by one:
Incr orderid
Check the results returned by shell. Is redis increasing at an interval of 1?

15. Perform a list operation:
15.1 add 5 Integers to the left-to-right of the List:
127.0.0.1: 6379> lpush nums 10 20 30 40 50
The result returned by shell is as follows:
(Integer) 5
15.2 let's take the value from the right side, execute the following command five times, and view shell feedback:
127.0.0.1: 6379> rpop nums
"10"
Wagner. 0.0.1: 6379>
127.0.0.1: 6379> rpop nums
"20"
127.0.0.1: 6379> rpop nums
"30"
127.0.0.1: 6379> rpop nums
"40"
127.0.0.1: 6379> rpop nums
"50"
127.0.0.1: 6379> rpop nums
(Nil)
127.0.0.1: 6379> rpop nums
(Nil)
When the execution is performed for 6th times, the value cannot be obtained, which is not like the "Heap" in the data structure "?
15.3 run the following command five times from the left and view the shell feedback:
127.0.0.1: 6379> lpop nums
"50"
127.0.0.1: 6379> lpop nums
"40"
127.0.0.1: 6379> lpop nums
"30"
127.0.0.1: 6379> lpop nums
"20"
127.0.0.1: 6379> lpop nums
"10"
127.0.0.1: 6379> lpop nums
(Nil)
When the execution reaches 6th times, the value cannot be obtained. It looks like a "Heap" in the data structure!

You may also like the following articles about Redis. For details, refer:

Install and test Redis in Ubuntu 14.04

Basic configuration of Redis master-slave Replication

Redis cluster details

Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis

Redis series-installation, deployment, and maintenance

Install Redis in CentOS 6.3

Learning notes on Redis installation and deployment

Redis. conf

Redis details: click here
Redis: click here

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.