In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to build Redis services, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
The official redis image is used to build the database service. The current latest version corresponds to version 5.0.8. Mount the local data directory, configuration directory and log directory to facilitate data backup and migration.
1 create mount directories and files
Create the configuration directory ~ / docker/redis/conf, data directory ~ / docker/redis/data and log directory ~ / docker/redis/log in the host, and create the file ~ / docker/redis/conf/redis.conf in the configuration directory. The configuration file is as follows.
Logfile / log/redis.log
The final directory structure is shown below:
2 pull redis image
Use the latest official version of redis image, which is currently version 5.0.8.
Docker pull redis3 creates the container and starts
Mount the local configuration, data, and log directories into the container.
#-name redis container name is redis#-p 6379redis 6379 bind native port 6379 to container port 6379 (redis service port) #-v ~ / docker/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf mount local configuration file #-v ~ / docker/redis/log/:/log/ mount local log directory #-v ~ / mount data text #-d background runs # redis-server / usr/local/etc/redis/redis.conf-- appendonly yes uses a custom configuration file And enable disk data persistence docker run-- name redis- p 6379vis6379-v / docker/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf-v / docker/redis/log/:/log/-v / docker/redis/data:/data-d redis redis-server / usr/local/etc/redis/redis.conf-- appendonly yes
After the container is started, you can check the operation of redis through the local ~ / docker/redis/log/redis.log.
4 Redis usage
Use the local redis-cli client to connect to redis and add the key value vSecret1. After performing several operations, the appendonly.aof file in the ~ / docker/redis/data directory already has the relevant data content.
5 simulate the effect of data migration
If you stop the redis container at this point and start a new redis container to mount the same directory, the redis in the new container already contains the data from the previous container.
Docker run-- name redis1-p 6379 docker/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf-v / docker/redis/log/:/log/-v / docker/redis/data:/data-d redis redis-server / usr/local/etc/redis/redis.conf-- appendonly yes
For more custom configuration, you can add it in the local ~ / docker/redis/conf/redis.conf file
After reading the above, do you know how to build Redis services? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.