说明:本文内容参考自一些资料,如有雷同,还请见谅。

部分参考:

http://blog.csdn.net/su377486/article/details/51803616

http://blog.csdn.net/wzygis/article/details/51705559

1.下载redis

[root@zhangmeng ~]#  wget http://download.redis.io/releases/redis-3.2.10.tar.gz
---- ::-- http://download.redis.io/releases/redis-3.2.10.tar.gz
Resolving download.redis.io... 109.74.203.151
Connecting to download.redis.io|109.74.203.151|:... connected.
HTTP request sent, awaiting response... OK
Length: (1.5M) [application/x-gzip]
Saving to: ?.edis-3.2..tar.gz? %[=======================================================================================>] ,, 510K/s in .0s -- :: ( KB/s) - ?.edis-3.2..tar.gz?.saved [/] [root@zhangmeng ~]# ll
total
-rw-------. root root Jun : anaconda-ks.cfg
-rw-r--r--. root root Aug : cp_cmpyun_test.sql
-rw-r--r--. root root Jun : install.log
-rw-r--r--. root root Jun : install.log.syslog
-rw-r--r--. root root Nov mysql-community-release-el6-.noarch.rpm
-rw-r--r--. root root Jul : redis-3.2..tar.gz

2.解压文件

[root@zhangmeng ~]# tar xf redis-3.2..tar.gz
[root@zhangmeng ~]#
[root@zhangmeng ~]# ll
total
-rw-------. root root Jun : anaconda-ks.cfg
-rw-r--r--. root root Aug : cp_cmpyun_test.sql
-rw-r--r--. root root Jun : install.log
-rw-r--r--. root root Jun : install.log.syslog
-rw-r--r--. root root Nov mysql-community-release-el6-.noarch.rpm
drwxrwxr-x. root root Jul : redis-3.2.
-rw-r--r--. root root Jul : redis-3.2..tar.gz

3.编译及安装

[root@zhangmeng ~]# cd redis-3.2.
[root@zhangmeng redis-3.2.]# make && make install
cd src && make all
make[]: Entering directory `/root/redis-3.2./src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[]: Entering directory `/root/redis-3.2./deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd geohash-int && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[]: Leaving directory `/root/redis-3.2./deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic -DREDIS_STATIC='' >> .make-settings
echo WARN=-Wall -W >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -DREDIS_STATIC='' -Wall -W -O2 -g -ggdb -I../deps/geohash-int -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_FINAL_LDFLAGS= -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua geohash-int jemalloc)
make[]: Entering directory `/root/redis-3.2./deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd geohash-int && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-ldflags)
(echo "" > .make-cflags)
MAKE hiredis
cd hiredis && make static
make[]: Entering directory `/root/redis-3.2./deps/hiredis'
gcc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
make[]: gcc: Command not found
make[]: *** [net.o] Error
make[]: Leaving directory `/root/redis-3.2./deps/hiredis'
make[]: *** [hiredis] Error
make[]: Leaving directory `/root/redis-3.2./deps'
make[]: [persist-settings] Error (ignored)
CC adlist.o
/bin/sh: cc: command not found
make[]: *** [adlist.o] Error
make[]: Leaving directory `/root/redis-3.2./src'
make: *** [all] Error
[root@zhangmeng redis-3.2.]#

4.上面报错:

make[3]: gcc: Command not found

/bin/sh: cc: command not found

是由于系统没有安装gcc

安装gcc:yum -y install gcc

Dependencies Resolved

==========================================================================================
Package Arch Version Repository Size
==========================================================================================
Installing:
gcc x86_64 4.4.-.el6 base M
Installing for dependencies:
cloog-ppl x86_64 0.15.-1.2.el6 base k
cpp x86_64 4.4.-.el6 base 3.7 M
glibc-devel x86_64 2.12-1.209.el6_9. updates k
glibc-headers x86_64 2.12-1.209.el6_9. updates k
kernel-headers x86_64 2.6.-696.6..el6 updates 4.5 M
libgomp x86_64 4.4.-.el6 base k
mpfr x86_64 2.4.-.el6 base k
ppl x86_64 0.10.-.el6 base 1.3 M
Updating for dependencies:
glibc x86_64 2.12-1.209.el6_9. updates 3.8 M
glibc-common x86_64 2.12-1.209.el6_9. updates M
libgcc x86_64 4.4.-.el6 base k
tzdata noarch 2017b-.el6 updates k Transaction Summary

5.重新编译安装,还是报错

[root@zhangmeng redis-3.2.]# make && make install
cd src && make all
make[]: Entering directory `/root/redis-3.2./src'
CC adlist.o
In file included from adlist.c::
zmalloc.h::: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h::: error: #error "Newer version of jemalloc required"
make[]: *** [adlist.o] Error
make[]: Leaving directory `/root/redis-3.2./src'
make: *** [all] Error

6.上网查了一下,将make改为make MALLOC=libc,推测是因为编译库的问题。

    [root@zhangmeng redis-3.2.10]# make MALLOC=libc
  ......
  CC crc64.o
CC bitops.o
CC sentinel.o
CC notify.o
CC setproctitle.o
CC blocked.o
CC hyperloglog.o
CC latency.o
CC sparkline.o
CC redis-check-rdb.o
CC geo.o
LINK redis-server
INSTALL redis-sentinel
CC redis-cli.o
LINK redis-cli
CC redis-benchmark.o
LINK redis-benchmark
INSTALL redis-check-rdb
CC redis-check-aof.o
LINK redis-check-aof Hint: It's a good idea to run 'make test' ;) make[]: Leaving directory `/root/redis-3.2./src'
[root@zhangmeng redis-3.2.]#

7.make完成之后,进行install,默认安装路径为/usr/local/bin下,这里我们把他安装目录放到/usr/local/redis下,使用PREFIX指定目录

[root@zhangmeng redis-3.2.]# mkdir /usr/local/redis
[root@zhangmeng redis-3.2.]# make PREFIX=/usr/local/redis install
cd src && make install
make[]: Entering directory `/root/redis-3.2./src' Hint: It's a good idea to run 'make test' ;) INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
make[]: Leaving directory `/root/redis-3.2./src'
[root@zhangmeng redis-3.2.]#

8.将redis可执行目录添加到环境变量中,编辑~/.bash_profile添加redis环境变量

[root@zhangmeng redis-3.2.]# vi ~/.bash_profile
[root@zhangmeng redis-3.2.]#
[root@zhangmeng redis-3.2.]# cat ~/.bash_profile
# .bash_profile # Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi # User specific environment and startup programs PATH=/usr/local/redis/bin:$PATH:$HOME/bin export PATH
[root@zhangmeng redis-3.2.]#

9.拷贝redis.conf文件到/etc下

[root@zhangmeng redis-3.2.]# cp redis.conf /etc/

10.查看redis参数

[root@zhangmeng redis-3.2.]# redis-server --help
Usage: ./redis-server [/path/to/redis.conf] [options]
./redis-server - (read config from stdin)
./redis-server -v or --version
./redis-server -h or --help
./redis-server --test-memory <megabytes> Examples:
./redis-server (run the server with default conf)
./redis-server /etc/redis/.conf
./redis-server --port
./redis-server --port --slaveof 127.0.0.1
./redis-server /etc/myredis.conf --loglevel verbose Sentinel mode:
./redis-server /etc/sentinel.conf --sentinel
[root@zhangmeng redis-3.2.]#

11.版本查看

[root@zhangmeng redis-3.2.10]# redis-server -v
Redis server v=3.2.10 sha=00000000:0 malloc=libc bits=64 build=a60a764624df1665

12.启动redis服务

[root@zhangmeng redis-3.2.]# redis-server /etc/redis.conf
:M Aug ::51.251 * Increased maximum number of open files to (it was originally set to ).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2. (/) bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port:
| `-._ `._ / _.-' | PID: 3268
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' :M Aug ::51.355 # WARNING: The TCP backlog setting of cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of .
:M Aug ::51.355 # Server started, Redis version 3.2.
:M Aug ::51.356 # WARNING overcommit_memory is set to ! 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.
:M Aug ::51.357 # 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.
:M Aug ::51.357 * The server is now ready to accept connections on port

13.测试启动 redis-cli ping 返回PONG,启动成功。

[root@zhangmeng ~]# redis-cli ping
PONG
[root@zhangmeng ~]#
[root@zhangmeng ~]# netstat -tulnp |grep
tcp 127.0.0.1: 0.0.0.0:* LISTEN /redis-server

14.关闭redis服务(备注:可指定端口:redis-cli -p <port> shutdown)

[root@zhangmeng ~]# redis-cli shutdown
[root@zhangmeng ~]#
[root@zhangmeng ~]# netstat -tulnp |grep
[root@zhangmeng ~]#
[root@zhangmeng ~]# redis-cli ping
Could not connect to Redis at 127.0.0.1:: Connection refused
[root@zhangmeng ~]# .......
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.10 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 3268
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                                3268:M 21 Aug 15:10:51.355 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
3268:M 21 Aug 15:10:51.355 # Server started, Redis version 3.2.10
3268:M 21 Aug 15:10:51.356 # 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.
3268:M 21 Aug 15:10:51.357 # 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.
3268:M 21 Aug 15:10:51.357 * The server is now ready to accept connections on port 6379
3268:M 21 Aug 15:19:09.124 # User requested shutdown...
3268:M 21 Aug 15:19:09.124 * Saving the final RDB snapshot before exiting.
3268:M 21 Aug 15:19:09.185 * DB saved on disk
3268:M 21 Aug 15:19:09.185 * Removing the pid file.
3268:M 21 Aug 15:19:09.185 # Redis is now ready to exit, bye bye...

15.连接redis,下面的提示是因为刚才我们把redis关了(连接redis的两种方法见http://www.cnblogs.com/xphdbky/p/7405825.html

[root@zhangmeng ~]# redis-cli
Could not connect to Redis at 127.0.0.1:: Connection refused
Could not connect to Redis at 127.0.0.1:: Connection refused

【redis的搭建】centos6.4下搭建redis的更多相关文章

  1. Centos6.8下搭建SVN服务器

    1.Centos6.8下搭建SVN服务器 Subversion是一个自由,开源的版本控制系统.Subversion将文件存放在中心版本库里.这个版本库很像一个普通的文件服务器,不同的是,它可以记录每一 ...

  2. [IDS]CentOS6.6下搭建基于snort+barnyard2+base的入侵检测系统,超详细!!!

    最详细的CentOS6.6下搭建基于snort+barnyard2+base的入侵检测系统免责声明一.如果因为使用本文档照成损失(系统崩溃.数据丢失等),作者不承担任何责任.二.本文档只是个人使用本文 ...

  3. centos6环境下搭建irc服务器

    问题描述 有时候逛技术社区,经常会发现有个叫IRC的东西存在,想搭建下看看到底是个什么东西 说明: 操作系统环境为CentOS6.5_64 安装irc服务器 通过yum进行安装,命令如下: yum i ...

  4. CentOS6.5下搭建LAMP+FreeRadius+Daloradius Web管理和TP-LINK路由器、H3C交换机连接,实现,上网认证和记账功能

    什么是RADIUS服务: RADIUS:(Remote Authentication Dial In User Service)中文名为远程用户拨号认证服务,简称RADIUS,是目前应用最广泛的AAA ...

  5. CentOS6.5下搭建NFS文件服务器

    本文参考这里 CentOS下搭建NFS服务器总结 环境介绍: 1. 服务器: 192.168.0.100 2. 客户机: 192.168.0.101 安装软件包: 服务器和客户机都要安装nfs 和 r ...

  6. centos6.5下安装Redis

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

  7. CentOS6.8下安装redis并配置开机自启动

    参考资料:http://www.bubuko.com/infodetail-1006383.html   http://www.cnblogs.com/skyessay/p/6433349.html ...

  8. CentOS6.8下安装Redis

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

  9. CentOS6.5下搭建ftp服务器(三种认证模式:匿名用户、本地用户、虚拟用户)

    CentOS 6.5下搭建ftp服务器 vsftpd(very secure ftp daemon,非常安全的FTP守护进程)是一款运行在Linux操作系统上的FTP服务程序,不仅完全开源而且免费,此 ...

随机推荐

  1. 【react】慕课网视频学习笔记

    1.JSX:语法糖,对语言的功能并没有影响,但更方便程序员使用,增强可读性. 2.jsFiddle:前端在线调试工具 3.为什么要把this额外声明成_self变量,因为window.setTimeo ...

  2. rocket-console控制台安装

    1.下载 github地址:https://github.com/apache/rocketmq-externals 2.选择稳定版本: 3.下载到本地:       环境需求 maven  jdk ...

  3. TCP连接三次握手协议,释放连接四次挥手,以及使用 awl伪造mac地址进行多线程syn洪泛攻击。

    这个TCP连接就是一次追女生-谈恋爱-分手,追求比分手简单,但是分手比追求复杂.哥,谈了半年的女朋友,在就快要成功了的时候分了,原因是因为有人在后面该老子背后搞SYN洪泛攻击,最后女朋友丢失了.学会T ...

  4. Selenium自动化测试之结果处理

    Selenium自动化测试之结果处理 一.断言 断言相当于性能测试中的检查点,常用断言种类很多,具体可以查看断言API:判断预期结果和实际结果是否一致,断言成功,程序继续处理,失败则终止运行,示例如下 ...

  5. SwaggerUI用户手册

    SwaggerUI是一个非常好用的API文档工具,最关键的是他还能在工具内调试API,简直爽的不要不要的~网上针对开发者的文档非常多,但是给用户的手册却非常少.所以我来简单写个用户手册,供没有使用过s ...

  6. 【OC底层】OC对象本质,如 isa, super-class

    Objective-C的本质 1.我们编写的Objective-C,底层现实都是C/C++,代码生成步骤如下:   2.在OC中的所有面向对象的实现,都是基于C/C++的数据结构实现的 3.将Obje ...

  7. WebSocket 客户端实例

    Node.js var ws = require("ws"); var socket = new ws("ws://127.0.0.1:8001); var socket ...

  8. php之微型博客的创建

    一,微型博客的开发思路 微型博客的创建,确定无疑我们会用到PHP和mysql之间的增添删改查,首先来看一下思维导图: 搭建好计算机里的apache php 和mysql的联动功能,打开phpmyadm ...

  9. CentOS6安装各种大数据软件 第三章:Linux基础软件的安装

    相关文章链接 CentOS6安装各种大数据软件 第一章:各个软件版本介绍 CentOS6安装各种大数据软件 第二章:Linux各个软件启动命令 CentOS6安装各种大数据软件 第三章:Linux基础 ...

  10. spring data elasticsearch 使用

    很久之前就安装了elasticsearch,一直没用java用过,最近看了一下spring data系列的elasticsearch,这里写一篇心得. 如果尚未安装elasticsearch,可以 参 ...