Stopping redis if auth is turned on

1,007 views
Skip to first unread message

dukha

unread,
Aug 9, 2011, 8:25:38 PM8/9/11
to Redis DB
Hi
I've just started with redis. Have it installed according to the
"proper" directions in quickstart. It runs and works. I set a auth
password. Works also. However the auth thing works a little too well.
I can't shut the server down without going to redis-cli, giving a
password and then shutting down. How can I allow root to shut the
server down without a password? Or how to make redis respond to a kill
in general?

Thanks for the help

dukha

Josiah Carlson

unread,
Aug 10, 2011, 4:23:21 PM8/10/11
to redi...@googlegroups.com
Redis should respond to a kill with a save then shutdown (at least
every version I've used does). Which version of Redis are you using?

Regards,
- Josiah

> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
>
>

Mark Lennon

unread,
Aug 11, 2011, 12:11:57 AM8/11/11
to redi...@googlegroups.com
Hi Josiah
Thanks for the reply. I'm on 2.2.6.

If I try shutting down the system (not as root) then it just hangs with a message saying waiting for redis to shutdown(every second or so). The only thng that I can do is hold down the start button on the box.

kind regards

dukha

Josiah Carlson

unread,
Aug 11, 2011, 12:21:58 AM8/11/11
to redi...@googlegroups.com
It sounds like Redis is being shut down and is trying to sync to disk.
How long does it normally take for Redis to save everything to disk
for you?

You can always do 'sudo kill -9 <redis pid>', and that will definitely
stop Redis, but it won't leave you with the most recent dump.

Regards,
- Josiah

Mark Lennon

unread,
Aug 11, 2011, 12:27:05 AM8/11/11
to redi...@googlegroups.com
Hi Josiah
I've never waited it out: certainly minutes. I'll give it more time when I get back to my development server (I'm away now.)

If I turn off save and use aof will it be happier?

Most recent dump should not be a problem. It's going to be 99% read server. ( for translations)

Kind regards

Mark

Josiah Carlson

unread,
Aug 11, 2011, 12:53:14 AM8/11/11
to redi...@googlegroups.com
On Wed, Aug 10, 2011 at 9:27 PM, Mark Lennon <mple...@gmail.com> wrote:
> Hi Josiah
> I've never waited it out: certainly minutes. I'll give it more time when I
> get back to my development server (I'm away now.)
>
> If I turn off save and use aof will it be happier?
>
> Most recent dump should not be a problem. It's going to be 99% read server.
> ( for translations)

If it's mostly reads, then you shouldn't have much of a problem with
the AOF (just enable rewriting on occasion to handle the growth of the
AOF over time).

I'm curious, how much translation data do you have for it to take
minutes to sync to disk? I've got about 25 gigs of misc data in one of
my instances, and it flushes to disk in 60-90 seconds.

- Josiah

Nicholas Knight

unread,
Aug 11, 2011, 6:35:27 AM8/11/11
to redi...@googlegroups.com
On Aug 10, 2011, at 9:11 PM, Mark Lennon wrote:

> Hi Josiah
> Thanks for the reply. I'm on 2.2.6.
>
> If I try shutting down the system (not as root) then it just hangs with a message saying waiting for redis to shutdown(every second or so). The only thng that I can do is hold down the start button on the box.
>


Wait, so are you using redis-cli or kill? It sounds like you're using the included init script (or a variation of it), which uses redis-cli. kill is a separate command, and you'll have to change the script to use it.

-NK

Pieter Noordhuis

unread,
Aug 11, 2011, 8:48:27 AM8/11/11
to redi...@googlegroups.com
That's right. Redis saves a dump and exits after receiving the TERM signal.

Cheers,
Pieter

Mark Lennon

unread,
Aug 11, 2011, 9:11:10 PM8/11/11
to redi...@googlegroups.com
Thanks Pieter, Nick, Joshua,
Being just a developer, I'm not always clear about installing system things on my box.

I have just a litle dev data in redis now (more or less experimenting in preparation for the development). I'll turn off the snapshot, but that doesn't seem to be the problem.

I installed redis as root and now want to be able to exit the machine as me. This works fine for things like postgres. May be I need to do what postgres does and use redis with a dedicated redis user to start it. Then shutdown issued by me can stop it without a problem???

I'm still away from my machine and so can't try anything  for the coming days.

Regards

Mark

Nicholas Knight

unread,
Aug 12, 2011, 3:59:27 AM8/12/11
to redi...@googlegroups.com
On Aug 11, 2011, at 6:11 PM, Mark Lennon wrote:

> Thanks Pieter, Nick, Joshua,
> Being just a developer, I'm not always clear about installing system things on my box.
>
> I have just a litle dev data in redis now (more or less experimenting in preparation for the development). I'll turn off the snapshot, but that doesn't seem to be the problem.
>
> I installed redis as root and now want to be able to exit the machine as me. This works fine for things like postgres. May be I need to do what postgres does and use redis with a dedicated redis user to start it. Then shutdown issued by me can stop it without a problem???


When you issue a shutdown command, you're starting a root-level process (magic that may vary in details between systems, but you can consider it a setuid binary, which it often is). The init scripts are run as root, no matter what user you issued "shutdown" as.

What you are experiencing is not a system permissions issue, but a problem with the way the init script is trying to shut down Redis.

Step by step:

* Your init script (probably in /etc/init.d/redis or something similar) probably does something like this on shutdown (from the default init script):

echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"

($CLIEXEC holding the path to redis-cli)

* This doesn't work if you set a password, because redis-cli can't connect to the server without the password.

* You have two options to make this work:

A) Change

$CLIEXEC -p $REDISPORT shutdown

to something like

$CLIEXEC -p $REDISPORT -a yourpassword shutdown

This gives redis-cli the password and it can now connect and issue the shutdown command.

Downside: Your password is now stored in an init script. This probably isn't a big deal, but it's not ideal, either, especially if you change it later, you have to remember to change it in the init script.

OR

B) Change

$CLIEXEC -p $REDISPORT shutdown

to something like

/bin/kill ${PID}

This bypasses Redis' built-in authentication by sending the process a TERM signal rather than connecting. Redis catches the TERM signal, saves, and shuts down.

Downside: If there's something wrong with your system, there's some chance of killing the wrong process, and thus also some chance of shutdown proceeding without Redis actually having received the TERM signal sent by kill, thus possible data loss.

-NK

Mark Lennon

unread,
Aug 12, 2011, 5:13:55 PM8/12/11
to redi...@googlegroups.com
Hi Nicholas
The -a switch was what I was looking for.  I also appreciate the description of what linux does on shutdown. A little extra info is great.

Many thanks to everyone that helped me with this

dukha


-NK

Marty Weiner

unread,
Sep 1, 2011, 8:52:59 PM9/1/11
to redi...@googlegroups.com
Hi,
We currently have redis sharded to 3 32GB boxes on EC2. We're at 75% of
RAM on these boxes, and now we're seeing occassional CPU spikes. Normal
CPU hovers around 4%, but suddenly it pegs at 100% and stays there for a
bit. Anybody know what's going on?

On a similar question, we're storing 1,000,000 lists of about 1000
numbers each. A rough estimate of 64-bits per value, that would
calculate out to 8GB. Seems like a lot of overhead? Anybody know where
that overhead is coming from?

Jeremy Zawodny

unread,
Sep 1, 2011, 8:57:08 PM9/1/11
to redi...@googlegroups.com
Are you doing periodic save/bgsave operations?

Jeremy

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+unsubscribe@googlegroups.com.

Greg Andrews

unread,
Sep 1, 2011, 9:08:20 PM9/1/11
to redi...@googlegroups.com

I sugest graphing your cpu, memory and disk i/o performance numbers on your Redis machines and see if the cpu spikes coincide with spikes in memory growth and/or disk i/o.

Also see if the spikes coincide with background save-to-file events, or rewrites of an append-only-file, or slave instances attaching themselves to the Redis instance on the server.

  -Greg

On Thu, Sep 1, 2011 at 5:52 PM, Marty Weiner <ma...@pinterest.com> wrote:

Didier Spezia

unread,
Sep 2, 2011, 2:28:19 AM9/2/11
to redi...@googlegroups.com

>>calculate out to 8GB.  Seems like a lot of overhead?  Anybody know where 
>>that overhead is coming from?


Redis list are double-linked lists (3 pointers of 8 bytes). Each value 
is backed by a 16 bytes structure containing meta-information 
(like reference counters for instance). And then you have the overhead
of the memory allocator itself (glibc malloc mininum granularity is
32 bytes for  instance).

32 (linked list) + 32 + (robj) + 32 (value) = 96 bytes per items.
You have 1 billion of them => 96 GB.

You may see interesting benefits if you use jemalloc or tcmalloc
with this kind of data.

Regards,
Didier.

Didier Spezia

unread,
Sep 2, 2011, 2:34:36 AM9/2/11
to redi...@googlegroups.com

The previous calculation assumes that most of your lists are not zipped.

You may also want to experiment with the ziplist configuration parameters.
If you increase the maximum number of items in a zipped list, it may result
in dramatic savings.

Regards,
Didier.

sebl...@gmail.com

unread,
Sep 2, 2011, 3:41:08 PM9/2/11
to redi...@googlegroups.com
Nevermind, your sister just showed up. Thanks




-- Sent from my Palm Pre


--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To view this discussion on the web visit https://groups.google.com/d/msg/redis-db/-/_10nwlhJZ94J.

To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages