去官网下载Redis-3.2.0.tar.gz,将redis-3.2.0.tar.gz放入/opt目录下

解压redis-3.2.0.tar.gz

xiaoyao@xiaoyao-virtual-machine:/opt$ sudo tar -zxvf redis-3.2.0.tar.gz

编译redis

xiaoyao@xiaoyao-virtual-machine:/opt$ cd redis-3.2.0/
xiaoyao@xiaoyao-virtual-machine:/opt/redis-3.2.0$ sudo make

安装

xiaoyao@xiaoyao-virtual-machine:/opt/redis-3.2.0$ sudo make install

测试是否安装通过

xiaoyao@xiaoyao-virtual-machine:/opt/redis-3.2.0$ sudo make test
见到此字样:\o/ All tests passed without errors!表示测试安装通过

如果出现You need tcl 8.5 or newer in order to run the Redis test错误

解决办法

xiaoyao@xiaoyao-virtual-machine:/opt/redis-3.2.0$ sudo apt-get install tcl8.5

修改配置文件,以便其它机器能连接redis服务

xiaoyao@xiaoyao-virtual-machine:/opt/redis-3.2.0$ sudo vim /opt/redis-3.2.0/redis.conf

将bind 127.0.0.1改为bind 0.0.0.0

将redis.conf文件拷贝至/etc/redis目录下

xiaoyao@xiaoyao-virtual-machine:/opt/redis-3.2.0$ sudo mkdir /etc/redis
xiaoyao@xiaoyao-virtual-machine:/opt/redis-3.2.0$ sudo cp redis.conf /etc/redis/redis.conf

启动redis服务

xiaoyao@xiaoyao-virtual-machine:/opt/redis-3.2.0$ /usr/local/bin/redis-server /etc/redis/redis.conf

进入redis客户端,测试redis

xiaoyao@xiaoyao-virtual-machine:/usr/local/bin$ ./redis-cli
127.0.0.1:6379> ping
PONG

通过redisclient软件去连接redis也没有问题。

设置开机自启动

  • 修改redis.conf

    #打开后台运行选项
    daemonize yes
    #设置日志文件路径
    logfile "/var/log/redis.log"
  • 编写脚本

    xiaoyao@xiaoyao-virtual-machine:/usr/local/bin$ sudo touch /etc/init.d/redis
    xiaoyao@xiaoyao-virtual-machine:/usr/local/bin$ sudo vim /etc/init.d/redis

    下面是脚本的内容

    #!/bin/sh
    # chkconfig: 2345 10 90
    # description: Start and Stop redis PATH=/usr/local/bin
    REDISPORT=6379
    EXEC=/usr/local/bin/redis-server
    REDIS_CLI=/usr/local/bin/redis-cli
    PIDFILE=/var/run/redis.pid
    CONF="/etc/redis/redis.conf" case "$1" in
    start)
    if [ -f $PIDFILE ]
    then
    echo "$PIDFILE exists, process is already running or crashed."
    else
    echo "Starting Redis server..."
    $EXEC $CONF
    fi
    if [ "$?"="0" ]
    then
    echo "Redis is running..."
    fi
    ;;
    stop)
    if [ ! -f $PIDFILE ]
    then
    echo "$PIDFILE exists, process is not running."
    else
    PID=$(cat $PIDFILE)
    echo "Stopping..."
    $REDIS_CLI -p $REDISPORT SHUTDOWN
    while [ -x $PIDFILE ]
    do
    echo "Waiting for Redis to shutdown..."
    sleep 1
    done
    echo "Redis stopped"
    fi
    ;;
    restart|force-reload)
    ${0} stop
    ${0} start
    ;;
    *)
    echo "Usage: /etc/init.d/redis {start|stop|restart|fore-reload}"
    exit 1
    esac
  • 添加脚本的执行权限

    xiaoyao@xiaoyao-virtual-machine:/usr/local/bin$ sudo chmod +x /etc/init.d/redis
  • 设置开机自动启动

    xiaoyao@xiaoyao-virtual-machine:/usr/local/bin$ sudo update-rc.d redis defaults
  • 使用脚本启动服务

    开启redis
    xiaoyao@xiaoyao-virtual-machine:/usr/local/bin$ service redis start
    停止redis
    xiaoyao@xiaoyao-virtual-machine:/usr/local/bin$ service redis stop
    重启redis
    xiaoyao@xiaoyao-virtual-machine:/usr/local/bin$ service redis restart
  • 将机器关机,重新启动

此时发现redis服务也启动了

 
 

Ubuntu14.04下安装redis-3.2.0以及开机自启动的更多相关文章

  1. Ubuntu14.04下安装redis

    1.首先在官网上下载redis压缩包 redis-3.2.0.tar.gz 2.解压到到当前文件夹(这里可以解压到随意位置) tar zvxf redis-3.2.0.tar.gz 3.切换到redi ...

  2. 二、Ubuntu14.04下安装Hadoop2.4.0 (伪分布模式)

    在Ubuntu14.04下安装Hadoop2.4.0 (单机模式)基础上配置 一.配置core-site.xml /usr/local/hadoop/etc/hadoop/core-site.xml ...

  3. Ubuntu14.04下安装Hadoop2.5.1 (单机模式)

    本文地址:http://www.cnblogs.com/archimedes/p/hadoop-standalone-mode.html,转载请注明源地址. 欢迎关注我的个人博客:www.wuyudo ...

  4. Ubuntu14.04下安装Flash Player

    Ubuntu14.04下安装Flash Player youhaidong@youhaidong:~$ sudo apt-get install flashplugin-nonfree [sudo] ...

  5. Ubuntu14.04下 安装p4c

    参考: Github p4c README Ubuntu14.04下 安装p4c 这里提供一个直接安装p4c的脚本:install_p4c.sh. 1.git clone下来p4c: $ git cl ...

  6. Ubuntu14.04下安装Libsvm,并使用Libsvm

    (1)Ubuntu14.04下安装Libsvm 转载:https://blog.csdn.net/katrinawj/article/details/78915874 一.下载: 网址:http:// ...

  7. Ubuntu16.04下安装redis

    Ubuntu16.04下安装redis 保证网络畅通,选定好下载工作路径,执行以下命令下载redis-3.2.6: sudo wget http://download.redis.io/release ...

  8. ubuntu14.04下安装ffmpeg

    ubuntu14.04下安装ffmpeg 一.安装各种依赖包 1.yasm(libx264需要依赖yasm) sudo apt-get install yasm 2.libx264 sudo apt- ...

  9. ubuntu14.04下安装cudnn5.1.3,opencv3.0,编译caffe及配置matlab和python接口过程记录

    已有条件: ubuntu14.04+cuda7.5+anaconda2(即python2.7)+matlabR2014a 上述已经装好了,开始搭建caffe环境. 1. 装cudnn5.1.3,参照: ...

随机推荐

  1. 回顾MySQL中的事务特征

    一.事务定义Transaction事务:一个最小的不可再分的工作单元:通常一个事务对应一个完整的业务(例如银行账户转账业务,该业务就是一个最小的工作单元)一个完整的业务需要批量的DML(insert. ...

  2. 使用 IntraWeb (35) - TIWJQueryWidget

    可有可无的东西, 因为没有它也可以方便达成其目的, 使用它貌似更形象一些; 也可以通过它调用其他 js 库. 利用类似手段, 有人推出了 CGDevTools; 它主要是利用 JQuery 扩展而成, ...

  3. 解决IE9下交通银行网上银行无法输入密码的问题

    自系统升级到 Win 7以后,突然发现用 IE9 浏览器登陆交通银行网上银行时,始终不能正常 输入密码.原来,非要进行特别的设置才可.现记录如下: 1.没有交通银行安装安全输入控件,安装即可.   当 ...

  4. DIY自己的AllocateHWnd函数

    Classes单元的AllocateHWnd函数是需要传入一个处理消息的类的方法的作为参数的,原型: function AllocateHWnd(Method: TWndMethod): HWND; ...

  5. Spring boot设置文件上传大小限制

    原文:https://blog.csdn.net/lizhangyong1989/article/details/78586421 Spring boot1.0版本的application.prope ...

  6. 删除weblogic应用缓存,weblogic 缓存的删除方法

    security (注意:security目录下为安全认证文件,切不可删除!) 正常情况下只需删除tmp目录下缓存文件(不同的工程在tmp下面有不同的路径,如果不清楚的话可以一起删除). 个别情况下会 ...

  7. 如何在本地搭建一个Android应用crashing跟踪系统-ACRA

    https://github.com/bboyfeiyu/android-tech-frontier/tree/master/others/%E5%A6%82%E4%BD%95%E5%9C%A8%E6 ...

  8. DotNetty z

    使用说明 客户端的代码和服务端的代码相差很少,体现了Netty统一的编程模型.有几个不同点: 客户端的Bootstrap不是ServerBootstrap: 客户端不需要主线程组,只有工作线程组,消息 ...

  9. C# System.Collections.Queue

    using System; using System.Collections; public class SamplesQueue { public static void Main() { // C ...

  10. ES 插入十万条数据耗时1573秒