Redis的安装步骤:

步骤1.安装redis必须已经安装了gcc,如果没安装gcc 就使用命令 yum install -y gcc
步骤2.下载redis包 下载地址:http://download.redis.io/releases/redis-3.0.7.tar.gz上传到你要安装的目录然后解压。我解压在usr目录下
步骤3.进入usr/redis-3.0.7/src
步骤4.make #编译
步骤5.make test

  [root@localhost src]# make test

  You need tcl 8.5 or newer in order to run the Redis test

  make: *** [test] 错误 1

步骤6.根据错误下载tcl
  使用命令:yum install -y tcl 然后make test

步骤7.make install
  [root@localhost src]# make install

  Hint: It's a good idea to run 'make test' ;)
  INSTALL install
  INSTALL install
  INSTALL install
  INSTALL install
  INSTALL install

见到这个你就安装成功了,意思是说好习惯是先运行测试,然后我们再来移动和修改配置文件。

步骤8.移动文件,便于管理:(所有源代码安装的软件都安装在/usr/local下)
  创建两个文件夹,bin用于存放命令,etc拥有存放配置文件。
  [root@localhost src]$ sudo mkdir -p /usr/local/redis/bin
  [root@localhost src]$ sudo mkdir -p /usr/local/redis/etc
  -p是递归创建

步骤9.接下来,将redis-3.0.7文件夹下的redis.conf复制到/usr/local/redis/etc/
  并将src目录下的7个命令文件(绿色的),移动到/usr/local/redis/bin/

  sudo mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server  /usr/local/redis/bin/

步骤10:启动Redis服务:
  首先进入刚才安装redis的目录:
  [root@localhost src]$ cd /usr/local/redis/bin
  [root@localhost src]$ ls
    mkreleasehdr.sh redis-check-aof redis-cli redis-server
    redis-benchmark redis-check-dump redis-sentinel
  之后我们启动redis服务。启动redis服务需要用到命令redis-server

[root@localhost bin]$ ./redis-server

[13019] 15 Mar 22:34:24.568 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
[13019] 15 Mar 22:34:24.569 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 2.8.19 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in stand alone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 13019
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               
 
[13019] 15 Mar 22:34:24.570 # Server started, Redis version 2.8.19
[13019] 15 Mar 22:34:24.570 # 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.
[13019] 15 Mar 22:34:24.570 # 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.
[13019] 15 Mar 22:34:24.570 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
[13019] 15 Mar 22:34:24.570 * The server is now ready to accept connections on port 6379

但是,这样做的话,我们并没有使用etc的下的配置文件进行启动。

如果希望通过指定的配置文件启动,需要在启动时指定配置文件:

这里我们先用ctrl+C来终止服务,然后查看redis服务是否终止干净了,之后通过设置配置文件来启动服务:

步骤11:查看redis是否启动
  netstat -tunpl | grep 6379 如果什么都没有就是没有启动
步骤12:启动redis服务
  进入/usr/local/redis/bin/目录下执行./redis-server /usr/local/redis/etc/redis.conf命令开启Redis服务。
  例:[root@localhost bin]# ./redis-server /usr/local/redis/etc/redis.conf
  然后再查看redis是否启动,我们往往需要查看6379端口是否被占用,如果出现以下情况那么就服务开启成功.
  [root@localhost bin]# netstat -tunpl | grep 6379
    tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 41645/./redis-serve
    tcp6 0 0 :::6379 :::* LISTEN 41645/./redis-serve
至此,redis服务已经按照配置文件启动成功!!

步骤13:我们进行测试客户端连接
[root@localhost bin]# ./redis-cli
  127.0.0.1:6379> set name 张三
   OK
  127.0.0.1:6379> get name
   "\xe5\xbc\xa0\xe4\xb8\x89"
中文出现这样 我们就重新连接,后面加上 --raw
[root@localhost bin]# ./redis-cli --raw
  127.0.0.1:6379> get name
    张三
  127.0.0.1:6379> keys *
    name
  127.0.0.1:6379> del name
    1

退出就ctrl+c 或者 exit

步骤14:关闭redis服务
  进入/usr/local/redis/bin/目录下执行./redis-cli shutdown
步骤15:修改配置文件
  vim /usr/local/redis/etc/redis.conf
  daemonize 改为yes可以吧redis改为后台启动
  修改完daemonize参数之后,redis就能够通过daemon方式启动了,那么下一步就是把redis加入到linux开机启动服务配置中了,具体步骤如下:
  使用VI编辑器打开Linux开机启动服务配置文件/etc/rc.local,并在其中加入下面的一行代码:
  /usr/local/redis/bin/redis-server /etc/redis.conf
  编辑完后保存,然后重启系统就OK了。
  然后再次启动redis服务就可以了.
  reids搭建基本工作准备完成.

O(∩_∩)O哈哈~

redis命令:
查看redis是否启动
netstat -tunpl | grep 6379

开启redis服务
进入/usr/local/redis/bin/目录下执行./redis-server /usr/local/redis/etc/redis.conf命令开启Redis服务。
注意:开启redis服务需要指定配置文件,如不指定配置文件则加载默认配置文件。

关闭redis服务
进入/usr/local/redis/bin/目录下执行./redis-cli shutdown

Linux上安装Redis教程的更多相关文章

  1. linux上安装redis的踩坑过程2

    昨天在linux上安装redis后马上发现了其它问题,服务器很卡,cpu使用率上升,top命令查看下,原来有恶意程序在挖矿,此程序入侵了很多redis服务器,马上用kill杀掉它 然后开始一些安全策略 ...

  2. linux上安装redis的踩坑过程

    redis用处很广泛,我不再啰嗦了,我按照网上教程想在linux上安装下,开始了踩坑过程,网上买了一个linux centos7.3,滴滴云的,巨坑无比啊,不建议大家用这家的! redis 为4.0, ...

  3. linux 上安装 redis

    一.安装gcc Redis是c语言开发的. 安装 redis 需要 c 语言的编译环境.如果没有 gcc 需要在线安装. yum install gcc-c++ 二.下载 redis 链接:https ...

  4. Redis在CentOS for LInux上安装详细教程

    1.首先上传安装包,这里我以 redis-5.0.8.tar.gz 为例子. Linux下载redis地址:wget http://download.redis.io/releases/redis-5 ...

  5. 如何在Linux上安装Redis(内附详细教程)

    前言 hello,好久不见,又断更了一段时间.同事大部分离职了,但是活还是一样,所以只能硬着头皮顶上.现在总算歇会了,决定开启Redis源码系列,希望不要啪啪啪打脸. ​ 什么是redis? Redi ...

  6. Linux(Debian)上安装Redis教程

    -- 第一步下载文件到该目录 cd /usr/local/src wget http:.tar.gz 解压 tar xzf redis.tar.gz -- 第二步编译安装 make make all ...

  7. Linux上安装Redis

    很多编程的小朋友一提到Linux脑袋就大了,我也一样,我是一个大专的学生,没有学过Linux,感觉自己欠缺很多,也知道了人和人之间的差距,当你真正的走上社会,才知道社会是什么,才知道没有学历找工作有多 ...

  8. linux 上安装redis

    下载地址:http://redis.io/download,下载最新文档版本. 本教程使用的最新文档版本为 2.8.17,下载并安装: $ wget http://download.redis.io/ ...

  9. linux上安装redis并使用

    1.下载:curl -O http://download.redis.io/releases/redis-4.0.6.tar.gz 2.在/usr/local/redis上解压:tar -zxvf r ...

随机推荐

  1. linux cfs 负载均衡

    确定新的负载的时候,代码中给出的公式是: (old×(2^i-1) + new))/2^i 整理下来是: old + (new-old)/2^i i的范围是[1, 4],也就是说,i的层级越高,那么n ...

  2. kudu介绍及安装配置

    kudu介绍及安装配置 介绍 Kudu 是一个针对 Apache Hadoop 平台而开发的列式存储管理器.Kudu 共享 Hadoop 生态系统应用的常见技术特性: 它在 commodity har ...

  3. IE6,7,8支持css圆角

    我们知道Webkit内核的浏览器支持-webkit-border-radius: 10px;属性(10px是圆角半径),可以直接解析出圆角;Firefox浏览器支持-moz-border-radius ...

  4. [Leetcode] Best time to buy and sell stock ii 买卖股票的最佳时机

    Say you have an array for which the i th element is the price of a given stock on day i. Design an a ...

  5. 【ZJ选讲·BZOJ 5073】

    小A的咒语 给出两个字符串A,B (len<=105) 现在可以把A串拆为任意段,然后取出不超过 x 段,按在A串中的前后顺序拼接起来 问是否可以拼出B串. [题解]       ①如果遇 ...

  6. 【CF MEMSQL 3.0 D. Third Month Insanity】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  7. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) B

    B. Little Artem and Grasshopper time limit per test 2 seconds memory limit per test 256 megabytes in ...

  8. vm虚拟机 开启时报错 无法打开内核设备“\\.\Global\vmx86”: 系统找不到指定的文件。

    解决办法 方案一 1/http://jingyan.baidu.com/article/455a9950aaf4aea167277878.html 方案二 2.http://jingyan.baidu ...

  9. IDEA 用maven创建web项目编译时不能发布resources中的文件

    1.在pom.xml加入 <build> <resources> <resource> <directory>${basedir}/src/main/j ...

  10. PHP 抽象类,接口,抽象方法,静态方法

    1.Abstract class(抽象类) 抽象类是指在 class 前加了 abstract 关键字且存在抽象方法(在类方法 function 关键字前加了 abstract 关键字)的类. 抽象类 ...