温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

安装redis(3.2.9)

发布时间:2020-03-31 15:52:23 来源:网络 阅读:1064 作者:Innocence_caosm 栏目:数据库

安装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.执行安装脚本进行安装

[root@caosm103 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.服务开启状态


[root@caosm103 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


[root@caosm103 src]# wget http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
[root@caosm103 src]# tar zxf apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
[root@caosm103 src]# mv apps/sys-utils/start-stop-daemon-IR1_9_18-2/ ./
[root@caosm103 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
[root@caosm103 src]# rm -rf apps
[root@caosm103 src]# cd start-stop-daemon-IR1_9_18-2/
[root@caosm103 start-stop-daemon-IR1_9_18-2]# cc start-stop-daemon.c -o start-stop-daemon
[root@caosm103 start-stop-daemon-IR1_9_18-2]# cp start-stop-daemon /usr/local/bin/start-stop-daemon

start-stop-demo 参数介绍
root@caosm103 redis]# start-stop-daemon --help
start-stop-daemon 1.9.18 for Debian - small and fast C version written by
Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>, 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.启动测试:


[root@caosm103 redis]# /etc/init.d/redis-server stop
Stopping redis-server: [OK]
[root@caosm103 redis]# /etc/init.d/redis-server start
Starting redis-server: [OK]
[root@caosm103 redis]#
[root@caosm103 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 服务端


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI