安装redis(3.2.9)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装redis(3.2.9)相关的知识,希望对你有一定的参考价值。

安装redis(3.2.9)

1.redis 官网地址:https://redis.io/

2.部署安装redis3.2.9   实验环境:centos 6.5

wget http://download.redis.io/releases/redis-3.2.9.tar.gz
yum install automake autoconf ruby rubygems -y #安装依赖插件
make && make install  #这里使用的是默认安装

3.创建相对应的目录


mkdir -p /usr/local/redis/bin/
mkdir /usr/local/redis/ && mkdir -p /data/redis/

4.执行安装脚本进行安装

[[email protected] utils]# ./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] 6379
Please select the redis config file name [/etc/redis/redis.conf] /usr/local/redis/redis_6378.conf  
Please select the redis log file name [/var/log/redis_6379.log] /usr/local/redis/redis_6378.log
Please select the data directory for this instance [/var/lib/redis/6379] /data/redis/
Please select the redis executable path [/usr/local/bin/redis-server] /usr/local/redis_6379/bin
Selected config:
Port           : 6379
Config file    : /usr/local/redis/redis.conf
Log file       : /usr/local/redis/redis_6379.log
Data dir       : /data/redis/
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.

5.服务开启状态


[[email protected] redis]# redis-server  redis.conf  
#程序 配置文件配置文件这里bind ip 地址改成了本机的ip地址

6.修改启动脚本


#! /bin/sh
### BEGIN INIT INFO
# Provides:     redis-server
# Required-Start:   $syslog
# Required-Stop:    $syslog
# Should-Start:     $local_fs
# Should-Stop:      $local_fs
# Default-Start:    2 3 4 5
# Default-Stop:     0 1 6
# Short-Description:    redis-server - Persistent key-value db
# Description:      redis-server - Persistent key-value db
### END INIT INFO
### 注意 需要创建 redis 用户   redis.conf  redis_6379.pid redis_6379.log  /data/redis 所有者要改为redis,并赋予执行权限755  


PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/redis-server
DAEMON_ARGS=/usr/local/redis/redis.conf
NAME=redis-server
DESC=redis-server
PIDFILE=/var/run/redis_6379.pid

test -x $DAEMON || exit 0
test -x $DAEMONBOOTSTRAP || exit 0

set -e

case "$1" in
 start)
   echo -n "Starting $DESC: "
   touch $PIDFILE
   chown redis:redis $PIDFILE
   if start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS
   then
     echo "[OK]"
   else
     echo "failed"
   fi
   ;;
 stop)
   echo -n "Stopping $DESC: "
   if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
   then
     echo "[OK]"
   else
     echo "failed"
   fi
   rm -f $PIDFILE
   ;;
 status)
   if [ ! -r $PIDFILE ] ; then
     echo "redis-server is stopped"
     exit 0
   fi

   PID=`cat $PIDFILE`
   if ps -p $PID | grep -q $PID; then
     echo "redis-server (pid $PID) is running..."
   else
     echo "redis-server dead but pid file exists"
   fi
   ;;
 restart|force-reload)
   ${0} stop
   ${0} start
   ;;
 *)
   echo "Usage: /etc/init.d/$NAME {start|stop|restart|status|force-reload}" >&2
   exit 1
   ;;
esac

exit 0

7.安装start-stop-daemon


[[email protected] src]# wget http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
[[email protected] src]# tar zxf apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
[[email protected] src]# mv apps/sys-utils/start-stop-daemon-IR1_9_18-2/ ./
[[email protected] src]# ls
apps  apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz  nginx-1.8.0  redis-3.2.9  redis-3.2.9.tar.gz  start-stop-daemon-IR1_9_18-2
[[email protected] src]# rm -rf apps
[[email protected] src]# cd start-stop-daemon-IR1_9_18-2/
[[email protected] start-stop-daemon-IR1_9_18-2]# cc start-stop-daemon.c -o start-stop-daemon
[[email protected] start-stop-daemon-IR1_9_18-2]# cp start-stop-daemon /usr/local/bin/start-stop-daemon

start-stop-demo 参数介绍
[email protected] redis]# start-stop-daemon --help
start-stop-daemon 1.9.18 for Debian - small and fast C version written by
Marek Michalkiewicz <[email protected]>, public domain.

Usage:
 start-stop-daemon -S|--start options ... -- arguments ...
 start-stop-daemon -K|--stop options ...
 start-stop-daemon -H|--help
 start-stop-daemon -V|--version

Options (at least one of --exec|--pidfile|--user is required):
 -x|--exec <executable>        program to start/check if it is running
 -p|--pidfile <pid-file>       pid file to check
 -c|--chuid <name|uid[:group|gid]>
       change to this user/group before starting process
 -u|--user <username>|<uid>    stop processes owned by this user
 -n|--name <process-name>      stop processes with this name
 -s|--signal <signal>          signal to send (default TERM)
 -a|--startas <pathname>       program to start (default is <executable>)
 -N|--nicelevel <incr>         add incr to the process‘s nice level
 -b|--background               force the process to detach
 -m|--make-pidfile             create the pidfile before starting
 -R|--retry <schedule>         check whether processes die, and retry
 -t|--test                     test mode, don‘t do anything
 -o|--oknodo                   exit status 0 (not 1) if nothing done
 -q|--quiet                    be more quiet
 -v|--verbose                  be more verbose
Retry <schedule> is <item>|/<item>/... where <item> is one of
-<signal-num>|[-]<signal-name>  send that signal
<timeout>                       wait that many seconds
forever                         repeat remainder forever
or <schedule> may be just <timeout>, meaning <signal>/<timeout>/KILL/<timeout>

Exit status:  0 = done      1 = nothing done (=> 0 if --oknodo)
             3 = trouble   2 = with --retry, processes wouldn‘t die

8.启动测试:


[[email protected] redis]# /etc/init.d/redis-server stop
Stopping redis-server: [OK]
[[email protected] redis]# /etc/init.d/redis-server start
Starting redis-server: [OK]
[[email protected] redis]#
[[email protected] redis]# /etc/init.d/redis-server restart
Stopping redis-server: [OK]
Starting redis-server: [OK]
现在都能够正常进行运行!

9.redis工具介绍

redis-benchmark  性能测试工具
redis-check-aof  日志文件检测工(比如断电造成日志损坏,可以检测并修复)
redis-check-dump  快照文件检测工具,效果类上
redis-cli  客户端
redis-server 服务端


本文出自 “天真无邪” 博客,请务必保留此出处http://innocence.blog.51cto.com/4313888/1982244

以上是关于安装redis(3.2.9)的主要内容,如果未能解决你的问题,请参考以下文章

redis-3.2.9安装

centos7.0 安装redis 3.2.9

Centos 6.9 安装 Redis 3.2.9

linux安装redis

CentOS7上Redis安装与配置

1.Redis安装(Linux环境)