安装redis(3.2.9)
admin
2023-05-21 18:02:22
0

安装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 , 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        program to start/check if it is running
 -p|--pidfile       pid file to check
 -c|--chuid
       change to this user/group before starting process
 -u|--user |    stop processes owned by this user
 -n|--name      stop processes with this name
 -s|--signal          signal to send (default TERM)
 -a|--startas       program to start (default is )
 -N|--nicelevel         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         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 is |//... where is one of
-|[-]  send that signal
                      wait that many seconds
forever                         repeat remainder forever
or may be just , meaning //KILL/

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 服务端


相关内容

热门资讯

洁丽雅报警,“私生子传闻造成严... 5月18日晚间,洁丽雅官方微博发布严正声明。声明提到,近日,网络上出现关于洁丽雅家居股份有限公司、董...
产学研共探规模化路径 量子科仪... 上证报中国证券网讯(记者 刘一枫)量子精密测量正加速跨越技术验证门槛,从“能不能用”的实验室探索,迈...
广西柳州再发生5.2级地震,震... 中国地震台网正式测定:05月18日21时44分在广西柳州市柳南区(北纬24.37度,东经109.26...
研究揭示:人们普遍认为AI比人... IT之家 5 月 18 日消息,如今,全球越来越多民众日常使用人工智能系统,尽管众多用户愿意相信人工...
红魔11S Pro正式发布:骁... 今天红魔11S Pro系列正式发布,发布后数码圈热度居高不下,不少网友直接给到电竞机皇的评价。作为常...
赖清德弹劾案19日举行投票,蓝... 海峡导报综合报道 台民意机构19日将举行赖清德弹劾案的记名投票,朝野甲级动员。中国国民党团今天(18...
小米18全员首发2nm芯片:安... 快科技5月18日消息,博主数码闲聊站最新爆料,今年下半年发布的旗舰机型中,只有小米和苹果两家的旗舰能...
文脉华章|草原文脉汇青城 多元... 央视网消息 金辉灼灼映草原,玉韵悠悠贯千年。5 月17 日,2026 年“5 ·18 国际博物馆日”...
广西再通报车辆坠河事件,已致9... 广西环江毛南族自治县人民政府5月18日通报:截至2026年5月18日20时,河池环江“5·16”过桥...
基地启用,机器人有了国家级职业... 5月16日,国家人工智能应用中试基地(具身智能)在浙江杭州挂牌启用,机器人有了国家级职业技能训练场。...