linux上安装redis4.0.9

redis安装从3.0的版本到现在4.0的版本,现在装一个4.0的版本供大家学习使用。

先yum安装gcc

 yum -y install gcc
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirror.bit.edu.cn
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 gcc.x86_64.0.4.8.5-16.el7_4.2 将被 安装
--> 解决依赖关系完成

依赖关系解决

==============================================================================================================
 Package             架构                   版本                                源                       大小
==============================================================================================================
正在安装:
 gcc                 x86_64                 4.8.5-16.el7_4.2                    updates                  16 M

事务概要
==============================================================================================================
安装  1 软件包

总下载量:16 M
安装大小:37 M
Downloading packages:
gcc-4.8.5-16.el7_4.2.x86_64.rpm                                                        |  16 MB  00:00:33     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : gcc-4.8.5-16.el7_4.2.x86_64                                                               1/1 
  验证中      : gcc-4.8.5-16.el7_4.2.x86_64                                                               1/1 

已安装:
  gcc.x86_64 0:4.8.5-16.el7_4.2                                                                               

完毕!

下载redis最新4.0版本的tar包

wget http://download.redis.io/releases/redis-4.0.9.tar.gz
--2018-04-20 15:15:36--  http://download.redis.io/releases/redis-4.0.9.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
长度:1737022 (1.7M) [application/x-gzip]
正在保存至: “redis-4.0.9.tar.gz”

100%[====================================================================>] 1,737,022   75.3KB/s 用时 43s    

2018-04-20 15:16:20 (39.2 KB/s) - 已保存 “redis-4.0.9.tar.gz” [1737022/1737022])

开始编译安装

tar -xvf redis-4.0.9.tar.gz 
cd redis-4.0.9/
make MALLOC=libc

 继续中...............

[[email protected] redis-4.0.9]# 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

安装好了,启动试试。 

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

37399:M 20 Apr 16:08:57.448 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
37399:M 20 Apr 16:08:57.448 # Server initialized
37399:M 20 Apr 16:08:57.448 # 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.
37399:M 20 Apr 16:08:57.450 # 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.
37399:M 20 Apr 16:08:57.450 * Ready to accept connections

 这种方式退出就服务就停了,所以让它在后台运行可以这样做:

第一种:直接在启动服务后面加上 & 符号,让它在后台运行。

src/redis-server redis.conf &
[1] 36412
[[email protected] redis-4.0.9]# 36412:C 20 Apr 15:28:08.362 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
36412:C 20 Apr 15:28:08.362 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=36412, just started
36412:C 20 Apr 15:28:08.362 # Configuration loaded
36412:M 20 Apr 15:28:08.364 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 4.0.9 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 36412
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

36412:M 20 Apr 15:28:08.370 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
36412:M 20 Apr 15:28:08.370 # Server initialized
36412:M 20 Apr 15:28:08.371 # 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.
36412:M 20 Apr 15:28:08.371 # 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.
36412:M 20 Apr 15:28:08.371 * DB loaded from disk: 0.000 seconds
36412:M 20 Apr 15:28:08.371 * Ready to accept connections

 第二种:修改redis.conf配置文件

#daemonize no
daemonize yes

启动服务

src/redis-server redis.conf 

36443:C 20 Apr 15:33:12.897 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 36443:C 20 Apr 15:33:12.898 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=36443, just started 36443:C 20 Apr 15:33:12.898 # Configuration loaded

 查看服务是否启动

ps -ef |grep redis
root      36412   5190  0 15:28 pts/1    00:00:00 src/redis-server 127.0.0.1:6379
root      36417   5190  0 15:28 pts/1    00:00:00 grep --color=auto redis

 停止redis服务

kill -9 进程号

 设置redis登陆密码

vim redis.conf
修改成下面内容即可
# requirepass foobared
requirepass 123456

 此时重启redis,登陆时需要密码验证

[[email protected] redis-4.0.9]# src/redis-server redis.conf 
36516:C 20 Apr 15:42:02.221 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
36516:C 20 Apr 15:42:02.221 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=36516, just started
36516:C 20 Apr 15:42:02.221 # Configuration loaded
[[email protected] redis-4.0.9]# src/redis-cli 
127.0.0.1:6379> ping 
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> ping 
PONG
127.0.0.1:6379>

  好了,这就是简单的redis部署环境了,生产环境其实一样,没什么复杂的,配置好了,然后就把ip和端口告诉开发,开发就会去连接redis,或者写到配置文件中,最后将整个的包发给我们运维,让我们去部署就行了,非常简单。

原文地址:http://blog.51cto.com/12889016/2108825

时间: 2024-07-31 11:10:46

linux上安装redis4.0.9的相关文章

Linux上编译Redis4.0.2

Linux上安装部署Redis4.0.2 安装Redis4.0.2,需要先安装依赖: yum -y install gcc gcc-c++ libstdc++-devel tcl -y 下载Redis4.0.2的安装包: wget http://219.238.7.71/files/403400000ABE0C0C/download.redis.io/releases/redis-4.0.2.tar.gz 解压缩: tar -zxvf redis-4.0.2.tar.gz -C /usr/loc

在Linux 上安装WAS7.0

1. 系统软硬件环境 硬件及网络环境: n CPU:4核 2.0 GHz及以上 n 内存:8GB及以上 n 磁盘:200G及以上 n IP:192.168.217.133 软件环境: JDK 1.7.0_45 2. 前提条件 查看/etc/hosts中是否已经有正确的主机名定义:192.168.217.133  master wasserver 其中192.168.217.133为本机IP,master wasserver为本机主机名全称.根据实际情况定 如果配置文件中没有主机名定义,需要手工添

(十)Linux安装Redis-4.0.8

Redis的安装 1.上传 redis-4.0.8.tar.gz 到/usr/local/src文件夹 2.解压 tar xzf redis-4.0.8.tar.gz 3.cd redis-4.0.8 4.编译 make(因为下载的源码,需要编译) 编译完成之后,可以看到解压文件redis-4.0.8 中会有对应的src文件夹.conf文件. 5.编译成功后,进入src文件夹,执行make install进行Redis安装 Redis的部署 安装成功后,下面对Redis 进行部署, 1.首先为了

linux上安装ORACLE_10.2.0提示缺少系统安装包libXp.so.6,调用jdk报错

今天在VWMARE上做了下Linux, oracle 的安装实验, 我系统环境配置: OS:Linux test 2.6.18-8.el5 #1 SMP Fri Jan 26 14:15:21 EST 2007 i686 i686 i386 GNU/Linux Database: 10201_database_linux32.iso 在安装ORACLE软件的时候突然出现如下的错误: [[email protected] database3]$ ./runInstaller Starting Or

Linux 上安装 weblogic12C (静默安装) (一)

最近负责在linux上安装weblogic,领导说要安装最新的版本,版本号为 12.1.X.开始以为和旧版安装一样,使用控制台的方式,下载bin文件,然后一步步在console执行下来就行了.万万没想到,从12C版本后, bin文件不提供了,改成全系统通用的jar文件 (generic.jar).试了半天原来那种安装方式不能用了,非得用图形界面安装.由于服务器是在其他地方,肯定不能跑到主机的地址那边.于是各种google.各种找材料, 最后终于找到一种静默方式的安装.大家看下文. PS:经过公司

Linux上安装MySQL5.6

OS & MySQL的版本和配置: MySQL Version: 5.6.19 Linux Version: Linux boston.oracle.com 2.6.18-164.el5 #1 SMP Thu Sep 3 02:16:47 EDT 2009 i686 i686 i386 GNU/Linux 一,下载MySQL安装软件,请到www.oracle.com   去找DATABASE DOWNLOAD,下载MySQL需要注册一个账号.我下载的版本如下: 下载后解压就是以下的8个文件 :

Kali Linux 上安装Nessus的方法

Nessus是系统漏洞扫描与分析软件,但Nessus在Kali Linux上的安装可不简单,没有提供一个图形化的安装借口,下面就给大家介绍下如何在Kali Linux上安装Nessus.利用Iceweasel 打开http://www.tenable.com/products/nessus/select-your-operating-system 根据自己的需要下载相应的版本 Debian 6, 7, 8 / Kali Linux 1 AMD64 File: Nessus-6.10.6-debi

CentOS 6.5上安装GlassFish4.0 过程笔记

CentOS 6.5上安装GlassFish4.0 过程笔记 1.安装JDK, 注意操作系统的位数, 64 or 32: [[email protected] ~]# mkdir /usr/java  [[email protected] ~]# cd /usr/java[[email protected] java]#rpm -Uvh /bak/jdk-7u55-linux-x64.rpm  [[email protected] java]# JAVA_HOME=/usr/java/jdk1.

linux上安装php7 memcache扩展 和 安装服务端memcached

linux上安装memcached不算太困难.唯一让本人感到困难的是 php7的memcache扩展安装.真的蛋疼! 先说安装服务端 memcached 1. 首先安装Libevent事件触发管理器. wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz tar vxf libevent-2.0.21-stable.tar.gz cd libevent-2.0.21-stable ./c