Redis学习笔记1 - 下载和安装

VMWare服务器环境及工具:centos 7.0, Xshell 6.

1. 进入redis官网(redis.io), 复制稳定版链接:http://download.redis.io/releases/redis-5.0.7.tar.gz

2. Xshell进入centos7,  command:  wget http://download.redis.io/releases/redis-5.0.7.tar.gz

  

3. 为了方便管理下载文件,将下载文件剪切到‘/usr/local/src’, comman: mv redis-5.0.7.tar.gz /usr/local/src

4. 转到/usr/local/src目录(comand: cd /usr/local/src)并解压, command:  tar zxvf redis-5.0.7.tar.gz

 5. 进入解压文件夹, command: cd redis-5.0.7

6. 直接make,command: make 

 

 

 7.  [非必须]按它提示进行make test进行测试, command: make test

  (注:这里提示执行test需要安装一下tcl库,如果继续测试可以通过yum tcl进行先安装, comman: yum install tcl)

再次make test, command: make test

 8. 安装,在此指定安装路径, command: make install PREFIX=/usr/local/redis

 9. 查看bin安装目录(command: cd /usr/local/redis),可以看到如下文件, command: ll bin/

redis-benchmark: 性能检测工具

redis-check-aof: 检查aof日志工具

redis-check-rdb: 检查rdb日志工具

redis-cli: 连接redis用的客户端

redis-server: 服务进程

 10. 继续从解压后的目录复制配置文件(redis.conf)到当前目录,command: cp /usr/local/src/redis-5.0.7/redis.conf ./

 11. 启动, command: ./bin/redis-server ./redis.conf

12. 配置守护进程并测试缓存,需要修改redis.conf中的daemonize属性,command: vim redis.conf

 将daemonize no修改为daemonize yes

 保存并退出vim, command: :wq

13. 重新运行step11启动Redis,安装完成(查看后台Redis进程,command: ps aux|grep redis

 

 

补充:

1) 开机自动启动脚本配置

创建脚本文件命令:vi /etc/init.d/redis

#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.

### BEGIN INIT INFO
# Provides:     redis_6379
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Redis data structure server
# Description:          Redis data structure server. See https://redis.io
### END INIT INFO
#redis服务器监听的端口
REDISPORT
=6379
#服务端所处位置 EXEC
=/usr/local/redis/bin/redis-server
#客户端位置 REDIS_CLI
=/usr/local/redis/bin/redis-cli #redis的PID文件位置(需要修改) PIDFILE=/var/run/redis_6379.pid
#redis的配置文件位置 CONF
="/usr/local/redis/redis.conf" case "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, process is already running or crashed" else echo "Starting Redis server..." $EXEC $CONF fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE does not exist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." $CLIEXEC -p $REDISPORT shutdown while [ -x /proc/${PID} ] do echo "Waiting for Redis to shutdown ..." sleep 1 done echo "Redis stopped" fi ;; *) echo "Please use start or stop as first argument" ;; esac

 

 

(如果在启动Redis时总是有问题,可以从Redis安装包目录下的utils文件夹下找到启动脚本,如下图)

参考开机启动配置步骤:https://www.cnblogs.com/mybxy/p/10258878.html

 

2) 其它常用Redis配置redis.conf

# daemonize:  'yes'
# logfile: logfile "/var/log/redis.log"
# requirepass: set 'requirepass' as 'xxxxxx'
# bind 127.0.0.1 修改为 0.0.0.0  #这样供其它IP地址访问(比如用RedisDesktopManager工具进行连接)

 

3)查看 redis进程

command: ps -aux |grep redis

posted @ 2020-01-12 15:30  【舍予】  阅读(136)  评论(0编辑  收藏  举报