Centos-7.4_安装_Redis_4.0.8

一、安装redis

第一步:下载redis安装包

[[email protected] ~]# mkdir /usr/local/redis/                      --创建目录

[[email protected] redis]# cd /usr/local/redis/                        --进入当前目录

[[email protected] ~]# wget http://download.redis.io/releases/redis-4.0.8.tar.gz       --下载软件包
--2018-12-30 12:20:30-- http://download.redis.io/releases/redis-4.0.8.tar.gz
正在解析主机 download.redis.io (download.redis.io)... 109.74.203.151
正在连接 download.redis.io (download.redis.io)|109.74.203.151|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1729973 (1.6M) [application/x-gzip]
正在保存至: “redis-4.0.8.tar.gz”

100%[===================================================================================================================================================>] 1,729,973 841KB/s 用时 2.0s

2018-12-30 12:20:32 (841 KB/s) - 已保存 “redis-4.0.8.tar.gz” [1729973/1729973])

第二步:解压压缩包

[[email protected] redis]# tar -zxvf redis-4.0.8.tar.gz

第三步:yum安装gcc依赖

[[email protected] redis]# yum -y install gcc-*

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

[[email protected] redis]# cd redis-4.0.8/

第五步:编译安装

[[email protected] redis]# make MALLOC=libc

将/usr/local/redis-4.0.8/src目录下的文件加到/usr/local/bin目录

cd src && make install

[[email protected] redis-4.0.8]# 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目录下

[[email protected] redis-4.0.8]# cd src/

1、直接启动redis

[[email protected] src]# ./redis-server
35611:C 30 Dec 12:16:11.035 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
35611:C 30 Dec 12:16:11.036 # Redis version=4.0.8, bits=64, commit=00000000, modified=0, pid=35611, just started
35611:C 30 Dec 12:16:11.036 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
35611:M 30 Dec 12:16:11.036 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ‘‘-._
_.-`` `. `_. ‘‘-._ Redis 4.0.8 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ‘‘-._
( ‘ , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|‘` _.-‘| Port: 6379
| `-._ `._ / _.-‘ | PID: 35611
`-._ `-._ `-./ _.-‘ _.-‘
|`-._`-._ `-.__.-‘ _.-‘_.-‘|
| `-._`-._ _.-‘_.-‘ | http://redis.io
`-._ `-._`-.__.-‘_.-‘ _.-‘
|`-._`-._ `-.__.-‘ _.-‘_.-‘|
| `-._`-._ _.-‘_.-‘ |
`-._ `-._`-.__.-‘_.-‘ _.-‘
`-._ `-.__.-‘ _.-‘
`-._ _.-‘
`-.__.-‘

35611:M 30 Dec 12:16:11.037 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
35611:M 30 Dec 12:16:11.037 # Server initialized
35611:M 30 Dec 12:16:11.037 # 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.
35611:M 30 Dec 12:16:11.037 # 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.
35611:M 30 Dec 12:16:11.037 * Ready to accept connections

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

按 ctrl + c可以关闭窗口。

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

第一步:修改redis.conf文件

[[email protected] src]# vim /usr/local/redis/redis-4.0.8/redis.conf

daemonize no

修改为

daemonize yes

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

[[email protected] src]# ./redis-server /usr/local/redis/redis-4.0.8/redis.conf
45390:C 30 Dec 12:42:32.886 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
45390:C 30 Dec 12:42:32.886 # Redis version=4.0.8, bits=64, commit=00000000, modified=0, pid=45390, just started
45390:C 30 Dec 12:42:32.886 # Configuration loaded

第三步:关闭redis进程

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

[[email protected] src]# ps -aux | grep redis
root 45391 0.0 0.0 141816 2004 ? Rsl 12:42 0:00 ./redis-server 127.0.0.1:6379

使用kill命令杀死进程

[[email protected] src]# kill -9 45391

3、设置redis开机自启动

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

mkdir redis

[[email protected] src]# mkdir /etc/redis

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

[[email protected] src]# cp /usr/local/redis/redis-4.0.8/redis.conf /etc/redis/6379.com

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

[[email protected] src]# cp /usr/local/redis/redis-4.0.8/utils/redis_init_script /etc/init.d/redisd

4、设置redis开机自启动

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

然后执行自启命令

[[email protected] init.d]# chkconfig redisd on
服务 redisd 不支持 chkconfig

看结果是redisd不支持chkconfig

解决方法:

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

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

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

[[email protected] init.d]# chkconfig redisd on

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

启动:

service redisd start

如果出现如下问题:

[[email protected] ~]# service redisd start 
Please use start or stop as first argument

可用安装文件启动     redis-server /etc/redis/6379.conf

[[email protected] ~]# redis-server /etc/redis/6379.conf
9562:C 30 Dec 13:44:57.160 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
9562:C 30 Dec 13:44:57.160 # Redis version=4.0.8, bits=64, commit=00000000, modified=0, pid=9562, just started
9562:C 30 Dec 13:44:57.160 # Configuration loaded

参考文件:

redis报错可参考资料:http://blog.csdn.net/luozhonghua2014/article/details/54649295

redis安装可参考资料:http://blog.csdn.net/zc474235918/article/details/50974483

redis安装可参考资料:http://blog.csdn.net/gxw19874/article/details/51992125

原文地址:https://www.cnblogs.com/lilihong/p/10199232.html

时间: 2024-11-02 23:25:43

Centos-7.4_安装_Redis_4.0.8的相关文章

CentOS 6.5安装Tomcat-9.0.0.M19

一下载并安装JDK 下载并安装jdk-8u121-linux-i586.tar.gz,下载地址http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 新建/usr/java文件夹,将jdk-8u121-linux-i586.tar.gz放到该文件夹中,并将工作目录切换到/usr/java目录下. [[email protected] java]# tar zxvf jdk-8u121-

centos 7下安装mysql-8.0

本篇文章主要介绍在centos7 环境下安装mysql8.0并设置为开机自启. 安装步骤 1.配置yum源 首先在 https://dev.mysql.com/downloads/repo/yum/ 找到 yum 源 rpm 安装包,但是我那会打开这个网页时有点慢毕竟是国外的网站,所以我分享到百度网盘了,链接:https://pan.baidu.com/s/1-gX5eN2QnSH5ptcxsIiq3Q 密码:pirb. 下载完成上传到服务器,我是传到了opt目录下. 2.安装mysql源 yu

centos 6.5 安装redis3.0.6

1.下载redis安装包 地址:http://download.redis.io/releases/redis-3.0.6.tar.gz2.解压安装包 命令:tar zvxf redis-3.0.6.tar.gz 3.进入文件夹并安装 命令:cd redis-3.0.6.tar.gz 命令:make 4.测试是否安装成功 命令:make test 出现错误: [[email protected] redis-stable]# make testcd src && make testmake

CentOS 6下安装nodejs 0.9.0

确保安装了python,大部分安装失败都是由于python版本过低导致.安装之前,升级python版本,升级步骤 http://www.tomtalk.net/wiki/Python. [[email protected] ~]# python -V Python 2.7.3 开始安装: 1).下载nodejs到本地并解压缩 [[email protected] node]# wget http://nodejs.org/dist/v0.9.0/node-v0.9.0.tar.gz [[emai

在CentOS 7上安装MySQL8.0.15

需求 用最简单.最清晰的方式,在CentOS7上,通过yum repo方式,安装目前最新的MySQL版本,因为只是用来后续的学习,所以密码强度不用太高,设置成root就行. 步骤 1.安装官方仓库. 1 yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm 2.安装数据库 1 yum install mysql-server 这一步会把它所依赖的客户端和类库也一起装上.推荐使用阿里云

编译安装 Centos 7 x64 + tengine.2.0.3 (实测+笔记)

环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G) 系统版本:CentOS Linux release 7.0.1406 安装步骤: 1.系统环境 1.1 更新系统 [[email protected] ~]# yum update -y 1.2 查看环境 [[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.0.1406 (Core) [[email protected] ~]#

CentOS 7安装zabbix3.0

  CentOS 7安装zabbix3.0 一.环境介绍 # systemctl stop firewalld # setenforce 0 # yum -y install unzip vim net-tools lrzsz Zabbix 需要依赖LAMP/LNMP环境 # yum -y install httpd mariadb mariadb-server php   二.Zabbix 安装 1.安装服务器端包 1 2 3 #rpm -ivh http://repo.zabbix.com/

CentOS 7上安装Zabbix Server 3.0 图文详解

转载自 http://www.linuxidc.com/Linux/2016-09/135204.htm CentOS 7上安装Zabbix Server 3.0 图文详解 1.查看系统信息. cat /etc/RedHat-releaseCentOS Linux release 7.0.1406 (Core) uname -a Linux VM_96_155_centos3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_

CentOS 6 中安装Node.js 4.0 版本或以上

如果想在CentOS 6 中安装Node.js >4.0,如果通过以往的方式安装: wget https://nodejs.org/dist/latest/node-v4.0.0.tar.xz tar zvxf node-v4.0.0.tar.xz cd node-v4.0.0 ./configure make && make install 会遇到报错提示: WARNING: C++ compiler too old, need g++ 4.8 or clang++ 3.4 (CX