设为首页 加入收藏

TOP

理解 Redis(2) - 手把手教你理清 Redis 安装全过程
2019-08-24 00:07:30 】 浏览:146
Tags:理解 Redis 手把手 理清 安装 全过程

Redis 官网 https://redis.io/

之前学习 Redis 学了好多次, 下载安装也都按照教程或官网文档弄过, 但是对于安装过程一直有点迷糊, 感觉稀里糊涂地就好了, 就可以用了. 这种迷糊得到的结果就是一旦遇到一点问题就会不知就里.
今天学到了安装的过程, 记录一下, 顺便分享~~~ but, only for mac 系统.

首先, 安装的位置, 可以自定义, 你可以放在任何位置, 比如桌面上新建一个 redis 文件夹都是可以的. 但是根据常规, mac 系统里安装的程序都是放在 usr/bin 文件夹里. 所以在终端执行以下命令:

进入 /usr/local 文件夹:

cd /usr/local 

新建一个 redis 文件夹:

mkdir redis

这时大家可以在 finder 里打开 /usr/local/redis 文件夹, 看下目前文件夹是空的.

下载 redis 压缩包:

wget http://download.redis.io/releases/redis-5.0.3.tar.gz 

这时再看 finder 里的 redis 文件夹, 就会发现多了一个压缩文件. 后面走的每一步都可以对照着看文件夹里的变化, 就可以很清楚整个安装过程了.

解压:

tar xzf redis-5.0.3.tar.gz 

打开解压后的文件夹:

cd redis-5.0.3 

安装:

make

测试(可选操作):

make test

开启 redis 服务:

redis-5.0.3 src/redis-server 18073:C 20 Feb 2019 14:48:14.525 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 18073:C 20 Feb 2019 14:48:14.526 # Redis version=5.0.3, bits=64, commit=00000000, modified=0, pid=18073, just started 18073:C 20 Feb 2019 14:48:14.526 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf 18073:M 20 Feb 2019 14:48:14.529 * Increased maximum number of open files to 10032 (it was originally set to 4864). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 5.0.3 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 18073 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 18073:M 20 Feb 2019 14:48:14.537 # Server initialized 18073:M 20 Feb 2019 14:48:14.537 * Ready to accept connections 

然后再另外开启一个窗口, 进入 redis 安装文件所在的位置:

cd /usr/local/redis/redis-5.0.3 

开启 redis 客户端:

redis-5.0.3 src/redis-cli 127.0.0.1:6379> 

在命令行输入 ping, 得到 PONG, 证明一切运行正常. 

127.0.0.1:6379> ping PONG 

以上, 就是 redis 的下载安装过程, 下面还有最后一个问题, 就是如果我们退出当前客户端

127.0.0.1:6379> exit 

再随便进入一个非 redis 的安装包所在的目录, 比如 ~ 家目录:

?  redis-5.0.3 cd ~ 

然后再执行 redis-cli, 就会报错, 因为目前的 redis 命令不能全局应用. 这时, 可以这样解决:

首先, 还是进入 redis 的安装文件夹

~ cd /usr/local/redis/redis-5.0.3 

执行以下命令, 并输入密码:

?  redis-5.0.3 sudo make install Password: cd src && /Library/Developer/CommandLineTools/usr/bin/make install Hint: It's a good idea to run 'make test' ;) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL install 

之后就可以在全局任何位置执行 redis-server 和 redis-cli 命令啦......

新开一个终端窗口, 执行以下命令, 就可以在新窗口中监控另一个窗口执行的所有命令:

?  ~ redis-cli monitor OK 1550678835.524638 [0 127.0.0.1:59846] "keys" "*" 1550678855.806835 [0 127.0.0.1:59846] "del" "sut-1" 1550678871.371261 [0 127.0.0.1:59846] "keys" "*"





】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇linux 系统运行级别一般为 0-6,.. 下一篇在 OSX 下使用 supervisor 管理服..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目