当前位置:网站首页>Docker installation redis

Docker installation redis

2022-06-09 02:24:00 Tag heartbeat


step

1. Pull redis Mirror image

docker pull redis

2. Create mount directory

mkdir -p /srv/redis/conf
mkdir -p /srv/redis/data

3. download redis.conf file

Enter the first conf Catalog :

cd /srv/redis/conf

Download the official conf file :

wget http://download.redis.io/redis-stable/redis.conf

4. give redis.conf jurisdiction

chmod 777 redis.conf

chmod 777 Is to change the file read and write permissions , and chmod +x Is to change the file status to executable .

 Insert picture description here

5. Modify default configuration information

vim redis.conf

Modify the following parameters :

bind 127.0.0.1 #  This line needs to be commented out , Remove local connection restrictions 
protected-mode no #  Default yes, If set to yes, Only the loopback connection of this machine is allowed , Other machines cannot be connected .
daemonize no #  Default no  Not in daemon mode ,docker The deployment does not need to be changed to yes,docker run -d Itself is the background startup , Otherwise, there will be conflicts 
requirepass 123456 #  Set the password 
appendonly yes #  Persistence 

6. start-up redis

docker run --name redis \
-p 6379:6379 \
-v /srv/redis/conf/redis.conf:/etc/redis/redis.conf \
-v /srv/redis/data:/data \
-d redis redis-server /etc/redis/redis.conf --appendonly yes

Parameter description :

-p 6379:6379: Port mapping , In front is the host computer , Behind it is the container .
–name redis: Specify the container name .
-v  Mount a file or directory : In front is the host computer , Behind it is the container .
-d redis redis-server /etc/redis/redis.conf: Indicates background start redis, Start with configuration file redis, Load the... In the container conf file .
appendonly yes: Turn on redis  Persistence .

7. Release port ( Ignore the firewall )

Parameter description : The scope is public, to open up tcp Agreed 6379 port , Always working :

firewall-cmd --zone=public --add-port=6379/tcp --permanent

8. Update firewall rules

firewall-cmd --reload

9. Check redis Running state

docker ps

 Insert picture description here

10. Test connection

 Insert picture description here

原网站

版权声明
本文为[Tag heartbeat]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090215005758.html