Contents
Redisとは
Redisとはmemcachedと同様の、in memoryタイプのKVSデータベースである。
- 公式ページ
http://redis.io/
AOF(Append Only File)
AOF(Append Only File)とは永続化方法の一種であり、クエリーをログファイルに書き込む方法である。
ファイルへの書き込み頻度がRDBよりもより頻繁にできるため、RDBによる永続化よりもより耐久性のある永続化の方法である。
クエリーをログファイルへ書き込むために、変更のあったものや削除されたものも以前のデータが残ってしまう。
そのため、一定のタイミングでログファイルを再度新しく書き出し、置き換える。これをrewriteという。
環境
- OS
CentOS release 6.4 (64bit)
- Redis Version
2.8.4
サーバの構築
NTP
時刻調整のためにNTPをインストールする。
インストール
yum install ntp
- log
[root@mysql1 ~]# yum install ntp Loaded plugins: fastestmirror base | 3.7 kB 00:00 base/primary_db | 3.5 MB 00:00 extras | 3.4 kB 00:00 extras/primary_db | 18 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 765 kB 00:01 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package ntp.i686 0:4.2.6p5-1.el6.centos will be installed --> Processing Dependency: ntpdate = 4.2.6p5-1.el6.centos for package: ntp-4.2.6p5-1.el6.centos.i686 --> Processing Dependency: libcrypto.so.10(libcrypto.so.10) for package: ntp-4.2.6p5-1.el6.centos.i686 --> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.1) for package: ntp-4.2.6p5-1.el6.centos.i686 --> Running transaction check ---> Package ntpdate.i686 0:4.2.6p5-1.el6.centos will be installed ---> Package openssl.i686 0:1.0.0-27.el6 will be updated ---> Package openssl.i686 0:1.0.1e-16.el6_5.1 will be an update --> Processing Dependency: make for package: openssl-1.0.1e-16.el6_5.1.i686 --> Running transaction check ---> Package make.i686 1:3.81-20.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: ntp i686 4.2.6p5-1.el6.centos base 586 k Installing for dependencies: make i686 1:3.81-20.el6 base 386 k ntpdate i686 4.2.6p5-1.el6.centos base 74 k Updating for dependencies: openssl i686 1.0.1e-16.el6_5.1 updates 1.5 M Transaction Summary ================================================================================ Install 3 Package(s) Upgrade 1 Package(s) Total download size: 2.5 M Is this ok [y/N]: y Downloading Packages: (1/4): make-3.81-20.el6.i686.rpm | 386 kB 00:00 (2/4): ntp-4.2.6p5-1.el6.centos.i686.rpm | 586 kB 00:00 (3/4): ntpdate-4.2.6p5-1.el6.centos.i686.rpm | 74 kB 00:00 (4/4): openssl-1.0.1e-16.el6_5.1.i686.rpm | 1.5 MB 00:04 -------------------------------------------------------------------------------- Total 520 kB/s | 2.5 MB 00:04 warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 Importing GPG key 0xC105B9DE: Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org> Package: centos-release-6-4.el6.centos.10.i686 (@anaconda-CentOS-201303020136.i386/6.4) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 Is this ok [y/N]: y Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : 1:make-3.81-20.el6.i686 1/5 Updating : openssl-1.0.1e-16.el6_5.1.i686 2/5 Installing : ntpdate-4.2.6p5-1.el6.centos.i686 3/5 Installing : ntp-4.2.6p5-1.el6.centos.i686 4/5 Cleanup : openssl-1.0.0-27.el6.i686 5/5 Verifying : openssl-1.0.1e-16.el6_5.1.i686 1/5 Verifying : ntp-4.2.6p5-1.el6.centos.i686 2/5 Verifying : 1:make-3.81-20.el6.i686 3/5 Verifying : ntpdate-4.2.6p5-1.el6.centos.i686 4/5 Verifying : openssl-1.0.0-27.el6.i686 5/5 Installed: ntp.i686 0:4.2.6p5-1.el6.centos Dependency Installed: make.i686 1:3.81-20.el6 ntpdate.i686 0:4.2.6p5-1.el6.centos Dependency Updated: openssl.i686 0:1.0.1e-16.el6_5.1 Complete!
NTPの設定
ここでは仮に公開ntpサーバを利用する設定を以下のように行う。
独立行政法人情報通信研究機構 (NICT)のNTPサーバ:ntp.nict.jp と
インターネットマルチフィードのNTPサーバ:ntp.jst.mfeed.ad.jpの2つを設定する。
vi /etc/ntp.conf
- 変更内容
初期状態の「*.centos.pool.ntp.org」をコメントアウトし、
#server 0.centos.pool.ntp.org #server 1.centos.pool.ntp.org #server 2.centos.pool.ntp.org server ntp.nict.jp minpoll 6 maxpoll 6 server ntp.jst.mfeed.ad.jp minpoll 6 maxpoll 6 tinker panic 0
ここで、「minpoll 6 maxpoll 6」とは同期タイミングの設定で、2^6秒、つまり64秒ごとに同期を行う。
更にデフォルトではNTPサーバとクライアントの時刻差が1000秒以上あると正常に同期できないので、
その差を無視するよう設定する。
常に起動し続ける本番環境であれば、これらは不要である。
ntpサービス起動
ntpサービスは停止しているので、起動させる。
service ntpd start
更にntpdサービスをOS起動時に起動するように設定する。
- 現在の設定
[root@mysql1 ~]# chkconfig --list ntpd ntpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
- Level3で有効化
chkconfig --level 3 ntpd on
- 結果
[root@mysql1 ~]# chkconfig --list ntpd ntpd 0:off 1:off 2:off 3:on 4:off 5:off 6:off
時刻確認
dateコマンドで現在時刻が正しく同期されているかを確認する。
サービス
不要なサービスがあれば終了し、必要なサービスがあれば導入する。
Redisの構築
ソースコードからインストール
関連パッケージ
インストールに必要なパッケージをインストールする
- gcc
コンパイラをインストールする
yum install gcc
- tcl
動作テストにtclを使用するのでインストールする。
yum install tcl
- wget
wgetでソースコードを取得する場合は、wgetもインストールしておく。
yum install wget
- まとめてインストール
yum install gcc tcl wget
Redis本体のインストール
- ソースコードを取得する
- wgetで取得する場合
wget http://download.redis.io/releases/redis-2.8.4.tar.gz
- wgetで取得する場合
- 展開する
tar xvzf redis-*.tar.gz cd redis-*
- コンパイル最適化設定を行う
export CFLAGS="-O3 -m64 -march=native"
※make test時に次のようなエラーが出る場合、”-march=native”は外す
[err]: Cant' start the Redis server
- コンパイルする
make distclean make 2>&1 | tee make.log
ログ
[root@XXX redis-2.8.4]# make distclean cd src && make distclean make[1]: Entering directory `/root/redis-2.8.4/src' rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html (cd ../deps && make distclean) make[2]: Entering directory `/root/redis-2.8.4/deps' (cd hiredis && make clean) > /dev/null || true (cd linenoise && make clean) > /dev/null || true (cd lua && make clean) > /dev/null || true (cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true (rm -f .make-*) make[2]: Leaving directory `/root/redis-2.8.4/deps' (rm -f .make-*) make[1]: Leaving directory `/root/redis-2.8.4/src' [root@XXX redis-2.8.4]# make cd src && make all make[1]: Entering directory `/root/redis-2.8.4/src' rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html (cd ../deps && make distclean) make[2]: Entering directory `/root/redis-2.8.4/deps' (cd hiredis && make clean) > /dev/null || true (cd linenoise && make clean) > /dev/null || true (cd lua && make clean) > /dev/null || true (cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true (rm -f .make-*) make[2]: Leaving directory `/root/redis-2.8.4/deps' (rm -f .make-*) echo STD=-std=c99 -pedantic >> .make-settings echo WARN=-Wall >> .make-settings echo OPT=-O2 >> .make-settings echo MALLOC=jemalloc >> .make-settings echo CFLAGS= >> .make-settings echo LDFLAGS= >> .make-settings echo REDIS_CFLAGS= >> .make-settings echo REDIS_LDFLAGS= >> .make-settings echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -Wall -O2 -g -ggdb -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings echo PREV_FINAL_LDFLAGS= -g -ggdb -rdynamic >> .make-settings (cd ../deps && make hiredis linenoise lua jemalloc) make[2]: Entering directory `/root/redis-2.8.4/deps' (cd hiredis && make clean) > /dev/null || true (cd linenoise && make clean) > /dev/null || true (cd lua && make clean) > /dev/null || true (cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true (rm -f .make-*) (echo "" > .make-ldflags) (echo "" > .make-cflags) MAKE hiredis cd hiredis && make static make[3]: Entering directory `/root/redis-2.8.4/deps/hiredis' cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb hiredis.c cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb sds.c cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb async.c ar rcs libhiredis.a net.o hiredis.o sds.o async.o make[3]: Leaving directory `/root/redis-2.8.4/deps/hiredis' MAKE linenoise cd linenoise && make make[3]: Entering directory `/root/redis-2.8.4/deps/linenoise' cc -Wall -Os -g -c linenoise.c make[3]: Leaving directory `/root/redis-2.8.4/deps/linenoise' MAKE lua cd lua/src && make all CFLAGS="-O2 -Wall -DLUA_ANSI " MYLDFLAGS="" make[3]: Entering directory `/root/redis-2.8.4/deps/lua/src' cc -O2 -Wall -DLUA_ANSI -c -o lapi.o lapi.c cc -O2 -Wall -DLUA_ANSI -c -o lcode.o lcode.c cc -O2 -Wall -DLUA_ANSI -c -o ldebug.o ldebug.c cc -O2 -Wall -DLUA_ANSI -c -o ldo.o ldo.c cc -O2 -Wall -DLUA_ANSI -c -o ldump.o ldump.c cc -O2 -Wall -DLUA_ANSI -c -o lfunc.o lfunc.c cc -O2 -Wall -DLUA_ANSI -c -o lgc.o lgc.c cc -O2 -Wall -DLUA_ANSI -c -o llex.o llex.c cc -O2 -Wall -DLUA_ANSI -c -o lmem.o lmem.c cc -O2 -Wall -DLUA_ANSI -c -o lobject.o lobject.c cc -O2 -Wall -DLUA_ANSI -c -o lopcodes.o lopcodes.c cc -O2 -Wall -DLUA_ANSI -c -o lparser.o lparser.c cc -O2 -Wall -DLUA_ANSI -c -o lstate.o lstate.c cc -O2 -Wall -DLUA_ANSI -c -o lstring.o lstring.c cc -O2 -Wall -DLUA_ANSI -c -o ltable.o ltable.c cc -O2 -Wall -DLUA_ANSI -c -o ltm.o ltm.c cc -O2 -Wall -DLUA_ANSI -c -o lundump.o lundump.c cc -O2 -Wall -DLUA_ANSI -c -o lvm.o lvm.c cc -O2 -Wall -DLUA_ANSI -c -o lzio.o lzio.c cc -O2 -Wall -DLUA_ANSI -c -o strbuf.o strbuf.c cc -O2 -Wall -DLUA_ANSI -c -o lauxlib.o lauxlib.c cc -O2 -Wall -DLUA_ANSI -c -o lbaselib.o lbaselib.c cc -O2 -Wall -DLUA_ANSI -c -o ldblib.o ldblib.c cc -O2 -Wall -DLUA_ANSI -c -o liolib.o liolib.c cc -O2 -Wall -DLUA_ANSI -c -o lmathlib.o lmathlib.c cc -O2 -Wall -DLUA_ANSI -c -o loslib.o loslib.c cc -O2 -Wall -DLUA_ANSI -c -o ltablib.o ltablib.c cc -O2 -Wall -DLUA_ANSI -c -o lstrlib.o lstrlib.c cc -O2 -Wall -DLUA_ANSI -c -o loadlib.o loadlib.c cc -O2 -Wall -DLUA_ANSI -c -o linit.o linit.c cc -O2 -Wall -DLUA_ANSI -c -o lua_cjson.o lua_cjson.c cc -O2 -Wall -DLUA_ANSI -c -o lua_struct.o lua_struct.c cc -O2 -Wall -DLUA_ANSI -c -o lua_cmsgpack.o lua_cmsgpack.c lua_cmsgpack.c: In function ‘table_is_an_array’: lua_cmsgpack.c:370:21: warning: variable ‘max’ set but not used [-Wunused-but-set-variable] ar rcu liblua.a lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o strbuf.o lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o lua_cjson.o lua_struct.o lua_cmsgpack.o # DLL needs all object files ranlib liblua.a cc -O2 -Wall -DLUA_ANSI -c -o lua.o lua.c cc -o lua lua.o liblua.a -lm cc -O2 -Wall -DLUA_ANSI -c -o luac.o luac.c cc -O2 -Wall -DLUA_ANSI -c -o print.o print.c cc -o luac luac.o print.o liblua.a -lm make[3]: Leaving directory `/root/redis-2.8.4/deps/lua/src' MAKE jemalloc cd jemalloc && ./configure --with-jemalloc-prefix=je_ --enable-cc-silence CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS="" checking for xsltproc... /usr/bin/xsltproc checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking size of void *... 8 checking size of int... 4 checking size of long... 8 checking size of intmax_t... 8 checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking whether __asm__ syntax is compilable... yes checking whether __attribute__ syntax is compilable... yes checking whether compiler supports -fvisibility=hidden... yes checking whether compiler supports -Werror... yes checking whether tls_model attribute is compilable... no checking for a BSD-compatible install... /usr/bin/install -c checking for ranlib... ranlib checking for ar... /usr/bin/ar checking for ld... /usr/bin/ld checking for autoconf... no checking for memalign... yes checking for valloc... yes checking configured backtracing method... N/A checking for sbrk... yes checking whether utrace(2) is compilable... no checking whether valgrind is compilable... no checking STATIC_PAGE_SHIFT... 12 checking pthread.h usability... yes checking pthread.h presence... yes checking for pthread.h... yes checking for pthread_create in -lpthread... yes checking for _malloc_thread_cleanup... no checking for _pthread_mutex_init_calloc_cb... no checking for TLS... yes checking whether a program using ffsl is compilable... yes checking whether atomic(9) is compilable... no checking whether Darwin OSAtomic*() is compilable... no checking whether to force 32-bit __sync_{add,sub}_and_fetch()... no checking whether to force 64-bit __sync_{add,sub}_and_fetch()... no checking whether Darwin OSSpin*() is compilable... no checking for stdbool.h that conforms to C99... yes checking for _Bool... yes configure: creating ./config.status config.status: creating Makefile config.status: creating doc/html.xsl config.status: creating doc/manpages.xsl config.status: creating doc/jemalloc.xml config.status: creating include/jemalloc/jemalloc.h config.status: creating include/jemalloc/internal/jemalloc_internal.h config.status: creating test/jemalloc_test.h config.status: creating config.stamp config.status: creating bin/jemalloc.sh config.status: creating include/jemalloc/jemalloc_defs.h config.status: executing include/jemalloc/internal/size_classes.h commands =============================================================================== jemalloc version : 3.2.0-0-g87499f6748ebe4817571e817e9f680ccb5bf54a9 library revision : 1 CC : gcc CPPFLAGS : -D_GNU_SOURCE -D_REENTRANT CFLAGS : -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -fvisibility=hidden LDFLAGS : LIBS : -lm -lpthread RPATH_EXTRA : XSLTPROC : /usr/bin/xsltproc XSLROOT : PREFIX : /usr/local BINDIR : /usr/local/bin INCLUDEDIR : /usr/local/include LIBDIR : /usr/local/lib DATADIR : /usr/local/share MANDIR : /usr/local/share/man srcroot : abs_srcroot : /root/redis-2.8.4/deps/jemalloc/ objroot : abs_objroot : /root/redis-2.8.4/deps/jemalloc/ JEMALLOC_PREFIX : je_ JEMALLOC_PRIVATE_NAMESPACE : install_suffix : autogen : 0 experimental : 1 cc-silence : 1 debug : 0 stats : 1 prof : 0 prof-libunwind : 0 prof-libgcc : 0 prof-gcc : 0 tcache : 1 fill : 1 utrace : 0 valgrind : 0 xmalloc : 0 mremap : 0 munmap : 0 dss : 0 lazy_lock : 0 tls : 1 =============================================================================== cd jemalloc && make CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS="" lib/libjemalloc.a make[3]: Entering directory `/root/redis-2.8.4/deps/jemalloc' gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/jemalloc.o src/jemalloc.c src/jemalloc.c: In function ‘je_realloc’: src/jemalloc.c:1082:9: warning: variable ‘old_rzsize’ set but not used [-Wunused-but-set-variable] src/jemalloc.c: In function ‘je_free’: src/jemalloc.c:1230:10: warning: variable ‘rzsize’ set but not used [-Wunused-but-set-variable] src/jemalloc.c: In function ‘je_rallocm’: src/jemalloc.c:1477:9: warning: variable ‘old_rzsize’ set but not used [-Wunused-but-set-variable] src/jemalloc.c: In function ‘je_dallocm’: src/jemalloc.c:1622:9: warning: variable ‘rzsize’ set but not used [-Wunused-but-set-variable] gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/arena.o src/arena.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/atomic.o src/atomic.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/base.o src/base.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/bitmap.o src/bitmap.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk.o src/chunk.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk_dss.o src/chunk_dss.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk_mmap.o src/chunk_mmap.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ckh.o src/ckh.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ctl.o src/ctl.c src/ctl.c: In function ‘epoch_ctl’: src/ctl.c:1112:11: warning: variable ‘newval’ set but not used [-Wunused-but-set-variable] gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/extent.o src/extent.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/hash.o src/hash.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/huge.o src/huge.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mb.o src/mb.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mutex.o src/mutex.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/prof.o src/prof.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/quarantine.o src/quarantine.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/rtree.o src/rtree.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/stats.o src/stats.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/tcache.o src/tcache.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/util.o src/util.c gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/tsd.o src/tsd.c ar crus lib/libjemalloc.a src/jemalloc.o src/arena.o src/atomic.o src/base.o src/bitmap.o src/chunk.o src/chunk_dss.o src/chunk_mmap.o src/ckh.o src/ctl.o src/extent.o src/hash.o src/huge.o src/mb.o src/mutex.o src/prof.o src/quarantine.o src/rtree.o src/stats.o src/tcache.o src/util.o src/tsd.o make[3]: Leaving directory `/root/redis-2.8.4/deps/jemalloc' make[2]: Leaving directory `/root/redis-2.8.4/deps' CC adlist.o CC ae.o CC anet.o CC dict.o CC redis.o CC sds.o CC zmalloc.o CC lzf_c.o CC lzf_d.o CC pqsort.o CC zipmap.o CC sha1.o CC ziplist.o CC release.o CC networking.o CC util.o CC object.o CC db.o CC replication.o CC rdb.o CC t_string.o CC t_list.o CC t_set.o CC t_zset.o CC t_hash.o CC config.o CC aof.o CC pubsub.o CC multi.o CC debug.o CC sort.o CC intset.o CC syncio.o CC migrate.o CC endianconv.o CC slowlog.o CC scripting.o CC bio.o CC rio.o CC rand.o CC memtest.o CC crc64.o CC bitops.o CC sentinel.o CC notify.o CC setproctitle.o LINK redis-server INSTALL redis-sentinel CC redis-cli.o LINK redis-cli CC redis-benchmark.o LINK redis-benchmark CC redis-check-dump.o LINK redis-check-dump CC redis-check-aof.o LINK redis-check-aof Hint: To run 'make test' is a good idea ;) make[1]: Leaving directory `/root/redis-2.8.4/src'
- 動作テストを行う
make test 2>&1 | tee maketest.log
ログ
[root@XXX redis-2.8.4]# make test cd src && make test make[1]: Entering directory `/root/redis-2.8.4/src' ** SLOW COMPUTER ** Using a single client to avoid false positives. Cleanup: may take some time... OK Starting test server at port 11111 [ready]: 3510 Testing unit/printver Testing Redis version 2.8.4 (00000000) [1/35 done]: unit/printver (0 seconds) Testing unit/auth [ok]: AUTH fails if there is no password configured server side [ok]: AUTH fails when a wrong password is given [ok]: Arbitrary command gives an error when AUTH is required [ok]: AUTH succeeds when the right password is given [ok]: Once AUTH succeeded we can actually send commands to the server [2/35 done]: unit/auth (1 seconds) Testing unit/protocol [ok]: Handle an empty query [ok]: Negative multibulk length [ok]: Out of range multibulk length [ok]: Wrong multibulk payload header [ok]: Negative multibulk payload length [ok]: Out of range multibulk payload length [ok]: Non-number multibulk payload length [ok]: Multi bulk request not followed by bulk arguments [ok]: Generic wrong number of args [ok]: Unbalanced number of quotes [ok]: Protocol desync regression test #1 [ok]: Protocol desync regression test #2 [ok]: Protocol desync regression test #3 [ok]: Regression for a crash with blocking ops and pipelining [3/35 done]: unit/protocol (1 seconds) Testing unit/basic [ok]: DEL all keys to start with a clean DB [ok]: SET and GET an item [ok]: SET and GET an empty item [ok]: DEL against a single item [ok]: Vararg DEL [ok]: KEYS with pattern [ok]: KEYS to get all keys [ok]: DBSIZE [ok]: DEL all keys [ok]: Very big payload in GET/SET [ok]: Very big payload random access [ok]: SET 10000 numeric keys and access all them in reverse order [ok]: DBSIZE should be 10101 now [ok]: INCR against non existing key [ok]: INCR against key created by incr itself [ok]: INCR against key originally set with SET [ok]: INCR over 32bit value [ok]: INCRBY over 32bit value with over 32bit increment [ok]: INCR fails against key with spaces (left) [ok]: INCR fails against key with spaces (right) [ok]: INCR fails against key with spaces (both) [ok]: INCR fails against a key holding a list [ok]: DECRBY over 32bit value with over 32bit increment, negative res [ok]: INCRBYFLOAT against non existing key [ok]: INCRBYFLOAT against key originally set with SET [ok]: INCRBYFLOAT over 32bit value [ok]: INCRBYFLOAT over 32bit value with over 32bit increment [ok]: INCRBYFLOAT fails against key with spaces (left) [ok]: INCRBYFLOAT fails against key with spaces (right) [ok]: INCRBYFLOAT fails against key with spaces (both) [ok]: INCRBYFLOAT fails against a key holding a list [ok]: INCRBYFLOAT does not allow NaN or Infinity [ok]: INCRBYFLOAT decrement [ok]: SETNX target key missing [ok]: SETNX target key exists [ok]: SETNX against not-expired volatile key [ok]: SETNX against expired volatile key [ok]: EXISTS [ok]: Zero length value in key. SET/GET/EXISTS [ok]: Commands pipelining [ok]: Non existing command [ok]: RENAME basic usage [ok]: RENAME source key should no longer exist [ok]: RENAME against already existing key [ok]: RENAMENX basic usage [ok]: RENAMENX against already existing key [ok]: RENAMENX against already existing key (2) [ok]: RENAME against non existing source key [ok]: RENAME where source and dest key is the same [ok]: RENAME with volatile key, should move the TTL as well [ok]: RENAME with volatile key, should not inherit TTL of target key [ok]: DEL all keys again (DB 0) [ok]: DEL all keys again (DB 1) [ok]: MOVE basic usage [ok]: MOVE against key existing in the target DB [ok]: SET/GET keys in different DBs [ok]: MGET [ok]: MGET against non existing key [ok]: MGET against non-string key [ok]: RANDOMKEY [ok]: RANDOMKEY against empty DB [ok]: RANDOMKEY regression 1 [ok]: GETSET (set new value) [ok]: GETSET (replace old value) [ok]: MSET base case [ok]: MSET wrong number of args [ok]: MSETNX with already existent key [ok]: MSETNX with not existing keys [ok]: STRLEN against non-existing key [ok]: STRLEN against integer-encoded value [ok]: STRLEN against plain string [ok]: SETBIT against non-existing key [ok]: SETBIT against string-encoded key [ok]: SETBIT against integer-encoded key [ok]: SETBIT against key with wrong type [ok]: SETBIT with out of range bit offset [ok]: SETBIT with non-bit argument [ok]: SETBIT fuzzing [ok]: GETBIT against non-existing key [ok]: GETBIT against string-encoded key [ok]: GETBIT against integer-encoded key [ok]: SETRANGE against non-existing key [ok]: SETRANGE against string-encoded key [ok]: SETRANGE against integer-encoded key [ok]: SETRANGE against key with wrong type [ok]: SETRANGE with out of range offset [ok]: GETRANGE against non-existing key [ok]: GETRANGE against string value [ok]: GETRANGE against integer-encoded value [ok]: GETRANGE fuzzing [ok]: Extended SET can detect syntax errors [ok]: Extended SET NX option [ok]: Extended SET XX option [ok]: Extended SET EX option [ok]: Extended SET PX option [ok]: Extended SET using multiple options at once [ok]: KEYS * two times with long key, Github issue #1208 [4/35 done]: unit/basic (30 seconds) Testing unit/scan [ok]: SCAN basic [ok]: SCAN COUNT [ok]: SCAN MATCH [ok]: SSCAN with encoding intset [ok]: SSCAN with encoding hashtable [ok]: HSCAN with encoding ziplist [ok]: HSCAN with encoding hashtable [ok]: ZSCAN with encoding ziplist [ok]: ZSCAN with encoding skiplist [ok]: SCAN guarantees check under write load [ok]: SSCAN with integer encoded object (issue #1345) [ok]: SSCAN with PATTERN [ok]: HSCAN with PATTERN [ok]: ZSCAN with PATTERN [5/35 done]: unit/scan (1 seconds) Testing unit/type/list [ok]: LPUSH, RPUSH, LLENGTH, LINDEX, LPOP - ziplist [ok]: LPUSH, RPUSH, LLENGTH, LINDEX, LPOP - regular list [ok]: R/LPOP against empty list [ok]: Variadic RPUSH/LPUSH [ok]: DEL a list - ziplist [ok]: DEL a list - regular list [ok]: BLPOP, BRPOP: single existing list - linkedlist [ok]: BLPOP, BRPOP: multiple existing lists - linkedlist [ok]: BLPOP, BRPOP: second list has an entry - linkedlist [ok]: BRPOPLPUSH - linkedlist [ok]: BLPOP, BRPOP: single existing list - ziplist [ok]: BLPOP, BRPOP: multiple existing lists - ziplist [ok]: BLPOP, BRPOP: second list has an entry - ziplist [ok]: BRPOPLPUSH - ziplist [ok]: BLPOP, LPUSH + DEL should not awake blocked client [ok]: BLPOP, LPUSH + DEL + SET should not awake blocked client [ok]: BLPOP with same key multiple times should work (issue #801) [ok]: MULTI/EXEC is isolated from the point of view of BLPOP [ok]: BLPOP with variadic LPUSH [ok]: BRPOPLPUSH with zero timeout should block indefinitely [ok]: BRPOPLPUSH with a client BLPOPing the target list [ok]: BRPOPLPUSH with wrong source type [ok]: BRPOPLPUSH with wrong destination type [ok]: BRPOPLPUSH maintains order of elements after failure [ok]: BRPOPLPUSH with multiple blocked clients [ok]: Linked BRPOPLPUSH [ok]: Circular BRPOPLPUSH [ok]: Self-referential BRPOPLPUSH [ok]: BRPOPLPUSH inside a transaction [ok]: PUSH resulting from BRPOPLPUSH affect WATCH [ok]: BRPOPLPUSH does not affect WATCH while still blocked [ok]: BRPOPLPUSH timeout [ok]: BLPOP: with single empty list argument [ok]: BLPOP: with negative timeout [ok]: BLPOP: with non-integer timeout [ok]: BLPOP: with zero timeout should block indefinitely [ok]: BLPOP: second argument is not a list [ok]: BLPOP: timeout [ok]: BLPOP: arguments are empty [ok]: BRPOP: with single empty list argument [ok]: BRPOP: with negative timeout [ok]: BRPOP: with non-integer timeout [ok]: BRPOP: with zero timeout should block indefinitely [ok]: BRPOP: second argument is not a list [ok]: BRPOP: timeout [ok]: BRPOP: arguments are empty [ok]: BLPOP inside a transaction [ok]: LPUSHX, RPUSHX - generic [ok]: LPUSHX, RPUSHX - linkedlist [ok]: LINSERT - linkedlist [ok]: LPUSHX, RPUSHX - ziplist [ok]: LINSERT - ziplist [ok]: LINSERT raise error on bad syntax [ok]: LPUSHX, RPUSHX convert from ziplist to list [ok]: LINSERT convert from ziplist to list [ok]: LINDEX consistency test - ziplist [ok]: LINDEX random access - ziplist [ok]: Check if list is still ok after a DEBUG RELOAD - ziplist [ok]: LINDEX consistency test - linkedlist [ok]: LINDEX random access - linkedlist [ok]: Check if list is still ok after a DEBUG RELOAD - linkedlist [ok]: LLEN against non-list value error [ok]: LLEN against non existing key [ok]: LINDEX against non-list value error [ok]: LINDEX against non existing key [ok]: LPUSH against non-list value error [ok]: RPUSH against non-list value error [ok]: RPOPLPUSH base case - linkedlist [ok]: RPOPLPUSH with the same list as src and dst - linkedlist [ok]: RPOPLPUSH with linkedlist source and existing target linkedlist [ok]: RPOPLPUSH with linkedlist source and existing target ziplist [ok]: RPOPLPUSH base case - ziplist [ok]: RPOPLPUSH with the same list as src and dst - ziplist [ok]: RPOPLPUSH with ziplist source and existing target linkedlist [ok]: RPOPLPUSH with ziplist source and existing target ziplist [ok]: RPOPLPUSH against non existing key [ok]: RPOPLPUSH against non list src key [ok]: RPOPLPUSH against non list dst key [ok]: RPOPLPUSH against non existing src key [ok]: Basic LPOP/RPOP - linkedlist [ok]: Basic LPOP/RPOP - ziplist [ok]: LPOP/RPOP against non list value [ok]: Mass RPOP/LPOP - ziplist [ok]: Mass RPOP/LPOP - linkedlist [ok]: LRANGE basics - linkedlist [ok]: LRANGE inverted indexes - linkedlist [ok]: LRANGE out of range indexes including the full list - linkedlist [ok]: LRANGE out of range negative end index - linkedlist [ok]: LRANGE basics - ziplist [ok]: LRANGE inverted indexes - ziplist [ok]: LRANGE out of range indexes including the full list - ziplist [ok]: LRANGE out of range negative end index - ziplist [ok]: LRANGE against non existing key [ok]: LTRIM basics - linkedlist [ok]: LTRIM out of range negative end index - linkedlist [ok]: LTRIM basics - ziplist [ok]: LTRIM out of range negative end index - ziplist [ok]: LSET - linkedlist [ok]: LSET out of range index - linkedlist [ok]: LSET - ziplist [ok]: LSET out of range index - ziplist [ok]: LSET against non existing key [ok]: LSET against non list value [ok]: LREM remove all the occurrences - linkedlist [ok]: LREM remove the first occurrence - linkedlist [ok]: LREM remove non existing element - linkedlist [ok]: LREM starting from tail with negative count - linkedlist [ok]: LREM starting from tail with negative count (2) - linkedlist [ok]: LREM deleting objects that may be int encoded - linkedlist [ok]: LREM remove all the occurrences - ziplist [ok]: LREM remove the first occurrence - ziplist [ok]: LREM remove non existing element - ziplist [ok]: LREM starting from tail with negative count - ziplist [ok]: LREM starting from tail with negative count (2) - ziplist [ok]: LREM deleting objects that may be int encoded - ziplist [ok]: Regression for bug 593 - chaining BRPOPLPUSH with other blocking cmds [6/35 done]: unit/type/list (15 seconds) Testing unit/type/list-2 [ok]: LTRIM stress testing - linkedlist [ok]: LTRIM stress testing - ziplist [7/35 done]: unit/type/list-2 (14 seconds) Testing unit/type/list-3 [ok]: Explicit regression for a list bug [ok]: ziplist implementation: value encoding and backlink [ok]: ziplist implementation: encoding stress testing [8/35 done]: unit/type/list-3 (37 seconds) Testing unit/type/set [ok]: SADD, SCARD, SISMEMBER, SMEMBERS basics - regular set [ok]: SADD, SCARD, SISMEMBER, SMEMBERS basics - intset [ok]: SADD against non set [ok]: SADD a non-integer against an intset [ok]: SADD an integer larger than 64 bits [ok]: SADD overflows the maximum allowed integers in an intset [ok]: Variadic SADD [ok]: Set encoding after DEBUG RELOAD [ok]: SREM basics - regular set [ok]: SREM basics - intset [ok]: SREM with multiple arguments [ok]: SREM variadic version with more args needed to destroy the key [ok]: Generated sets must be encoded as hashtable [ok]: SINTER with two sets - hashtable [ok]: SINTERSTORE with two sets - hashtable [ok]: SINTERSTORE with two sets, after a DEBUG RELOAD - hashtable [ok]: SUNION with two sets - hashtable [ok]: SUNIONSTORE with two sets - hashtable [ok]: SINTER against three sets - hashtable [ok]: SINTERSTORE with three sets - hashtable [ok]: SUNION with non existing keys - hashtable [ok]: SDIFF with two sets - hashtable [ok]: SDIFF with three sets - hashtable [ok]: SDIFFSTORE with three sets - hashtable [ok]: Generated sets must be encoded as intset [ok]: SINTER with two sets - intset [ok]: SINTERSTORE with two sets - intset [ok]: SINTERSTORE with two sets, after a DEBUG RELOAD - intset [ok]: SUNION with two sets - intset [ok]: SUNIONSTORE with two sets - intset [ok]: SINTER against three sets - intset [ok]: SINTERSTORE with three sets - intset [ok]: SUNION with non existing keys - intset [ok]: SDIFF with two sets - intset [ok]: SDIFF with three sets - intset [ok]: SDIFFSTORE with three sets - intset [ok]: SDIFF with first set empty [ok]: SDIFF with same set two times [ok]: SDIFF fuzzing [ok]: SINTER against non-set should throw error [ok]: SUNION against non-set should throw error [ok]: SINTER should handle non existing key as empty [ok]: SINTER with same integer elements but different encoding [ok]: SINTERSTORE against non existing keys should delete dstkey [ok]: SUNIONSTORE against non existing keys should delete dstkey [ok]: SPOP basics - hashtable [ok]: SRANDMEMBER - hashtable [ok]: SPOP basics - intset [ok]: SRANDMEMBER - intset [ok]: SRANDMEMBER with <count> against non existing key [ok]: SRANDMEMBER with <count> - hashtable [ok]: SRANDMEMBER with <count> - intset [ok]: SMOVE basics - from regular set to intset [ok]: SMOVE basics - from intset to regular set [ok]: SMOVE non existing key [ok]: SMOVE non existing src set [ok]: SMOVE from regular set to non existing destination set [ok]: SMOVE from intset to non existing destination set [ok]: SMOVE wrong src key type [ok]: SMOVE wrong dst key type [ok]: SMOVE with identical source and destination [ok]: intsets implementation stress testing [9/35 done]: unit/type/set (20 seconds) Testing unit/type/zset [ok]: Check encoding - ziplist [ok]: ZSET basic ZADD and score update - ziplist [ok]: ZSET element can't be set to NaN with ZADD - ziplist [ok]: ZSET element can't be set to NaN with ZINCRBY [ok]: ZINCRBY calls leading to NaN result in error [ok]: ZADD - Variadic version base case [ok]: ZADD - Return value is the number of actually added items [ok]: ZADD - Variadic version does not add nothing on single parsing err [ok]: ZADD - Variadic version will raise error on missing arg [ok]: ZINCRBY does not work variadic even if shares ZADD implementation [ok]: ZCARD basics - ziplist [ok]: ZREM removes key after last element is removed [ok]: ZREM variadic version [ok]: ZREM variadic version -- remove elements after key deletion [ok]: ZRANGE basics - ziplist [ok]: ZREVRANGE basics - ziplist [ok]: ZRANK/ZREVRANK basics - ziplist [ok]: ZRANK - after deletion - ziplist [ok]: ZINCRBY - can create a new sorted set - ziplist [ok]: ZINCRBY - increment and decrement - ziplist [ok]: ZRANGEBYSCORE/ZREVRANGEBYSCORE/ZCOUNT basics [ok]: ZRANGEBYSCORE with WITHSCORES [ok]: ZRANGEBYSCORE with LIMIT [ok]: ZRANGEBYSCORE with LIMIT and WITHSCORES [ok]: ZRANGEBYSCORE with non-value min or max [ok]: ZREMRANGEBYSCORE basics [ok]: ZREMRANGEBYSCORE with non-value min or max [ok]: ZREMRANGEBYRANK basics [ok]: ZUNIONSTORE against non-existing key doesn't set destination - ziplist [ok]: ZUNIONSTORE with empty set - ziplist [ok]: ZUNIONSTORE basics - ziplist [ok]: ZUNIONSTORE with weights - ziplist [ok]: ZUNIONSTORE with a regular set and weights - ziplist [ok]: ZUNIONSTORE with AGGREGATE MIN - ziplist [ok]: ZUNIONSTORE with AGGREGATE MAX - ziplist [ok]: ZINTERSTORE basics - ziplist [ok]: ZINTERSTORE with weights - ziplist [ok]: ZINTERSTORE with a regular set and weights - ziplist [ok]: ZINTERSTORE with AGGREGATE MIN - ziplist [ok]: ZINTERSTORE with AGGREGATE MAX - ziplist [ok]: ZUNIONSTORE with +inf/-inf scores - ziplist [ok]: ZUNIONSTORE with NaN weights ziplist [ok]: ZINTERSTORE with +inf/-inf scores - ziplist [ok]: ZINTERSTORE with NaN weights ziplist [ok]: Check encoding - skiplist [ok]: ZSET basic ZADD and score update - skiplist [ok]: ZSET element can't be set to NaN with ZADD - skiplist [ok]: ZSET element can't be set to NaN with ZINCRBY [ok]: ZINCRBY calls leading to NaN result in error [ok]: ZADD - Variadic version base case [ok]: ZADD - Return value is the number of actually added items [ok]: ZADD - Variadic version does not add nothing on single parsing err [ok]: ZADD - Variadic version will raise error on missing arg [ok]: ZINCRBY does not work variadic even if shares ZADD implementation [ok]: ZCARD basics - skiplist [ok]: ZREM removes key after last element is removed [ok]: ZREM variadic version [ok]: ZREM variadic version -- remove elements after key deletion [ok]: ZRANGE basics - skiplist [ok]: ZREVRANGE basics - skiplist [ok]: ZRANK/ZREVRANK basics - skiplist [ok]: ZRANK - after deletion - skiplist [ok]: ZINCRBY - can create a new sorted set - skiplist [ok]: ZINCRBY - increment and decrement - skiplist [ok]: ZRANGEBYSCORE/ZREVRANGEBYSCORE/ZCOUNT basics [ok]: ZRANGEBYSCORE with WITHSCORES [ok]: ZRANGEBYSCORE with LIMIT [ok]: ZRANGEBYSCORE with LIMIT and WITHSCORES [ok]: ZRANGEBYSCORE with non-value min or max [ok]: ZREMRANGEBYSCORE basics [ok]: ZREMRANGEBYSCORE with non-value min or max [ok]: ZREMRANGEBYRANK basics [ok]: ZUNIONSTORE against non-existing key doesn't set destination - skiplist [ok]: ZUNIONSTORE with empty set - skiplist [ok]: ZUNIONSTORE basics - skiplist [ok]: ZUNIONSTORE with weights - skiplist [ok]: ZUNIONSTORE with a regular set and weights - skiplist [ok]: ZUNIONSTORE with AGGREGATE MIN - skiplist [ok]: ZUNIONSTORE with AGGREGATE MAX - skiplist [ok]: ZINTERSTORE basics - skiplist [ok]: ZINTERSTORE with weights - skiplist [ok]: ZINTERSTORE with a regular set and weights - skiplist [ok]: ZINTERSTORE with AGGREGATE MIN - skiplist [ok]: ZINTERSTORE with AGGREGATE MAX - skiplist [ok]: ZUNIONSTORE with +inf/-inf scores - skiplist [ok]: ZUNIONSTORE with NaN weights skiplist [ok]: ZINTERSTORE with +inf/-inf scores - skiplist [ok]: ZINTERSTORE with NaN weights skiplist [ok]: ZINTERSTORE regression with two sets, intset+hashtable [ok]: ZUNIONSTORE regression, should not create NaN in scores [ok]: ZINTERSTORE #516 regression, mixed sets and ziplist zsets [ok]: ZSCORE - ziplist [ok]: ZSCORE after a DEBUG RELOAD - ziplist [ok]: ZSET sorting stresser - ziplist [ok]: ZRANGEBYSCORE fuzzy test, 100 ranges in 128 element sorted set - ziplist [ok]: ZSETs skiplist implementation backlink consistency test - ziplist [ok]: ZSETs ZRANK augmented skip list stress testing - ziplist [ok]: ZSCORE - skiplist [ok]: ZSCORE after a DEBUG RELOAD - skiplist [ok]: ZSET sorting stresser - skiplist [ok]: ZRANGEBYSCORE fuzzy test, 100 ranges in 100 element sorted set - skiplist [ok]: ZSETs skiplist implementation backlink consistency test - skiplist [ok]: ZSETs ZRANK augmented skip list stress testing - skiplist [10/35 done]: unit/type/zset (23 seconds) Testing unit/type/hash [ok]: HSET/HLEN - Small hash creation [ok]: Is the small hash encoded with a ziplist? [ok]: HSET/HLEN - Big hash creation [ok]: Is the big hash encoded with a ziplist? [ok]: HGET against the small hash [ok]: HGET against the big hash [ok]: HGET against non existing key [ok]: HSET in update and insert mode [ok]: HSETNX target key missing - small hash [ok]: HSETNX target key exists - small hash [ok]: HSETNX target key missing - big hash [ok]: HSETNX target key exists - big hash [ok]: HMSET wrong number of args [ok]: HMSET - small hash [ok]: HMSET - big hash [ok]: HMGET against non existing key and fields [ok]: HMGET against wrong type [ok]: HMGET - small hash [ok]: HMGET - big hash [ok]: HKEYS - small hash [ok]: HKEYS - big hash [ok]: HVALS - small hash [ok]: HVALS - big hash [ok]: HGETALL - small hash [ok]: HGETALL - big hash [ok]: HDEL and return value [ok]: HDEL - more than a single value [ok]: HDEL - hash becomes empty before deleting all specified fields [ok]: HEXISTS [ok]: Is a ziplist encoded Hash promoted on big payload? [ok]: HINCRBY against non existing database key [ok]: HINCRBY against non existing hash key [ok]: HINCRBY against hash key created by hincrby itself [ok]: HINCRBY against hash key originally set with HSET [ok]: HINCRBY over 32bit value [ok]: HINCRBY over 32bit value with over 32bit increment [ok]: HINCRBY fails against hash value with spaces (left) [ok]: HINCRBY fails against hash value with spaces (right) [ok]: HINCRBY can detect overflows [ok]: HINCRBYFLOAT against non existing database key [ok]: HINCRBYFLOAT against non existing hash key [ok]: HINCRBYFLOAT against hash key created by hincrby itself [ok]: HINCRBYFLOAT against hash key originally set with HSET [ok]: HINCRBYFLOAT over 32bit value [ok]: HINCRBYFLOAT over 32bit value with over 32bit increment [ok]: HINCRBYFLOAT fails against hash value with spaces (left) [ok]: HINCRBYFLOAT fails against hash value with spaces (right) [ok]: Hash ziplist regression test for large keys [ok]: Hash fuzzing #1 - 10 fields [ok]: Hash fuzzing #2 - 10 fields [ok]: Hash fuzzing #1 - 512 fields [ok]: Hash fuzzing #2 - 512 fields [ok]: Stress test the hash ziplist -> hashtable encoding conversion [11/35 done]: unit/type/hash (12 seconds) Testing unit/sort [ok]: Ziplist: SORT BY key [ok]: Ziplist: SORT BY key with limit [ok]: Ziplist: SORT BY hash field [ok]: Linked list: SORT BY key [ok]: Linked list: SORT BY key with limit [ok]: Linked list: SORT BY hash field [ok]: Big Linked list: SORT BY key [ok]: Big Linked list: SORT BY key with limit [ok]: Big Linked list: SORT BY hash field [ok]: Intset: SORT BY key [ok]: Intset: SORT BY key with limit [ok]: Intset: SORT BY hash field [ok]: Hash table: SORT BY key [ok]: Hash table: SORT BY key with limit [ok]: Hash table: SORT BY hash field [ok]: Big Hash table: SORT BY key [ok]: Big Hash table: SORT BY key with limit [ok]: Big Hash table: SORT BY hash field [ok]: SORT GET # [ok]: SORT GET <const> [ok]: SORT GET (key and hash) with sanity check [ok]: SORT BY key STORE [ok]: SORT BY hash field STORE [ok]: SORT DESC [ok]: SORT ALPHA against integer encoded strings [ok]: SORT sorted set [ok]: SORT sorted set BY nosort should retain ordering [ok]: SORT sorted set BY nosort + LIMIT [ok]: SORT sorted set BY nosort works as expected from scripts [ok]: SORT sorted set: +inf and -inf handling [ok]: SORT regression for issue #19, sorting floats [ok]: SORT with STORE returns zero if result is empty (github isse 224) [ok]: SORT with STORE does not create empty lists (github issue 224) [ok]: SORT with STORE removes key if result is empty (github issue 227) [ok]: SORT with BY <constant> and STORE should still order output [ok]: SORT will complain with numerical sorting and bad doubles (1) [ok]: SORT will complain with numerical sorting and bad doubles (2) [ok]: SORT BY sub-sorts lexicographically if score is the same [ok]: SORT GET with pattern ending with just -> does not get hash field [ok]: SORT speed, 100 element list BY key, 100 times [ok]: SORT speed, 100 element list BY hash field, 100 times [ok]: SORT speed, 100 element list directly, 100 times [ok]: SORT speed, 100 element list BY <const>, 100 times [12/35 done]: unit/sort (26 seconds) Testing unit/expire [ok]: EXPIRE - set timeouts multiple times [ok]: EXPIRE - It should be still possible to read 'x' [ok]: EXPIRE - After 2.1 seconds the key should no longer be here [ok]: EXPIRE - write on expire should work [ok]: EXPIREAT - Check for EXPIRE alike behavior [ok]: SETEX - Set + Expire combo operation. Check for TTL [ok]: SETEX - Check value [ok]: SETEX - Overwrite old key [ok]: SETEX - Wait for the key to expire [ok]: SETEX - Wrong time parameter [ok]: PERSIST can undo an EXPIRE [ok]: PERSIST returns 0 against non existing or non volatile keys [ok]: EXPIRE pricision is now the millisecond [ok]: PEXPIRE/PSETEX/PEXPIREAT can set sub-second expires [ok]: TTL returns tiem to live in seconds [ok]: PTTL returns time to live in milliseconds [ok]: TTL / PTTL return -1 if key has no expire [ok]: TTL / PTTL return -2 if key does not exit [ok]: Redis should actively expire keys incrementally [ok]: Redis should lazy expire keys [ok]: EXPIRE should not resurrect keys (issue #1026) [ok]: 5 keys in, 5 keys out [13/35 done]: unit/expire (10 seconds) Testing unit/other [ok]: SAVE - make sure there are all the types as values [ok]: FUZZ stresser with data model binary [ok]: FUZZ stresser with data model alpha [ok]: FUZZ stresser with data model compr [ok]: BGSAVE [ok]: SELECT an out of range DB [ok]: EXPIRES after a reload (snapshot + append only file rewrite) [ok]: EXPIRES after AOF reload (without rewrite) [ok]: PIPELINING stresser (also a regression for the old epoll bug) [ok]: APPEND basics [ok]: APPEND basics, integer encoded values [ok]: APPEND fuzzing [ok]: FLUSHDB [ok]: Perform a final SAVE to leave a clean DB on disk [14/35 done]: unit/other (16 seconds) Testing unit/multi [ok]: MUTLI / EXEC basics [ok]: DISCARD [ok]: Nested MULTI are not allowed [ok]: MULTI where commands alter argc/argv [ok]: WATCH inside MULTI is not allowed [ok]: EXEC fails if there are errors while queueing commands #1 [ok]: EXEC fails if there are errors while queueing commands #2 [ok]: If EXEC aborts, the client MULTI state is cleared [ok]: EXEC works on WATCHed key not modified [ok]: EXEC fail on WATCHed key modified (1 key of 1 watched) [ok]: EXEC fail on WATCHed key modified (1 key of 5 watched) [ok]: EXEC fail on WATCHed key modified by SORT with STORE even if the result is empty [ok]: After successful EXEC key is no longer watched [ok]: After failed EXEC key is no longer watched [ok]: It is possible to UNWATCH [ok]: UNWATCH when there is nothing watched works as expected [ok]: FLUSHALL is able to touch the watched keys [ok]: FLUSHALL does not touch non affected keys [ok]: FLUSHDB is able to touch the watched keys [ok]: FLUSHDB does not touch non affected keys [ok]: WATCH is able to remember the DB a key belongs to [ok]: WATCH will consider touched keys target of EXPIRE [ok]: WATCH will not consider touched expired keys [ok]: DISCARD should clear the WATCH dirty flag on the client [ok]: DISCARD should UNWATCH all the keys [ok]: MULTI / EXEC is propagated correctly (single write command) [ok]: MULTI / EXEC is propagated correctly (empty transaction) [ok]: MULTI / EXEC is propagated correctly (read-only commands) [ok]: MULTI / EXEC is propagated correctly (write command, no effect) [15/35 done]: unit/multi (2 seconds) Testing unit/quit [ok]: QUIT returns OK [ok]: Pipelined commands after QUIT must not be executed [ok]: Pipelined commands after QUIT that exceed read buffer size [16/35 done]: unit/quit (0 seconds) Testing unit/aofrw [ok]: Turning off AOF kills the background writing child if any [ok]: AOF rewrite of list with ziplist encoding, string data [ok]: AOF rewrite of list with linkedlist encoding, string data [ok]: AOF rewrite of list with ziplist encoding, int data [ok]: AOF rewrite of list with linkedlist encoding, int data [ok]: AOF rewrite of set with intset encoding, string data [ok]: AOF rewrite of set with hashtable encoding, string data [ok]: AOF rewrite of set with intset encoding, int data [ok]: AOF rewrite of set with hashtable encoding, int data [ok]: AOF rewrite of hash with ziplist encoding, string data [ok]: AOF rewrite of hash with hashtable encoding, string data [ok]: AOF rewrite of hash with ziplist encoding, int data [ok]: AOF rewrite of hash with hashtable encoding, int data [ok]: AOF rewrite of zset with ziplist encoding, string data [ok]: AOF rewrite of zset with skiplist encoding, string data [ok]: AOF rewrite of zset with ziplist encoding, int data [ok]: AOF rewrite of zset with skiplist encoding, int data [ok]: BGREWRITEAOF is delayed if BGSAVE is in progress [ok]: BGREWRITEAOF is refused if already in progress [17/35 done]: unit/aofrw (21 seconds) Testing integration/replication [ok]: First server should have role slave after SLAVEOF [ok]: BRPOPLPUSH replication, when blocking against empty list [ok]: BRPOPLPUSH replication, list exists [ok]: Second server should have role master at first [ok]: SLAVEOF should start with link status "down" [ok]: The role should immediately be changed to "slave" [ok]: Sync should have transferred keys from master [ok]: The link status should be up [ok]: SET on the master should immediately propagate [ok]: FLUSHALL should replicate [ok]: Connect multiple slaves at the same time (issue #141) [18/35 done]: integration/replication (14 seconds) Testing integration/replication-2 [ok]: First server should have role slave after SLAVEOF [ok]: MASTER and SLAVE dataset should be identical after complex ops [19/35 done]: integration/replication-2 (21 seconds) Testing integration/replication-3 [ok]: First server should have role slave after SLAVEOF [ok]: MASTER and SLAVE consistency with expire [ok]: First server should have role slave after SLAVEOF [ok]: MASTER and SLAVE consistency with EVALSHA replication [20/35 done]: integration/replication-3 (68 seconds) Testing integration/replication-4 [ok]: First server should have role slave after SLAVEOF [ok]: Test replication with parallel clients writing in differnet DBs [ok]: First server should have role slave after SLAVEOF [ok]: With min-slaves-to-write (1,3): master should be writable [ok]: With min-slaves-to-write (2,3): master should not be writable [ok]: With min-slaves-to-write: master not writable with lagged slave [ok]: First server should have role slave after SLAVEOF [ok]: Replication: commands with many arguments (issue #1221) [21/35 done]: integration/replication-4 (42 seconds) Testing integration/replication-psync [ok]: First server should have role slave after SLAVEOF [ok]: Test replication partial resync: ok psync [ok]: First server should have role slave after SLAVEOF [ok]: Test replication partial resync: no backlog [ok]: First server should have role slave after SLAVEOF [ok]: Test replication partial resync: ok after delay [ok]: First server should have role slave after SLAVEOF [ok]: Test replication partial resync: backlog expired [22/35 done]: integration/replication-psync (40 seconds) Testing integration/aof [ok]: Unfinished MULTI: Server should have logged an error [ok]: Short read: Server should have logged an error [ok]: Short read: Utility should confirm the AOF is not valid [ok]: Short read: Utility should be able to fix the AOF [ok]: Fixed AOF: Server should have been started [ok]: Fixed AOF: Keyspace should contain values that were parsable [ok]: AOF+SPOP: Server should have been started [ok]: AOF+SPOP: Set should have 1 member [ok]: AOF+EXPIRE: Server should have been started [ok]: AOF+EXPIRE: List should be empty [ok]: Redis should not try to convert DEL into EXPIREAT for EXPIRE -1 [23/35 done]: integration/aof (2 seconds) Testing integration/rdb [ok]: RDB encoding loading test [ok]: Server started empty with non-existing RDB file [ok]: Server started empty with empty RDB file [ok]: Server should not start if RDB is corrupted [24/35 done]: integration/rdb (1 seconds) Testing integration/convert-zipmap-hash-on-load [ok]: RDB load zipmap hash: converts to ziplist [ok]: RDB load zipmap hash: converts to hash table when hash-max-ziplist-entries is exceeded [ok]: RDB load zipmap hash: converts to hash table when hash-max-ziplist-value is exceeded [25/35 done]: integration/convert-zipmap-hash-on-load (2 seconds) Testing unit/pubsub [ok]: PUBLISH/SUBSCRIBE basics [ok]: PUBLISH/SUBSCRIBE with two clients [ok]: PUBLISH/SUBSCRIBE after UNSUBSCRIBE without arguments [ok]: SUBSCRIBE to one channel more than once [ok]: UNSUBSCRIBE from non-subscribed channels [ok]: PUBLISH/PSUBSCRIBE basics [ok]: PUBLISH/PSUBSCRIBE with two clients [ok]: PUBLISH/PSUBSCRIBE after PUNSUBSCRIBE without arguments [ok]: PUNSUBSCRIBE from non-subscribed channels [ok]: Mix SUBSCRIBE and PSUBSCRIBE [ok]: PUNSUBSCRIBE and UNSUBSCRIBE should always reply [ok]: Keyspace notifications: we receive keyspace notifications [ok]: Keyspace notifications: we receive keyevent notifications [ok]: Keyspace notifications: we can receive both kind of events [ok]: Keyspace notifications: we are able to mask events [ok]: Keyspace notifications: general events test [ok]: Keyspace notifications: list events test [ok]: Keyspace notifications: set events test [ok]: Keyspace notifications: zset events test [ok]: Keyspace notifications: hash events test [ok]: Keyspace notifications: expired events (triggered expire) [ok]: Keyspace notifications: expired events (background expire) [ok]: Keyspace notifications: evicted events [ok]: Keyspace notifications: test CONFIG GET/SET of event flags [26/35 done]: unit/pubsub (0 seconds) Testing unit/slowlog [ok]: SLOWLOG - check that it starts with an empty log [ok]: SLOWLOG - only logs commands taking more time than specified [ok]: SLOWLOG - max entries is correctly handled [ok]: SLOWLOG - GET optional argument to limit output len works [ok]: SLOWLOG - RESET subcommand works [ok]: SLOWLOG - logged entry sanity check [ok]: SLOWLOG - commands with too many arguments are trimmed [ok]: SLOWLOG - too long arguments are trimmed [ok]: SLOWLOG - EXEC is not logged, just executed commands [27/35 done]: unit/slowlog (1 seconds) Testing unit/scripting [ok]: EVAL - Does Lua interpreter replies to our requests? [ok]: EVAL - Lua integer -> Redis protocol type conversion [ok]: EVAL - Lua string -> Redis protocol type conversion [ok]: EVAL - Lua true boolean -> Redis protocol type conversion [ok]: EVAL - Lua false boolean -> Redis protocol type conversion [ok]: EVAL - Lua status code reply -> Redis protocol type conversion [ok]: EVAL - Lua error reply -> Redis protocol type conversion [ok]: EVAL - Lua table -> Redis protocol type conversion [ok]: EVAL - Are the KEYS and ARGV arrays populated correctly? [ok]: EVAL - is Lua able to call Redis API? [ok]: EVALSHA - Can we call a SHA1 if already defined? [ok]: EVALSHA - Can we call a SHA1 in uppercase? [ok]: EVALSHA - Do we get an error on invalid SHA1? [ok]: EVALSHA - Do we get an error on non defined SHA1? [ok]: EVAL - Redis integer -> Lua type conversion [ok]: EVAL - Redis bulk -> Lua type conversion [ok]: EVAL - Redis multi bulk -> Lua type conversion [ok]: EVAL - Redis status reply -> Lua type conversion [ok]: EVAL - Redis error reply -> Lua type conversion [ok]: EVAL - Redis nil bulk reply -> Lua type conversion [ok]: EVAL - Is Lua affecting the currently selected DB? [ok]: EVAL - Is Lua seleced DB retained? [ok]: EVAL - Scripts can't run certain commands [ok]: EVAL - Scripts can't run certain commands [ok]: EVAL - No arguments to redis.call/pcall is considered an error [ok]: EVAL - redis.call variant raises a Lua error on Redis cmd error (1) [ok]: EVAL - redis.call variant raises a Lua error on Redis cmd error (1) [ok]: EVAL - redis.call variant raises a Lua error on Redis cmd error (1) [ok]: SCRIPTING FLUSH - is able to clear the scripts cache? [ok]: SCRIPT EXISTS - can detect already defined scripts? [ok]: SCRIPT LOAD - is able to register scripts in the scripting cache [ok]: In the context of Lua the output of random commands gets ordered [ok]: SORT is normally not alpha re-ordered for the scripting engine [ok]: SORT BY <constant> output gets ordered for scripting [ok]: SORT BY <constant> with GET gets ordered for scripting [ok]: redis.sha1hex() implementation [ok]: Globals protection reading an undeclared global variable [ok]: Globals protection setting an undeclared global* [ok]: Test an example script DECR_IF_GT [ok]: Scripting engine resets PRNG at every script execution [ok]: Scripting engine PRNG can be seeded correctly [ok]: EVAL does not leak in the Lua stack [ok]: EVAL processes writes from AOF in read-only slaves [ok]: Timedout read-only scripts can be killed by SCRIPT KILL [ok]: Timedout script link is still usable after Lua returns [ok]: Timedout scripts that modified data can't be killed by SCRIPT KILL [ok]: SHUTDOWN NOSAVE can kill a timedout script anyway [ok]: Before the slave connects we issue two EVAL commands [ok]: Connect a slave to the main instance [ok]: Now use EVALSHA against the master, with both SHAs [ok]: If EVALSHA was replicated as EVAL, 'x' should be '4' [ok]: Replication of script multiple pushes to list with BLPOP [28/35 done]: unit/scripting (5 seconds) Testing unit/maxmemory [ok]: maxmemory - is the memory limit honoured? (policy allkeys-random) [ok]: maxmemory - is the memory limit honoured? (policy allkeys-lru) [ok]: maxmemory - is the memory limit honoured? (policy volatile-lru) [ok]: maxmemory - is the memory limit honoured? (policy volatile-random) [ok]: maxmemory - is the memory limit honoured? (policy volatile-ttl) [ok]: maxmemory - only allkeys-* should remove non-volatile keys (allkeys-random) [ok]: maxmemory - only allkeys-* should remove non-volatile keys (allkeys-lru) [ok]: maxmemory - only allkeys-* should remove non-volatile keys (volatile-lru) [ok]: maxmemory - only allkeys-* should remove non-volatile keys (volatile-random) [ok]: maxmemory - only allkeys-* should remove non-volatile keys (volatile-ttl) [ok]: maxmemory - policy volatile-lru should only remove volatile keys. [ok]: maxmemory - policy volatile-random should only remove volatile keys. [ok]: maxmemory - policy volatile-ttl should only remove volatile keys. [29/35 done]: unit/maxmemory (14 seconds) Testing unit/introspection [ok]: CLIENT LIST [ok]: MONITOR can log executed commands [ok]: MONITOR can log commands issued by the scripting engine [ok]: CLIENT GETNAME should return NIL if name is not assigned [ok]: CLIENT LIST shows empty fields for unassigned names [ok]: CLIENT SETNAME does not accept spaces [ok]: CLIENT SETNAME can assign a name to this connection [ok]: CLIENT SETNAME can change the name of an existing connection [ok]: After CLIENT SETNAME, connection can still be closed [30/35 done]: unit/introspection (1 seconds) Testing unit/limits [ok]: Check if maxclients works refusing connections [31/35 done]: unit/limits (1 seconds) Testing unit/obuf-limits [ok]: Client output buffer hard limit is enforced [ok]: Client output buffer soft limit is not enforced if time is not overreached [ok]: Client output buffer soft limit is enforced if time is overreached [32/35 done]: unit/obuf-limits (344 seconds) Testing unit/dump [ok]: DUMP / RESTORE are able to serialize / unserialize a simple key [ok]: RESTORE can set an arbitrary expire to the materialized key [ok]: RESTORE can set an expire that overflows a 32 bit integer [ok]: RESTORE returns an error of the key already exists [ok]: DUMP of non existing key returns nil [ok]: MIGRATE is able to migrate a key between two instances [ok]: MIGRATE propagates TTL correctly [ok]: MIGRATE can correctly transfer large values [ok]: MIGRATE can correctly transfer hashes [ok]: MIGRATE timeout actually works [33/35 done]: unit/dump (6 seconds) Testing unit/bitops [ok]: BITCOUNT returns 0 against non existing key [ok]: BITCOUNT against test vector #1 [ok]: BITCOUNT against test vector #2 [ok]: BITCOUNT against test vector #3 [ok]: BITCOUNT against test vector #4 [ok]: BITCOUNT against test vector #5 [ok]: BITCOUNT fuzzing [ok]: BITCOUNT with start, end [ok]: BITCOUNT syntax error #1 [ok]: BITCOUNT regression test for github issue #582 [ok]: BITOP NOT (empty string) [ok]: BITOP NOT (known string) [ok]: BITOP where dest and target are the same key [ok]: BITOP AND|OR|XOR don't change the string with single input key [ok]: BITOP missing key is considered a stream of zero [ok]: BITOP shorter keys are zero-padded to the key with max length [ok]: BITOP and fuzzing [ok]: BITOP or fuzzing [ok]: BITOP xor fuzzing [ok]: BITOP NOT fuzzing [ok]: BITOP with integer encoded source objects [ok]: BITOP with non string source key [ok]: BITOP with empty string after non empty string (issue #529) [34/35 done]: unit/bitops (5 seconds) Testing unit/memefficiency [ok]: Memory efficiency with values in range 32 [ok]: Memory efficiency with values in range 64 [ok]: Memory efficiency with values in range 128 [ok]: Memory efficiency with values in range 1024 [ok]: Memory efficiency with values in range 16384 [35/35 done]: unit/memefficiency (319 seconds) The End Execution time of different units: 0 seconds - unit/printver 1 seconds - unit/auth 1 seconds - unit/protocol 30 seconds - unit/basic 1 seconds - unit/scan 15 seconds - unit/type/list 14 seconds - unit/type/list-2 37 seconds - unit/type/list-3 20 seconds - unit/type/set 23 seconds - unit/type/zset 12 seconds - unit/type/hash 26 seconds - unit/sort 10 seconds - unit/expire 16 seconds - unit/other 2 seconds - unit/multi 0 seconds - unit/quit 21 seconds - unit/aofrw 14 seconds - integration/replication 21 seconds - integration/replication-2 68 seconds - integration/replication-3 42 seconds - integration/replication-4 40 seconds - integration/replication-psync 2 seconds - integration/aof 1 seconds - integration/rdb 2 seconds - integration/convert-zipmap-hash-on-load 0 seconds - unit/pubsub 1 seconds - unit/slowlog 5 seconds - unit/scripting 14 seconds - unit/maxmemory 1 seconds - unit/introspection 1 seconds - unit/limits 344 seconds - unit/obuf-limits 6 seconds - unit/dump 5 seconds - unit/bitops 319 seconds - unit/memefficiency \o/ All tests passed without errors! Cleanup: may take some time... OK make[1]: Leaving directory `/root/redis-2.8.4/src'
- インストールする
make PREFIX=/usr/local/redis-2.8.4/ install 2>&1 | tee make_install.log
- リンクを作成する
ln -s /usr/local/redis-2.8.4 /usr/local/redis
- データ用ディレクトリを作成する
mkdir /usr/local/redis/data
- コンフィグファイルをコピーする
cat redis.conf | sed -e "s/^dir .\/$/dir \/usr\/local\/redis\/data\//g" > /usr/local/redis/redis.conf
- ユーザを作成する
useradd --user-group --no-create-home --shell /sbin/nologin redis
- 起動スクリプトを作成する
vi /etc/init.d/redis
以下を記述する
#!/bin/sh # # chkconfig: 3 56 10 # # description: redis # CONFIG=/usr/local/redis/redis.conf BIN_SERVER=/usr/local/redis/bin/redis-server LOCK=/var/lock/subsys/redis PID=/var/run/redis.pid # Source function library. if [ -f /etc/rc.d/init.d/functions ]; then . /etc/rc.d/init.d/functions elif [ -f /etc/init.d/functions ]; then . /etc/init.d/functions fi start() { echo "Starting Redis with $CONFIG" if [ -f $LOCK ]; then echo "Redis is running now." exit 1 fi daemon --pidfile $PID --user redis $BIN_SERVER $CONFIG > /dev/null 2>&1 & touch $LOCK return 0 } stop() { echo "Stopping Redis" killproc redis-server rm -f $LOCK rm -f $PID echo "Stoped Redis" return 0 } restart() { stop start return 0 } case "$1" in start) start ;; stop) stop ;; restart) restart ;; status) status $BIN_SERVER ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 esac exit 0
- オーナー・権限を変更する
chown redis:redis /etc/init.d/redis chmod 755 /etc/init.d/redis chown -R redis:redis /usr/local/redis/
- サービス登録する
chkconfig --add redis chkconfig --list redis
- パスを通す
export REDIS_HOME=/usr/local/redis export PATH=$REDIS_HOME/bin/:$PATH # 永続化する vi /etc/bashrc
設定
- パス
$REDIS_HOME/redis.conf
デフォルトの設定
# Redis configuration file example # Note on units: when memory size is needed, it is possible to specify # it in the usual form of 1k 5GB 4M and so forth: # # 1k => 1000 bytes # 1kb => 1024 bytes # 1m => 1000000 bytes # 1mb => 1024*1024 bytes # 1g => 1000000000 bytes # 1gb => 1024*1024*1024 bytes # # units are case insensitive so 1GB 1Gb 1gB are all the same. ################################## INCLUDES ################################### # Include one or more other config files here. This is useful if you # have a standard template that goes to all Redis server but also need # to customize a few per-server settings. Include files can include # other files, so use this wisely. # # Notice option "include" won't be rewritten by command "CONFIG REWRITE" # from admin or Redis Sentinel. Since Redis always uses the last processed # line as value of a configuration directive, you'd better put includes # at the beginning of this file to avoid overwriting config change at runtime. # # If instead you are interested in using includes to override configuration # options, it is better to use include as the last line. # # include /path/to/local.conf # include /path/to/other.conf ################################ GENERAL ##################################### # By default Redis does not run as a daemon. Use 'yes' if you need it. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized. daemonize no # When running daemonized, Redis writes a pid file in /var/run/redis.pid by # default. You can specify a custom pid file location here. pidfile /var/run/redis.pid # Accept connections on the specified port, default is 6379. # If port 0 is specified Redis will not listen on a TCP socket. port 6379 # By default Redis listens for connections from all the network interfaces # available on the server. It is possible to listen to just one or multiple # interfaces using the "bind" configuration directive, followed by one or # more IP addresses. # # Examples: # # bind 192.168.1.100 10.0.0.1 # bind 127.0.0.1 # Specify the path for the Unix socket that will be used to listen for # incoming connections. There is no default, so Redis will not listen # on a unix socket when not specified. # # unixsocket /tmp/redis.sock # unixsocketperm 755 # Close the connection after a client is idle for N seconds (0 to disable) timeout 0 # TCP keepalive. # # If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence # of communication. This is useful for two reasons: # # 1) Detect dead peers. # 2) Take the connection alive from the point of view of network # equipment in the middle. # # On Linux, the specified value (in seconds) is the period used to send ACKs. # Note that to close the connection the double of the time is needed. # On other kernels the period depends on the kernel configuration. # # A reasonable value for this option is 60 seconds. tcp-keepalive 0 # Specify the server verbosity level. # This can be one of: # debug (a lot of information, useful for development/testing) # verbose (many rarely useful info, but not a mess like the debug level) # notice (moderately verbose, what you want in production probably) # warning (only very important / critical messages are logged) loglevel notice # Specify the log file name. Also the empty string can be used to force # Redis to log on the standard output. Note that if you use standard # output for logging but daemonize, logs will be sent to /dev/null logfile "" # To enable logging to the system logger, just set 'syslog-enabled' to yes, # and optionally update the other syslog parameters to suit your needs. # syslog-enabled no # Specify the syslog identity. # syslog-ident redis # Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7. # syslog-facility local0 # Set the number of databases. The default database is DB 0, you can select # a different one on a per-connection basis using SELECT <dbid> where # dbid is a number between 0 and 'databases'-1 databases 16 ################################ SNAPSHOTTING ################################ # # Save the DB on disk: # # save <seconds> <changes> # # Will save the DB if both the given number of seconds and the given # number of write operations against the DB occurred. # # In the example below the behaviour will be to save: # after 900 sec (15 min) if at least 1 key changed # after 300 sec (5 min) if at least 10 keys changed # after 60 sec if at least 10000 keys changed # # Note: you can disable saving at all commenting all the "save" lines. # # It is also possible to remove all the previously configured save # points by adding a save directive with a single empty string argument # like in the following example: # # save "" save 900 1 save 300 10 save 60 10000 # By default Redis will stop accepting writes if RDB snapshots are enabled # (at least one save point) and the latest background save failed. # This will make the user aware (in a hard way) that data is not persisting # on disk properly, otherwise chances are that no one will notice and some # disaster will happen. # # If the background saving process will start working again Redis will # automatically allow writes again. # # However if you have setup your proper monitoring of the Redis server # and persistence, you may want to disable this feature so that Redis will # continue to work as usual even if there are problems with disk, # permissions, and so forth. stop-writes-on-bgsave-error yes # Compress string objects using LZF when dump .rdb databases? # For default that's set to 'yes' as it's almost always a win. # If you want to save some CPU in the saving child set it to 'no' but # the dataset will likely be bigger if you have compressible values or keys. rdbcompression yes # Since version 5 of RDB a CRC64 checksum is placed at the end of the file. # This makes the format more resistant to corruption but there is a performance # hit to pay (around 10%) when saving and loading RDB files, so you can disable it # for maximum performances. # # RDB files created with checksum disabled have a checksum of zero that will # tell the loading code to skip the check. rdbchecksum yes # The filename where to dump the DB dbfilename dump.rdb # The working directory. # # The DB will be written inside this directory, with the filename specified # above using the 'dbfilename' configuration directive. # # The Append Only File will also be created inside this directory. # # Note that you must specify a directory here, not a file name. dir ./ ################################# REPLICATION ################################# # Master-Slave replication. Use slaveof to make a Redis instance a copy of # another Redis server. Note that the configuration is local to the slave # so for example it is possible to configure the slave to save the DB with a # different interval, or to listen to another port, and so on. # # slaveof <masterip> <masterport> # If the master is password protected (using the "requirepass" configuration # directive below) it is possible to tell the slave to authenticate before # starting the replication synchronization process, otherwise the master will # refuse the slave request. # # masterauth <master-password> # When a slave loses its connection with the master, or when the replication # is still in progress, the slave can act in two different ways: # # 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will # still reply to client requests, possibly with out of date data, or the # data set may just be empty if this is the first synchronization. # # 2) if slave-serve-stale-data is set to 'no' the slave will reply with # an error "SYNC with master in progress" to all the kind of commands # but to INFO and SLAVEOF. # slave-serve-stale-data yes # You can configure a slave instance to accept writes or not. Writing against # a slave instance may be useful to store some ephemeral data (because data # written on a slave will be easily deleted after resync with the master) but # may also cause problems if clients are writing to it because of a # misconfiguration. # # Since Redis 2.6 by default slaves are read-only. # # Note: read only slaves are not designed to be exposed to untrusted clients # on the internet. It's just a protection layer against misuse of the instance. # Still a read only slave exports by default all the administrative commands # such as CONFIG, DEBUG, and so forth. To a limited extent you can improve # security of read only slaves using 'rename-command' to shadow all the # administrative / dangerous commands. slave-read-only yes # Slaves send PINGs to server in a predefined interval. It's possible to change # this interval with the repl_ping_slave_period option. The default value is 10 # seconds. # # repl-ping-slave-period 10 # The following option sets the replication timeout for: # # 1) Bulk transfer I/O during SYNC, from the point of view of slave. # 2) Master timeout from the point of view of slaves (data, pings). # 3) Slave timeout from the point of view of masters (REPLCONF ACK pings). # # It is important to make sure that this value is greater than the value # specified for repl-ping-slave-period otherwise a timeout will be detected # every time there is low traffic between the master and the slave. # # repl-timeout 60 # Disable TCP_NODELAY on the slave socket after SYNC? # # If you select "yes" Redis will use a smaller number of TCP packets and # less bandwidth to send data to slaves. But this can add a delay for # the data to appear on the slave side, up to 40 milliseconds with # Linux kernels using a default configuration. # # If you select "no" the delay for data to appear on the slave side will # be reduced but more bandwidth will be used for replication. # # By default we optimize for low latency, but in very high traffic conditions # or when the master and slaves are many hops away, turning this to "yes" may # be a good idea. repl-disable-tcp-nodelay no # Set the replication backlog size. The backlog is a buffer that accumulates # slave data when slaves are disconnected for some time, so that when a slave # wants to reconnect again, often a full resync is not needed, but a partial # resync is enough, just passing the portion of data the slave missed while # disconnected. # # The biggest the replication backlog, the longer the time the slave can be # disconnected and later be able to perform a partial resynchronization. # # The backlog is only allocated once there is at least a slave connected. # # repl-backlog-size 1mb # After a master has no longer connected slaves for some time, the backlog # will be freed. The following option configures the amount of seconds that # need to elapse, starting from the time the last slave disconnected, for # the backlog buffer to be freed. # # A value of 0 means to never release the backlog. # # repl-backlog-ttl 3600 # The slave priority is an integer number published by Redis in the INFO output. # It is used by Redis Sentinel in order to select a slave to promote into a # master if the master is no longer working correctly. # # A slave with a low priority number is considered better for promotion, so # for instance if there are three slaves with priority 10, 100, 25 Sentinel will # pick the one with priority 10, that is the lowest. # # However a special priority of 0 marks the slave as not able to perform the # role of master, so a slave with priority of 0 will never be selected by # Redis Sentinel for promotion. # # By default the priority is 100. slave-priority 100 # It is possible for a master to stop accepting writes if there are less than # N slaves connected, having a lag less or equal than M seconds. # # The N slaves need to be in "online" state. # # The lag in seconds, that must be <= the specified value, is calculated from # the last ping received from the slave, that is usually sent every second. # # This option does not GUARANTEES that N replicas will accept the write, but # will limit the window of exposure for lost writes in case not enough slaves # are available, to the specified number of seconds. # # For example to require at least 3 slaves with a lag <= 10 seconds use: # # min-slaves-to-write 3 # min-slaves-max-lag 10 # # Setting one or the other to 0 disables the feature. # # By default min-slaves-to-write is set to 0 (feature disabled) and # min-slaves-max-lag is set to 10. ################################## SECURITY ################################### # Require clients to issue AUTH <PASSWORD> before processing any other # commands. This might be useful in environments in which you do not trust # others with access to the host running redis-server. # # This should stay commented out for backward compatibility and because most # people do not need auth (e.g. they run their own servers). # # Warning: since Redis is pretty fast an outside user can try up to # 150k passwords per second against a good box. This means that you should # use a very strong password otherwise it will be very easy to break. # # requirepass foobared # Command renaming. # # It is possible to change the name of dangerous commands in a shared # environment. For instance the CONFIG command may be renamed into something # hard to guess so that it will still be available for internal-use tools # but not available for general clients. # # Example: # # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 # # It is also possible to completely kill a command by renaming it into # an empty string: # # rename-command CONFIG "" # # Please note that changing the name of commands that are logged into the # AOF file or transmitted to slaves may cause problems. ################################### LIMITS #################################### # Set the max number of connected clients at the same time. By default # this limit is set to 10000 clients, however if the Redis server is not # able to configure the process file limit to allow for the specified limit # the max number of allowed clients is set to the current file limit # minus 32 (as Redis reserves a few file descriptors for internal uses). # # Once the limit is reached Redis will close all the new connections sending # an error 'max number of clients reached'. # # maxclients 10000 # Don't use more memory than the specified amount of bytes. # When the memory limit is reached Redis will try to remove keys # according to the eviction policy selected (see maxmemory-policy). # # If Redis can't remove keys according to the policy, or if the policy is # set to 'noeviction', Redis will start to reply with errors to commands # that would use more memory, like SET, LPUSH, and so on, and will continue # to reply to read-only commands like GET. # # This option is usually useful when using Redis as an LRU cache, or to set # a hard memory limit for an instance (using the 'noeviction' policy). # # WARNING: If you have slaves attached to an instance with maxmemory on, # the size of the output buffers needed to feed the slaves are subtracted # from the used memory count, so that network problems / resyncs will # not trigger a loop where keys are evicted, and in turn the output # buffer of slaves is full with DELs of keys evicted triggering the deletion # of more keys, and so forth until the database is completely emptied. # # In short... if you have slaves attached it is suggested that you set a lower # limit for maxmemory so that there is some free RAM on the system for slave # output buffers (but this is not needed if the policy is 'noeviction'). # # maxmemory <bytes> # MAXMEMORY POLICY: how Redis will select what to remove when maxmemory # is reached. You can select among five behaviors: # # volatile-lru -> remove the key with an expire set using an LRU algorithm # allkeys-lru -> remove any key accordingly to the LRU algorithm # volatile-random -> remove a random key with an expire set # allkeys-random -> remove a random key, any key # volatile-ttl -> remove the key with the nearest expire time (minor TTL) # noeviction -> don't expire at all, just return an error on write operations # # Note: with any of the above policies, Redis will return an error on write # operations, when there are not suitable keys for eviction. # # At the date of writing this commands are: set setnx setex append # incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd # sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby # zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby # getset mset msetnx exec sort # # The default is: # # maxmemory-policy volatile-lru # LRU and minimal TTL algorithms are not precise algorithms but approximated # algorithms (in order to save memory), so you can select as well the sample # size to check. For instance for default Redis will check three keys and # pick the one that was used less recently, you can change the sample size # using the following configuration directive. # # maxmemory-samples 3 ############################## APPEND ONLY MODE ############################### # By default Redis asynchronously dumps the dataset on disk. This mode is # good enough in many applications, but an issue with the Redis process or # a power outage may result into a few minutes of writes lost (depending on # the configured save points). # # The Append Only File is an alternative persistence mode that provides # much better durability. For instance using the default data fsync policy # (see later in the config file) Redis can lose just one second of writes in a # dramatic event like a server power outage, or a single write if something # wrong with the Redis process itself happens, but the operating system is # still running correctly. # # AOF and RDB persistence can be enabled at the same time without problems. # If the AOF is enabled on startup Redis will load the AOF, that is the file # with the better durability guarantees. # # Please check http://redis.io/topics/persistence for more information. appendonly no # The name of the append only file (default: "appendonly.aof") appendfilename "appendonly.aof" # The fsync() call tells the Operating System to actually write data on disk # instead to wait for more data in the output buffer. Some OS will really flush # data on disk, some other OS will just try to do it ASAP. # # Redis supports three different modes: # # no: don't fsync, just let the OS flush the data when it wants. Faster. # always: fsync after every write to the append only log . Slow, Safest. # everysec: fsync only one time every second. Compromise. # # The default is "everysec", as that's usually the right compromise between # speed and data safety. It's up to you to understand if you can relax this to # "no" that will let the operating system flush the output buffer when # it wants, for better performances (but if you can live with the idea of # some data loss consider the default persistence mode that's snapshotting), # or on the contrary, use "always" that's very slow but a bit safer than # everysec. # # More details please check the following article: # http://antirez.com/post/redis-persistence-demystified.html # # If unsure, use "everysec". # appendfsync always appendfsync everysec # appendfsync no # When the AOF fsync policy is set to always or everysec, and a background # saving process (a background save or AOF log background rewriting) is # performing a lot of I/O against the disk, in some Linux configurations # Redis may block too long on the fsync() call. Note that there is no fix for # this currently, as even performing fsync in a different thread will block # our synchronous write(2) call. # # In order to mitigate this problem it's possible to use the following option # that will prevent fsync() from being called in the main process while a # BGSAVE or BGREWRITEAOF is in progress. # # This means that while another child is saving, the durability of Redis is # the same as "appendfsync none". In practical terms, this means that it is # possible to lose up to 30 seconds of log in the worst scenario (with the # default Linux settings). # # If you have latency problems turn this to "yes". Otherwise leave it as # "no" that is the safest pick from the point of view of durability. no-appendfsync-on-rewrite no # Automatic rewrite of the append only file. # Redis is able to automatically rewrite the log file implicitly calling # BGREWRITEAOF when the AOF log size grows by the specified percentage. # # This is how it works: Redis remembers the size of the AOF file after the # latest rewrite (if no rewrite has happened since the restart, the size of # the AOF at startup is used). # # This base size is compared to the current size. If the current size is # bigger than the specified percentage, the rewrite is triggered. Also # you need to specify a minimal size for the AOF file to be rewritten, this # is useful to avoid rewriting the AOF file even if the percentage increase # is reached but it is still pretty small. # # Specify a percentage of zero in order to disable the automatic AOF # rewrite feature. auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb ################################ LUA SCRIPTING ############################### # Max execution time of a Lua script in milliseconds. # # If the maximum execution time is reached Redis will log that a script is # still in execution after the maximum allowed time and will start to # reply to queries with an error. # # When a long running script exceed the maximum execution time only the # SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be # used to stop a script that did not yet called write commands. The second # is the only way to shut down the server in the case a write commands was # already issue by the script but the user don't want to wait for the natural # termination of the script. # # Set it to 0 or a negative value for unlimited execution without warnings. lua-time-limit 5000 ################################## SLOW LOG ################################### # The Redis Slow Log is a system to log queries that exceeded a specified # execution time. The execution time does not include the I/O operations # like talking with the client, sending the reply and so forth, # but just the time needed to actually execute the command (this is the only # stage of command execution where the thread is blocked and can not serve # other requests in the meantime). # # You can configure the slow log with two parameters: one tells Redis # what is the execution time, in microseconds, to exceed in order for the # command to get logged, and the other parameter is the length of the # slow log. When a new command is logged the oldest one is removed from the # queue of logged commands. # The following time is expressed in microseconds, so 1000000 is equivalent # to one second. Note that a negative number disables the slow log, while # a value of zero forces the logging of every command. slowlog-log-slower-than 10000 # There is no limit to this length. Just be aware that it will consume memory. # You can reclaim memory used by the slow log with SLOWLOG RESET. slowlog-max-len 128 ############################# Event notification ############################## # Redis can notify Pub/Sub clients about events happening in the key space. # This feature is documented at http://redis.io/topics/keyspace-events # # For instance if keyspace events notification is enabled, and a client # performs a DEL operation on key "foo" stored in the Database 0, two # messages will be published via Pub/Sub: # # PUBLISH __keyspace@0__:foo del # PUBLISH __keyevent@0__:del foo # # It is possible to select the events that Redis will notify among a set # of classes. Every class is identified by a single character: # # K Keyspace events, published with __keyspace@<db>__ prefix. # E Keyevent events, published with __keyevent@<db>__ prefix. # g Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ... # $ String commands # l List commands # s Set commands # h Hash commands # z Sorted set commands # x Expired events (events generated every time a key expires) # e Evicted events (events generated when a key is evicted for maxmemory) # A Alias for g$lshzxe, so that the "AKE" string means all the events. # # The "notify-keyspace-events" takes as argument a string that is composed # by zero or multiple characters. The empty string means that notifications # are disabled at all. # # Example: to enable list and generic events, from the point of view of the # event name, use: # # notify-keyspace-events Elg # # Example 2: to get the stream of the expired keys subscribing to channel # name __keyevent@0__:expired use: # # notify-keyspace-events Ex # # By default all notifications are disabled because most users don't need # this feature and the feature has some overhead. Note that if you don't # specify at least one of K or E, no events will be delivered. notify-keyspace-events "" ############################### ADVANCED CONFIG ############################### # Hashes are encoded using a memory efficient data structure when they have a # small number of entries, and the biggest entry does not exceed a given # threshold. These thresholds can be configured using the following directives. hash-max-ziplist-entries 512 hash-max-ziplist-value 64 # Similarly to hashes, small lists are also encoded in a special way in order # to save a lot of space. The special representation is only used when # you are under the following limits: list-max-ziplist-entries 512 list-max-ziplist-value 64 # Sets have a special encoding in just one case: when a set is composed # of just strings that happens to be integers in radix 10 in the range # of 64 bit signed integers. # The following configuration setting sets the limit in the size of the # set in order to use this special memory saving encoding. set-max-intset-entries 512 # Similarly to hashes and lists, sorted sets are also specially encoded in # order to save a lot of space. This encoding is only used when the length and # elements of a sorted set are below the following limits: zset-max-ziplist-entries 128 zset-max-ziplist-value 64 # Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in # order to help rehashing the main Redis hash table (the one mapping top-level # keys to values). The hash table implementation Redis uses (see dict.c) # performs a lazy rehashing: the more operation you run into a hash table # that is rehashing, the more rehashing "steps" are performed, so if the # server is idle the rehashing is never complete and some more memory is used # by the hash table. # # The default is to use this millisecond 10 times every second in order to # active rehashing the main dictionaries, freeing memory when possible. # # If unsure: # use "activerehashing no" if you have hard latency requirements and it is # not a good thing in your environment that Redis can reply form time to time # to queries with 2 milliseconds delay. # # use "activerehashing yes" if you don't have such hard requirements but # want to free memory asap when possible. activerehashing yes # The client output buffer limits can be used to force disconnection of clients # that are not reading data from the server fast enough for some reason (a # common reason is that a Pub/Sub client can't consume messages as fast as the # publisher can produce them). # # The limit can be set differently for the three different classes of clients: # # normal -> normal clients # slave -> slave clients and MONITOR clients # pubsub -> clients subscribed to at least one pubsub channel or pattern # # The syntax of every client-output-buffer-limit directive is the following: # # client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds> # # A client is immediately disconnected once the hard limit is reached, or if # the soft limit is reached and remains reached for the specified number of # seconds (continuously). # So for instance if the hard limit is 32 megabytes and the soft limit is # 16 megabytes / 10 seconds, the client will get disconnected immediately # if the size of the output buffers reach 32 megabytes, but will also get # disconnected if the client reaches 16 megabytes and continuously overcomes # the limit for 10 seconds. # # By default normal clients are not limited because they don't receive data # without asking (in a push way), but just after a request, so only # asynchronous clients may create a scenario where data is requested faster # than it can read. # # Instead there is a default limit for pubsub and slave clients, since # subscribers and slaves receive data in a push fashion. # # Both the hard or the soft limit can be disabled by setting them to zero. client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 # Redis calls an internal function to perform many background tasks, like # closing connections of clients in timeout, purging expired keys that are # never requested, and so forth. # # Not all tasks are performed with the same frequency, but Redis checks for # tasks to perform accordingly to the specified "hz" value. # # By default "hz" is set to 10. Raising the value will use more CPU when # Redis is idle, but at the same time will make Redis more responsive when # there are many keys expiring at the same time, and timeouts may be # handled with more precision. # # The range is between 1 and 500, however a value over 100 is usually not # a good idea. Most users should use the default of 10 and raise this up to # 100 only in environments where very low latency is required. hz 10 # When a child rewrites the AOF file, if the following option is enabled # the file will be fsync-ed every 32 MB of data generated. This is useful # in order to commit the file to the disk more incrementally and avoid # big latency spikes. aof-rewrite-incremental-fsync yes
設定項目
サイズを指定する際、kb、mbなど単位を指定することができる。
指定しない場合、バイトとなる。
なお、大文字で指定することも可能。
基本設定
- logfile
- pidfile
/var/run/redis.pid
- dbfilename
dump.rdb
- unixsocket
- dir <作業ディレクトリパス>
作業ディレクトリ。データを保存する際はここに書き込まれる。
以下のようにすることで、サーバ起動時のカレントディレクトリとすることも可能
./
- bind <IPアドレス> […]
接続を受け付けるIPアドレスを指定する。
- requirepass <パスワード>
アクセス時に必要なパスワード。
指定しない場合、パスワードは不要となる。
- port
6379
- daemonize
no
- loglevel
notice
性能
- maxmemory
0 - maxmemory-samples
3 - timeout
0 - tcp-keepalive
0 - maxclients
3984
RDB(Redis DataBase)ダンプ
AOF(Append Only File)
AOFによる永続化設定。
- appendonly <yes|no>
AOFを有効にする - appendfsync
- everysec
毎秒毎に書き込みが行われる。 - always
毎クエリー毎に書き込みが行われる。 - no
Redis側で書き込みを制御せず、OS側が制御するタイミングで書き込まれる
- everysec
- auto-aof-rewrite-percentage <前回rewrite時サイズ比>
前回rewriteが行われた際のサイズと比較して現在のログサイズが指定した割合以上であれば、rewriteが実施される。 - auto-aof-rewrite-min-size <ログサイズ>
rewriteを行うことができる、最小のログファイルサイズ。
auto-aof-rewrite-percentageによってrewriteが頻繁に行われすぎてしまうことを防ぐ。 - aof-rewrite-incremental-fsync (yes|no)
ファイルをディスクに書き込む際、32MBに毎に書き込み(fsync)を実施する。
これによって、大量にファイル書き込みする際もディスクアクセスの遅延を緩和できる。 - appendfilename “<ファイル名>”
AOFとして書き込むファイル名。
- デフォルト
appendfilename "appendonly.aof"
レプリケーション
- masterauth
- slave-priority
100 - min-slaves-to-write
0 - min-slaves-max-lag
10
- slaveof
- slave-serve-stale-data
yes - slave-read-only
yes
- repl-ping-slave-period
10 - repl-timeout
60 - repl-backlog-size
1048576 - repl-backlog-ttl
3600
Lua script
- lua-time-limit
5000
Slow Log
- 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
- databases <DB数>
データベース数
- watchdog-period
0
- hz <秒間処理回数>
コネクション破棄のようなバックグラウンド処理を行う秒間の回数。
1から500まで設定可能であるが、100以上は設定を避けるべきである。 - no-appendfsync-on-rewrite
no
- stop-writes-on-bgsave-error
yes
- rdbcompression
yes - rdbchecksum
yes - activerehashing
yes - repl-disable-tcp-nodelay
no
- maxmemory-policy
volatile-lru
- save
3600 1 300 100 60 10000
- client-output-buffer-limit
normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60 - unixsocketperm
0
- notify-keyspace-events
インストール時デフォルト
- dbfilename
dump.rdb
- requirepass
- masterauth
- unixsocket
- logfile
- pidfile
/var/run/redis.pid
- maxmemory
0
- maxmemory-samples
3
- timeout
0
- tcp-keepalive
0
- auto-aof-rewrite-percentage
100
- auto-aof-rewrite-min-size
1048576
- 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
- lua-time-limit
5000
- slowlog-log-slower-than
10000
- slowlog-max-len
128
- port
6379
- databases
16
- repl-ping-slave-period
10
- repl-timeout
60
- repl-backlog-size
1048576
- repl-backlog-ttl
3600
- maxclients
3984
- watchdog-period
0
- slave-priority
100
- min-slaves-to-write
0
- min-slaves-max-lag
10
- hz
10
- no-appendfsync-on-rewrite
no
- slave-serve-stale-data
yes
- slave-read-only
yes
- stop-writes-on-bgsave-error
yes
- daemonize
no
- rdbcompression
yes
- rdbchecksum
yes
- activerehashing
yes
- repl-disable-tcp-nodelay
no
- aof-rewrite-incremental-fsync
yes
- appendonly
no
- dir
./
- maxmemory-policy
volatile-lru
- appendfsync
everysec
- save
3600 1 300 100 60 10000
- loglevel
notice
- client-output-buffer-limit
normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60
- unixsocketperm
0
- slaveof
- notify-keyspace-events
- bind
全て可能
ツール
redis-server
Redisのサーバプログラム
書式
redis-server [設定ファイルパス] [オプション]
- オプション
- -v –version
バージョン情報を表示し、終了する - –port <ポート番号>
- -v –version
- –slaveof <マスターサーバIPアドレス> <ポート番号>
- –loglevel <ログレベル>
- verbose
- debug
- notice
- warning
redis-cli
参考:http://redis.io/commands
- 使用方法
redis-cli 2.8.4 Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]] -h <hostname> Server hostname (default: 127.0.0.1) -p <port> Server port (default: 6379) -s <socket> Server socket (overrides hostname and port) -a <password> Password to use when connecting to the server -r <repeat> Execute specified command N times -i <interval> When -r is used, waits <interval> seconds per command. It is possible to specify sub-second times like -i 0.1 -n <db> Database number -x Read last argument from STDIN -d <delimiter> Multi-bulk delimiter in for raw formatting (default: \n) -c Enable cluster mode (follow -ASK and -MOVED redirections) --raw Use raw formatting for replies (default when STDOUT is not a tty) --csv Output in CSV format --latency Enter a special mode continuously sampling latency --latency-history Like --latency but tracking latency changes over time. Default time interval is 15 sec. Change it using -i. --slave Simulate a slave showing commands received from the master --rdb <filename> Transfer an RDB dump from remote server to local file. --pipe Transfer raw Redis protocol from stdin to server --pipe-timeout <n> In --pipe mode, abort with error if after sending all data no reply is received within <n> seconds. Default timeout: 30. Use 0 to wait forever. --bigkeys Sample Redis keys looking for big keys --eval <file> Send an EVAL command using the Lua script at <file> --help Output this help and exit --version Output version and exit Examples: cat /etc/passwd | redis-cli -x set mypasswd redis-cli get mypasswd redis-cli -r 100 lpush mylist x redis-cli -r 100 -i 1 info | grep used_memory_human: redis-cli --eval myscript.lua key1 key2 , arg1 arg2 arg3 (Note: when using --eval the comma separates KEYS[] from ARGV[] items) When no command is given, redis-cli starts in interactive mode. Type "help" in interactive mode for information on available commands.
Key系サブコマンド
- DEL key [key …]
Delete a key - DUMP key
Return a serialized version of the value stored at the specified key. - EXISTS key
Determine if a key exists - EXPIRE key seconds
Set a key’s time to live in seconds - EXPIREAT key timestamp
Set the expiration for a key as a UNIX timestamp - KEYS pattern
指定したパターンに合致する全てのキーを取得する。
ワイルドカード(“*”)を指定することで、全てのキーを取得可能。 - MIGRATE host port key destination-db timeout [COPY] [REPLACE]
Atomically transfer a key from a Redis instance to another one. - MOVE key db
Move a key to another database - OBJECT subcommand [arguments [arguments …]]
Inspect the internals of Redis objects - PERSIST key
Remove the expiration from a key - PEXPIRE key milliseconds
Set a key’s time to live in milliseconds - PEXPIREAT key milliseconds-timestamp
Set the expiration for a key as a UNIX timestamp specified in milliseconds - PTTL key
Get the time to live for a key in milliseconds - RANDOMKEY
Return a random key from the keyspace - RENAME key newkey
Rename a key - RENAMENX key newkey
Rename a key, only if the new key does not exist - RESTORE key ttl serialized-value
Create a key using the provided serialized value, previously obtained using DUMP. - SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern …]] [ASC|DESC] [ALPHA] [STORE destination]
Sort the elements in a list, set or sorted set - TTL key
Get the time to live for a key - TYPE key
Determine the type stored at key - SCAN cursor [MATCH pattern] [COUNT count]
Incrementally iterate the keys space
String系サブコマンド
- APPEND key value
指定した値を指定したキーの値の後に連結する。
値が保存されていない場合は、指定した値のみを保存する。 - BITCOUNT key start end [start end …]
Count set bits in a string - BITOP operation destkey key [key …]
Perform bitwise operations between strings - BITPOS key bit [start] [end]
Find first bit set or clear in a string - DECR key
Decrement the integer value of a key by one - DECRBY key decrement
Decrement the integer value of a key by the given number - GET key
指定したキーの値を取得する - GETBIT key offset
Returns the bit value at offset in the string value stored at key - GETRANGE key start end
Get a substring of the string stored at a key - GETSET key value
Set the string value of a key and return its old value - INCR key
Increment the integer value of a key by one - INCRBY key increment
Increment the integer value of a key by the given amount - INCRBYFLOAT key increment
Increment the float value of a key by the given amount - MGET key [key …]
Get the values of all the given keys - MSET key value [key value …]
Set multiple keys to multiple values - MSETNX key value [key value …]
Set multiple keys to multiple values, only if none of the keys exist - PSETEX key milliseconds value
Set the value and expiration in milliseconds of a key - SET key value [EX seconds] [PX milliseconds] [NX|XX]
Set the string value of a key - SETBIT key offset value
Sets or clears the bit at offset in the string value stored at key - SETEX key seconds value
Set the value and expiration of a key - SETNX key value
Set the value of a key, only if the key does not exist - SETRANGE key offset value
Overwrite part of a string at key starting at the specified offset - STRLEN key
Get the length of the value stored in a key
Hash系サブコマンド
- HDEL key field [field …]
Delete one or more hash fields - HEXISTS key field
Determine if a hash field exists - HGET key field
Get the value of a hash field - HGETALL key
Get all the fields and values in a hash - HINCRBY key field increment
Increment the integer value of a hash field by the given number - HINCRBYFLOAT key field increment
Increment the float value of a hash field by the given amount - HKEYS key
Get all the fields in a hash - HLEN key
Get the number of fields in a hash - HMGET key field [field …]
Get the values of all the given hash fields - HMSET key field value [field value …]
Set multiple hash fields to multiple values - HSET key field value
Set the string value of a hash field - HSETNX key field value
Set the value of a hash field, only if the field does not exist - HVALS key
Get all the values in a hash - HSCAN key cursor [MATCH pattern] [COUNT count]
Incrementally iterate hash fields and associated values
List系サブコマンド
- BLPOP key [key …] timeout
Remove and get the first element in a list, or block until one is available - BRPOP key [key …] timeout
Remove and get the last element in a list, or block until one is available - BRPOPLPUSH source destination timeout
Pop a value from a list, push it to another list and return it; or block until one is available - LINDEX key index
Get an element from a list by its index - LINSERT key BEFORE|AFTER pivot value
Insert an element before or after another element in a list - LLEN key
Get the length of a list - LPOP key
Remove and get the first element in a list - LPUSH key value [value …]
Prepend one or multiple values to a list - LPUSHX key value
Prepend a value to a list, only if the list exists - LRANGE key start stop Get a range of elements from a list
- LREM key count value
Remove elements from a list - LSET key index value
Set the value of an element in a list by its index - LTRIM key start stop
Trim a list to the specified range - RPOP key
Remove and get the last element in a list - RPOPLPUSH source destination
Remove the last element in a list, append it to another list and return it - RPUSH key value [value …]
Append one or multiple values to a list - RPUSHX key value
Append a value to a list, only if the list exists
Set系サブコマンド
- SADD key member [member …]
Add one or more members to a set - SCARD key
Get the number of members in a set - SDIFF key [key …]
Subtract multiple sets - SDIFFSTORE destination key [key …]
Subtract multiple sets and store the resulting set in a key - SINTER key [key …]
Intersect multiple sets - SINTERSTORE destination key [key …]
Intersect multiple sets and store the resulting set in a key - SISMEMBER key member
Determine if a given value is a member of a set - SMEMBERS key
Get all the members in a set - SMOVE source destination member
Move a member from one set to another - SPOP key
Remove and return a random member from a set - SRANDMEMBER key [count]
Get one or multiple random members from a set - SREM key member [member …]
Remove one or more members from a set - SUNION key [key …]
Add multiple sets - SUNIONSTORE destination key [key …]
Add multiple sets and store the resulting set in a key - SSCAN key cursor [MATCH pattern] [COUNT count]
Incrementally iterate Set elements
Sorted Set系サブコマンド
- ZADD key score member [score member …]
Add one or more members to a sorted set, or update its score if it already exists - ZCARD key
Get the number of members in a sorted set - ZCOUNT key min max
Count the members in a sorted set with scores within the given values - ZINCRBY key increment member
Increment the score of a member in a sorted set - ZINTERSTORE destination numkeys key [key …] [WEIGHTS weight [weight …]] [AGGREGATE SUM|MIN|MAX]
Intersect multiple sorted sets and store the resulting sorted set in a new key - ZLEXCOUNT key min max
Count the number of members in a sorted set between a given lexicographical range - ZRANGE key start stop [WITHSCORES]
Return a range of members in a sorted set, by index - ZRANGEBYLEX key min max [LIMIT offset count]
Return a range of members in a sorted set, by lexicographical range - ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]
Return a range of members in a sorted set, by score - ZRANK key member
Determine the index of a member in a sorted set - ZREM key member [member …]
Remove one or more members from a sorted set - ZREMRANGEBYLEX key min max
Remove all members in a sorted set between the given lexicographical range - ZREMRANGEBYRANK key start stop
Remove all members in a sorted set within the given indexes - ZREMRANGEBYSCORE key min max
Remove all members in a sorted set within the given scores - ZREVRANGE key start stop [WITHSCORES]
Return a range of members in a sorted set, by index, with scores ordered from high to low - ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]
Return a range of members in a sorted set, by score, with scores ordered from high to low - ZREVRANK key member
Determine the index of a member in a sorted set, with scores ordered from high to low - ZSCORE key member
Get the score associated with the given member in a sorted set - ZUNIONSTORE destination numkeys key [key …] [WEIGHTS weight [weight …]] [AGGREGATE SUM|MIN|MAX]
Add multiple sorted sets and store the resulting sorted set in a new key - ZSCAN key cursor [MATCH pattern] [COUNT count]
Incrementally iterate sorted sets elements and associated scores
HyperLogLog系サブコマンド
- PFADD key element [element …]
Adds the specified elements to the specified HyperLogLog. - PFCOUNT key [key …]
Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s). - PFMERGE destkey sourcekey [sourcekey …]
Merge N different HyperLogLogs into a single one.
Pub/Sub系サブコマンド
- PSUBSCRIBE pattern [pattern …]
Listen for messages published to channels matching the given patterns - PUBSUB subcommand [argument [argument …]]
Inspect the state of the Pub/Sub subsystem - PUBLISH channel message
Post a message to a channel - PUNSUBSCRIBE [pattern [pattern …]]
Stop listening for messages posted to channels matching the given patterns - SUBSCRIBE channel [channel …]
Listen for messages published to the given channels - UNSUBSCRIBE [channel [channel …]]
Stop listening for messages posted to the given channels
Transaction系サブコマンド
- DISCARD
Discard all commands issued after MULTI - EXEC
Execute all commands issued after MULTI - MULTI
Mark the start of a transaction block - UNWATCH
Forget about all watched keys - WATCH key [key …]
Watch the given keys to determine execution of the MULTI/EXEC block
Scripting系サブコマンド
- EVAL script numkeys key [key …] arg [arg …]
Execute a Lua script server side - EVALSHA sha1 numkeys key [key …] arg [arg …]
Execute a Lua script server side - SCRIPT EXISTS script [script …]
Check existence of scripts in the script cache. - SCRIPT FLUSH
Remove all the scripts from the script cache. - SCRIPT KILL
Kill the script currently in execution. - SCRIPT LOAD script
Load the specified Lua script into the script cache.
Connection系サブコマンド
- AUTH password
Authenticate to the server - ECHO message
Echo the given string - PING
Ping the server - QUIT
Close the connection - SELECT index
Change the selected database for the current connection
Server系サブコマンド
- BGREWRITEAOF
Asynchronously rewrite the append-only file - BGSAVE
Asynchronously save the dataset to disk - CLIENT KILL ip:port
Kill the connection of a client - CLIENT LIST
Get the list of client connections - CLIENT GETNAME
Get the current connection name - CLIENT PAUSE timeout
Stop processing commands from clients for some time - CLIENT SETNAME connection-name
Set the current connection name - CONFIG GET parameter
指定したパラメータの設定を取得する。
アスタリスクを使用したワイルドカード指定も可能。
例えば、”*log*”とすることで、logを含んだパラメータを全て取得可能。
同様に、全てのパラメータを取得する場合は”*”で行える。
出力形式は次のように奇数番目に設定項目、偶数番目にその値となる。
1) "logfile" 2) ""
- CONFIG REWRITE
Rewrite the configuration file with the in memory configuration - CONFIG SET parameter value
Set a configuration parameter to the given value - CONFIG RESETSTAT
Reset the stats returned by INFO - DBSIZE
Return the number of keys in the selected database - DEBUG OBJECT key
Get debugging information about a key - DEBUG SEGFAULT
Make the server crash - FLUSHALL
全てのデータベースから全てのデータを削除する。 - FLUSHDB
現在のデータベースから全てのデータを削除する。 - INFO [section]
Get information and statistics about the server - LASTSAVE
Get the UNIX time stamp of the last successful save to disk - MONITOR
Listen for all requests received by the server in real time - SAVE
ディスクに現在のデータのダンプ(RDB)ファイルを保存する - SHUTDOWN [NOSAVE] [SAVE]
Synchronously save the dataset to disk and then shut down the server - SLAVEOF host port
Make the server a slave of another instance, or promote it as master - SLOWLOG subcommand [argument]
Manages the Redis slow queries log - SYNC
Internal command used for replication - TIME
Return the current server time
よく使うコマンド
- redisのステータスを確認する
redis-cli info
- 値をセットする
redis-cli set key1 val1
- 値を取得する
redis-cli get key1
- サーバの設定を確認する
redis-cli config get "*" | grep -A 1 daemonize
redis-check-aof
AOFのログファイルが壊れていないかチェックサムを確認する。
破損している場合、修復も可能
- チェック
redis-check-aof <AOFファイルパス>
- 修復
redis-check-aof --fix <AOFファイルパス>
redis-check-dump
RDSのダンプファイルが壊れていないかチェックサムを確認する
redis-check-dump <RDBファイルパス>
redis-benchmark
運用
RDBからAOFへの切り替え
- Make a backup of your latest dump.rdb file.
- Transfer this backup into a safe place.
- Issue the following two commands:
- redis-cli config set appendonly yes
- redis-cli config set save “”
- Make sure that your database contains the same number of keys it contained.
- Make sure that writes are appended to the append only file correctly.
PHPライブラリ
使用方法:https://github.com/nicolasff/phpredis/#usage
インストール
- 最新版のURLを取得する
http://pecl.php.net/package/redis - ダウンロードする
wget http://pecl.php.net/get/redis -O redis.tgz
- 展開する
tar xvzf redis.tgz cd redis-*
- コンパイル、インストールする
phpize ./configure make make install
- リンクする
vi $PHP_HOME/lib/php.ini
以下を追記
extension=redis.so