参考资料:http://www.bubuko.com/infodetail-1006383.html

       http://www.cnblogs.com/skyessay/p/6433349.html

一、安装

下载redis-3.0.5.tar.gz

[root@yeebian ~]# cd /opt
[root@yeebian opt]# wget http://192.168.10.173:8080/website/linux/redis-3.0.5.tar.gz
[root@yeebian opt]# tar -zxvf redis-3.0.5.tar.gz
[root@yeebian opt]# cd redis-3.0.5
[root@yeebian redis-3.0.5# make

这里在make的时候可能会有如下两个报错:

(1)

[root@localhost redis-3.0.5]# make
cd src && make all
make[1]: Entering directory `/root/redis-3.0.5/src‘
CC adlist.o
/bin: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/root/redis-3.0.5/src‘
make: *** [all] Error 2

未安装gcc包,使用yum -y install gcc安装即可。

(2)

[root@localhost redis-3.0.5]# make
cd src && make all
make[1]: Entering directory `/root/redis-3.0.5、src‘
CC adlist.o
In file included from adlist.c:34:
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/root/redis-3.0.5/src‘
make: *** [all] Error 2

将make换成make MALLOC=libc,原因可能是因为编译库的问题。

安装编译后的文件:make install,redis可执行文件将被复制到/usr/local/bin,但没有配置,手动复制配置:cp redis.conf /usr/local/bin

设置redis密码,编辑刚复制的配置文件:vi.conf,解除requierpass参数的注释,并设置值,例如:requierpass ljx520

使用配置文件启动redis数据库:./redis-server ../redis.conf,看到如下界面说明redis启动成功:

二、开机自启动设置

1. 设置redis.conf中daemonize为yes,确保守护进程开启,也就是在后台可以运行.(设置为yes后,启动时好像没有redis的启动界面,不知道为什么)

2. 复制redis配置文件(启动脚本需要用到配置文件内容,所以要复制)

[root@localhost /]# mkdir /etc/redis    #在/etc下新建redis文件夹
[root@localhost redis]# cp /opt/redis-3.0.5/redis.conf /etc/redis/6379.conf #把安装redis目录里面的redis.conf文件复制到/etc/redis/6379.conf里面,6379.conf启动脚本里面的变量会读取这个名称,6379是redis的端口号

3.复制redis启动脚本

[root@localhost redis]# find / -name redis_init_script    #redis启动脚本一般在redis根目录的utils,如果不知道路径,可以先查看路径
/usr/redis/redis-3.2.4/utils/redis_init_script
[root@localhost redis]# cp /opt/redis-3.0.5/utils/redis_init_script /etc/init.d/redis #复制启动脚本到/etc/rc.d/init.d/redis文件中

4.修改启动脚本参数

[root@localhost redis]# vim /etc/rc.d/init.d/redis
#在/etc/init.d/redis文件的头部添加下面两行注释代码,也就是在文件中#!/bin/sh的下方添加
# chkconfig: 2345 10 90
# description: Start and Stop redis

同时还要修改参数,指定redis的安装路径

以下是我的安装路径:
REDISPORT=6379
EXEC=/opt/redis-3.0.5/src/redis-server
CLIEXEC=/opt/redis-3.0.5/src/redis-cli

5. 设置redis开机自启动

# chkconfig --add redis

# chkconfig redis on   开启开机启动

# chkconfig redis off   关闭开机启动

打开redis命令:service redis start

关闭redis命令:service redis stop

重启redis命令:service redis restart

CentOS6.8下安装redis并配置开机自启动的更多相关文章

  1. OS X下安装Redis及配置开机启动

    1.下载redis源码包redis-3.0.5.tar(此步骤可在图形界面下操作) 2.解压源码包 tar zxvf redis-3.0.5.tar 3.编译源码并安装 #进入源码目录 cd redi ...

  2. CentOS6.8下安装memcached并设置开机自启动

    参考资料:http://www.cnblogs.com/handongyu/p/6419305.html    http://coolnull.com/1986.html 一.安装libevent 首 ...

  3. centos6.2下安装redis和phpredis扩展,亲测好用

    安装redis: 下载:http://www.redis.io/download redis-2.6.2.tar.gz ]# tar -zxf redis-2.6.2.tar.gz ]# cd red ...

  4. centos6.5下安装Redis

    已有redis-3.2.1.tar.gz文件 拖到centos系统的桌面 现在在桌面目录下 tar -zxv -f redis-3.2.1.tar.gz以解压压缩包 cd redis-3.2.1以切换 ...

  5. linux系统下安装redis及配置

    下载Redis redis-3.2.11.tar.gz 解压编译 tar xzf redis-3.2.11.tar.gz cd redis-3.2.11 make 编译完成之后,可以看到解压文件red ...

  6. CentOS6.8下安装Redis

    1.由于Redis是使用C语言开发的,安装时需要对Redis的源码进行编译,编译依赖gcc环境,如果没有gcc,需要先安装gcc: yum install gcc-c++ 2.安装完成后,进入Redi ...

  7. Centos下安装并设置nginx开机自启动

    一.在centos环境下安装下载并安装nginx,由于nginx需要依赖一些环境才能安装,主要依赖g++.gcc.openssl-devel.pcre-devel和zlib-devel这些环境,首先得 ...

  8. centos 6.5系统下安装ibus及设置开机自启动

    先说一下系统环境:centos 6.5,然后我是以root身份执行的,没有权限的用户参见sudo用法 第1步:查找并安装ibus安装包,命令如下: 找到一行: ibus-pinyin.x86_64 : ...

  9. linux下安装redis并配置

    redis官网上给出了安装步骤,这里做一下总结. 1.Download, extract and compile Redis with: wget http://download.redis.io/r ...

随机推荐

  1. How To Install MySQL on Ubuntu 16.04

    https://help.ubuntu.com/lts/serverguide/mysql.html http://www.cnblogs.com/wuhou/archive/2008/09/28/1 ...

  2. Jquery 组 checkbox全选按钮

    <!DOCTYPE html><html lang="zh-cn"><head> <meta charset="utf-8&qu ...

  3. springMVC 使用WebApplicationContext获取ApplicationContext对象

    主要用于从application中获取bean 1.applicationContext 在web.xml中使用listener配置 <context-param> <param-n ...

  4. 微信小程序的界面下拉刷新

    小程序的下拉刷新的值设置:需要设置app.json的window中 "navigationBarTextStyle":true  

  5. python之pygal:掷一个骰子统计次数并以直方图形式显示

    源码如下: # pygal包:生成可缩放的矢量图形文件,可自适应不同尺寸的屏幕显示 # 安装:python -m pip intall pygal-2.4.0-py2.py3-none-any.whl ...

  6. Highcharts之饼图

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  7. Google社交梦之隐私问题

    导读 2011年6月底,Google+ 作为Facebook最有力狙击者的身份诞生,同时以隐私功能作为两者主要区分点:2018年10月,Google+被曝发生重大隐私泄露问题,消费版本被宣布仅剩10个 ...

  8. Mysql误删表中数据与误删表的恢复方法

    由于头两天面试时被问了这样一个问题,如果某同事误删了某个表,你该怎么恢复? 当时想了一下,因为博主没有遇到过这个问题,但是也多少了解一些,所以就回答通过mysql的binlog日志进行恢复. 面试官当 ...

  9. 设计模式【PHP案例】

    内容来源: 波客 菜鸟教程 策略模式 在策略模式(Strategy Pattern)中,一个类的行为或其算法可以在运行时更改.这种类型的设计模式属于行为型模式. 在策略模式中,我们创建表示各种策略的对 ...

  10. BZOJ5286: [Hnoi2018]转盘 (线段树)

    题意 给你绕成一圈的物品共 \(n\) 个 , 然后从其中一个开始选 , 每次有两种操作 , 一是继续选择当前物品 , 二是选择这个后一个物品 . 选择后一个物品要求当前的时刻大于后一个的 \(T_i ...