redis是一个NOSql数据库,在java web中,经常用来存储session等,官网是https://redis.io/

当前官网指出的稳定版本为3.2.6,下载地址为http://download.redis.io/releases/redis-3.2.6.tar.gz

1.下载redis

[root@iZ25ufmpy4sZ local]# wget http://download.redis.io/releases/redis-3.2.6.tar.gz
--2017-01-18 16:44:49--  http://download.redis.io/releases/redis-3.2.6.tar.gz
Resolving download.redis.io (download.redis.io)... 109.74.203.151
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... failed: Connection timed out.
Retrying.--2017-01-18 16:46:57--  (try: 2)  http://download.redis.io/releases/redis-3.2.6.tar.gz
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1544806 (1.5M) [application/x-gzip]
Saving to: ‘redis-3.2.6.tar.gz’100%[======================================================================================================================================================================================>] 1,544,806   1.40MB/s   in 1.1s   2017-01-18 16:46:59 (1.40 MB/s) - ‘redis-3.2.6.tar.gz’ saved [1544806/1544806]

2.解压

[root@iZ25ufmpy4sZ local]# tar -xvf redis-3.2.6.tar.gz 

3.进入redis目录并make

[root@iZ25ufmpy4sZ local]# cd  redis-3.2.6
[root@iZ25ufmpy4sZ redis-3.2.6]# ls
00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Makefile  MANIFESTO  README.md  redis.conf  runtest  runtest-cluster  runtest-sentinel  sentinel.conf  src  tests  utils
[root@iZ25ufmpy4sZ redis-3.2.6]# make
cd src && make all
make[1]: Entering directory `/usr/local/redis-3.2.6/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[2]: Entering directory `/usr/local/redis-3.2.6/deps'
make[1]: Leaving directory `/usr/local/redis-3.2.6/src'

4.进入src目录make install

[root@iZ25ufmpy4sZ redis-3.2.6]# cd src/
[root@iZ25ufmpy4sZ src]# ls
adlist.c     anet.o       cluster.h  debug.c       geo.o          lzf_d.c          networking.o  quicklist.o        redis-check-aof.c  release.h      sds.o           slowlog.h       t_hash.o    valgrind.sup
adlist.h     aof.c        cluster.o  debugmacro.h  help.h         lzf_d.o          notify.c      rand.c             redis-check-aof.o  release.o      sentinel.c      slowlog.o       t_list.c    version.h
adlist.o     aof.o        config.c   debug.o       hyperloglog.c  lzf.h            notify.o      rand.h             redis-check-rdb    replication.c  sentinel.o      solarisfixes.h  t_list.o    ziplist.c
ae.c         asciilogo.h  config.h   dict.c        hyperloglog.o  lzfP.h           object.c      rand.o             redis-check-rdb.c  replication.o  server.c        sort.c          t_set.c     ziplist.h
ae_epoll.c   bio.c        config.o   dict.h        intset.c       Makefile         object.o      rdb.c              redis-check-rdb.o  rio.c          server.h        sort.o          t_set.o     ziplist.o
ae_evport.c  bio.h        crc16.c    dict.o        intset.h       Makefile.dep     pqsort.c      rdb.h              redis-cli          rio.h          server.o        sparkline.c     t_string.c  zipmap.c
ae.h         bio.o        crc16.o    endianconv.c  intset.o       memtest.c        pqsort.h      rdb.o              redis-cli.c        rio.o          setproctitle.c  sparkline.h     t_string.o  zipmap.h
ae_kqueue.c  bitops.c     crc64.c    endianconv.h  latency.c      memtest.o        pqsort.o      redisassert.h      redis-cli.o        scripting.c    setproctitle.o  sparkline.o     t_zset.c    zipmap.o
ae.o         bitops.o     crc64.h    endianconv.o  latency.h      mkreleasehdr.sh  pubsub.c      redis-benchmark    redis-sentinel     scripting.o    sha1.c          syncio.c        t_zset.o    zmalloc.c
ae_select.c  blocked.c    crc64.o    fmacros.h     latency.o      multi.c          pubsub.o      redis-benchmark.c  redis-server       sdsalloc.h     sha1.h          syncio.o        util.c      zmalloc.h
anet.c       blocked.o    db.c       geo.c         lzf_c.c        multi.o          quicklist.c   redis-benchmark.o  redis-trib.rb      sds.c          sha1.o          testhelp.h      util.h      zmalloc.o
anet.h       cluster.c    db.o       geo.h         lzf_c.o        networking.c     quicklist.h   redis-check-aof    release.c          sds.h          slowlog.c       t_hash.c        util.o
[root@iZ25ufmpy4sZ src]# make installHint: It's a good idea to run 'make test' ;)
INSTALL installINSTALL installINSTALL installINSTALL installINSTALL install

5.此时启动,只要运行scr目录下的redis-server,但是不符合Linux管理,建议在Nginx根目录下创建一个bin和etc来分别存放系统文件和配置文件,如下

[root@iZ25ufmpy4sZ redis-3.2.6]# pwd
/usr/local/redis-3.2.6
[root@iZ25ufmpy4sZ redis-3.2.6]# mkdir bin
[root@iZ25ufmpy4sZ redis-3.2.6]# mkdir etc
[root@iZ25ufmpy4sZ redis-3.2.6]# ls
00-RELEASENOTES  bin  BUGS  CONTRIBUTING  COPYING  deps  etc  INSTALL  Makefile  MANIFESTO  README.md  redis.conf  runtest  runtest-cluster  runtest-sentinel  sentinel.conf  src  tests  utils

View Code

6.copy对应文件到bin和etc目录下

[root@iZ25ufmpy4sZ redis-3.2.6]# cd src
[root@iZ25ufmpy4sZ src]# ls
adlist.c     anet.o       cluster.h  debug.c       geo.o          lzf_d.c          networking.o  quicklist.o        redis-check-aof.c  release.h      sds.o           slowlog.h       t_hash.o    valgrind.sup
adlist.h     aof.c        cluster.o  debugmacro.h  help.h         lzf_d.o          notify.c      rand.c             redis-check-aof.o  release.o      sentinel.c      slowlog.o       t_list.c    version.h
adlist.o     aof.o        config.c   debug.o       hyperloglog.c  lzf.h            notify.o      rand.h             redis-check-rdb    replication.c  sentinel.o      solarisfixes.h  t_list.o    ziplist.c
ae.c         asciilogo.h  config.h   dict.c        hyperloglog.o  lzfP.h           object.c      rand.o             redis-check-rdb.c  replication.o  server.c        sort.c          t_set.c     ziplist.h
ae_epoll.c   bio.c        config.o   dict.h        intset.c       Makefile         object.o      rdb.c              redis-check-rdb.o  rio.c          server.h        sort.o          t_set.o     ziplist.o
ae_evport.c  bio.h        crc16.c    dict.o        intset.h       Makefile.dep     pqsort.c      rdb.h              redis-cli          rio.h          server.o        sparkline.c     t_string.c  zipmap.c
ae.h         bio.o        crc16.o    endianconv.c  intset.o       memtest.c        pqsort.h      rdb.o              redis-cli.c        rio.o          setproctitle.c  sparkline.h     t_string.o  zipmap.h
ae_kqueue.c  bitops.c     crc64.c    endianconv.h  latency.c      memtest.o        pqsort.o      redisassert.h      redis-cli.o        scripting.c    setproctitle.o  sparkline.o     t_zset.c    zipmap.o
ae.o         bitops.o     crc64.h    endianconv.o  latency.h      mkreleasehdr.sh  pubsub.c      redis-benchmark    redis-sentinel     scripting.o    sha1.c          syncio.c        t_zset.o    zmalloc.c
ae_select.c  blocked.c    crc64.o    fmacros.h     latency.o      multi.c          pubsub.o      redis-benchmark.c  redis-server       sdsalloc.h     sha1.h          syncio.o        util.c      zmalloc.h
anet.c       blocked.o    db.c       geo.c         lzf_c.c        multi.o          quicklist.c   redis-benchmark.o  redis-trib.rb      sds.c          sha1.o          testhelp.h      util.h      zmalloc.o
anet.h       cluster.c    db.o       geo.h         lzf_c.o        networking.c     quicklist.h   redis-check-aof    release.c          sds.h          slowlog.c       t_hash.c        util.o
[root@iZ25ufmpy4sZ src]# cp  redis-benchmark redis-check-aof redis-cli redis-server ../bin
[root@iZ25ufmpy4sZ src]# cd ../bin
[root@iZ25ufmpy4sZ bin]# ls
redis-benchmark  redis-check-aof  redis-cli  redis-server

7.修改配置文件redis.cnf,把属性daemonize改为yes

# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0# TCP keepalive.
#
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
# of communication. This is useful for two reasons:
#
# 1) Detect dead peers.
# 2) Take the connection alive from the point of view of network
#    equipment in the middle.
#
# On Linux, the specified value (in seconds) is the period used to send ACKs.
# Note that to close the connection the double of the time is needed.
# On other kernels the period depends on the kernel configuration.
#
# A reasonable value for this option is 300 seconds, which is the new
# Redis default starting with Redis 3.2.1.
tcp-keepalive 300################################# GENERAL ###################################### By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
#   supervised no      - no supervision interaction
#   supervised upstart - signal upstart by putting Redis into SIGSTOP mode
#   supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
#   supervised auto    - detect upstart or systemd method based on
#                        UPSTART_JOB or NOTIFY_SOCKET environment variables
# Note: these supervision methods only signal "process is ready."
#       They do not enable continuous liveness pings back to your supervisor.
supervised no# If a pid file is specified, Redis writes it where specified at startup
# and removes it at exit.
#
# When the server runs non daemonized, no pid file is created if none is
# specified in the configuration. When the server is daemonized, the pid file
# is used even if not specified, defaulting to "/var/run/redis.pid".
#
# Creating a pid file is best effort: if Redis is not able to create it
# nothing bad happens, the server will start and run normally.
pidfile /var/run/redis_6379.pid

8.启动redis

[root@iZ25ufmpy4sZ bin]# ./redis-server ../etc/redis.conf _._                                                  _.-``__ ''-._                                             _.-``    `.  `_.  ''-._           Redis 3.2.6 (00000000/0) 64 bit.-`` .-```.  ```\/    _.,_ ''-._                                   (    '      ,       .-`  | `,    )     Running in standalone mode|`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379|    `-._   `._    /     _.-'    |     PID: 4496`-._    `-._  `-./  _.-'    _.-'                                   |`-._`-._    `-.__.-'    _.-'_.-'|                                  |    `-._`-._        _.-'_.-'    |           http://redis.io        `-._    `-._`-.__.-'_.-'    _.-'                                   |`-._`-._    `-.__.-'    _.-'_.-'|                                  |    `-._`-._        _.-'_.-'    |                                  `-._    `-._`-.__.-'_.-'    _.-'                                   `-._    `-.__.-'    _.-'                                       `-._        _.-'                                           `-.__.-'                                               4496:M 18 Jan 17:10:46.374 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
4496:M 18 Jan 17:10:46.374 # Server started, Redis version 3.2.6
4496:M 18 Jan 17:10:46.374 # 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.
4496:M 18 Jan 17:10:46.374 # 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.
4496:M 18 Jan 17:10:46.374 * The server is now ready to accept connections on port 6379

9.如果还是觉得麻烦,可以在redis根目录创建两个脚本,start.sh和stop.sh,内容分别如下

[root@iZ25ufmpy4sZ redis]# ls
00-RELEASENOTES  bin  BUGS  CONTRIBUTING  COPYING  deps  dump.rdb  etc  INSTALL  Makefile  MANIFESTO  README.md  redis.conf  runtest  runtest-cluster  runtest-sentinel  sentinel.conf  src  start.sh  stop.sh  tests  utils
[root@iZ25ufmpy4sZ redis]# cat start.sh
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
[root@iZ25ufmpy4sZ redis]# cat stop.sh
/usr/local/redis/bin/redis-cli shutdown 

转载于:https://www.cnblogs.com/qizhelongdeyang/p/6297582.html

十一.安装Redis相关推荐

  1. Spring Boot(十一)Redis集成从Docker安装到分布式Session共享

    2019独角兽企业重金招聘Python工程师标准>>> 一.简介 Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并 ...

  2. redis安装、持久化、数据类型、常用操作、操作键值、安全设置、慢查询日志、存储session、主从配置、集群介绍、集群搭建配置、集群操作,php安装redis扩展...

    21.9 redis介绍 21.10 redis安装 21.11 redis持久化 21.12 redis数据类型 21.13/21.14/21.15 redis常用操作 21.16 redis操作键 ...

  3. PVE系列教程(十七)、安装Redis服务器

    PVE系列教程(十七).安装Redis服务器 为了更好的浏览体验,欢迎光顾勤奋的凯尔森同学个人博客http://www.huerpu.cc:7000 一.前期准备 在PVE里安装好了ubuntu,并对 ...

  4. Redis学习之路(一)--下载安装redis

    redis学习之路--下载安装redis windows安装redis 1.下载redis 2.安装 3.查看是否安装成功 windows安装redis 1.下载redis 网址:https://gi ...

  5. xshell连接不了服务器显示22端口,win10安装redis,xshell无法连接22端口

    先下载redis,找到下载的压缩包 redis-64.3.0.503.zip,解压后,重命名为redis-3.0,置于某个文件夹下(如D:\Program Files). 1. 运行Redis服务器端 ...

  6. Windows下安装Redis服务

    2019独角兽企业重金招聘Python工程师标准>>> Redis是有名的NoSql数据库,一般Linux都会默认支持.但在Windows环境中,可能需要手动安装设置才能有效使用.这 ...

  7. Redis进阶实践之三如何在Windows系统上安装安装Redis

    一.Redis的简介 Redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合).zset( ...

  8. ubuntu安装redis的方法以及PHP安装redis扩展、CI框架sess使用redis的方法

    为什么80%的码农都做不了架构师?>>>    再一次被网上那些教程误导后决定自己写一个.真心被那些奇怪的教程误导了好几次,之前研究其它东西的时候也是.蛋疼啊. 安装redis 直接 ...

  9. centos6.5命令安装redis并设置redis自启动,可远程连接

    2019独角兽企业重金招聘Python工程师标准>>> 一.安装 1.切换为root账户,安装redis所需的必要包 yum install gcc 2.进入要安装redis的路径下 ...

最新文章

  1. angular 缓存 html5,Angular 如何及时更新客户端缓存?
  2. mac电脑如何与手机同步复制粘贴_苹果换安卓手机如何同步手机自带备忘录便签?...
  3. 本期赠书中奖名单公布
  4. 流量银行与阿里联手放大招 1毛钱换1块钱
  5. 2018南京网络赛L题 Magical Girl Haze(分层图+优先队列优化的dijkstra)
  6. 第1节 yarn:15、关于yarn中常用的参数设置
  7. python爬虫中的ip代理设置
  8. Spring MVC,Ajax和JSON第3部分–客户端代码
  9. [css] 有用过scss和sass吗?说说它们之间的区别是什么?
  10. 机器人--寒暄库(4)
  11. python esp8266_浅谈MircoPython---ESP8266
  12. linux c++应用程序内存高或者占用CPU高的解决方案_20161213
  13. arraylist可以存储不同类型吗_创新科技 - 不同防冻液可以混加吗
  14. 为什么在加油站上班,一个月休3天,工资2000元,却有人干?
  15. springboot+mybatis 的org.mybatis.spring.MyBatisSystemException 解决方法
  16. 【java学习之路】(java SE篇)(练习)集合练习:经典例题
  17. 第2章 神经网络的数学基础
  18. 智能机器人机器人心得_如果机器人说到上帝
  19. uiautomatorviewer 提示 Error obtaining UI hierarchy 的解决办法
  20. java节假日算法_「国家法定节假日」java 国家法定节假日和双休日判断工具类 - seo实验室...

热门文章

  1. 09_Mybatis开发Dao方法——mapper代理开发规范
  2. (9)C#之ADO.NET 两个ListBox联动案例
  3. Ant在MyEclipse中的配置总结
  4. 算法学习:后缀数组 height的求取
  5. https的基本原理,看完你的程序员女朋友再也不和你提分手了
  6. 1-5-20:球弹跳高度的计算
  7. 【Android基础】点击Back键退出应用程序
  8. JavaScript 同源策略
  9. android studio换主题,为Android Studio换上一副更加好看的主题
  10. hdu1828 线段树扫描线求矩形面积的周长