Redis series: liudongdong. Top/categories /… This source: liudongdong. Top/archives/re…

Public number: walk in the rain Sahara note: welcome to pay attention to the public number, study together, common progress!

First, Windows installation

1. Download

  1. Download from GitHub github.com/microsoftar…

  2. If the GitHub network speed is too slow, you can also pay attention to the public account walking in the rain Sahara, reply keywords 020, to download.

2. Decompress as follows

image.png

  1. Redis-server. exe: indicates the redis service

  2. Redis -cli.exe: redis client

  3. Redis-check-aof. Exe: aOF persistence check

  4. Redis-benchmark. exe: benchmark pressure test tool

3. Start

  1. Start the server (double-click)

    image.png

  2. Start the client (double-click)

    image.png

4. Test

Client operation

  1. Enter ping

  2. Enter set to save the value

  3. Enter the value of get

image.png

2. Linux installation (centos6.5)

0. Install GCC

Since Redis is written in C, it requires a C environment to run, so we need to install GCC first. The installation command is as follows:

yum install gcc-c++

Copy the code

1. Download

Wget download. Redis. IO/releases/re…

image.png

You can also download redis. IO/Download

image.png

2. Unzip

The tar - ZXF redis - 6.2.5. Tar. GzCopy the code

image.png

3. The compilation

In the decompressed Redis package, compile

CD redis - 6.2.5 / makeCopy the code

image.png

image.png

4. Install redis

cd src/
make install

Copy the code

image.png

5. File classification management

Create bin and etc files in the redis directory and move the redis.conf file to the etc directory. Move mkReleasehdr. sh, redis-benchmark, redis-check-aof, redis-cli, and redis-server to the bin file

[root@node2 redis-6.2.5]# mkdir etc [root@node2 redis-6.2.5]# mkdir bin [root@node2 redis-6.2.5]# mv redis.conf [root@node2 redis-6.2.5]# mv SRC /mkreleasehdr.sh SRC /redis-benchmark SRC /redis-check-aof SRC /redis-cli SRC /redis-server The. / bin/root @ 2 redis - 6.2.5] #Copy the code

6. Modify the Redis configuration file

[root @ 2 redis - 6.2.5] # vim etc/redis. ConfCopy the code

1. Enable remote access to Redis

  1. Comment out the bind 127.0.0.1 line in the redis. Conf configuration file. Bind means that only the specified network segment can access the redis remotely.

image.png

  1. Set protected-mode in the redis.conf configuration file to no (default is yes to prevent remote access, after redis3.2.3)

image.png

2. Enable background startup

Change the daemonize property in the file to yes (indicating that it needs to run in the background)

image.png

3. Change the default password

  1. In ESC mode, /requirepass search (n down, large n up)

  2. Uncomment and change your password

    image.png

4. Add automatic startup (optional based on actual requirements)

/etc/rc.d/rc.local Additional tail/root/designed/redis/redis - 6.2.5 / bin/redis server/root/designed/redis/redis - 6.2.5 / etc/redis. ConfCopy the code

7. Start

  1. Start the redis – service
[root @ 2 redis - 6.2.5] # bin/redis - server etc/redis. ConfCopy the code

image.png

  1. Start the redis – cli
[root @ 2 redis - 6.2.5] # bin/redis - cliCopy the code

Test 8.

Client operation

  1. Enter ping

  2. Enter set to save the value

  3. Enter the value of get

    image.png

Docker installation

1. Select a tag based on your version requirements and pull the tag

hub.docker.com/\_/redis/

image.png

2. Pull down the specified version

I’m just pulling the latest version for a learning test

  1. Query the redis repository
docker search redis

Copy the code

image.png

  1. To pull
Docker pull Redis is the latest version of docker pull redisCopy the code

image.png

3. Start

  1. Preparation process, Create a mount directory Start need to first create the Redis external mounted configuration file (/ mydata/Redis/conf/Redis. Conf) to create first, because the container Redis itself is only the/etc/Redis directory, Conf file is not created. When the server and container do not have the redis.conf file, docker will create the redis.conf directory when executing the startup command

Create a file with the content in appendix. Create a file with the content in Appendix. Create a file with the content in Appendix

# # to create directory mkdir -p/root/designed/redis/dockerredis / # # create a file, the file content for under appendix content touch/root/designed/redis/dockerredis/redis. ConfCopy the code
  1. Start the redis
docker run -p 6379:6379 \
--name docker_redis  \
-v  /root/programs/redis/dockerredis/redis.conf:/etc/redis/redis.conf \
-v  /root/programs/redis/dockerredis/data:/data  \
-d redis redis-server /etc/redis/redis.conf  \
--appendonly yes

Copy the code

-p 6379:6379 Port mapping: indicates the host part, and indicates the container part. –name docker_redis Specifies the container name, which is easy to view and operate. -v Indicates the mount directory. The rules are the same as those for port mapping. -d redis indicates to start the redis in the background redis redis-server /etc/redis/redis. Conf Start the redis in the configuration file and load the conf file in the container. Eventually found is mounted directory/root/designed/redis/dockerredis/redis. Conf appendonly yes open redis persistence

image.png

3. Modify the configuration

Modify the mount the/root/designed/redis/dockerredis/redis. Conf file, the file content synchronization in a container configuration file

Modify the configuration, for example, modify the configuration in Linux

4. Test

Enter the Redis container

docker exec -it docker_redis /bin/bash

Copy the code

Client operation

  1. Enter ping

  2. Enter set to save the value

  3. Enter the value of get

image.png

Appendix: Redis configuration under Docker

The appendix is too long to be shown here. Please read the original text or go to:

Liudongdong. Top/archives/re…