Redis does not shut down the service properly

Source: Internet
Author: User
Tags redis version

Tag: Redis user hot Forget RMI cat net possibility exit

Pre-Knowledge: The simplest basic command for Redis:

1. System Terminal

./redis-server Start Redis Service

./REDIS-CLI starting the Redis client

./redis-cli shutdown turn off Redis service

2. After using the./redis-cli to enter the Redis command terminal,

Shutdown turn off Redis service

Save Storage to disk

Set [key] [value] assigns a value to key [key] [value]

Get [key] gets the value corresponding to key [key]

Problem Description:

After the Redis installation is complete, use the./redis-server to start, run./redis-cli into Redis terminal, the operation of key value can be completed normally, but shutdown and save will error, the specific in the terminal or log reflected as:

1. Shutdown request failed:

1550:m 18:22:48.778 # User requested shutdown ...
1550:m 18:22:48.779 * Saving the final RDB snapshot before exiting.
1550:m 18:22:48.781 # Failed opening the RDB file Dump.rdb (in server root dir/usr/share/redis/redis-3.2.6/src) fo R Saving:permission denied
1550:m 18:22:48.782 # Error trying to save the DB, can ' t exit.

2. Save failed

1550:m 18:42:05.298 # Failed opening the RDB file Dump.rdb (in server root dir/usr/share/redis/redis-3.2.6/src) fo R Saving:permission denied

Shutdown and save failed for the same reason, the operation of the Rdb file Dump.rdb problem (although the log shows permission denied, but not necessarily a permissions issue, may be the directory or file cannot be generated, etc.)

Workaround:

The following two points are taken into account (I'm sorry, because both parts are fixed at the same time, so it's not possible to determine which is causing the problem)

1. After the service starts, the log information is displayed as follows warning:

1550:m 18:16:12.147 # warning:the TCP Backlog setting of 511 cannot be enforced because/proc/sys/net/core/soma Xconn is set to the lower value of 128.
1550:m 18:16:12.148 # Server started, Redis version 3.2.6
1550:m Jan 18:16:12.148 # WARNING Overcommit_me Mory 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.overcom Mit_memory=1 ' for the take effect.
1550:m 18:16:12.148 # WARNING You has Transparent Huge Pages (THP) support for enabled in your kernel. This would create latency and memory usage issues with Redis. To fix this issue run the command ' echo never >/sys/kernel/mm/transparent_hugepage/enabled ' as root, and add it to you R/etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.

Presumably due to the extremely low upper limit on some storage (which looks like the default 0), the creation of a file failed, as I understand it: the permission to create a file of size x is not causing permission denied

2. According to the error log shows that the Rdb file is established under/USR/SHARE/REDIS/REDIS-3.2.6/SRC (that is, the Redis installation directory), but the actual view of this directory and wood has an rdb file, even if Redis is under the root user of the system to start the service, Shutdown and save will still have the above error. So there's no way to feel like there's no file permission here, but finally, the change configuration file updates the default build directory for the Rdb file.

Operation:

1. Resolve Warning

A. Terminal root user execution: Sysctl vm.overcommit_memory=1

B. Terminal root user execution: Echo never >/sys/kernel/mm/transparent_hugepage/enabled

C. Terminal root User execution: Vim/etc/rc.local, after opening the file, add echo never >/sys/kernel/mm/transparent_hugepage/enabled before statement exit 0

2. Change the Rdb file default path

Modify the Conf file, which is recommended here, to copy a new conf file, such as test.conf, when the test.conf is modified, and then when you start Redis, use the script./redis-server test.conf start the service.

How to modify: Find the redis.conf file in the original Redis directory (you can also find its location in the terminal with the command locate redis.conf).

When opened, navigate to the following location:

# The working directory.
#
# The DB would be is written inside this directory, with the filename specified
# above using the ' dbfilename ' configuration directive.
#
# The Append only File would also is created inside this directory.
#
# Note that you must specify a directory here, not a file name.

Dir./

Modify the "dir./" to the corresponding directory, such as "Dir/home/distance/redis_dbfiles/" (Here you need to be aware that the last slash cannot be forgotten, if the slash is missing may be parsed as files rather than directories), save.

After the above operation is complete, save and shutdown can be normal.

Redis does not shut down the service properly

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.