A previous article Redis installation and master-slave configuration describes the installation configuration of Redis, and another document describes the Docker CentOS installation openssh. Combine two papers today-build a Redis cache database in a Docker CentOS environment.
Redis installation and master-slave configuration performed to "2.2.4 Start Redis Service" can be identified as the REDIS environment is completed. But it's not so easy to build these things in a Docker container. For example, in your container to have make, g++, AutoConfig and other environments, but think about it, these compilation needs of the environment in the real run when there is no o use. So we don't have to build this way today. We use the following methods:
1, on the Docker host, according to the Docker CentOS installation OpenSSH, build Docker centos SSH Environment
2, on the ordinary Linux server, follow the Redis installation and master-slave configuration to "2.2.4 Start Redis Service"
3. Copy the folder/usr/local/webserver/redis from the previous step to the Docker CentOS SSH environment, and do not assign permissions to the executable file.
4. Write Boot script
VI /run. SH #!/bin/bash/usr/local/webserver/redis/start. SH/usr/sbin/sshd-d
OK, it's so easy to finish.
Also want to share a problem I encountered, after creating a Redis container, the process of restarting the container on the host, if the Redis database is doing read and write tasks, the restarted container may not be able to start the Redis service. The specific error is as follows:
[Email protected] redis]#/usr/local/webserver/redis/redis-server/usr/local/webserver/redis/conf/redis.conf _._ _.-``__"'-._ _.-`` `. `_."'-._ Redis2.6. -(00000000/0) -bit.-`` .-```. ```\/ _.,_"'-._ ( ' , .-` | `, ) Running in stand alone mode|`-._`-...-` __...-.``-._|'` _.-'| Port:6379| `-._ `._ / _.-' | Pid:42`-._ `-._ `-./ _.-' _.-'|`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-'| http//Redis.io`-._ `-._`-.__.-'_.-'_.-'|`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-'| `-._ `-._`-.__.-'_.-'_.-'`-._ `-.__.-' _.-' `-._ _.-'`-.__.-' [ the] -Jul -:Geneva:30.511# Server started, Redis version2.6. -[ the] -Jul -:Geneva:30.511# WARNING Overcommit_memory is set to0! Background save may fail under low memory condition. To fix this issue add'vm.overcommit_memory = 1'To/etc/sysctl.conf and ThenReboot or run the command'sysctl Vm.overcommit_memory=1' forThis is take effect. [ the] -Jul -:Geneva:30.511# wrong signature trying to load DB fromfile[ the] -Jul -:Geneva:30.511#Fatal Error loading the Db:invalid argument. Exiting.
The reason for this analysis is that Redis is forced to stop when manipulating data files, resulting in incomplete data files and proper formatting.
Workaround:
Delete the *.rdb file under the/usr/local/webserver/redis/db/folder and restart the Redis container
Docker CentOS Installation Redis and problem handling