Redis 安装

Redis Windows 安装

在 Redis 官网上https://redis.io/download下载页面没找到Windows 安装包。

我们直接到微软gitHub上下载Redis-x64-3.2.100.zip安装包。

解压Redis-x64-3.2.100.zip压缩包:

下面各文件说明:

  • 配置文件redis.conf:复制目录下的redis.windows.conf文件并修改为配置文件名。
  • 服务器端启动文件:redis-server.exe
  • 客户端启动文件:redis-cli.exe

Redis 配置和启动doc命令编辑

服务器端启动doc命令文件【start-server.bat】内容如下:

redis-server.exe redis.conf

客户端启动doc命令文件【start-client.bat】内容如下:

redis-cli.exe -p 6379

直接运行:批处理文件start-server.bat:

F:\system\env\mainboot\redis\Redis-x64-3.2>redis-server.exe redis.conf
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 3.2.100 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 7760
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

[7760] 23 Apr 22:15:16.150 # Server started, Redis version 3.2.100
[7760] 23 Apr 22:15:16.150 * The server is now ready to accept connections on po
rt 6379
 

批处理文件start-client.bat:

	F:\system\env\mainboot\redis\Redis-x64-3.2>redis-cli.exe -p 6379
	127.0.0.1:6379> set mainboot "https://www.mainboot.com"
	OK
	127.0.0.1:6379> get mainboot
	"https://www.mainboot.com"
	127.0.0.1:6379>

Redis Linux 安装

以Centos版本来安装。

下载地址:http://redis.io/download,下载最新稳定版本。

使用的最新文档版本为redis-5.0.4下载并安装:

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

tar -zxvf redis-5.0.4.tar.gz

cd redis-5.0.4

make && make install

安装已经完成,安装的执行文件都在/usr/local/bin目录下:

cd /usr/local/bin

ll

总用量 39164
-rwxr-xr-x. 1 root root 6614593 4月  12 23:21 docker-compose
-rw-r--r--. 1 root root      92 4月  12 23:50 dump.rdb
-rwxr-xr-x. 1 root root 4366576 4月  12 23:48 redis-benchmark
-rwxr-xr-x. 1 root root 8101256 4月  12 23:48 redis-check-aof
-rwxr-xr-x. 1 root root 8101256 4月  12 23:48 redis-check-rdb
-rwxr-xr-x. 1 root root 4806808 4月  12 23:48 redis-cli
lrwxrwxrwx. 1 root root      12 4月  12 23:48 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 8101256 4月  12 23:48 redis-server

下面各文件说明:

  • 服务器端启动文件:redis-server
  • 客户端启动文件:redis-cli

启动和停止 Redis

redis-server

12250:C 13 Apr 2019 00:05:59.335 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
12250:C 13 Apr 2019 00:05:59.335 # Redis version=5.0.4, bits=64, commit=00000000, modified=0, pid=12250, just started
12250:C 13 Apr 2019 00:05:59.335 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
12250:M 13 Apr 2019 00:05:59.336 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.4 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 12250
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

12250:M 13 Apr 2019 00:05:59.339 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
12250:M 13 Apr 2019 00:05:59.339 # Server initialized
12250:M 13 Apr 2019 00:05:59.339 # 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.
12250:M 13 Apr 2019 00:05:59.339 # 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.
12250:M 13 Apr 2019 00:05:59.340 * DB loaded from disk: 0.000 seconds
12250:M 13 Apr 2019 00:05:59.340 * Ready to accept connections

redis-cli

127.0.0.1:6379> set mainboot "https://www.mainboot.com"
OK
127.0.0.1:6379> get mainboot
"https://www.mainboot.com"
127.0.0.1:6379> 

通过初始化脚本启动Redis

Docker 安装 Redis

在我们Docker 系列教程中的Docker 安装 Redis有详细的安装步骤。

Copyright © 2019-2019主引教程mainboot.com All Rights Reserved. 备案号: 闽ICP备13019624号-4