Linux

[Linux][Redis][doc] Redis Administration

Binceline 2013. 9. 30. 18:29

This page contains topics related to the administration of Redis instances. Every topic is self contained in form of a FAQ. New topics will be created in the future.

이 페이지는 Redis instance를 관리하는 것과 관련된 주제들을 포함한다. 모든 주제는 FAQ 형식으로 포함된다. 새로운 주제는 나중에 추가될 것이다.

Redis setup hints 

Redis 설정 힌트
  • We suggest deploying Redis using the Linux operating system. Redis is also tested heavily on osx, and tested from time to time on FreeBSD and OpenBSD systems. However Linux is where we do all the major stress testing, and where most production deployments are working.

Redis를 Linux operating system을 사용해서 배포하길 권장한다. Redis는 osx에서 확실하게 테스트해 봤고, 가끔 FreeBSD와 OpenBSD 시스템에서도 테스트해 봤다. 그러나 Linux는 모든 부하 테스트를 했고, 가장 좋은 상태로 제품을 배포했던 OS이다.

  • Make sure to set the Linux kernel overcommit memory setting to 1. 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 immediately.

Linux kernel의 overcommit memory를 1로 설정해라. /etc/sysctl.conf에 vm.overcommit_memory = 1을 추가해라. 그 후 재부팅을 하거나 systl vm.overcommit_memory=1 명령을 실행하는 것으로 즉시 적용시킬 수 있다.

  • Make sure to setup some swap in your system (we suggest as much as swap as memory). If Linux does not have swap and your Redis instance accidentally consumes too much memory, either Redis will crash for out of memory or the Linux kernel OOM killer will kill the Redis process.

시스템의 swap을 설정해라(메모리 만큼 swap을 설정하길 권장한다). 만약 Linux가 swap을 가지지 않고 Redis instance가 너무 많은 메모리를 사용한다면, Redis가 out of memory로 셧다운되거나 Linux kernel OutOfMemory 킬러가 Redis 프로세스를 종료시킬 것이다.

  • If you are using Redis in a very write-heavy application, while saving an RDB file on disk or rewriting the AOF log Redis may use up to 2 times the memory normally used. The additional memory used is proportional to the number of memory pages modified by writes during the saving process, so it is often proportional to the number of keys (or aggregate types items) touched during this time. Make sure to size your memory accordingly.

만약 매우 많은 write를 하는 어플리케이션에서 Redis를 사용한다면, RDB 파일을 디스크에 저장하거나 AOF log를 rewriting하는 동안 Redis는 2배의 메모리가 사용될 것이다. 추가로 사용된 메모리는 프로세스를 저장하는 동안 수행되는 write작업에 의해 덮어쓰기된 메모리 페이지들의 수에 비례하고, 그래서 이것은 이 시간 동안 자주 사용된 key의 수(또는 aggregate 타입의 key들)에 비례한다. 메모리에 따라 size를 설정해라.

  • Even if you have persistence disabled, Redis will need to perform RDB saves if you use replication.

persistence disable되었을 때 조차도, 복제를 사용하는 경우 Redis는 RDB를 저장할 필요가 있다.

  • The use of Redis persistence with EC2 EBS volumes is discouraged since EBS performance is usually poor. Use ephemeral storage to persist and then move your persistence files to EBS when possible.

EC2 EBS volume으로 Redis persistence를 사용하는 것은 권장하지 않는다. EBS 성능이 그닥 좋지 않아서...

persist하기 위해 잠깐 사용하는 저장소를 사용해라. 그 후 가능할 때 persistence 파일들을 EBS로 이동시켜라.

  • If you are deploying using a virtual machine that uses the Xen hypervisor you may experience slow fork() times. This may block Redis from a few milliseconds up to a few seconds depending on the dataset size. Check the latency page for more information. This problem is not common to other hypervisors.

만약 Xen hypervisor를 사용하는 virtual machine을 사용한 것을 배포한다면,  아마 fork() 시간이 느리다는 것을 알 수 있을 것이다. 이것은 Data set의 크기에 따라 최소 몇 밀리초에서 몇 초까지 Redis를 block한다. 자세한 내용은 대기 페이지를 확인해라. 이 문제는 다른 hypervisor들에서는 상관없는 문제이다.

  • Use daemonize no when run under daemontools.

daemontools가 실행될 때 daemonize를 사용해라.

Upgrading or restarting a Redis instance without downtime

Redis instance를 종료하지 않고 실행 중에 업그레이드 또는 재시작하는 것.

Redis is designed to be a very long running process in your server. For instance many configuration options can be modified without any kind of restart using the CONFIG SET command.

Redis는 프로세스가 서버에서 매우 오랫동안 살아있을 수 있도록 설계되어 있다. 예를 들면 CONFIG SET 명령을 사용하는 것으로 재샐행할 필요 없이 여러 configuration 옵션들을 덮어쓸 수 있다.


Starting from Redis 2.2 it is even possible to switch from AOF to RDB snapshots persistence or the other way around without restarting Redis. Check the output of the 'CONFIG GET *' command for more information.

Redis 2.2부터 시작하는 것 조차도 AOF에서 RDB snapshot persistence로 변경하는 것이 가능하고, 또 다른 방법은 Redis를 재실행할 필요가 없다. 더 많은 정보는 CONFIG GET 명령의 output을 확인해라.


However from time to time a restart is mandatory, for instance in order to upgrade the Redis process to a newer version, or when you need to modify some configuration parameter that is currently not supported by the CONFIG command.

The following steps provide a very commonly used way in order to avoid any downtime.

그러나 가끔 의무적으로 재실행을 해야 한다. 예를 들어 Redis 프로세스를 새로운 버젼으로 업그레이드하기 위해, 또는 어떤 현재 지원되지 않는 CONFIG 명렬의 configuration 인수를 덮어써야 할 때(재실행을 해라).

다음은 매우 일반적으로 셧다운을 피하기 위해 사용되는 방법을 제공한다.

  • Setup your new Redis instance as a slave for your current Redis instance. In order to do so you need a different server, or a server that has enough RAM to keep two instances of Redis running at the same time.

현재 Redis instance(master)에서 새로운 Redis instance를 slave로 설정해라. 그러기 위해 다른 서버, 또는 2 개의 Redis instance가 동시에 실행되도록 RAM 메모리가 충분한 서버가 필요하다.

  • If you use a single server, make sure that the slave is started in a different port than the master instance, otherwise the slave will not be able to start at all.

만약 하나의 서버를 사용한다면, master instance가 아닌 다른 포트에서 slave가 시작되는지 확인해라.

그렇지 않으면 그 slave는 절대 시작할 수 없다.

  • Wait for the replication initial synchronization to complete (check the slave log file).

초기 동기화로 인한 복제가 완료될 때까지 기다려라(slave log 파일을 체크해라).

  • Make sure using INFO that there are the same number of keys in the master and in the slave. Check with redis-cli that the slave is working as you wish and is replying to your commands.

master와 slave의 key들의 숫자가 같은지 INFO를 사용해 확인해라. slave가 너가 원하는 대로 동작하는지, 명령에 reply를 하는지 redis-cli를 확인해라.

  • Configure all your clients in order to use the new instance (that is, the slave).

새로운 instance를 사용하기 위해 모든 클라이언트들을 configure한다(slave들).

  • Once you are sure that the master is no longer receiving any query (you can check this with the MONITOR command), elect the slave to master using the SLAVEOF NO ONE command, and shut down your master.

master가 오랫동안 어떤 명령을 받지 못했는지 확인해라(MONITOR 명령으로 확인할 수 있다). 그리고 SLAVEOF NO ONE 명령을 사용하여 slave를 master로 뽑아내라. 그리고 master를 셧다운시켜라.

반응형

'Linux' 카테고리의 다른 글

[Llinux] Cron에 대해 알아보자  (0) 2016.09.29
[스크랩][Linux] dd 명령어 옵션 설명  (0) 2014.08.16
[Redis][Doc] Redis Clients Handling  (0) 2013.10.07
[Linux][Redis][doc] Redis Configuration  (0) 2013.09.30