Redis full name: Remote Dictionary Server is a high performance (key/value) distributed memory database, which runs on memory and supports persistent NoSQL database. Is currently one of the most popular NoSql databases, also known as data structure server.

1. Redis is introduced

Redis. IO www.redis.cn

Redis shares three characteristics with other key-value caching products

  • Redis supports persistent data, which can keep data in memory on disk and be reloaded for use upon restart
  • Redis not only supports simple key-value type data, but also provides the storage of list, set, zset, hash and other data structures
  • Redis supports data backup, namely, data backup in master-slave mode

2. Redis installation

Docker is the recommended way to install Redis and is easy to maintain.

2.1 Downloading an Image

Redis image official website: hub.docker.com/_/redis/

Run the docker pull redis command to download the image successfully.

~ docker pull redis
Using default tag: latest
latest: Pulling from library/redis
68ced04f60ab: Pull complete
7ecc253967df: Pull complete
765957bf98d4: Pull complete
91fff01e8fef: Pull complete
76feb725b7e3: Pull complete
75797de34ea7: Pull complete
Digest: sha256:ddf831632db1a51716aa9c2e9b6a52f5035fc6fa98a8a6708f6e83033a49508d
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest
Copy the code

2.2 Create and run containers

~ docker run -itd --name local-redis -p 6379:6379 redis
b26758de6935aa9f7ab7e85d19fac064fced84ced322f42359741467c4068fdc
Copy the code

2.3 Checking whether the installation is successful

~ docker logs -f local-redis
1:C 17 Mar 2020 10:17:22.157 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 17 Mar 2020 10:17:22.157 # Redis version=5.0.8, bits=64, commit=00000000, Modified =0, PID =1, just started
1:C 17 Mar 2020 10:17:22.157 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf_ the _ _. - ` ` __' '-) _ _) - ` ` `. ` _.' '- _ Redis 5.0.8 (00000000/0), 64 - bit. - ` `. - ` ` `. ` ` ` \ / _, _' '-. _ (' , .-` | `, ) Running in standalone mode |`-._`-... - ` __... -. ` ` - _ | '` _....'| Port: 6379 | `-._ `._ / _.-'    |     PID: 1
  `-._    `-._  `-./  _.-'_. -| ` -) _ ` -) _ ` -. __. -'_. -_. -'| | ` -. _ ` -. _ _. -'_. -' | http://redis.io `-._ `-._`-.__.-'_. -'_. -| ` -) _ ` -) _ ` -. __. -'_. -_. -'| | ` -. _ ` -. _ _. -'_. -'| ` -) _ ` -) _ ` - __. -'_. -'_. -` - _ ` -. __. -'_. -` -. _ _. -'` -. __. -

1:M 17 Mar 2020 10:17:22.161 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 17 Mar 2020 10:17:22.161 # Server initialized
1:M 17 Mar 2020 10:17:22.161 # 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.
1:M 17 Mar 2020 10:17:22.161 * Ready to accept connections
Copy the code

If the preceding logs are displayed, Redis is successfully installed.

3. Tool recommendations

3.1 redis – cli

The command line tool of redis is stored in /usr/local/bin

Go to the container console:

~ docker exec -it local-redis /bin/bash
Copy the code

Link redis-cli and use ping command:

root@b26758de6935:~# /usr/local/bin/redis-cli127.0.0.1:6379 > ping PONGCopy the code

Redis 3.2 Desktop Manager

Official website: redisdesktop.com/

This tool on the Mac will use a high performance graphics card, relatively power, and a bit of a card, not recommended.

3.3 RedisInsight

The official website: redislabs.com/redisinsigh…

Recommended use, the console is a web page, anyway, also want to open the browser, more than open a TAB page does not matter, and the appearance level is also good!

4. Other

The default Redis installation directory is /usr/local/bin

/usr/local/bin = /usr/local/bin

root@b26758de6935:~# ls -al /usr/local/bin/
total 24580
drwxr-xr-x 1 root root     4096 Mar 13 20:21 .
drwxr-xr-x 1 root root     4096 Feb 24 00:00 ..
-rwxrwxr-x 1 root root      374 Mar 13 20:20 docker-entrypoint.sh
-rwxr-xr-x 1 root root  2294944 Oct 15  2018 gosu
-rwxr-xr-x 1 root root  5940736 Mar 13 20:21 redis-benchmark
lrwxrwxrwx 1 root root       12 Mar 13 20:21 redis-check-aof -> redis-server
lrwxrwxrwx 1 root root       12 Mar 13 20:21 redis-check-rdb -> redis-server
-rwxr-xr-x 1 root root  6484736 Mar 13 20:21 redis-cli
lrwxrwxrwx 1 root root       12 Mar 13 20:21 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 10424488 Mar 13 20:21 redis-server
Copy the code

The main documents are described below:

  • Docker-entrypoint. sh: indicates the docker startup script
  • Redis-benchmark: a performance test tool
  • Redis-check-aof: Fixes faulty AOF files
  • Redis-check-dump: Repair the dump. RDB file
  • Redis -cli: client connection script
  • Redis-sentinel: Redis cluster script
  • Redis-server: startup script of the Redis server

Tips

Welcome to collect and forward, thank you for your support! (๑ • ̀ ㅂ ́) organisation ✧

Welcome to pay attention to me: back-end brother, focus on back-end development, hope to progress with you!