linux下centos7.2下安装redis 4.0.6

一、安装 redis

第一步:下载 redis 安装包

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

[root@localhost ~]#wget http://download.redis.io/releases/redis-4.0.6.tar.gz

–2020-05-08 12 :35 :12 — http://download.redis.io/releases/redis-4.0.6.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 |:80 … connected.

HTTP request sent, awaiting response…200 OK

Length:1723533 (1.6M ) [application/x-gzip ]

Saving to: ‘redis-4.0 .6 .tar .gz’

100 %[==========================================================================================================>]1 ,723 ,533 608KB/s in 2 .8s

2020-05-08 12 :35 :15 (608 KB/s) – ‘redis-4.0 .6 .tar .gz’ saved [1723533 /1723533 ]

第二步:解压压缩包

tar -zxvf redis-4.0.6.tar.gz

[root@localhost home]#tar -zxvf redis-4.0 .6 .tar .gz

第三步: yum 安装 gcc 依赖

yum install gcc

[root@localhost home]#yum install gcc

遇到选择,输入y 即可

第四步:跳转到 redis 解压目录下

cd redis-4.0.6

[root@localhost home]# cd redis-4.0 .6

第五步:编译安装

make MALLOC=libc

[root@localhost redis-4.0 .6 ]#make MALLOC=libc

将/usr/local/redis-4.0.6/src 目录下的文件加到/usr/local/bin 目录cp –rf 就行

cd src && make install

[root@localhost redis-4.0 .6 ]# cd src &&make install

CC Makefile.dep

Hint: It ‘s a good idea to run ‘make test ‘ ;)

INSTALL install

INSTALL install

INSTALL install

INSTALL install

INSTALL install

二、启动 redis 的三种方式

先切换到redis src 目录下

[root@localhost redis-4.0.6]# cd src

1 、直接启动 redis

./redis-server

[root@localhost src]# ./redis-server

18685 :C 13 Dec 12 :56 :12.507 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

18685 :C 13 Dec 12 :56 :12.507 # Redis version=4.0 .6 , bits=64 , commit=00000000 , modified=0 , pid=18685 , just started

18685 :C 13 Dec 12 :56 :12.507 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf

.

.-__”-.

.-</code>. .''-._ Redis 4.0 .6 (00000000 /0 )64 bit

.- .-.\/ .,''-._

(' , .-|, ) Running in standalone mode

|-._-...-__...-.-._|' _.-'| Port:6379

| -._. / .-' | PID: 18685

-._-. -./ </em>.-' _.-'</p> <p>|<code>-._</code>-.<em> -.__.-' .-'_.-'|

| -._-. .-'_.-'| http://redis.io

-._-.-.__.-'</em>.-'_.-'</p> <p>|<code>-._</code>-.<em> -.__.-' .-'_.-'|

| -._-. .-'_.-'|

-._-.-.__.-'</em>.-'_.-'</p> <p><code>-._</code>-.__.-' _.-'</p> <p>-. .-'

`-.__.-'

18685 :M 13 Dec 12 :56 :12.508 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128 .

18685 :M 13 Dec 12 :56 :12.508 # Server initialized

18685 :M 13 Dec 12 :56 :12.508 # WARNING overcommit_memory is set to 0 ! 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.

18685 :M 13 Dec 12 :56 :12.508 # 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.

18685 :M 13 Dec 12 :56 :12.508 * Ready to accept connections

如上图:redis 启动成功,但是这种启动方式需要一直打开窗口,不能进行其他操作,不太方便。

按ctrl + c 可以关闭窗口。

2 、以后台进程方式启动 redis

第一步:修改redis.conf 文件

daemonize no

修改为

daemonize yes

第二步:指定redis.conf 文件启动

./redis-server /usr/local/redis-4.0.6/redis.conf

[root@localhost src]# ./redis-server /usr/local/redis-4.0 .6 /redis.conf

18713 :C 13 Dec 13 :07 :41.109 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

18713 :C 13 Dec 13 :07 :41.109 # Redis version=4.0 .6 , bits=64 , commit=00000000 , modified=0 , pid=18713 , just started

18713 :C 13 Dec 13 :07 :41.109 # Configuration loaded

第三步:关闭redis 进程

首先使用ps -aux | grep redis 查看redis 进程

[root@localhost src]#ps -aux |grep redis

root 18714 0.0 0.1 141752 2008 ? Ssl 13 :07 0 :00 ./redis-server 127.0 .0.1 :6379

root 18719 0.0 0.0 112644 968 pts/0 R+13 :09 0 :00 grep --color=auto redis

使用kill 命令杀死进程

[root@localhost src]#kill 18714

3 、设置 redis 开机自启动

1 、在/etc 目录下新建redis 目录

mkdir redis

[root@localhost etc]#mkdir redis

2 、将/usr/local/redis-4.0.6/redis.conf 文件复制一份到/etc/redis 目录下,并命名为6379.conf

[root@localhost redis]#cp /usr/local/redis-4.0 .6 /redis.conf /etc/redis/6379 .conf

3 、将redis 的启动脚本复制一份放到/etc/init.d 目录下

[root@localhost init.d]#cp /usr/local/redis-4.0 .6 /utils/redis_init_script /etc/init.d/redisd

4 、设置redis 开机自启动

先切换到/etc/init.d 目录下

然后执行自启命令

[root@localhost init.d]# chkconfig redisd on

service redisd does not support chkconfig

看结果是redisd 不支持chkconfig

解决方法:

使用vim 编辑redisd 文件,在第一行加入如下两行注释,保存退出

chkconfig:2345 90 10

description: Redis is a persistent key-value database

注释的意思是,redis 服务必须在运行级2 ,3 ,4 ,5 下被启动或关闭,启动的优先级是90 ,关闭的优先级是10 。

再次执行开机自启命令,成功

[root@localhost init.d]# chkconfig redisd on

现在可以直接已服务的形式启动和关闭redis 了

启动:

service redisd start

[root@localhost ~]# service redisd start

Starting Redis server...

2288 :C 13 Dec 13 :51 :38.087 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

2288 :C 13 Dec 13 :51 :38.087 # Redis version=4.0 .6 , bits=64 , commit=00000000 , modified=0 , pid=2288 , just started

2288 :C 13 Dec 13 :51 :38.087 # Configuration loaded

关闭:

方法1 :service redisd stop

[root@localhost ~]# service redisd stop

Stopping ...

Redis stopped

方法2 :redis-cli SHUTDOWN

三、 linux 服务器端可以连接而远程无法连接的原因

[root@localhost src]# vim ../redis.conf

把protected-mode yes 改为protected-mode no (在没有密码的情况下,关闭保护模式)

注释掉bind 127.0.0.1 (取消绑定本地地址)

把daemonize no 改为daemonize yes (是否为进程守护,关闭ssh 窗口后即是否在后台继续运行)

在redis-conf 注释掉bind 127.0.0.1 (取消绑定本地地址)

若还不能访问则开启制定端口号或者关闭防火墙,在这采用关闭防火墙,由于是centos7 ,防火墙进行了升级

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall 开机启动

如果出现如下问题:

[root@localhost ~]# service redisd start

/var/run/redis_6379.pid exists, process is already running or crashed

删除redis_6379.pid 即可

Original: https://www.cnblogs.com/angelasp/p/12853446.html
Author: Angelasp
Title: linux下centos7.2下安装redis 4.0.6

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/611768/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • Try-with-resources are not supported at language level ‘5’

    Try-with-resources are not supported at language level ‘5’没有指定maven版本导致 的 指定ma…

    数据库 2023年6月16日
    066
  • 分析了2020年3万多条的微博热搜,我看到了什么

    前言 2020年是艰难的一年,但即使再难,也都过去了。 分析一下2020年的新闻热搜,可以大致了解网民都在关注什么。 微博热搜以娱乐为主,头条的热搜更偏向民生与时事。今天,我们先分…

    数据库 2023年6月16日
    0101
  • Centos7环境使用Mysql离线安装包安装Mysql5.7

    服务器环境:centos7 x64 需要安装:mysql5.7+ 1)检查mysql组合用户是否存在 2)若不存在,则创建mysql组和用户 版本选择,可以选择以下两种方式: 1)…

    数据库 2023年6月14日
    088
  • CentOS 7 RabbitMQ 单机部署

    RabbitMQ版本:3.8.5 安装Erlang RabbitMQ的集群基于Erlang的分布式特性实现,所以需要先安装Erlang。 下载yum源配置脚本: curl -#LO…

    数据库 2023年6月9日
    096
  • 即时通讯课设Android端问题记录

    转眼间,就已经是大四学生,目前正在写毕设。Android 端没有系统的学习过,都是哪里不会查哪里,基本靠度娘。所以,在此记录下课设开发过程中,Android 端遇到的问题。 在主线…

    数据库 2023年6月9日
    058
  • 文件传输工具:FileZilla的使用

    FileZilla FileZilla 是一款高效的 FTP 客户端工具。FileZilla 可以帮助您将本地计算机上的文件上传到虚拟主机实例中。 FileZilla 界面介绍 如…

    数据库 2023年6月11日
    089
  • MySQL新建用户与授权

    test为用户名,1234为密码,%意思是任何一台主机都可以登录,如果只能本机登录则设置为localhost 说明:test为数据库的名称 说明:第一个test为数据库的名称,第二…

    数据库 2023年6月9日
    084
  • Vue插件

    Vue插件 插件作用 插件通常用来为 Vue 添加全局功能 例如:1、添加全局资源:指令/过滤器/过渡等。如 vue-touch2、通过全局混入来添加一些组件选项。3、添加 Vue…

    数据库 2023年6月11日
    075
  • XPath和Selenium的使用

    XPath 是一门在 XML 文档中查找信息的语言 /: ——># 从根节点选取: //: ——># 不管位置,直接找 /@属性名 ——># 获取对应属性值 /t…

    数据库 2023年6月9日
    075
  • Java8Stream流

    Stream流呢,以前我也有所了解,像一些面试题中也出现过,Java8的新特性,有一块就是这个Stream操作集合,而且在看一些项目中也使用的比较多。但总感觉自己学的一知半解,所以…

    数据库 2023年6月11日
    081
  • pg小工:pgsql的介绍

    支持邮件列表 http://www.postgresql.org/community/lists/ Original: https://www.cnblogs.com/lyhabc…

    数据库 2023年6月9日
    0102
  • Python第五十一天 python2升级为python3

    Python第五十一天 python2升级为python3 公司使用的生产环境系统是centos7,所以这里以centos7系统为基础,讲解将python2升级为python3的方…

    数据库 2023年6月9日
    078
  • mysql 内部函数

    1. group_concat 返回一个字符串结果,该结果由分组中的值连接组合而成。 函数语法: group_concat( [DISTINCT] 要连接的字段 [Order BY…

    数据库 2023年6月16日
    084
  • java四种访问修饰符及各自的权限

    1.public,即共有的,是访问权限限制最宽的修饰符。被public修饰的类、属性、及方法不仅可以跨类访问,而且可以跨包访问。 2. protected,即保护访问权限,是介于p…

    数据库 2023年6月11日
    095
  • MySQL主从备库过滤参数分析和测试

    测试环境: GTID的主从复制,主库(9900)——》备库(9909),存在测试库表: 9900_db1库:t1、t2、t3、t4、t5表 9900_db2库:t6、t7、t8、t…

    数据库 2023年5月24日
    064
  • 视频语义分割基准数据集与评估方法

    概述 本文来源于《A Benchmark Dataset and Evaluation Methodology for Video Object Segmentation》,论文主…

    数据库 2023年6月11日
    081
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球