摘要:说明本篇文章将介绍在三大主流操作系统上安装。所以此处也介绍在和下的安装。在下安装最简单的方式就是使用来一键搞定了。一路狂点鼠标,安装完成即可。
[TOC]
说明本篇文章将介绍在三大主流操作系统(Linux,mac,windows)上安装redis。
Linux上的安装介绍自不必说,很少有人用除了Linux之外的其他操作系统在生成环境下部署redis吧……
但是在开发的时候,很有可能不是在Linux环境下开发的,有必要在自己的操作系统上装一个来开发测试用。所以此处也介绍在mac和windows下的安装。
1 linux[CentOS-6.8-x64]安装 1.1 下载解压wget http://download.redis.io/releases/redis-3.2.8.tar.gz tar -zxvf redis-3.2.8.tar.gz1.2 编译安装
cd redis-3.2.8 make PREFIX=/usr/local/bin install # 目录可以自己指定
至此,安装完成,可以看看生成了哪些东西
# 在/usr/local/bin下,已经在环境变量里了 [root@h4 redis-3.2.8]$ ls -l /usr/local/bin/ total 26348 -rwxr-xr-x. 1 root root 5580319 Apr 4 15:27 redis-benchmark -rwxr-xr-x. 1 root root 22185 Apr 4 15:27 redis-check-aof -rwxr-xr-x. 1 root root 7829986 Apr 4 15:27 redis-check-rdb -rwxr-xr-x. 1 root root 5709187 Apr 4 15:27 redis-cli lrwxrwxrwx. 1 root root 12 Apr 4 15:27 redis-sentinel -> redis-server -rwxr-xr-x. 1 root root 7829986 Apr 4 15:27 redis-server1.3 配置
复制redis.conf
# 从redis解压目录将redis.conf配置文件复制到/data/redis # 此处的/data/redis目录是本人的习惯,按你自己的需要来就行 cp redis.conf /data/redis/
修改配置文件
# 编辑配置文件/data/redis/redis.conf # 修改以下几项 vim /data/redis/redis.conf # 后台模式运行 daemonize yes # 修改日志文件路径 logfile "/data/redis/log.log" # 关闭保护模式,虽然这样不安全,但是从其他主机连接redis时是要关闭保护模式的 protected-mode no1.4 将redis做成系统服务[可选]
[root@h4 redis-3.2.8]$ utils/install_server.sh Welcome to the redis service installer This script will help you easily set up a running redis server Please select the redis port for this instance: [6379] Selecting default: 6379 Please select the redis config file name [/etc/redis/6379.conf] /data/redis/redis.conf Please select the redis log file name [/var/log/redis_6379.log] /data/redis/log.log Please select the data directory for this instance [/var/lib/redis/6379] /data/redis Please select the redis executable path [/usr/local/bin/redis-server] Selected config: Port : 6379 Config file : /data/redis/redis.conf Log file : /data/redis/log.log Data dir : /data/redis Executable : /usr/local/bin/redis-server Cli Executable : /usr/local/bin/redis-cli Is this ok? Then press ENTER to go on or Ctrl-C to abort. Copied /tmp/6379.conf => /etc/init.d/redis_6379 Installing service... Successfully added to chkconfig! Successfully added to runlevels 345! /var/run/redis_6379.pid exists, process is already running or crashed Installation successful!1.5 启停控制
如果你执行了步骤1.4,即你把redis做成了系统服务,可以像下面这样操作:
# 启动Redis [root@h4 redis-3.2.8]$ service redis_6379 start Starting Redis server... # 查看redis进程 [root@h4 redis-3.2.8]$ ps -ef | grep redis root 17160 1 0 15:43 ? 00:00:00 /usr/local/bin/redis-server 127.0.0.1:6379 root 17164 3968 0 15:43 pts/1 00:00:00 grep --color redis # 查看redis使用的端口 [root@h4 redis-3.2.8]$ netstat -tnpl | grep 6379 tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 17160/redis-server # 连接客户端测试 [root@h4 redis-3.2.8]$ redis-cli -p 6379 127.0.0.1:6379> ping PONG 127.0.0.1:6379> exit # 停止Redis [root@h4 redis-3.2.8]$ service redis_6379 stop Stopping ... Redis stopped
如果没有做成系统服务,可以像下面这样操作:
# 启动Redis [root@h4 redis-3.2.8]# redis-server /data/redis/redis.conf # 查看redis进程 [root@h4 redis-3.2.8]# ps -ef | grep redis root 17238 1 0 15:48 ? 00:00:00 redis-server 127.0.0.1:6379 root 17243 3968 0 15:48 pts/1 00:00:00 grep --color redis # 查看redis使用的端口 [root@h4 redis-3.2.8]# netstat -tlnp | grep 6379 tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 17238/redis-server # 连接客户端测试 [root@h4 redis-3.2.8]# redis-cli -p 6379 127.0.0.1:6379> ping PONG 127.0.0.1:6379> exit # 停止Redis [root@h4 redis-3.2.8]# redis-cli shutdown2 mac安装
其实在mac下安装和在Linux(CentOS-6.8-x64)下是非常类似的。
在mac下安装redis最简单的方式就是使用brew install redis来一键搞定了。
如果你不喜欢瞎折腾,就是要最快的傻瓜式安装,那你就用上面的brew install redis吧。
否则,可以参考我们这里介绍的手动编译安装的方式:
2.1 下载解压$ wget http://download.redis.io/releases/redis-3.2.8.tar.gz $ tar -zxvf redis-3.2.8.tar.gz2.2 编译安装
$ cd redis-3.2.8/ $ make PREFIX=/usr/local/bin/redis install
由于此处我将redis安装到了/usr/local/bin/redis,不是默认的/usr/local/bin,所以得改下环境变量
$ vim ~/.bash_profile # 加入如下配置 export redis_home=/usr/local/bin/redis export PATH=$PATH:$redis_home/bin # 刷新环境变量 $ source ~/.bash_profile # 看看配好没? $ which redis-server /usr/local/bin/redis/bin/redis-server2.3 配置
复制redis.conf
$ mkdir /usr/local/etc/redis $ cp redis.conf /usr/local/etc/redis
编辑配置文件
$ cd /usr/local/etc/redis/ $ vim redis.conf # 按需修改如下几项 # 绑定所有网络地址 bind 0.0.0.0 # 数据目录(需事先手动建立目录) dir /Users/hylexus/data/redis/6379/ # 日志文件(需事先手动建立目录) logfile "/Users/hylexus/data/redis/log.log" # 后台运行 daemonize yes # 关闭保护模式 protected-mode no2.4 启停控制
# 启动Redis $ redis-server /usr/local/etc/redis/redis.conf # 查看redis进程 $ ps -ef | grep redis 501 5456 1 0 4:47下午 ?? 0:00.01 redis-server 0.0.0.0:6379 # 连接客户端 $ redis-cli -p 6379 # 测试 127.0.0.1:6379> ping PONG 127.0.0.1:6379> ping redis "redis" 127.0.0.1:6379> exit # 停止Redis $ redis-cli shutdown3 windows安装 3.1 下载msi安装包安装
以下是redis官网下载页面的部分截图:
也就是说redis是不支持windows的。
但是Microsoft Open Tech group维护了一个windows版本的redis。
地址在这里:https://github.com/MSOpenTech...。
去这里下载个msi安装包安装就行了:https://github.com/MSOpenTech...。
一路狂点鼠标[Next],安装完成即可。
有点需要注意的 最好在安装的时候勾选将redis可执行文件加入环境变量
3.2 将redis做成windows服务具体的步骤请看这里:https://raw.githubusercontent...
C:Program FilesRedis>redis-server --service-install redis.windows-service.conf --loglevel verbose
可以去服务窗口看看:
3.3 配置配置文件都在安装目录下:C:/Program Files/Redis
按需修改即可.
3.4 启停控制直接去windows提供的服务管理控制台(3.2中的截图)最方便
命令方式如下:
# 启动Redis # 注意:如果已经启动了,会提示错误。但是错误并不会告诉你已经启动了……………… C:Usershylexus> redis-server --service-start [13032] 04 Apr 17:58:42.168 # HandleServiceCommands: system error caught. error code=1056, message = StartService failed: unknown error # 先停止,再试试启动会不会正常 C:Usershylexus> redis-server --service-stop [5308] 04 Apr 17:58:47.284 # Redis service successfully stopped. # 再次尝试启动[成功] C:Usershylexus> redis-server --service-start [15200] 04 Apr 17:58:52.940 # Redis service successfully started. # 连接客户端测试 C:Program FilesRedis>redis-cli -p 6379 127.0.0.1:6379> ping PONG 127.0.0.1:6379> ping haha "haha" 127.0.0.1:6379> exit # 停止服务 C:Program FilesRedis>redis-server --service-stop [18564] 04 Apr 17:59:22.700 # Redis service successfully stopped. C:Program FilesRedis>参考资料
https://redis.io/download
https://github.com/MSOpenTech...
https://raw.githubusercontent...
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/36339.html
摘要:添加的方法有以下两种通过添加通过按钮,将加入到集群中通过命令行工具添加,方法如下最好采用通过添加其中以及分别为和的地址。 一.基本信息 服务器基本信息 ip地址 安装服务172.16.200.71 zk1、codis-dashboard、codis-fe、codis-ha、 codis-proxy1、group1_M(6379)、group2_S(6380)172.16....
摘要:在集群状态发生改变时,维护集群下所有的状态一致性。添加到集群并完成集群状态的同步,才能改变状态为。添加的方法有以下两种通过添加通过按钮,将加入到集群中通过命令行工具添加,方法如下最好采用通过添加其中以及分别为和的地址。 一.基本信息 1. 服务器基本信息 ip地址 安装服务 172.16.200.71 zk1、codis-dashboard、codis-fe、codis-ha...
摘要:数据过期处理可以精确到毫秒的安装及部署部署环境需要系统,同样也有版本,可以练习使用。官方不典型支持。关闭进程正常关闭服务的地址端口号如果是本地服务,而且端口是这些参数可以省略。命令可以设置的有效期。修改端口,允许集群。 NoSql数据库之Redis1、什么是nosql,nosql的应用场景2、Nonsql数据库的类型a) Key-valueb) 文档型(类似于json)c) 列式存储d...
摘要:数据过期处理可以精确到毫秒的安装及部署部署环境需要系统,同样也有版本,可以练习使用。官方不典型支持。关闭进程正常关闭服务的地址端口号如果是本地服务,而且端口是这些参数可以省略。命令可以设置的有效期。修改端口,允许集群。 NoSql数据库之Redis1、什么是nosql,nosql的应用场景2、Nonsql数据库的类型a) Key-valueb) 文档型(类似于json)c) 列式存储d...
摘要:集成文章目录集成概述测试自定义概述是什么,即远程字典服务。是一个开源的使用语言编写支持网络可基于内存亦可持久化的日志型数据库,并提供多种语言的。与一样,为了保证效率,数据都是缓存在内存中。 ...
阅读 1721·2021-09-23 11:21
阅读 1538·2019-08-29 17:27
阅读 869·2019-08-29 17:03
阅读 602·2019-08-29 15:07
阅读 1785·2019-08-29 11:13
阅读 2259·2019-08-26 12:14
阅读 731·2019-08-26 11:52
阅读 1608·2019-08-23 17:09