In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This paper realizes the function.
Resolve startup and failure when redis container starts redis.confession
A brief understanding of some configurations of redis.conf
Recognize the parameters of the docker run command
Understand the configuration file of redis.conf
When you open redis.conf, you will see a lot of useless information.
We use the grep command to simply deal with the next step, and then we can see all the configuration information of redis.conf, but the command you enter now cannot be edited.
Execute command: cat redis.conf | grep-v "#" | grep-v "^ $"
Although the above one has got all the configuration information of redis.conf out, it cannot be modified. We can output this content to another file. At this time, we can see a redis-test.conf file under redis.
Execute the command: cat redis.conf | grep-v "#" | grep-v "^ $"-> redis-test.conf
At this time, you can modify some configuration information in redis-test.conf.
Here we first learn about a few configurations, and the later configurations will be written out in order in subsequent files.
Daemonize no: redis is not used as a daemon by default, which means why starting redis with redis-server / redis/redis.conf directly when you do not modify the configuration file will directly display a service. You have no way to operate anything else on this terminal, but can only open a new terminal to connect to redis.
Requirepass foobared: redis does not have a password connection by default, but the password still needs to be set for security.
Bind 127.0.0.1: this configuration item is generally commented out directly. When this configuration is enabled, only the local machine can connect to redis.
The above configuration information is the three configuration information that this article needs to know.
Learn about docker run command parameter information
The docker run command is to create a new container
The following is a command I used to create the container `docker run-itd-- restart= "always"-- name redis- v / usr/local/docker/data:/data-v / usr/local/docker/redis.conf:/etc/redis.conf-- net mynetwork-p 6380pur6379-- ip 172.10.0.2 redis:4.0 redis-server / etc/ redis.conf`
I: open STDIN for console interaction
T: assign tty devices, which can support terminal login. Default is false.
D: specify whether the container runs in the foreground or in the background. Default is false.
V: Mount the storage volume to the container and mount it to a directory of the container
-- net: the container uses its own custom network
-p: is the port number
-- restart: specify the restart policy after the container is stopped no: do not restart when the container exits on-failure: restart when the container fails to exit (the return value is non-zero) always: always restart when the container exits
Resolve startup and failure when redis container starts redis.confession
When we know several parameters of redis.conf and several commonly used parameters of docker run, let's solve the problem of direct failure when starting with redis.conf.
Then start creating the container and some of your partners will find an error `WARNING: IPv4 forwarding is disabled. Networking will not work.`
Let's solve this problem first.
Execute the command `vim / usr/lib/sysctl.d/00- system.conf`
Add the following code `net.ipv4.ip_forward= 1`
Restart the network command `systemctl restart network`
If you come and execute it, there will be no problem.
Then you will find our problem when you enter the container. After creating the container, you will exit directly.
Is it very depressed at this time? why did you just quit? This is why we presented some configuration information for the redis.conf and docker run command parameters in the previous section.
At this time, we will review whether there is a parameter `daemonize no` in redis.conf whether it is executed as a daemon. During the development process, we will enable this configuration and configure it as yes.
Then recall that there is a parameter `- d` in the docker run command, which is also executed as a daemon.
Now it should be clear that redis.conf conflicts with docker configuration.
Open the configuration file and change the daemon to no
Then delete the redis container you just created, execute the above command here, and you can see that the container has now been created successfully and is open
At this time, when you enter the container `docker exec-it redis / bin/ bash`, you can see that we need to enter a password when connecting to redis-cli, which is configured in redis.conf.
These are the details of how to solve the failure of Redis container startup using redis.conf. Please pay attention to other related articles for more information.
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.