一、准备环境

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. KMP算法自我理解 和 模板

    字符串   abcd abc abcd abc 匹配串   cdabcd 匹配串的 next  0 0 0 0 1 2: 开始匹配 abcd abc abcd abc cd abc d a,d 匹配失 ...

  2. functional program language

    1.什么是函数式编程语言 函数式语言(functional language)一类程序设计语言,是一种非冯·诺伊曼式的程序设计语言.函数式语言主要成分是原始函数.定义函数和函数型.这种语言具有较强的组 ...

  3. 《DSP using MATLAB》Problem 5.34

    第1小题 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  4. jdk1.8新特性----接口可以有方法体,子类可以不用重写接口中已实现的方法

    是的这就是jdk1.8新特性之一,刚刚看到. 注意:编译环境是1.8. public interface Tree { public static String name="树名" ...

  5. Sping--注解(一) 常用注解总结

    Sping注解是很重要的一块.今天在这里对常用到的注解做个小结,会尽可能说得详细些. 推荐这个英文文档,官方文档当然是最好的.最近发现,学习东西,还是多看官方文档,最权威,最详细. https://d ...

  6. JDBC封装

    在模拟servlet调用dao中,我们发现在dao的实现类中有许多重复代码,我们可以将其封装起来. 步骤: 一. 创建一个类 DBUtil 1加载驱动和建立链接的代码 完全一样 加载驱动写到静态代码快 ...

  7. auto sudo password in shell

    here is the example how to implement the auto password in shell script. Echo yourpasswordhere | sudo ...

  8. 【转载】Win10桌面图标有小箭头怎么去掉?Win10去掉桌面图标小箭头的方法

    以下文章转载至系统之家 网址:http://www.xitongzhijia.net/xtjc/20190104/146560.html Win10桌面图标有小箭头怎么去掉?Win10去掉桌面图标小箭 ...

  9. 数学 它的内容,方法和意义 第一卷 (A. D. 亚历山大洛夫 著)

    第一章 数学概观 (已看) 1. 数学的特点 2. 算术 3. 几何 4. 算术和几何 5. 初等数学时代 6. 变量的数学 7. 现代数学 8. 数学的本质 9. 数学发展的规律性 第二章 数学分析 ...

  10. Physics for Game Programmers (Grant Palmer 著)

    CHAPTER1 Adding Realism to Your Games CHAPTER2 Some Basic Concepts CHAPTER3 Basic Newtonian Mechanic ...