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
---- ::-- 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|:... failed: Connection timed out.
Retrying. ---- ::-- (try: ) http://download.redis.io/releases/redis-3.2.6.tar.gz
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:... connected.
HTTP request sent, awaiting response... OK
Length: (1.5M) [application/x-gzip]
Saving to: ‘redis-3.2..tar.gz’ %[======================================================================================================================================================================================>] ,, .40MB/s in .1s -- :: (1.40 MB/s) - ‘redis-3.2..tar.gz’ saved [/]

2.解压

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

3.进入redis目录并make

[root@iZ25ufmpy4sZ local]# cd  redis-3.2.
[root@iZ25ufmpy4sZ redis-3.2.]# ls
-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.]# make
cd src && make all
make[]: Entering directory `/usr/local/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 `/usr/local/redis-3.2./deps'
make[]: Leaving directory `/usr/local/redis-3.2./src'

4.进入src目录make install

[root@iZ25ufmpy4sZ redis-3.2.]# 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 install Hint: It's a good idea to run 'make test' ;) INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install

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

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

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

[root@iZ25ufmpy4sZ redis-3.2.]# 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 ( to disable)
timeout # TCP keepalive.
#
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
# of communication. This is useful for two reasons:
#
# ) Detect dead peers.
# ) 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 seconds, which is the new
# Redis default starting with Redis 3.2..
tcp-keepalive ################################# 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= 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. (/) bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port:
| `-._ `._ / _.-' | PID: 4496
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' :M Jan ::46.374 # WARNING: The TCP backlog setting of cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of .
:M Jan ::46.374 # Server started, Redis version 3.2.
:M Jan ::46.374 # 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 Jan ::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.
:M Jan ::46.374 * The server is now ready to accept connections on port

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

[root@iZ25ufmpy4sZ redis]# ls
-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

十一.安装Redis的更多相关文章

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

    一.简介 Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API,Redis也是技术领域使用最为广泛的存储中间件,它是 ...

  2. python学习笔记(十一)redis的介绍及安装

    一.redis简介 1.redis是一个开源的.使用C语言编写的.支持网络交互的.可基于内存也可持久化的Key-Value数据库.       2.redis的官网地址,非常好记,是redis.io. ...

  3. centos8安装redis

    一,下载: 1,下载页面: https://redis.io/ 2,下载 [root@localhost source]# wget http://download.redis.io/releases ...

  4. Ubuntu安装redis并配置远程、密码以及开启php扩展

    一.前言 redis是当前流行的nosql数据库,很多网站都用它来做缓存,今天我们来安装并配置下redis 二.安装并配置redis 1.安装redis sudo apt-get install re ...

  5. CentOS 7 下安装redis步骤

    1. 从redis官网下载redis源码,本例安装在/usr/opt下 [root@localhost opt]# pwd /usr/opt [root@localhost opt]# wget ht ...

  6. 安装redis以windows服务形式

    安装redis以windows服务形式 安装redis以windows服务形式 redis windows windows 服务 以前跑redis,老是要开一个命令行窗口,一旦关闭,redis服务就挂 ...

  7. Mac Pro 编译安装 Redis 的 PHP 客户端 phpredis

    1.去官网下载 redis 扩展源码包 https://github.com/phpredis/phpredis 2.安装 redis 扩展 /usr/local/src/mac-sdk/source ...

  8. 编译安装PHP7并安装Redis扩展Swoole扩展

    编译安装PHP7并安装Redis扩展Swoole扩展 在编译php7的机器上已经有编译安装过php5.3以上的版本,从而依赖库都有了 本php7是编译成fpm-php 使用的, 如果是apache那么 ...

  9. 【安装Redis】CentOS7 下安装NodeJs+Express+MongoDB+Redis

    Redis,V3.2,官网l官方链接:http://www.redis.io/download,参考:http://blog.csdn.net/mlks_2008/article/details/19 ...

随机推荐

  1. bzoj 2164: 采矿

    Description 浩浩荡荡的cg大军发现了一座矿产资源极其丰富的城市,他们打算在这座城市实施新的采矿战略.这个城市可以看成一棵有n个节点的有根树,我们把每个节点用1到n的整数编号.为了方便起见, ...

  2. [转]使用依赖关系注入在 ASP.NET Core 中编写干净代码

    本文转自:http://blog.jobbole.com/101270/ 原文出处: Steve Smith    ASP.NET Core 1.0 是 ASP.NET 的完全重新编写,这个新框架的主 ...

  3. vue中添加favicon.ico

    1.首先将favicon.ico图片放在根目录下 2.修改webpack配置文件 1)找到build下的webpack.dev.conf.js文件 new HtmlWebpackPlugin({ fi ...

  4. Spring mvc 中 DispatcherServlet 的学习和理解

    上图表示当客户请求来到时,spring架构作出响应的流程,可以从图中看到看到请求分发的中心就是 DispatcherServlet 类,DispatcherServlet的任务是将请求发送给Sprin ...

  5. react-native学习之入门app

    1.项目初始化: react-native init MyProject 2.启动项目: cd MyProject react-native start 新开cmd窗口: react-native r ...

  6. Nexus-NuGet私有仓库服务搭建(一)

    搭建私有Nuget服务器的方式有很多,大多数人文章介绍在vs 中新建默认web项目,然后再Nuget 中安装 Nuget.Server,再部署到IIS 中即可.虽然能用,但是这种方式太过简陋,操作界面 ...

  7. java导入excle表格,并且对表格进行相应的修改,并对表格数据进行整理,最后导出本地表格等一系列操作

    1.首先创建一个java项目 完成效果如下图所示 2.导入以下jar包 3.代码如下 其中行和列的操作是根据需求自动划分的 public class auto_date { private stati ...

  8. 嵌套Golang对象的初始化

      比如有这样一个对象: type ProductConfig struct {     Site map[string]string } 对应的初始化可以如下写: var pc ProductCon ...

  9. Jvm性能监控和常用工具

    JDK常用命令行工具   Jps : jps [options] [hostid]  , -q 只显示jvmid, -m 传递给主类main的参数,-l 类全名,-v jvm启动参数 jstat : ...

  10. Effective C++ .17 函数调用时的资源管理

    以书上的代码为例 processWidget(shared_ptr<Widget>(new Widget), priority()) 虽然使用了智能指针来管理资源但是,由于参数值计算顺序的 ...