Redis in docker starts/restarts multiple times? - redis

I am trying to run redis in docker container by using docker-compose:
docker-compose.yml:
redis:
image: redis:3.0.4
command:
$ docker-compose up
output:
Starting test_redis_1...
Attaching to test_redis_1
redis_1 | 1:C 06 Oct 15:16:13.265 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1 | _._
redis_1 | _.-``__ ''-._
redis_1 | _.-`` `. `_. ''-._ Redis 3.0.4 (00000000/0) 64 bit
redis_1 | .-`` .-```. ```\/ _.,_ ''-._
redis_1 | ( ' , .-` | `, ) Running in standalone mode
redis_1 | |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
redis_1 | | `-._ `._ / _.-' | PID: 1
redis_1 | `-._ `-._ `-./ _.-' _.-'
redis_1 | |`-._`-._ `-.__.-' _.-'_.-'|
redis_1 | | `-._`-._ _.-'_.-' | http://redis.io
redis_1 | `-._ `-._`-.__.-'_.-' _.-'
redis_1 | |`-._`-._ `-.__.-' _.-'_.-'|
redis_1 | | `-._`-._ _.-'_.-' |
redis_1 | `-._ `-._`-.__.-'_.-' _.-'
redis_1 | `-._ `-.__.-' _.-'
redis_1 | `-._ _.-'
redis_1 | `-.__.-'
redis_1 |
redis_1 | 1:M 06 Oct 15:16:13.268 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1 | 1:M 06 Oct 15:16:13.268 # Server started, Redis version 3.0.4
redis_1 | 1:M 06 Oct 15:16:13.268 # 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.
redis_1 | 1:M 06 Oct 15:16:13.268 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will 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 your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1 | 1:M 06 Oct 15:16:13.268 * DB loaded from disk: 0.000 seconds
redis_1 | 1:M 06 Oct 15:16:13.268 * The server is now ready to accept connections on port 6379
redis_1 | 1:signal-handler (1444144583) Received SIGTERM scheduling shutdown...
redis_1 | 1:M 06 Oct 15:16:23.761 # User requested shutdown...
redis_1 | 1:M 06 Oct 15:16:23.761 * Saving the final RDB snapshot before exiting.
redis_1 | 1:M 06 Oct 15:16:23.770 * DB saved on disk
redis_1 | 1:M 06 Oct 15:16:23.770 # Redis is now ready to exit, bye bye...
redis_1 | 1:C 06 Oct 15:16:32.194 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1 | _._
redis_1 | _.-``__ ''-._
redis_1 | _.-`` `. `_. ''-._ Redis 3.0.4 (00000000/0) 64 bit
redis_1 | .-`` .-```. ```\/ _.,_ ''-._
redis_1 | ( ' , .-` | `, ) Running in standalone mode
redis_1 | |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
redis_1 | | `-._ `._ / _.-' | PID: 1
redis_1 | `-._ `-._ `-./ _.-' _.-'
redis_1 | |`-._`-._ `-.__.-' _.-'_.-'|
redis_1 | | `-._`-._ _.-'_.-' | http://redis.io
redis_1 | `-._ `-._`-.__.-'_.-' _.-'
redis_1 | |`-._`-._ `-.__.-' _.-'_.-'|
redis_1 | | `-._`-._ _.-'_.-' |
redis_1 | `-._ `-._`-.__.-'_.-' _.-'
redis_1 | `-._ `-.__.-' _.-'
redis_1 | `-._ _.-'
redis_1 | `-.__.-'
redis_1 |
redis_1 | 1:M 06 Oct 15:16:32.195 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1 | 1:M 06 Oct 15:16:32.195 # Server started, Redis version 3.0.4
redis_1 | 1:M 06 Oct 15:16:32.195 # 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.
redis_1 | 1:M 06 Oct 15:16:32.195 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will 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 your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1 | 1:M 06 Oct 15:16:32.195 * DB loaded from disk: 0.000 seconds
redis_1 | 1:M 06 Oct 15:16:32.195 * The server is now ready to accept connections on port 6379
redis_1 | 1:signal-handler (1444144597) Received SIGTERM scheduling shutdown...
redis_1 | 1:M 06 Oct 15:16:37.141 # User requested shutdown...
redis_1 | 1:M 06 Oct 15:16:37.141 * Saving the final RDB snapshot before exiting.
redis_1 | 1:M 06 Oct 15:16:37.144 * DB saved on disk
redis_1 | 1:M 06 Oct 15:16:37.144 # Redis is now ready to exit, bye bye...
redis_1 | 1:C 06 Oct 15:17:19.085 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1 | _._
redis_1 | _.-``__ ''-._
redis_1 | _.-`` `. `_. ''-._ Redis 3.0.4 (00000000/0) 64 bit
redis_1 | .-`` .-```. ```\/ _.,_ ''-._
redis_1 | ( ' , .-` | `, ) Running in standalone mode
redis_1 | |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
redis_1 | | `-._ `._ / _.-' | PID: 1
redis_1 | `-._ `-._ `-./ _.-' _.-'
redis_1 | |`-._`-._ `-.__.-' _.-'_.-'|
redis_1 | | `-._`-._ _.-'_.-' | http://redis.io
redis_1 | `-._ `-._`-.__.-'_.-' _.-'
redis_1 | |`-._`-._ `-.__.-' _.-'_.-'|
redis_1 | | `-._`-._ _.-'_.-' |
redis_1 | `-._ `-._`-.__.-'_.-' _.-'
redis_1 | `-._ `-.__.-' _.-'
redis_1 | `-._ _.-'
redis_1 | `-.__.-'
redis_1 |
redis_1 | 1:M 06 Oct 15:17:19.086 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1 | 1:M 06 Oct 15:17:19.086 # Server started, Redis version 3.0.4
redis_1 | 1:M 06 Oct 15:17:19.086 # 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.
redis_1 | 1:M 06 Oct 15:17:19.086 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will 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 your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1 | 1:M 06 Oct 15:17:19.086 * DB loaded from disk: 0.000 seconds
redis_1 | 1:M 06 Oct 15:17:19.086 * The server is now ready to accept connections on port 6379
redis_1 | 1:signal-handler (1444144647) Received SIGTERM scheduling shutdown...
redis_1 | 1:M 06 Oct 15:17:27.247 # User requested shutdown...
redis_1 | 1:M 06 Oct 15:17:27.247 * Saving the final RDB snapshot before exiting.
redis_1 | 1:M 06 Oct 15:17:27.256 * DB saved on disk
redis_1 | 1:M 06 Oct 15:17:27.256 # Redis is now ready to exit, bye bye...
For some reason redis starts multiple times, sometimes just once (this is random). And in logs there are many likes like:
redis_1 | 1:signal-handler (1444144597) Received SIGTERM scheduling shutdown...
env:
docker-compose version: 1.4.0
Docker version 1.8.0, build 0d03096
docker-machine version 0.4.0 (9d0dc7a)
edit: It happens only when using docker-compose. While running redis with docker run redis:304 it works fine.

Similar issue has been discussed here: https://github.com/docker/compose/issues/2148
Add --force-recreate to the docker-compose command seems to prevent it.

Related

when I run redis-stack-server,redis-stack config file is not work

I installed redis-stack on Ubuntu20. I changed redis-stack.conf but it not work.I changed daemonize to yes but it not work.
this is log when I run redis-stack-server
root#Server-30c80333-7b1b-40ce-a1e2-217630a6941b:~# redis-stack-server
Starting redis-stack-server, database path /var/lib/redis-stack
3601:C 03 Jun 2022 01:37:09.809 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
3601:C 03 Jun 2022 01:37:09.809 # Redis version=7.0.0, bits=64, commit=00000000, modified=0, pid=3601, just started
3601:C 03 Jun 2022 01:37:09.809 # Configuration loaded
3601:M 03 Jun 2022 01:37:09.810 * monotonic clock: POSIX clock_gettime
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 7.0.0 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 3601
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | https://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
this is config I read from redis-client
127.0.0.1:6379> info server
# Server
redis_version:7.0.0
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:23cf6761424b731f
redis_mode:standalone
os:Linux 5.4.0-100-generic x86_64
arch_bits:64
monotonic_clock:POSIX clock_gettime
multiplexing_api:epoll
atomicvar_api:c11-builtin
gcc_version:9.4.0
process_id:3601
process_supervised:no
run_id:4c157cf9e719b8afeb43fdbcbd11873448e650ac
tcp_port:6379
server_time_usec:1654191533516795
uptime_in_seconds:104
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:10024365
executable:/opt/redis-stack/bin/redis-server
config_file:/opt/redis-stack/etc/redis-stack.conf
io_threads_active:0
127.0.0.1:6379> config get daemonize
1) "daemonize"
2) "no"
127.0.0.1:6379> exit
I find redis-stack.conf in config_file path, but I can not find redis-config file in anywhere.
I want to change the daemonize to yes but I can't find redis-config file.
You should have a config file present in /opt/redis-stack/etc/.

StackExchange.Redis.RedisConnectionException

I'm trying to use Redis as a cache for blacklisting JWTs, to implement logout with JWT.
I have downloaded redis on my windows 10 machine and run "redis-server.exe" and it says :
[6112] 28 Nov 16:28:51.791 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.504 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 6112
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[6112] 28 Nov 16:28:51.798 # Server started, Redis version 3.0.504
[6112] 28 Nov 16:28:51.799 * DB loaded from disk: 0.001 seconds
[6112] 28 Nov 16:28:51.800 * The server is now ready to accept connections on port 6379
Redis 3.0.504 (00000000/0) 64 bit
Running in standalone mode
The server is now ready to accept connections on port 6379
which indicates that it is working correctly.
I'm using .NetCore 3.1 , and I have Microsoft.Extensions.Caching.Redis v2.2.0 Nuget package installed.
in my startup.cs I added
services.AddDistributedRedisCache(r =>
{
r.Configuration = Configuration["Redis:ConnectionString"];
});
and in my appsettings.json I have
"Redis": {
"ConnectionString": "localhsot"
}
but at any request I'm sending I'm getting the following exception :
StackExchange.Redis.RedisConnectionException: It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING
at StackExchange.Redis.ConnectionMultiplexer.ConnectAsync(String configuration, TextWriter log) in c:\code\StackExchange.Redis\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 801
at Microsoft.Extensions.Caching.Redis.RedisCache.ConnectAsync(CancellationToken token)
at Microsoft.Extensions.Caching.Redis.RedisCache.GetAndRefreshAsync(String key, Boolean getData, CancellationToken token)
at Microsoft.Extensions.Caching.Redis.RedisCache.GetAsync(String key, CancellationToken token)
at Microsoft.Extensions.Caching.Distributed.DistributedCacheExtensions.GetStringAsync(IDistributedCache cache, String key, CancellationToken token)
what I'm I doing wrong? why am I getting this exception??
btw I was following this tutorial on cancelling JWTs
I can't believe I'm saying this, but it turned out that the problem that caused this exception that drove me crazy was in the connection string.
instead of "localhost", I typed "localhsot". once I fixed it, everything worked as expected.

nova-compute service state is down

I have an all-in-one-setup with my controller and compute services running on the same node.all my nova and other dependent services are up and running. However, when i try to launch an instance the state of the nova-compute process becomes down. Because of this the instance is stuck in spawning state.
> [root#localhost nova(keystone_admin)]# nova service-list
> +----+------------------+-----------------------+----------+---------+-------+----------------------------+-----------------+ | Id | Binary | Host | Zone | Status |
> State | Updated_at | Disabled Reason |
> +----+------------------+-----------------------+----------+---------+-------+----------------------------+-----------------+ | 6 | nova-cert | localhost.localdomain | internal | enabled |
> up | 2016-11-04T07:24:32.000000 | - | | 7 |
> nova-consoleauth | localhost.localdomain | internal | enabled | up
> | 2016-11-04T07:24:32.000000 | - | | 8 | nova-scheduler
> | localhost.localdomain | internal | enabled | up |
> 2016-11-04T07:24:33.000000 | - | | 9 | nova-conductor
> | localhost.localdomain | internal | enabled | up |
> 2016-11-04T07:24:33.000000 | - | | 11 | nova-compute
> | localhost.localdomain | nova | enabled | **down** |
> 2016-11-04T06:43:03.000000 | - | | 12 | nova-console
> | localhost.localdomain | internal | enabled | up |
> 2016-11-04T07:24:32.000000 | - |
====
[root#localhost nova(keystone_admin)]# systemctl status
openstack-nova-compute.service -l ● openstack-nova-compute.service -
OpenStack Nova Compute Server Loaded: loaded
(/usr/lib/systemd/system/openstack-nova-compute.service; enabled;
vendor preset: disabled) Active: active (running) since Fri
2016-11-04 12:08:54 IST; 49min ago Main PID: 37586 (nova-compute)
CGroup: /system.slice/openstack-nova-compute.service
└─37586 /usr/bin/python2 /usr/bin/nova-compute
Nov 04 12:08:46 localhost.localdomain systemd[1]: Starting OpenStack
Nova Compute Server... Nov 04 12:08:53 localhost.localdomain
nova-compute[37586]: Option "verbose" from group "DEFAULT" is
deprecated for removal. Its value may be silently ignored in the
future. Nov 04 12:08:53 localhost.localdomain nova-compute[37586]:
Option "notification_driver" from group "DEFAULT" is deprecated. Use
option "driver" from group "oslo_messaging_notifications". Nov 04
12:08:54 localhost.localdomain systemd[1]: Started OpenStack Nova
Compute Server.
========
The status for the nova compute process is perfectly fine.
My rabbitmq service is also running
FYI,
[root#localhost nova(keystone_admin)]# systemctl status
rabbitmq-server ● rabbitmq-server.service - RabbitMQ broker Loaded:
loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled;
vendor preset: disabled) Drop-In:
/etc/systemd/system/rabbitmq-server.service.d
└─limits.conf
Active: active (running) since Thu 2016-11-03 12:32:08 IST; 24h ago
Main PID: 1835 (beam.smp) CGroup:
/system.slice/rabbitmq-server.service
├─1835 /usr/lib64/erlang/erts-5.10.4/bin/beam.smp -W w -K true -A30 -P 1048576 -- -root /usr/lib64/erlang -progname erl -- -home
/var/lib/rabbitmq --...
├─1964 /usr/lib64/erlang/erts-5.10.4/bin/epmd -daemon
├─5873 inet_gethost 4
└─5875 inet_gethost 4
Nov 04 12:13:12 localhost.localdomain rabbitmq-server[1835]:
{user,<<"guest">>, Nov 04 12:13:12 localhost.localdomain
rabbitmq-server[1835]: [administrator], Nov 04 12:13:12
localhost.localdomain rabbitmq-server[1835]:
rabbit_auth_backend_internal,...}, Nov 04 12:13:12
localhost.localdomain rabbitmq-server[1835]: <<"/">>, Nov 04 12:13:12
localhost.localdomain rabbitmq-server[1835]: [{<<...>>,...},{...}],
Nov 04 12:13:12 localhost.localdomain rabbitmq-server[1835]:
<0.14812.0>,<0.14816.0>]}}, Nov 04 12:13:12 localhost.localdomain
rabbitmq-server[1835]: {restart_type,intrinsic}, Nov 04 12:13:12
localhost.localdomain rabbitmq-server[1835]: {shutdown,4294967295},
Nov 04 12:13:12 localhost.localdomain rabbitmq-server[1835]:
{child_type,worker}]}]}} Nov 04 12:13:12 localhost.localdomain
rabbitmq-server[1835]: function_clause
=======
[root#localhost nova(keystone_admin)]# netstat -anp | grep 5672 | grep
37586 tcp 0 0 10.1.10.22:55628 10.1.10.22:5672
ESTABLISHED 37586/python2 tcp 0 0 10.1.10.22:56204
10.1.10.22:5672 ESTABLISHED 37586/python2 tcp 0 0 10.1.10.22:56959 10.1.10.22:5672 ESTABLISHED 37586/python2
===== 37586 is the nova-compute process id.
I have checked the logs for nova-compute, nova-api and nova-conductor and there are no errors.
I have checked the nova scheduler logs and there are some errors stating refused to connect to rabbitmq and the database service.
**
2016-11-03 12:24:50.930 2092 ERROR nova.servicegroup.drivers.db
DBConnectionError: (pymysql.err.OperationalError) (2003, "Can't
connect to MySQL server on '10.1.10 .22' ([Errno 111] ECONNREFUSED)")
2016-11-03 12:24:53.811 2092 ERROR oslo.messaging._drivers.impl_rabbit
[-] AMQP server on 10.1.10.22:5672 is unreachable: [Errno 111]
ECONNREFUSED. Trying again in
**
16 seconds.
=======
Can someone suggest what should i do to handle it.
As i am on the same node, why are these services not reachable?
If nova-compute is down, there are two possible reasons:
a. nova-compute is actually down
b. it cannot communicate with rabbit, or nova-conductor cannot communicate with rabbit.
As far as I can see in your logs, you have issue with rabbit: "10.1.10.22:5672 is unreachable". Check if you have rabbit listening on this IP/port. Check if you can connect to rabbit from compute host. I usually use nc 10.1.10.22 5672 to see if there are connection or not.
Check if nova settings for rabbit are correct. Example of correct settings:
[DEFAULT]
rpc_backend=rabbit
rabbit_host=rabbitmq-ip-here
rabbit_port=5672
rabbit_hosts=$rabbit_host:$rabbit_port
rabbit_use_ssl=false
rabbit_userid=guest
rabbit_password=guest
rabbit_login_method=AMQPLAIN
rabbit_virtual_host=/compute
Check logs in the /var/log/nova/*.log
Enable debug=true in the [DEFAULT] section of nova.conf

Redis on Ubuntu 14.04

I installed redis 2.8.12 from ppa but fails to start. Looking at the log this is what I get:
[4886 | signal handler] (1405388991) Received SIGTERM, scheduling shutdown...
[4886] 14 Jul 20:49:51.561 # User requested shutdown...
[4886] 14 Jul 20:49:51.561 * Saving the final RDB snapshot before exiting.
[4886] 14 Jul 20:49:51.566 * DB saved on disk
[4886] 14 Jul 20:49:51.566 * Removing the pid file.
[4886] 14 Jul 20:49:51.566 # Redis is now ready to exit, bye bye...
[6726] 14 Jul 20:56:04.063 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[6726] 14 Jul 20:56:04.063 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[6726] 14 Jul 20:56:04.063 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.12 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 6726
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[6726] 14 Jul 20:56:04.064 # Server started, Redis version 2.8.12
[6726] 14 Jul 20:56:04.064 # 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.
[6726] 14 Jul 20:56:04.064 * The server is now ready to accept connections on port 6379
I did ran the command sysctl vm.overcommit_memory=1 and rebooted as suggested but did not work. I'm not exactly what to do a this point. Does anybody has an idea?
When you get the overcommit warning, the server is up and running. However, when it will fork another process to save the database (RDB) or compact the AOF, you may get an error if the memory does not account for the copy-on-write overhead.
This is why Redis insists on having the overcommit mode set to 1.
Now, when you use sysctl to change the kernel parameters, they are only changed at runtime. Since the machine has been rebooted, you have just lost this change. If you want the definition to be permanent, it needs also to be added in file /etc/sysctl.conf
Note that on top of the overcommit memory issue, you also have an issue regarding the number of file descriptors. This can be increased by tweaking the /etc/security/limits.conf file (nofile parameter), or in some conditions, the ulimit settings of your session.
Simply do
sudo echo 1 > /proc/sys/vm/overcommit_memory
It will solve you that error. :)
Background saving is failing with a fork() error under Linux even if I've a lot of free RAM!
Short answer: echo 1 > /proc/sys/vm/overcommit_memory :)
And now the long one:
Redis background saving schema relies on the copy-on-write semantic of fork in modern operating systems: Redis forks (creates a child process) that is an exact copy of the parent. The child process dumps the DB on disk and finally exits. In theory the child should use as much memory as the parent being a copy, but actually thanks to the copy-on-write semantic implemented by most modern operating systems the parent and child process will share the common memory pages. A page will be duplicated only when it changes in the child or in the parent. Since in theory all the pages may change while the child process is saving, Linux can't tell in advance how much memory the child will take, so if the overcommit_memory setting is set to zero fork will fail unless there is as much free RAM as required to really duplicate all the parent memory pages, with the result that if you have a Redis dataset of 3 GB and just 2 GB of free memory it will fail.
Setting overcommit_memory to 1 says Linux to relax and perform the fork in a more optimistic allocation fashion, and this is indeed what you want for Redis.
A good source to understand how Linux Virtual Memory work and other alternatives for overcommit_memory and overcommit_ratio is this classic from Red Hat Magazine, "Understanding Virtual Memory". Beware, this article had 1 and 2 configuration values for overcommit_memory reversed: refer to the proc(5) man page for the right meaning of the available values.
Source: http://redis.io/topics/faq

Redis server started, but killed in a second

I created 500 MB rdb file on OS X machine and Redis server works fine there. But on Ubuntu Server it is killed in several seconds after having started:
$ src/redis-server configFile_6381.conf
[1004] 30 Jan 15:50:27.591 * Max number of open files set to 10032
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.6.17 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6381
| `-._ `._ / _.-' | PID: 1004
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[1004] 30 Jan 15:50:27.593 # Server started, Redis version 2.6.17
Killed
Config file (configFile_6381.conf):
daemonize yes
pidfile /var/run/redisVgo.pid
port 6381
timeout 0
tcp-keepalive 0
loglevel verbose
logfile /root/Dropbox/redis/_projects/vgo/vgo.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename vgo6381.rdb
dir ./
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
Sometimes before killing I see message in client output:
(error) LOADING Redis is loading the dataset in memory
Check if you run the same Redis version on both systems.
I used different Redis versions, which caused the trouble. On OS X it was 2.8, on Ubuntu Server it was 2.6. After I set up Redis 2.8 on Ubuntu Server, my .rdb file started there well.
I was running in a similar issue and it seems that my dump.rdb was corrupted. If you do not care about the data currently loaded in your Redis, you can simply remove /var/lib/redis/dump.rdb and restart redis-server.