码迷,mamicode.com
首页 > 其他好文 > 详细

编译安装redis

时间:2016-09-17 12:03:09      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

本文用于描述redis的编译安装

1、上传源码包到linux 服务器上;我已经上传到了root目录下:/root/redis-3.2.3.tar.gz

ll /root/ | grep redis.*gz
-rw-r--r--  1 root root    1541401 9月  17 18:37 redis-3.2.3.tar.gz

 

2、解压

tar -xzvf redis-3.2.3.tar.gz
ll /root/ | grep redis
drwxrwxr-x  6 root root       4096 8月   2 17:00 redis-3.2.3
-rw-r--r--  1 root root    1541401 9月  17 18:37 redis-3.2.3.tar.gz

 

3、make 这里可以直接make 是因为redis已经自己写好了make file 了;也就是说不用再执行configure 了、make 后编译好的文件会保存到src目录下

cd /root/redis-3.2.3
make
ll
总用量 196
-rw-rw-r--  1 root root 75147 8月   2 17:00 00-RELEASENOTES
-rw-rw-r--  1 root root    53 8月   2 17:00 BUGS
-rw-rw-r--  1 root root  1805 8月   2 17:00 CONTRIBUTING
-rw-rw-r--  1 root root  1487 8月   2 17:00 COPYING
drwxrwxr-x  7 root root  4096 9月  17 18:38 deps
-rw-rw-r--  1 root root    11 8月   2 17:00 INSTALL
-rw-rw-r--  1 root root   151 8月   2 17:00 Makefile
-rw-rw-r--  1 root root  4223 8月   2 17:00 MANIFESTO
-rw-rw-r--  1 root root  6834 8月   2 17:00 README.md
-rw-rw-r--  1 root root 46695 8月   2 17:00 redis.conf
-rwxrwxr-x  1 root root   271 8月   2 17:00 runtest
-rwxrwxr-x  1 root root   280 8月   2 17:00 runtest-cluster
-rwxrwxr-x  1 root root   281 8月   2 17:00 runtest-sentinel
-rw-rw-r--  1 root root  7109 8月   2 17:00 sentinel.conf
drwxrwxr-x  2 root root  4096 9月  17 18:39 src
drwxrwxr-x 10 root root  4096 8月   2 17:00 tests
drwxrwxr-x  7 root root  4096 8月   2 17:00 utils

 

4、make install 这一步会把src 目录下的二进制文件复制到/usr/local/bin/ 目录下;由于把文件保存到/usr/local/bin/目录下的方式不方便管理,于是我们把文件统一保存到

   /usr/local/redis/bin/目录下

mkdir -p /usr/local/redis/bin/
cd src
cp redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server redis-trib.rb /usr/local/redis/bin/

 

5、给redis提供一个启动脚本

#!/bin/bash

#chkconfig: 2345 50 50
#description: redis-server init scripts

server_exec=/usr/local/redis/bin/redis-server
pid_file=/usr/local/redis/redis_server.pid
port=6379

case $1 in

"start")
    if test -e $pid_file
    then
        echo "redisd has been started"
    else
        echo "start redisd ..."
        $server_exec --port $port --pidfile $pid_file &
    fi
;;

"stop")
    if test -e $pid_file
    then
        echo "will to stop redisd..."
        pid=`cat $pid_file`
        kill $pid
    else
        echo "redisd has been stop"
    fi
;;

"*")
    echo "not suport argument $1"
;;
esac

 

6、启动redisd

service redisd start

 

7、修改环境变量

export PATH=/usr/local/redis/bin:$PATH

 

编译安装redis

标签:

原文地址:http://www.cnblogs.com/JiangLe/p/5878160.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!