CentOS-6.5でredisサーバ構築

インストール

外部リポジトリに新しいパッケージがあるので、epelリポジトリを登録。

$ wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

# rpm -ivh epel-release-6-8.noarch.rpm

epelリポジトリを使ってインストール

# yum --enablerepo=epel install redis
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: ftp.jaist.ac.jp
 * epel: ftp.jaist.ac.jp
 * extras: ftp.jaist.ac.jp
 * updates: ftp.jaist.ac.jp
Setting up Install Process
Resolving Dependencies
    • > Running transaction check
      • > Package redis.x86_64 0:2.4.10-1.el6 will be installed
    • > Finished Dependency Resolution
Dependencies Resolved ================================================================================================================================================= Package Arch Version Repository Size ================================================================================================================================================= Installing: redis x86_64 2.4.10-1.el6 epel 213 k Transaction Summary ================================================================================================================================================= Install 1 Package(s) Total download size: 213 k Installed size: 668 k Is this ok [y/N]: y Downloading Packages: redis-2.4.10-1.el6.x86_64.rpm | 213 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : redis-2.4.10-1.el6.x86_64 1/1 Verifying : redis-2.4.10-1.el6.x86_64 1/1 Installed: redis.x86_64 0:2.4.10-1.el6 Complete!

起動

# /etc/init.d/redis start
redis-server を起動中:                                     [  OK  ]

動作確認

# /etc/init.d/redis status
redis-server (pid  2116) を実行中...

# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 127.0.0.1:6379              0.0.0.0:*                   LISTEN

〜〜
デフォルトではポート6379で動作するらしい

redis clientを使ってみる

redis本体と一緒にインストールされるredis clientでも動作確認

'foo'をhogeにセットしてゲット

$ redis-cli
redis 127.0.0.1:6379>

redis 127.0.0.1:6379> set hoge 'foo'
OK

redis 127.0.0.1:6379> get hoge
"foo"