In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "docker-compose how to configure and deploy redis service". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
I. Install docker and docker-compose###Install dockercurl -sSL https://get.daocloud.io/docker|sh###Start dockersystemctl start docker###Install docker-composiurl-L https://get.daocloud.io/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose##Apply executable permissions to the binary file chmod +x /usr/local/bin/docker-compose II. Download the redis version, version 6.2.6 selected in this article
Third, extract and copy the redis.conf configuration file to the server. This article is placed in/etc/redis/redis.conf
4. Modify the redis.conf configuration file ###Specify the host address bound by redis, comment out this part, so that redis can be accessed externally. # bind 127.0.0.1-::1###Specify port to access redis server port 6379###Specifies how long (e.g. 300) seconds the client will be idle when connecting to the redis server to close the connection (0 means disabled) timeout 0###Redis does not run as a daemon by default. If necessary, use "yes" daemonize no###Set password for redis, comment if password is not required # requirepass foobared###Enable redis persistence, default is no appendonly yes###Prevent an error where the remote host forces an existing connection to close Default is 300 tcp-keepalive 300###Specifies the log level of redis database. Common log levels include debug, verbose, notice and warning. The default log level is notice if no modification is made. loglevel notice###specifies how many times (s) redis database updates synchronize cached data to the local repository, e.g. save 600 2, which means 2 updates in 10 minutes, synchronize to the local repository save ###Specifies the maximum memory for redis. Because Redis loads data into memory at startup, when the data reaches maximum memory, Redis automatically loads expired and upcoming key values. So you can adjust the maximum memory you need according to your needs maxmemory 500mb###Sets maxmemory options, redis memory usage up to the limit. Some keys can be deleted by setting the LRU algorithm to free up space. The default is based on the expiration time. If the expiration time is not added at the time of set, the maxmemory will be filled with data. maxmemory-policy volatile-lru###Set redis service for external network connection. When enabled, bind ip needs to be configured or access password needs to be set. When disabled, external network can be accessed directly. # protected-mode yes V. Configure docker-compose.ymlmy_redis: image: redis:6.2.6-alpine #Specifies the service image, preferably consistent with the redis configuration file downloaded earlier container_name: my_redis #container name restart: on-failure #restart mode environment: - TZ=Asia/Shanghai #Set Time Zone volumes: #Configure data volumes - /root/redis/data:/data - /etc/redis/redis.conf:/etc/redis/redis.conf ports: #map ports - "6380:6379" sysctls: #Set kernel parameters in container - net.core.somaxconn=1024 # - vm.overcommit_memory=1 command: /bin/sh -c "echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf && redis-server /etc/redis/redis.conf --appendonly yes" #Specify configuration file and turn persistence on privileged: true #With this parameter, root inside the container has true root privileges. Otherwise, root in the container is only an ordinary user right outside. VI. Start the container ###Start the container docker-compose up -d###Enter the container docker exec -it my_redis /bin/sh##Enter the client redis-cli##If a password is set, you need to enter auth password auth your password ##View stored keykeys *##View redis information info VII. Problems encountered after redis starts
Warning: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128
TCP backlog setting 511 cannot be enforced because/proc/sys/net/core/somaxconn is set to a lower value of 128
echo "net.core.somaxconn=551" > /etc/sysctl.confsysctl net.core.somaxconn=551
Warning:overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect
The value of overcommit_memory is set to 0! Background saving may fail in low memory situations. To fix this, add "vm.overcommit_memory = 1" to/etc/sysctl.conf and restart or run the command "sysctl vm.overcommit_memory = 1" for it to take effect
echo 1 > /proc/sys/vm/overcommit_memoryecho "vm.overcommit_memory=1" >> /etc/sysctl.confsysctl vm.overcommit_memory=1
redis error: RDB: 0 MB of memory used by copy-on-write
Since my redis.conf configuration file configures save to synchronize cached data to the local repository, my temporary solution is to cancel save and set save ""
"Docker-compose how to configure and deploy redis service" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
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.