LoginSignup
13
11

More than 5 years have passed since last update.

redisの環境構築(mac marvericks)

Last updated at Posted at 2014-05-07

homebrewでインストールする。

自分はmacで起動時に自動起動させたいのでlaunchctlに設定する。

参考
http://qiita.com/checkpoint/items/58b9b0193c0c46400eeb

$ brew install redis
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/redis-2.8.8.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring redis-2.8.8.mavericks.bottle.tar.gz
==> Caveats
To have launchd start redis at login:
    ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Then to load redis now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Or, if you don't want/need launchctl, you can just run:
    redis-server /usr/local/etc/redis.conf
==> Summary
?  /usr/local/Cellar/redis/2.8.8: 10 files, 1.3M

$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

多分多くの人はここまでやればエラーなく起動できると思います。
しかし自分の場合はエラーが起きてしまいました。

なんか上手く起動できなかったので原因を調べる。

$ redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> 

$  redis-server /usr/local/etc/redis.conf

*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 369
>>> 'vm-enabled no'
Bad directive or wrong number of arguments

/usr/local/Cellar/redis/を見るとだいぶ昔にインストールしてた2.4.6が入ってた。

設定ファイルを見てみるとタイムスタンプが2012年ぐらいの時間だった。
上のエラーを見ると2.4.6の時の設定ファイルがそのまま今新しくいれた2.8.8を起動する時に読み込まれている感じだろうと思った。

そのため一旦redisを全てremoveして、設定ファイル(/usr/local/etc/redis.conf, /usr/local/etc/redis-sentinel.conf)を削除した後もう一度redisをインストールしなおした。

$ brew remove redis
Uninstalling /usr/local/Cellar/redis/2.8.8...
$ brew remove redis
Uninstalling /usr/local/Cellar/redis/2.4.6...

$ rm /usr/local/etc/redis.conf /usr/local/etc/redis-sentinel.conf

$ brew install redis
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/redis-2.8.8.mavericks.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/redis-2.8.8.mavericks.bottle.tar.gz
==> Pouring redis-2.8.8.mavericks.bottle.tar.gz
==> Caveats
To reload redis after an upgrade:
    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
==> Summary
?  /usr/local/Cellar/redis/2.8.8: 10 files, 1.3M

$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

ここまでやってコマンドライン上で挙動を確認したらうまく動作しました。

$ redis-cli
127.0.0.1:6379> set keyfuga fugafuga
OK
127.0.0.1:6379> get keyfuga
"fugafuga"
127.0.0.1:6379> keys *
1) "keyfuga"

13
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
11