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

Docker installation redis

2022-07-06 18:29:00 A vegetable chicken that is working hard

Docker install Redis

1. download redis Mirror image

 Insert picture description here

2. Create a local directory to facilitate data volume mapping

  • Create a directory structure as follows
     Insert picture description here
  • download redis.conf And modify the configuration
1. Basic configuration 
	#bind 127.0.0.1  # Comment out , send redis Can be accessed externally 
	requirepass a  # to redis Set the password a
	logfile/data/redis.log  # Specify log files 
	protected-mode no  # Turn off protection mode 
2.RDB Basic configuration of data file 
	# Set up RDB File name and file path 
	dbfilename dump.rdb  # Default 
	dir /data #./ Change to /data

	# Set the snapshot interval , The pressure can be adjusted according to the actual request 
	save 3600 1    #3600s There are 1 strip key Change is a snapshot , Low pressure 
	save 300 100   #300s There are 10 strip key Change is a snapshot 
	save 60 10000  #60s There are 10000 strip key Change is a snapshot , High pressure 
	#redis It's a memory library , But memory is afraid of shutdown , So we should persist the data to disk in time 

	rdbcompression yes  # Backup file compression 
	rdbchecksum yes  # Check code 
	stop-writes-on-bgsave-error yes  # Persistence error , Whether the main program stops writing 
3.AOF Basic configuration of log file 
	appendonly yes  #AOF Append mode backup 
	dir /data  # Backup file storage location 
	aof-use-rdb-preamble yes  # Mixed persistence 

3. start-up redis

  • There is an error in the statement in the figure , The correct command is in the following code
     Insert picture description here
docker run -itd --name redis -p 6379:6379 --restart=always -v d:\dockercontainers\redis\redis.conf:/etc/redis/redis.conf -v d:\dockercontainers\redis\data:/data redis redis-server /etc/redis/redis.conf

4. Into the container

docker exec -it redis /bin/bash

5. download redis Software , Test connection

 Insert picture description here
 Insert picture description here

原网站

版权声明
本文为[A vegetable chicken that is working hard]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207061030572739.html