Linux服务器:安装 Redis

2019-04-18  本文已影响0人  啊肉怪

Redis 是完全开源免费、遵守 BSD 协议的一个高性能 key-value 数据库。

Redis 与其他 key - value 缓存产品有以下三个特点

安装 redis

下载 redis 安装包

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(134, 145, 148); line-height: 1.6; border: none; text-align: right; background: rgb(239, 242, 243);">1
</pre>

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(77, 77, 76); line-height: 1.6; border: none; width: 428px; background: rgb(247, 247, 247);">wget http://download.redis.io/releases/redis-5.0.4.tar.gz
</pre>

|

解压压缩包

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(134, 145, 148); line-height: 1.6; border: none; text-align: right; background: rgb(239, 242, 243);">1
</pre>

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(77, 77, 76); line-height: 1.6; border: none; width: 221px; background: rgb(247, 247, 247);">tar -xzvf redis-5.0.4.tar.gz
</pre>

|

yum 安装 gcc 依赖

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(134, 145, 148); line-height: 1.6; border: none; text-align: right; background: rgb(239, 242, 243);">1
</pre>

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(77, 77, 76); line-height: 1.6; border: none; width: 128px; background: rgb(247, 247, 247);">yum install gcc
</pre>

|

这边我在配置 nginx 服务器的时候安卓过,所以此步略过

编译安装

先进入 redis 目录

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(134, 145, 148); line-height: 1.6; border: none; text-align: right; background: rgb(239, 242, 243);">1
</pre>

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(77, 77, 76); line-height: 1.6; border: none; width: 121px; background: rgb(247, 247, 247);">cd redis-5.0.4
</pre>

|

编译安装

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(134, 145, 148); line-height: 1.6; border: none; text-align: right; background: rgb(239, 242, 243);">1
</pre>

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(77, 77, 76); line-height: 1.6; border: none; width: 49px; background: rgb(247, 247, 247);">make
</pre>

|

测试编译结果

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(134, 145, 148); line-height: 1.6; border: none; text-align: right; background: rgb(239, 242, 243);">1
</pre>

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(77, 77, 76); line-height: 1.6; border: none; width: 85px; background: rgb(247, 247, 247);">make test
</pre>

|

启动 redis

切换到 redis/src 目录下

直接启动

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(134, 145, 148); line-height: 1.6; border: none; text-align: right; background: rgb(239, 242, 243);">1
</pre>

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(77, 77, 76); line-height: 1.6; border: none; width: 121px; background: rgb(247, 247, 247);">./redis-server
</pre>

|

image

如上图:redis 启动成功,但这种启动方式需要一直打开窗口,不能进行其他操作。按 ctrl + c 可以关闭窗口。

后台进程启动

修改 redis.conf 文件

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(134, 145, 148); line-height: 1.6; border: none; text-align: right; background: rgb(239, 242, 243);">1
</pre>

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(77, 77, 76); line-height: 1.6; border: none; width: 228px; background: rgb(247, 247, 247);">daemonize no => daemonize yes
</pre>

|

image

指定配置文件运行 redis

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(134, 145, 148); line-height: 1.6; border: none; text-align: right; background: rgb(239, 242, 243);">1
</pre>

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(77, 77, 76); line-height: 1.6; border: none; width: 221px; background: rgb(247, 247, 247);">./redis-server ../redis.conf
</pre>

|

使用自带的 redis-cli 客户端连接 redis-server 进行测试:

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(134, 145, 148); line-height: 1.6; border: none; text-align: right; background: rgb(239, 242, 243);">1
</pre>

|

<pre style="overflow: auto; font-family: consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(77, 77, 76); line-height: 1.6; border: none; width: 99px; background: rgb(247, 247, 247);">./redis-cli
</pre>

|

image

关闭 redis 进程

首先使用 ps -aux | grep redis 查看 redis 进程

使用 kill 命令杀死进程

image
上一篇 下一篇

猜你喜欢

热点阅读