mac redis安装_Redis 系列(二)Redis 安装

Redis 全称:Remote Dictionary Server(远程字典服务器),是完全开源免费的,用C语言编写的,遵守BSD协议,是一个高性能的(key/value)分布式内存数据库,基于内存运行并支持持久化的NoSQL数据库,是当前最热门的NoSql数据库之一,也被人们称为数据结构服务器。

9a0ae42b633591bb36982fb25a152087.png

1.Redis 介绍

官方网站https://redis.iohttp://www.redis.cn

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

  • Redis 支持数据的持久化,可以将内存中的数据保持在磁盘中,重启的时候可以再次加载进行使用
  • Redis 不仅仅支持简单的 key-value 类型的数据,同时还提供 list,set,zset,hash 等数据结构的存储
  • Redis 支持数据的备份,即 master-slave 模式的数据备份

2.Redis 安装

Docker 方式安装 redis 是非常推荐的方式,易于维护。

2.1 下载镜像

Redis 镜像官网:https://hub.docker.com/_/redis/

执行命令:docker pull redis,等待镜像下载成功。

~ docker pull redisUsing default tag: latestlatest: Pulling from library/redis68ced04f60ab: Pull complete7ecc253967df: Pull complete765957bf98d4: Pull complete91fff01e8fef: Pull complete76feb725b7e3: Pull complete75797de34ea7: Pull completeDigest: sha256:ddf831632db1a51716aa9c2e9b6a52f5035fc6fa98a8a6708f6e83033a49508dStatus: Downloaded newer image for redis:latestdocker.io/library/redis:latest

2.2 创建并运行容器

~ docker run -itd --name local-redis -p 6379:6379 redisb26758de6935aa9f7ab7e85d19fac064fced84ced322f42359741467c4068fdc

2.3 查看是否安装成功

~ docker logs -f local-redis1:C 17 Mar 2020 10:17:22.157 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo1:C 17 Mar 2020 10:17:22.157 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=1, just started1:C 17 Mar 2020 10:17:22.157 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf                _._           _.-``__ ''-._      _.-``    `.  `_.  ''-._           Redis 5.0.8 (00000000/0) 64 bit  .-`` .-```.  ```/    _.,_ ''-._ (    '      ,       .-`  | `,    )     Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379 |    `-._   `._    /     _.-'    |     PID: 1  `-._    `-._  `-./  _.-'    _.-' |`-._`-._    `-.__.-'    _.-'_.-'| |    `-._`-._        _.-'_.-'    |           http://redis.io  `-._    `-._`-.__.-'_.-'    _.-' |`-._`-._    `-.__.-'    _.-'_.-'| |    `-._`-._        _.-'_.-'    |  `-._    `-._`-.__.-'_.-'    _.-'      `-._    `-.__.-'    _.-'          `-._        _.-'              `-.__.-'1:M 17 Mar 2020 10:17:22.161 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.1:M 17 Mar 2020 10:17:22.161 # Server initialized1:M 17 Mar 2020 10:17:22.161 # 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.1:M 17 Mar 2020 10:17:22.161 * Ready to accept connections

出现上述日志,即表示 Redis 安装成功。

3.工具推荐

3.1 redis-cli

redis 自带的命令行工具,所在目录/usr/local/bin

进入到容器控制台:

~ docker exec -it local-redis /bin/bash

链接 redis-cli 并使用 ping 命令:

root@b26758de6935:~# /usr/local/bin/redis-cli127.0.0.1:6379> pingPONG

3.2 Redis Desktop Manager

官方网站:https://redisdesktop.com/

620831df931624f5b798f391605088e4.png

此工具在 Mac 上会使用高性能显卡,比较费电,还有点卡,不推荐。

3.3 RedisInsight

官方网站:https://redislabs.com/redisinsight/

be14ace0bc0bac18b60db81076c90d33.png

推荐使用,控制台是网页,反正也要打开浏览器的,多开一个标签页也无所谓,而且颜值还不错!

4.其他

Redis 默认安装目录:/usr/local/bin

首先查看下/usr/local/bin目录中的内容:

root@b26758de6935:~# ls -al /usr/local/bin/total 24580drwxr-xr-x 1 root root     4096 Mar 13 20:21 .drwxr-xr-x 1 root root     4096 Feb 24 00:00 ..-rwxrwxr-x 1 root root      374 Mar 13 20:20 docker-entrypoint.sh-rwxr-xr-x 1 root root  2294944 Oct 15  2018 gosu-rwxr-xr-x 1 root root  5940736 Mar 13 20:21 redis-benchmarklrwxrwxrwx 1 root root       12 Mar 13 20:21 redis-check-aof -> redis-serverlrwxrwxrwx 1 root root       12 Mar 13 20:21 redis-check-rdb -> redis-server-rwxr-xr-x 1 root root  6484736 Mar 13 20:21 redis-clilrwxrwxrwx 1 root root       12 Mar 13 20:21 redis-sentinel -> redis-server-rwxr-xr-x 1 root root 10424488 Mar 13 20:21 redis-server

下面对主要文件进行介绍:

  • docker-entrypoint.sh:docker 启动脚本
  • redis-benchmark:性能测试工具
  • redis-check-aof:修复有问题的 AOF 文件
  • redis-check-dump:修复有问题的 dump.rdb 文件
  • redis-cli:客户端链接脚本
  • redis-sentinel:redis 集群脚本
  • redis-server:redis 服务器启动脚本
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值