先到官网https://redis.io/download下安装包,现在最新是5.0.5版本,可惜点击下载后被windows禁了,那就下4版本的,往下看Other versions的Old(4.0),点4版本最新4.0.14:

  redis的优点之一就是安装包特别小,很快就能下好,点个赞。接下来进入linux的wlf用户,通过rz上传至soft目录,开始执行安装操作:

$ tar xzvf soft/redis-4.0..tar.gz
$ cd redis-4.0.
$ make

  make构建结束后,也就安装结束了:

    LINK redis-server
INSTALL redis-sentinel
CC redis-cli.o
LINK redis-cli
CC redis-benchmark.o
LINK redis-benchmark
INSTALL redis-check-rdb
INSTALL redis-check-aof Hint: It's a good idea to run 'make test' ;) make[]: Leaving directory `/home/wlf/redis-4.0./src'

  启动redis前我们用vi改下配置文件redis.conf:

# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1 # Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and if:
#
# ) The server is not binding explicitly to a set of addresses using the
# "bind" directive.
# ) No password is configured.
#
# The server only accepts connections from clients connecting from the
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::, and from Unix domain
# sockets.
#
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
protected-mode yes

  在bind 127.0.0.1前加#注掉,将protected-mode yes改为protected-mode no去掉保护策略,这样就能支持远程连接了。

# 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 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

  默认redis不是在后台运行的,将daemonize no改为daemonize yes,另外当后台运行时默认生成的pid文件是在/var/run目录下,我们可以指定为自己的目录,如改为/home/wlf/redis-4.0.14/run/redis_6379.pid

  保存好后启动redis:

$ src/redis-server redis.conf
:C Sep ::56.153 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Sep ::56.153 # Redis version=4.0., bits=, commit=, modified=, pid=, just started
:C Sep ::56.153 # Configuration loaded

  看下进程,已经起来了:

$ netstat -nlp | grep
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0.0.0.0: 0.0.0.0:* LISTEN /src/redis-ser
tcp6 ::: :::* LISTEN /src/redis-ser

  我们克隆会话打开另一个窗口,进入wlf用户开启客户端:

$ cd redis-4.0./
$ src/redis-cli
127.0.0.1:> set wlf wumanshu
OK
127.0.0.1:> get wlf
"wumanshu"

  如果我们想从客户端远程连接服务端,只需指定服务端ip即可,假如redis服务端ip是10.110.1.11,那么我在客户端机器使用命令需要加参数h(默认端口也是6379):

$ src/redis-cli -h 10.110.1.11

  关闭客户端,同时也将关闭服务端:

$ src/redis-cli shutdown
$ netstat -nlp | grep
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)

  或者使用telnet也可以从远程机器连接到redis。不过因为以上设置,redis本身的安全机制已经荡然无存,此时很容被入侵,具体方法和安全防护措施参见redis支持远程接入的安全防护问题

最新文章

  1. 自定义view文字垂直居中
  2. JS-学习-DOM元素尺寸和位置
  3. cocos2d-x + Lua接入iOS原生SDK的实现方案[转]
  4. 个人对js闭包的理解
  5. apache本地网址配置
  6. iOS开发系列--让你的应用“动”起来
  7. 降维(一)----说说主成分分析(PCA)的源头
  8. 选择服务器OS标准
  9. CSS 字体描边
  10. 为linux系统实现回收站
  11. 51nod_1627:瞬间移动
  12. UOJ#219. 【NOI2016】优秀的拆分 [后缀数组 ST表]
  13. c# .net 面试总结
  14. Python 使用 xlwings 往 excel 中写入一行数据的两种方法
  15. java调用monkeyrunner(亲测绝对可行)
  16. css3整理--transform
  17. 转载:阿里canal实现mysql binlog日志解析同步redis
  18. 执行Docker命令报错解决办法
  19. 用Use Case获取需求的方法是否有缺陷,还有哪些地方需要改进
  20. 调试大叔V2.1.0(2018.12.17)|http/s接口调试、数据分析程序员辅助开发神器

热门文章

  1. 原生js获取display属性注意事项
  2. Mongodb设置用户权限(整理版)
  3. 「NOI2012」骑行川藏
  4. python读取excel的内容
  5. Mybatis 不支持通配符扫包起别名问题
  6. MongoDB 主从复制及 自动故障转移
  7. [NgRx] NgRx Entity Adapter Configuration - Understanding sortComparer and selectId
  8. [C++11]C++可变参数模板
  9. 各种trick和细节错误汇总
  10. [matlab工具箱] 神经网络Neural Net