一、准备环境

1、下载

# wget http://download.redis.io/releases/redis-5.0.3.tar.gz

[root@localhost ~]# wget http://download.redis.io/releases/redis-5.0.3.tar.gz
---- ::-- http://download.redis.io/releases/redis-5.0.3.tar.gz
Resolving download.redis.io (download.redis.io)... 109.74.203.151
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:... connected.
HTTP request sent, awaiting response... OK
Length: (1.9M) [application/x-gzip]
Saving to: 'redis-5.0.3.tar.gz' %[============================================================================================================================>] ,, 751KB/s in .5s -- :: ( KB/s) - 'redis-5.0.3.tar.gz' saved [/] [root@localhost ~]# ls
redis-5.0..tar.gz

2、解压

[root@localhost ~]# tar xzf redis-5.0..tar.gz
[root@localhost ~]#
[root@localhost ~]# ls
anaconda-ks.cfg redis-5.0. redis-5.0..tar.gz
[root@localhost ~]#
[root@localhost ~]# cd redis-5.0.
[root@localhost redis-5.0.]#
[root@localhost redis-5.0.]# ls
-RELEASENOTES CONTRIBUTING deps Makefile README.md runtest runtest-sentinel src utils
BUGS COPYING INSTALL MANIFESTO redis.conf runtest-cluster sentinel.conf tests

3、yum安装gcc依赖

# yum install gcc -y

4、编译

# make

[root@localhost redis-5.0.]# make
……………………
……………………
Hint: It's a good idea to run 'make test' ;) make[]: Leaving directory `/root/redis-5.0./src'

5、简单启动

进入到解压后的 src 目录,通过如下命令启动Redis:

# ./redis-server

[root@localhost redis-5.0.]# ls
-RELEASENOTES CONTRIBUTING deps Makefile README.md runtest runtest-sentinel src utils
BUGS COPYING INSTALL MANIFESTO redis.conf runtest-cluster sentinel.conf tests
[root@localhost redis-5.0.]#
[root@localhost redis-5.0.]# cd src/
[root@localhost src]#
[root@localhost src]# ./redis-server
:C Mar ::12.145 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Mar ::12.145 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
:C Mar ::12.145 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
:M Mar ::12.147 * Increased maximum number of open files to (it was originally set to ).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0. (/) bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port:
| `-._ `._ / _.-' | PID: 6788
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' :M Mar ::12.151 # WARNING: The TCP backlog setting of cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of .
:M Mar ::12.151 # Server initialized
:M Mar ::12.151 # WARNING overcommit_memory is set to ! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
:M Mar ::12.151 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
:M Mar ::12.152 * Ready to accept connections

新打开一个窗口页进行简单的交互

可以使用内置的客户端与Redis进行交互:

# ./redis-cli

[root@localhost src]# ./redis-cli
127.0.0.1:> set foo bar
OK
127.0.0.1:> get foo
"bar"
127.0.0.1:>

二、正常安装

以下两个选项任选其一进行 (推荐选择默认安装)

  • 安装命令 (默认安装目录是/usr/local/bin/)

# make install

[root@localhost redis-5.0.]# make install
cd src && make install
make[]: Entering directory `/root/redis-5.0./src'
CC Makefile.dep
make[]: Leaving directory `/root/redis-5.0./src'
make[]: Entering directory `/root/redis-5.0./src' Hint: It's a good idea to run 'make test' ;) INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
make[]: Leaving directory `/root/redis-5.0./src'
[root@localhost redis-5.0.]#

查看安装目录

# ll /usr/local/bin/redis-*

[root@localhost redis-5.0.]# ll /usr/local/bin/redis-*
-rwxr-xr-x. root root Mar : /usr/local/bin/redis-benchmark
-rwxr-xr-x. root root Mar : /usr/local/bin/redis-check-aof
-rwxr-xr-x. root root Mar : /usr/local/bin/redis-check-rdb
-rwxr-xr-x. root root Mar : /usr/local/bin/redis-cli
lrwxrwxrwx. root root Mar : /usr/local/bin/redis-sentinel -> redis-server
-rwxr-xr-x. root root Mar : /usr/local/bin/redis-server
[root@localhost redis-5.0.]#
  • 指定redis安装目录

# make install PREFIX=/usr/local/redis

配置文件

配置文件在redis-5.0.3目录下,文件名是 redis.conf

根据你的安装目录,将配置文件拷贝至对应的目录,比如拷贝到 /root/目录下,命令如下:

[root@localhost redis-5.0.]# ls
-RELEASENOTES CONTRIBUTING deps Makefile README.md runtest runtest-sentinel src utils
BUGS COPYING INSTALL MANIFESTO redis.conf runtest-cluster sentinel.conf tests
[root@localhost redis-5.0.]#
[root@localhost redis-5.0.]# cp redis.conf /root/
[root@localhost redis-5.0.]#
[root@localhost redis-5.0.]# cd
[root@localhost ~]#
[root@localhost ~]# ls
anaconda-ks.cfg redis-5.0. redis-5.0..tar.gz redis.conf
[root@localhost ~]#

三、正常启动

启动redis命令和效果如下,默认是前台启动,按 ctrl+c 停止

# redis-server /root/redis-5.0.3/redis.conf

[root@localhost ~]# redis-server /root/redis-5.0./redis.conf
:C Mar ::14.612 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Mar ::14.612 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
:C Mar ::14.612 # Configuration loaded
:M Mar ::14.614 * Increased maximum number of open files to (it was originally set to ).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0. (/) bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port:
| `-._ `._ / _.-' | PID: 6991
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' :M Mar ::14.617 # WARNING: The TCP backlog setting of cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of .
:M Mar ::14.617 # Server initialized
:M Mar ::14.617 # WARNING overcommit_memory is set to ! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
:M Mar ::14.617 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
:M Mar ::14.617 * Ready to accept connections

后台启动

后台启动需要修改配置文件 (大概在136行 ),将daemonize no 改为 daemonize yes

重启启动,效果如下

# redis-server /root/redis-5.0.3/redis.conf

[root@localhost ~]# redis-server /root/redis-5.0./redis.conf
:C Mar ::35.264 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Mar ::35.264 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
:C Mar ::35.264 # Configuration loaded

查看redis服务进程

# ps aux | grep redis

[root@localhost ~]# ps aux | grep redis
root 0.2 0.4 ? Ssl : : redis-server 127.0.0.1:
root 0.0 0.0 pts/ S+ : : grep --color=auto redis
[root@localhost ~]#

本地客户端交互

[root@localhost ~]# redis-cli
127.0.0.1:> keys *
(empty list or set)
127.0.0.1:> set foo bar
OK
127.0.0.1:> get foo
"bar"
127.0.0.1:> exit
[root@localhost ~]#

远程客户端连接

直接使用客户端加参数 redis-cli -h <ip> 进行远程连接

[root@localhost ~]# redis-cli -h 192.168.2.88
Could not connect to Redis at 192.168.2.88:: Connection refused

默认配置会报错,连接被拒绝,需要修改配置文件 redis.conf

默认配置,69行默认绑定了本机地址,注释此配置或修改为自己的IP

# vi redis-5.0.3/redis.conf

redis-5.0.3 默认开启保护模式,protected-mode yes,修改为 protected-mode no

重新启动

# redis-server /root/redis-5.0.3/redis.conf

[root@localhost ~]# redis-server /root/redis-5.0./redis.conf
:C Mar ::06.700 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Mar ::06.700 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
:C Mar ::06.700 # Configuration loaded
[root@localhost ~]#

关闭redis服务

[root@localhost ~]# redis-cli shutdown
[root@localhost ~]#
[root@localhost ~]# ps aux | grep redis
root 0.0 0.0 pts/ S+ : : grep --color=auto redis
[root@localhost ~]#

四、Redis配置文件详解

主要用到的配置文件如下:

#设置节点的IP
bind 127.0.0.1 192.168.2.211
#redis-5.0.3 默认开启保护模式,protected-mode yes,修改为 protected-mode no
protected-mode no #redis端口号
port #redis后台运行
#设置后台启动
daemonize yes #设置连接节点的密码
requirepass #aof模式持久化文件的名字(appendonly默认是no,yes就是打开aof持久化)
appendfilename "appendonly.aof" #打开aof持久化
appendonly yes #pidfile文件对应redis_6379.pid
pidfile /var/run/redis_6379.pid

参考博客:

https://blog.csdn.net/weixin_39979119/article/details/86632582

https://blog.csdn.net/litte_frog/article/details/83278047

Redis配置文件详解

https://www.cnblogs.com/pqchao/p/6558688.html

end

部署redis5.0.3的更多相关文章

  1. 单机部署redis5.0集群环境

    #安装rediscd redis-5.0.0makemake install #部署集群mkdir redis_clustermkdir -p redis_cluster/{7000,7001,700 ...

  2. 多机部署redis5.0集群环境

    redis5.0集群部署 一.集群介绍 Redis 集群是一个可以在多个 Redis 节点之间进行数据共享的设施(installation). Redis 集群不支持那些需要同时处理多个键的 Redi ...

  3. redis-5.0.3集群搭建

    首先部署redis-5.0.3,请参考我的另一篇文章 https://www.cnblogs.com/djlsunshine/p/10592174.html 启动redis服务 # redis-ser ...

  4. redis-5.0.5 集群部署

    之前写过一套基于redis-4.0.6版本的测试集群部署 https://www.cnblogs.com/mrice/p/10730309.html 最近生产环境需要部署一套redis-5.0.5版本 ...

  5. Redis5.0.8 Cluster集群部署

    目录 一.Redis Cluster简介 二.部署 三.创建主库 一.Redis Cluster简介 Redis Cluster集群是一种去中心化的高可用服务,其内置的sentinel功能可以提供高可 ...

  6. Redis5.0 3台主机三主三从部署Cluster集群

    1.下载安装 [root@ip101 redis-5.0.4]# pwd /opt/app/redis-5.0.4 [root@ip101 redis-5.0.4]# ls 00-RELEASENOT ...

  7. 基于.NetCore的Redis5.0.3(最新版)快速入门、源码解析、集群搭建与SDK使用【原创】

    1.[基础]redis能带给我们什么福利 Redis(Remote Dictionary Server)官网:https://redis.io/ Redis命令:https://redis.io/co ...

  8. Redis-5.0.0集群配置

    版本:redis-5.0.0 参考:http://redis.io/topics/cluster-tutorial. 集群部署交互式命令行工具:https://github.com/eyjian/re ...

  9. Cloud Native Weekly | 华为云抢先发布Redis5.0,红帽宣布收购混合云提供商 NooBaa

    1——华为云抢先发布Redis5.0 2——DigitalOcean K8s服务正式上线 3——红帽宣布收购混合云提供商 NooBaa 4——微软发布多项 Azure Kubernetes 服务更新 ...

随机推荐

  1. Java 8 实战

    Java8 函数式接口,方法传递与Lambda Java8新特性 方法作为参数传递给方法,方法成为一等公民 Lambda,匿名函数 Stream API : 将一系列相关操作用流水线的思想分配到CPU ...

  2. 《DSP using MATLAB》Problem 7.1

    只有春节那么几天才能和家人团聚,看着爸爸妈妈一年比一年老,自己还是一无所有,照顾好自己尚且惭愧,真是悲从中来,又能怎么办呢, 唯有奋发努力,时不我待,多想想怎么赚钱,加油. 代码: function ...

  3. docker下搭建fastfds集群版

    搭建过程参考 作者 https://me.csdn.net/feng_qi_1984 的课程视频 声明:集群版是在我之前写的单机版基础之上进行搭建的,我将安装了fastfds单机版的docker打包成 ...

  4. mysql 之mvcc多版本控制

    MVCC是multiversion concurrency control的缩写,提供MySQL事物隔离级别下无锁读,例如一个事物在执行update等修改数据的sql,并未提交时其他事物进行数据读取是 ...

  5. 我的vim(持续更新)

    保存并退出:wq 退出但不保存修改:q! 不退出vi使用shell(bash)命令:!bash (如果想回到vi,bash下输入exit回车) 设置行号 :set nu 取消行号:set nonu 设 ...

  6. Atheros AR9285坑爹网卡仅仅有54M/65M,开启150M速率的方法

    版权声明:Max Sky 原创文章.转载时请保留全部权并以超链接形式标明文章出处.否则将追究相关法律责任. https://blog.csdn.net/maxsky/article/details/3 ...

  7. 20165308 预备作业3 Linux安装及学习

    Linux安装及学习 Linux的安装 因为做的比较晚, 安装过程按照老师给出的步骤和同学指导并未出现很多问题,只是安装VirtualBox虚拟机增强功能时,代码没输正确,结果一直无法正确安装,后来也 ...

  8. mybatis 一对多,(多对一,一对一

    多对一,和一对一是同一种写法,每种写法又分在数据库关联和在mybatis关联 1,多对一,一对一数据库关联 2,多对一,一对一mybatis关联 3,一对多,数据库关联,注意,Java type改of ...

  9. centos git server 的搭建

    安装环境  centos7 说明:centos  yum 库里面的git  好像是不区分 客户端和服务器端, 安装 git 以后 就可以创建  仓库,也可以检出 别的 git 仓库的  代码了.所以不 ...

  10. Flume 高可用配置案例+load balance负载均衡+ 案例:日志的采集及汇总

    高可用配置案例 (一).failover故障转移 在完成单点的Flume NG搭建后,下面我们搭建一个高可用的Flume NG集群,架构图如下所示: (1)节点分配 Flume的Agent和Colle ...