redisインストールマニュアル
インストールの準備
環境:CentOS release 6.8
今回のインストールバージョン:redis-3.2.7
redis tarパッケージダウンロード
コンパイル中、エラーが発生する可能性があります.エラーは以下の通りです.次のステップを報告しないと無視できます.
clock_gettimeはリアルタイムライブラリlibrt(real time)にあり、このライブラリにリンクしていないためエラーが発生します.
Makefileファイルにダイナミックリンクライブラリlibrt(-lrt)を追加し、新しくコンパイルする必要があります.
librt.を見つけたsoパス
その後、redis解凍パスの下でMakefileを見つけ、編集を追加します.
:set nuは108行を見つけ、108行の下に1行の内容を追加します.
コンパイルが通過したら、インストールパスを設定してインストールします
その後、ソフト接続を設定し、バージョン番号を削除して起動しやすくしました.
ソフト接続redisパスの下で、redisプロファイルredis.conf解凍下redis-3.2.7フォルダからコピー
環境変数の設定
以上の手順redisはインストール済みで、その後起動します.
redisが正常にインストールされたことを示します.
プロセスとポートを確認します.
redisサービスを閉じる
環境:CentOS release 6.8
今回のインストールバージョン:redis-3.2.7
redis tarパッケージダウンロード
https://redis.io
[root@ppt tools]# tar xf redis-3.2.7.tar.gz
[root@ppt tools]# cd redis-3.2.7
[root@ppt redis-3.2.7]# less README.md ---> readme.md,
Selecting a non-default memory allocator when building Redis is done by setting
the `MALLOC` environment variable. Redis is compiled and linked against libc
malloc by default, with the exception of jemalloc being the default on Linux
systems. This default was picked because jemalloc has proven to have fewer
fragmentation problems than libc malloc.
To force compiling against libc malloc, use:
% make MALLOC=libc
To compile against jemalloc on Mac OS X systems, use:
% make MALLOC=jemalloc
Verbose build
-------------
[root@ppt redis-3.2.7]# make MALLOC=jemalloc ---> jemalloc make
コンパイル中、エラーが発生する可能性があります.エラーは以下の通りです.次のステップを報告しないと無視できます.
undefined reference to `clock_gettime'
clock_gettimeはリアルタイムライブラリlibrt(real time)にあり、このライブラリにリンクしていないためエラーが発生します.
Makefileファイルにダイナミックリンクライブラリlibrt(-lrt)を追加し、新しくコンパイルする必要があります.
[root@ppt redis-3.2.7]# find / -name '*librt*'
/usr/lib64/librt.a
/usr/lib64/librt.so
/usr/lib/librt.a
/usr/lib/x86_64-redhat-linux5E/lib64/librt.a
/usr/lib/x86_64-redhat-linux5E/lib64/librt.so
/lib64/rtkaio/librtkaio-2.12.so
/lib64/rtkaio/librt.so.1
/lib64/librt-2.12.so
/lib64/librt.so.1
/lib/rtkaio/librtkaio-2.12.so
/lib/rtkaio/librt.so.1
/lib/rtkaio/i686/nosegneg/librtkaio-2.12.so
/lib/rtkaio/i686/nosegneg/librt.so.1
/lib/librt-2.12.so
/lib/librt.so.1
/lib/i686/nosegneg/librt-2.12.so
/lib/i686/nosegneg/librt.so.1
librt.を見つけたsoパス
[root@ppt redis-3.2.7]# ll /usr/lib64/librt.so
lrwxrwxrwx. 1 root root 22 Nov 9 11:48 /usr/lib64/librt.so -> ../../lib64/librt.so.1
その後、redis解凍パスの下でMakefileを見つけ、編集を追加します.
/app/tools/redis-3.2.7/src
[root@ppt src]# vim Makefile
:set nuは108行を見つけ、108行の下に1行の内容を追加します.
FINAL_LIBS+= /usr/lib64/librt.so
ifeq ($(MALLOC),jemalloc)
DEPENDENCY_TARGETS+= jemalloc
FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include
FINAL_LIBS+= ../deps/jemalloc/lib/libjemalloc.a
FINAL_LIBS+= /usr/lib64/librt.so --->
endif
コンパイルが通過したら、インストールパスを設定してインストールします
make PREFIX=/app/redis-3.2.7 install ---> redis /app/redis-3.2.7
その後、ソフト接続を設定し、バージョン番号を削除して起動しやすくしました.
ln -s /app/redis-3.2.7/ app/redis
ソフト接続redisパスの下で、redisプロファイルredis.conf解凍下redis-3.2.7フォルダからコピー
[root@ppt redis]# mkdir conf ---> redis conf
[root@ppt conf]# cp /app/tools/redis-3.2.7/redis.conf /app/redis/conf/
[root@ppt conf]# sysctl vm.overcommit_memory=1
環境変数の設定
[root@ppt conf]# echo "export PATH=/app/redis/bin:$PATH" >> /etc/profile
[root@ppt conf]# source /etc/profile
以上の手順redisはインストール済みで、その後起動します.
[root@ppt ~]# redis-server /app/redis/conf/redis.conf &
[1] 5395
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2.7 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 5395
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
5395:M 10 Feb 10:34:20.747 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
5395:M 10 Feb 10:34:20.747 # Server started, Redis version 3.2.7
5395:M 10 Feb 10:34:20.747 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
5395:M 10 Feb 10:34:20.747 * The server is now ready to accept connections on port 6379
redisが正常にインストールされたことを示します.
プロセスとポートを確認します.
[root@ppt ~]# ps -ef | grep redis
root 5395 1955 0 10:34 pts/0 00:00:00 redis-server 127.0.0.1:6379
root 5527 1955 0 10:36 pts/0 00:00:00 grep redis
[root@ppt ~]# netstat -anp | grep 6379
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 5395/redis-server 1
redisサービスを閉じる
[root@ppt ~]# redis-cli shutdown
5395:M 10 Feb 10:37:17.969 # User requested shutdown...
5395:M 10 Feb 10:37:17.969 * Saving the final RDB snapshot before exiting.
5395:M 10 Feb 10:37:18.047 * DB saved on disk
5395:M 10 Feb 10:37:18.047 * Removing the pid file.
5395:M 10 Feb 10:37:18.047 # Redis is now ready to exit, bye bye...
[1]+ Done redis-server /app/redis/conf/redis.conf