准备环境:

  1、一台centos7机器,配置没有什么要求(能联网)

  2、下载好redis压缩包

下载redis包:

  1、登录redis官网:

  https://redis.io/download

  2、选择适合自己用的版本,一定要下载稳定版,不推荐下载最新版本

  我这里就下载5.05版本作为案例:

  

下载其它版本:

其它历史版本需要在google code上下载

官方的安装教程:

我这边直接按照提供操作步骤安装出现报错:

  解压安装包到/usr/local目录下

  进入解压目录:

  执行编译:

    提示未找到gcc命令:

解决办法安装gcc命令:

# yum -y install gcc

gcc安装完成后从新执行make编译命令:

  又出现报错:

  

根据redis4.0的安装命令添加MALLOC=libc:

# make MALLOC=libc

  执行成功:

安装:

# make install

二、启动redis的三种方式:

切换到redis的src目录下:

[root@yzn redis-5.0.5]# cd src/

1、直接启动redis

[root@yzn src]# ./redis-server
12670:C 08 Jul 2019 15:17:07.387 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
12670:C 08 Jul 2019 15:17:07.387 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=12670, just started
12670:C 08 Jul 2019 15:17:07.387 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
12670:M 08 Jul 2019 15:17:07.389 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0.5 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 12670
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' 12670:M 08 Jul 2019 15:17:07.391 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
12670:M 08 Jul 2019 15:17:07.391 # Server initialized
12670:M 08 Jul 2019 15:17:07.391 # 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.
12670:M 08 Jul 2019 15:17:07.391 # 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.
12670:M 08 Jul 2019 15:17:07.391 * Ready to accept connections

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

ctrl+c可以关闭程序

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

第一步:修改redis.conf文件

daemonize参数:

      redis.conf配置文件中daemonize守护进程,默认是NO。
      daemonize是用来指定redis是否要用守护进程的方式启动
daemonize设置yes或者no的区别:   daemonize:yes:redis采用的是单进程多线程的模式,当redis.conf中选项daemonize参数为yes时,代表开启守护进程模式,该模式下,redis会在后台运行,并将进程pid号写入到redis.conf选项pidfile设置的文件中,此时redis将一直运行,除非手动kill该进程。   daemonize:no:当daemonize选项设置为no时,当前界面将进入redis的命令界面,exit强制退出或者关闭连接工具(putty、xshell等工具)都会导致redis进程退出

redis的配置文件在redis的主目录下:

  文件名:redis.conf

编辑文件:

  # vim redis.conf

我们修改为yes:

绑定地址(默认仅主机可连接,修改为任意主机可以连接):

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

[root@yzn redis-5.0.5]# /usr/local/redis-5.0.5/src/redis-server /usr/local/redis-5.0.5/redis.conf 

12706:C 08 Jul 2019 15:33:16.232 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
12706:C 08 Jul 2019 15:33:16.233 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=12706, just started
12706:C 08 Jul 2019 15:33:16.233 # Configuration loaded

 

查看程序是否启动

这里我们看到已经后台运行了,注意这里监听的地址为127.0.0.1:6379也就是只能本机连接需要局域网其它设别连接我们需要再修改配置文件修改bind参数

使用kill杀死进程:

  # kill 12707

# 注意:这里的12707是进程id号,在ps命令中查到的

3、设置redis开机自启:

  第一步、添加开机启动服务:

  [root@yzn ~]# vim /etc/systemd/system/redis-server.service  #文件不存在要编辑创建

  


[Unit]
Description=The redis-server Process Manager
After=syslog.target network.target


[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis-5.0.5/src/redis-server /usr/local/redis-5.0.5/redis.conf
PrivateTmp=True


[Install]
WantedBy=multi-user.target

设置为开机启动:

# systemctl daemon-reload

启动服务

# systemctl start redis-server

# 注:暂时没有添加暂停服务,后续会添加上

centos7下编译安装redis5.05的更多相关文章

  1. CentOS7下编译安装redis-5.0.9

    CentOS7下编译安装redis-5.0.9 本文地址http://yangjianyong.cn/?p=171转载无需经过作者本人授权 下载redis #code start wget https ...

  2. centos7下编译安装php-7.0.15(PHP-FPM)

    centos7下编译安装php-7.0.15(PHP-FPM) 一.下载php7源码包 http://php.net/downloads.php 如:php-7.0.15.tar.gz 二.安装所需依 ...

  3. CentOS7 下编译安装 Samba,什么是 SMB/CIFS 协议

    目录 一.关于 Samba 1. SMB 2. Samba 二.yum 安装 Samba 1. 安装 Samba 2. 查看版本 3. 查看配置文件 4. 启动服务 5. 本地客户端验证 6. Win ...

  4. centos7下编译安装php7.3

    一.下载php7.3的源码 https://www.php.net/downloads.php 下载php-7.3.4.tar.gz 二.安装gcc,gcc-c++,kernel-devel yum ...

  5. CentOS7下编译安装Python3.7.x【亲测有效】

    所有操作都在root用户下操作 下载安装包 编译安装 建立软链接 验证 安装: 更新yum: yum update 安装Python依赖: yum install openssl-devel bzip ...

  6. centos7下编译安装nginx-1.16.0

    一.下载nginx源码 http://nginx.org/en/download.html 如:nginx-1.16.0.tar.gz 二.创建用户和组,并解压 groupadd www userad ...

  7. Centos7下编译安装php扩展redis5.0.2

    安装环境:centos7 + php 7.2.191. 下载地址:http://pecl.php.net/get/redis-5.0.2.tgz .tgz http://pecl.php.net/ge ...

  8. CentOS7中编译安装redis5.0

    1. 环境介绍 CentOS7 (未安装Development Tools) 2. 下载Redis5.0-rc3 wget -O redis-5.0-rc3.tar.gz https://github ...

  9. centos7下编译安装python3.7,且与python2.7.5共存

    环境:Centos7.6 x64 一.安装python3.7 下载python源码包: wget https://www.python.org/ftp/python/3.7.4/Python-3.7. ...

随机推荐

  1. 从零开始一个个人博客 by asp.net core and angular(二)

    上一篇帖子讲了用了哪些技术,这个帖子就先介绍介绍api项目吧,项目就是一个普通的webapi项目,账户系统用的identity ,什么是identity呢? 其实就是官方封装好的一系列的可以用来操作数 ...

  2. OpenCL中读取image时的坐标

    本文测试OpenCL中读取image数据时关于坐标的两个问题: 使用float2坐标读取 使用int2坐标读取 首先完整的测试代码如下,测试平台为SDM855: #include <CL/cl. ...

  3. 并查集find,merge操作

    一.find操作 //find操作路径压缩版 inline int find(int x){ if(fa[x]==x) return x; int t=find(fa[x]); fa[x]=t; re ...

  4. 当页面提交时,执行相关JS函数检查输入是否合法

    当页面提交时,执行相关JS函数检查输入是否合法 关键代码 <form action="tj.php" method="post" onSubmit=&qu ...

  5. Anaconda 常用命令

    目录 包管理 环境管理 共享环境设置 包管理 安装包 conda install xxx conda install pandas ; conda install pandas numpy ; 同时安 ...

  6. MyBatis mapper文件中使用常量

    MyBatis mapper文件中使用常量 Java 开发中会经常写一些静态常量和静态方法,但是我们在写sql语句的时候会经常用到判断是否等于 //静态类 public class CommonCod ...

  7. Python第三方库requests的编码问题

    PS:这个解决方法可能很简单,但是这是平时的一些细节问题,所以有必要提醒一下! 首先代码不多,就是通过get方法去获取豆瓣首页信息,如图:但是会报UnicodeEncodeError: 'gbk' c ...

  8. LOJ #2876. 「JOISC 2014 Day2」水壶 BFS+最小生成树+倍增LCA

    非常好的一道图论问题. 显然,我们要求城市间的最小生成树,然后查询路径最大值. 然后我们有一个非常神的处理方法:进行多源 BFS,处理出每一个城市的管辖范围. 显然,如果两个城市的管辖范围没有交集的话 ...

  9. JS阻止事件冒泡与浏览器默认行为

    阻止冒泡 W3C的方法是e.stopPropagation() IE是e.cancelBubble = true; 阻止默认行为 W3C的方法e.preventDefault(), IE是e.retu ...

  10. mssql格式化工具——SQL PRETTY PRINTER

    1.mssql版本 mssql格式化工具有4个版本 1.桌面版 2.mssql插件 3.vs插件 4.api 2.下载地址 下载地址:http://www.dpriver.com/dlaction.p ...