LoginSignup
1
1

More than 5 years have passed since last update.

Redis 2.8.24 をソースからインストールする

Last updated at Posted at 2016-04-25

Redis 2.8.24をソースインストールします。
OSは、Ubuntu 14.04.3 LTSを使います。

1.インストールする前に

下記コマンドを実行しておきます。

sudo apt-get update
sudo apt-get install -y tcl

2.ソースファイルのダウンロード・解凍

ソースファイルは http://redis.io/download からダウンロードします。

$ cd /usr/local/src
$ sudo wget http://download.redis.io/releases/redis-2.8.24.tar.gz
$ sudo tar zxvf redis-2.8.24.tar.gz

3.インストール

redisユーザーを作成し、redisをインストールします。

$ sudo useradd -s /bin/false -M redis
$ cd /usr/local/src/redis-2.8.24
$ sudo make
$ sudo make install

install_server.shを実行し、redisの設定ファイルを作成します。

$ cd /usr/local/src/redis-2.8.24/utils
$ sudo ./install_server.sh
  Welcome to the redis service installer
  This script will help you easily set up a running redis server

  Please select the redis port for this instance: [6379]
  Selecting default: 6379
  Please select the redis config file name [/etc/redis/6379.conf]
  Selected default - /etc/redis/6379.conf
  Please select the redis log file name [/var/log/redis_6379.log]
  Selected default - /var/log/redis_6379.log
  Please select the data directory for this instance [/var/lib/redis/6379]
  Selected default - /var/lib/redis/6379
  Please select the redis executable path [/usr/local/bin/redis-server]
  Selected config:
  Port           : 6379
  Config file    : /etc/redis/6379.conf
  Log file       : /var/log/redis_6379.log
  Data dir       : /var/lib/redis/6379
  Executable     : /usr/local/bin/redis-server
  Cli Executable : /usr/local/bin/redis-cli
  Is this ok? Then press ENTER to go on or Ctrl-C to abort.
  Copied /tmp/6379.conf => /etc/init.d/redis_6379
  Installing service...
   System start/stop links for /etc/init.d/redis_6379 already exist.
  Success!
  /var/run/redis_6379.pid exists, process is already running or crashed
  Installation successful!

install_server.shに対する応答は、全部Enterを入力しました。
ここまで作業が完了すればredisが起動しているはずなので、起動確認をしましょう。

$ sudo service redis_6379 status
  Redis is running (26622)

redisが起動していますね。

4.インストール(一部のみインストール)

「3.インストール」だと全てのredisのパッケージをインストールする事になります。redis-cliなど、一部のパッケージをインストールしたい場合のインストール方法を記載しておきます。

redis-cli、redis-benchmark、redis-check-aof、redis-check-dumpをインストールします。「2.ソースファイルのダウンロード・解凍」を実施した後に、下記コマンドを実行してください。

$ sudo useradd -s /bin/false -M redis
$ cd /usr/local/src/redis-2.8.24/src
$ sudo make redis-benchmark
$ sudo make redis-cli
$ sudo make redis-check-aof
$ sudo make redis-check-dump
$ sudo cp -pf redis-benchmark /usr/local/bin/
$ sudo cp -pf redis-cli /usr/local/bin/
$ sudo cp -pf redis-check-aof /usr/local/bin/
$ sudo cp -pf redis-check-dump /usr/local/bin/

「redis-」と入力した後に、tabキーを入力します。

$ redis-
  redis-benchmark   redis-check-aof   redis-check-dump  redis-cli

redis-cliで軽くコマンドを叩いてみましょう。

$ redis-cli --version
  redis-cli 2.8.24
$ redis-cli --help
  redis-cli 2.8.24

  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).
    --no-raw           Force formatted output even when STDOUT is not a tty.
    --csv              Output in CSV format.
    --stat             Print rolling stats about server: mem, clients, ...
    --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.
    --latency-dist     Shows latency as a spectrum, requires xterm 256 colors.
                       Default time interval is 1 sec. Change it using -i.
    --lru-test <keys>  Simulate a cache workload with an 80-20 distribution.
    --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.
    --scan             List all keys using the SCAN command.
    --pattern <pat>    Useful with --scan to specify a SCAN pattern.
    --intrinsic-latency <sec> Run a test to measure intrinsic system latency.
                       The test will run for the specified amount of seconds.
    --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
    redis-cli --scan --pattern '*:12345*'

    (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.
1
1
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
1
1