1.首先在官网上下载redis压缩包

  redis-3.2.0.tar.gz

2.解压到到当前文件夹(这里可以解压到随意位置)

  tar zvxf redis-3.2.0.tar.gz

3.切换到redis-3.2.0目录下

  cd redis-3.2.0 然后执行编译和安装

  make 和 make install 命令

4.安装完成后,执行文件默认在/usr/local/bin目录下  

mars@mars-LIFEBOOK-LH531:/usr/local/bin$ ls
idea redis-check-aof redis-cli redis-server
redis-benchmark redis-check-rdb redis-sentinel

5.启动服务器端,客户端测试

  执行命令 ./redis-server

  #检测后台进程是否存在
  ps -ef |grep redis   #检测6379端口是否在监听
  sudo netstat -lntp | grep 6379

mars@mars-LIFEBOOK-LH531:/usr/local/bin$ ls
    idea redis-check-aof redis-cli redis-server
    redis-benchmark redis-check-rdb redis-sentinel
    mars@mars-LIFEBOOK-LH531:/usr/local/bin$ redis-cli
    127.0.0.1:6379> key *
   (error) ERR unknown command 'key'
   127.0.0.1:6379> keys *
   (empty list or set)
   127.0.0.1:6379> set key "hello word"
   OK
   127.0.0.1:6379> get key
   "hello word"
   127.0.0.1:6379>

6.通过制定的配置文件进行启动  

  可为redis服务启动指定配置文件,配置文件 redis.conf 在Redis根目录下

  #修改daemonize为yes,即默认以后台程序方式运行。
  daemonize no
  #可修改默认监听端口
  port 6379
  #修改生成默认日志文件位置
  logfile "/home/mars/logs/redis.log"
  #配置持久化文件存放位置
  dir /home/mars/data/redisData  启动时制定配置文件
  redis-server ./redis.conf
  #如果更改了端口,使用`redis-cli`客户端连接时,也需要指定端口,例如:
  redis-cli -p 6380

7. 使用Redis的启动脚本设置开机自启动

  推荐在生产环境中使用启动脚本方式启动redis服务。启动脚本redis_init_script 位于位于Redis的 /utils/ 目录下: 

  #大致浏览下该启动脚本,发现redis习惯性用监听的端口名作为配置文件等命名,我们后面也遵循这个约定。
  #redis服务器监听的端口
  REDISPORT=6379
  #服务端所处位置,在make install后默认存放与`/usr/local/bin/redis-server`,如果未make install则需要修改该路径,下同。
  EXEC=/usr/local/bin/redis-server
  #客户端位置
  CLIEXEC=/usr/local/bin/redis-cli
  #Redis的PID文件位置
  PIDFILE=/var/run/redis_${REDISPORT}.pid
  #配置文件位置,需要修改
  CONF="/etc/redis/${REDISPORT}.conf"

  <1>根据启动脚本要求,将修改好的配置文件以端口为名复制一份到指定目录。需使用root用户。   

    sudo mkdir /etc/redis
    sudo cp redis.conf /etc/redis/6379.conf

  <2>将启动脚本复制到/etc/init.d目录下,本例将启动脚本命名为redisd(通常都以d结尾表示是后台自启动服务).   

    cp redis_init_script /etc/init.d/redisd

  <3>设置为开机自启动:

    mars@mars-LIFEBOOK-LH531:/etc/init.d$ sudo chmod +x ./redisd

    mars@mars-LIFEBOOK-LH531:/etc/init.d$ sudo update-rc.d redisd defaults

    #启动服务   

    mars@mars-LIFEBOOK-LH531:/etc/init.d$ service redisd start
    Starting Redis server...

    #停止服务

    mars@mars-LIFEBOOK-LH531:/etc/init.d$ service redisd stop

      

在配置文件时,也可以使用它提供的设置脚本进行配置:

[root@marslv redis-3.2.0]# cd utils/
[root@marslv utils]# ls
build-static-symbols.tcl hyperloglog redis_init_script
cluster_fail_time.tcl install_server.sh redis_init_script.tpl
create-cluster lru releasetools
generate-command-help.rb redis-copy.rb speed-regression.tcl
hashtable redis-sha1.rb whatisdoing.sh
[root@marslv utils]# ./install_server.sh

默认的目录:

Port           : 6379

Config file    : /etc/redis/6379.conf

Log file       : /var/log/redis_6379.log

Data dir       : /var/lib/redis/6379

Executable     : /usr/local/bin/redis-server

Cli Executable : /usr/local/bin/redis-cli

添加环境变量:

vim /etc/profile

末尾添加以下两行:

PATH=/usr/local/bin:$PATH
export PATH

改下服务名称

[root@marslv init.d]# mv redis_6379 redisd
[root@marslv init.d]# service redisd start

在centos6下设置开机自启动:chkconfig redisd on(unbuntu 用sudo update-rc.d redisd defaults,也可以安装rcconf,貌似没有redhat系列的chkchonfig命令好用)

开启远程访问:将6379.cofig中的bind 改成0.0.0.0这样才能远程连接,默认的情况下只能本机用

给redis添加访问密码: 将6379.cofig中的这一行#requirepass foobared前面的#去掉,后面的foobared替换成你要设置的密码,然后重启服务就行

(vim中的查找命令:/ex  其中ex就是你要查找的关键字)

Ubuntu14.04下安装redis的更多相关文章

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

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

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

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

  3. Ubuntu16.04下安装redis

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

  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. ubuntu14.04下安装ffmpeg

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

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

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

  9. 在Ubuntu14.04下安装Docker CE(1) - repository篇

    从2017年3月开始,Docker开始分为社区版本和企业版,也就是Docker CE和Docker EE, 原来Ubuntu14.04下,通过sudo apt-get install docker.i ...

随机推荐

  1. sass 安装和使用

    1,安装ruby :检查本地是否安装ruby: #ruby -v 2,安装sass: #gem install sass 3,检查是否安装成功:#sass -v 4,.scss文件不能直接被浏览器解析 ...

  2. 给RelativeLayout设置背景,无效果bug解决

    drawable文件夹下面 tomyshop_selector.xml文件 <?xml version="1.0" encoding="utf-8"?&g ...

  3. Gs_Class._BaseQueryWeb查询页面基类(aspx.net)

    using System;using System.Data;using System.Configuration;using System.Collections;using System.Web; ...

  4. HTML a标签 target属性作用

    特殊的目标 有 4 个保留的目标名称用作特殊的文档重定向操作: _blank 浏览器总在一个新打开.未命名的窗口中载入目标文档. _self 这个目标的值对所有没有指定目标的 <a> 标签 ...

  5. 【XML】document.createEvent的使用方法

    <aclass="comment-mod"onclick="alert('ss')"href="#">评论</a> ...

  6. 修改LibreOffice Draw中定义的样式名称

    目前我使用的是LibreOffice 4.2.4.2.经过以往的测试和使用经验,这是诸多版本中较为稳定和bug相对较少的.今天无意中发现该版本的LibreOffice Draw存在一个问题:样式名称修 ...

  7. com.google.common.collect.Lists#transform使用注意

    /** * Returns a list that applies {@code function} to each element of {@code * fromList}. The return ...

  8. svn添加新文件自动忽略

    背景:做项目,用的客户端TortoiseSVN1.8,发现新建的文件,不是问号(?),而是自动忽略的减号,提交的时候也确实没有,说明不是符号混乱,确实是被忽略了,网上找了解决方案记录如下: 查看svn ...

  9. 连续多个git提交发生了冲突时

    git checkout -b test 创建并切换到分支test git clone git branch master git merge test 合并test到master (git merg ...

  10. 物流进程html+css页面

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head>     & ...