redis-cli

Docker安装Redis并配置远程连接

≡放荡痞女 提交于 2020-07-27 21:33:59
拉取最新镜像 docker pull redis 初次运行容器 docker run --name myredis -d -p6379:6379 redis 进入redis控制台 docker exec -it myredis redis-cli ,输入info回车可以查看对应版本号,我这redis版本号为6.0.3 ============================================== 删除上面的容器命令如下: 其实上面已经就启动好了redis,以下是我在阿里云ecs的操作 接下来就是去官网下载对于linux版本下的redis地址 下载地址 解压把redis.conf文件放到centos某个路径下,我是root身份登录的,就在/root建立了redis/conf,以及redis/data 接下来修改conf配置文件部分内容 大概69行 注释掉bind 127.0.0.1以便外网访问 大概88行 protected-mode 改成no 设置redis密码以便安全 切换当前用户目录 cd ~ ,执行 docker run -d -p 6379:6379 -v $PWD/conf/redis.conf:/usr/local/etc/redis/redis.conf -v $PWD/data:/data --name myredis6 docker.io/redis

centos7搭建redis集群

陌路散爱 提交于 2020-07-27 05:16:40
搭建环境 系统: centos 7.4 服务器金山云 安装ruby环境 [root@jsy-bj-test00 ~]# yum install -y ruby rubygems 复制6份redis服务 [work@jsy-bj-test00 ~]$ cp -rp redis redis1 [work@jsy-bj-test00 ~]$ cp -rp redis redis2 [work@jsy-bj-test00 ~]$ cp -rp redis redis3 redis配置文件修改 #六个节点需做如下更改 [work@jsy-bj-test00 ~]$ vim redis1/etc/redis.conf [work@jsy-bj-test00 ~]$ sed -i 's/port 6379/port 6380/g' redis5/etc/redis.conf #修改端口 port 6380 #打开注释,开启集群模式 cluster-enabled yes #集群的配置文件 cluster-config-file nodes-6380.conf [work@jsy-bj-test00 ~]$ sed -i 's/cluster-config-file nodes-6379.conf/cluster-config-file nodes-6380.conf/g' redis5/etc

Redis setting TTL on hSet Keys

守給你的承諾、 提交于 2020-07-16 06:23:29
问题 I am on an dead end with redis cache. I want to set an TTL on the initiation of a key. The key will be set by hSet($hash, $key, $data) expire($key, '3600') does not seem to work. Is there an hExpire() method? 回答1: Explanation: Redis supports expiration only on KEY level. It does not support expiration on inner element(s) of any data structure, let alone hash. Answer: No. There is no hExpire method/command in Redis. You're trying expire an inner element in a hash. This is not possible in Redis

Redis setting TTL on hSet Keys

二次信任 提交于 2020-07-16 06:23:10
问题 I am on an dead end with redis cache. I want to set an TTL on the initiation of a key. The key will be set by hSet($hash, $key, $data) expire($key, '3600') does not seem to work. Is there an hExpire() method? 回答1: Explanation: Redis supports expiration only on KEY level. It does not support expiration on inner element(s) of any data structure, let alone hash. Answer: No. There is no hExpire method/command in Redis. You're trying expire an inner element in a hash. This is not possible in Redis

Redis Pubsub and Message Queueing

五迷三道 提交于 2020-05-09 17:33:08
问题 My overall question is: Using Redis for PubSub, what happens to messages when publishers push messages into a channel faster than subscribers are able to read them? For example, let's say I have: A simple publisher publishing messages at the rate of 2 msg/sec. A simple subscriber reading messages at the rate of 1 msg/sec. My naive assumption would be the subscriber would only see 50% of the messages published onto Redis. To test this theory, I wrote two scripts: pub.py queue = redis

redis 系列16 持久化 RDB

非 Y 不嫁゛ 提交于 2020-05-09 07:10:26
一.概述   Redis是内存数据库,一旦服务器进程退出,服务器中的数据库内存数据状态也会消失。为了解决这个问题,Redis提供了RDB 持久化功能,这个功能可以将redis在内存中的数据库状态保存到磁盘中,避免数据意外丢失。   RDB持久化可以手动执行,也可以根据服务器配置选项定期执行,是在指定的时间间隔,对你的数据进行快照存储。该RDB文件快照是一个经过压缩的二进制文件。文件名为dump.rdb,该文件保存在redis目录下,当redis服务器停机后,只要RDB文件存在,下次重启Redis服务时就会自动还原数据库数据状态。   1.1 RDB文件的创建     通过Redis两个命令来生成RDB文件,一是SAVE,另一个是BGSAVE。SAVE命令是会阻塞Redis服务器进程,直到RDB文件创建完毕为止,在阻塞期间,服务器不能处理任何命令请求。 127.0 . 0.1 : 6379 > save -- 等待RDB文件创建完毕 OK     与SAVE不同,BGSAVE命令会派生出一个子进程,然后由子进程负责创建RDB文件,服务器进程(父进程)继续处理命令请求。当BGSAVE命令在执行期间,客户端再发送BGSAVE命令会被服务器拒绝,因为同时执行两个GBSAVE命令也会产生竞争条件。最后BGREWRITEAOF和GBSAVE两个命令也不能同时执行。 127.0 . 0.1 :

通过sudo的方式启动redis就能保存dump.rdb

落花浮王杯 提交于 2020-05-08 15:37:59
1.今天发现redis使用save命令后报ERR错误,原因是权限不够,所以使用sudo启动自然能解决。 sudo ./bin/redis-server ./etc/redis.conf redis-cli -h 192.168.2.194 -p 6379 2.或者使用redis的过程中全程都是在root权限下即可。 来源: oschina 链接: https://my.oschina.net/u/4305437/blog/4270347

Mac上的redis安装与jedis入门

不打扰是莪最后的温柔 提交于 2020-05-07 19:48:14
Redis 是一个开源(BSD许可)的,内存中的数据结构存储系统,它可以用作数据库、缓存和消息中间件 安装与配置 (1) https://redis.io/download 下载redis stable最新版 将压缩包解压到你的文件夹下 (2) 进入到redis文件夹的根目录 # 编译测试(跳过也可以) sudo make test # 编译安装 sudo make install # 安装完成以后启动 redis-server (3) 简单测试 新建一个terminal, 输入 redis-cli # 客户端 存一个简单的kv Jedis使用 Redis命令参考 http://redisdoc.com/list/ltrim.html [推荐, 很全] http://doc.redisfans.com/index.html [很全] (1) 连接到jedis服务 下载依赖的jar包 https://mvnrepository.com/artifact/redis.clients/jedis/2.9.0 或者使用Maven更方便 <!-- https://mvnrepository.com/artifact/redis.clients/jedis --> < dependency > < groupId > redis.clients </ groupId > <

redis集群安装多端口多实例部署

社会主义新天地 提交于 2020-05-07 18:26:38
目标(本文达成的结果,配对关系可能会变): 先在131上进行操作 1.下载redis http://download.redis.io/releases/redis-5.0.2.tar.gz 2.解压 [testapp@k8s-node2 ~]$ mkdir redis [testapp@k8s-node2 ~]$ cd redis 上传文件 [testapp@k8s-node2 ~/redis]$ tar -zxvf redis-5.0.2.tar.gz 3.修改/usr/local/bin/权限 su - root chmod 777 /usr/local/bin/ su - testapap 建立文件夹 [testapp@k8s-node2 ~/redis]$ mkdir redis_cluster [testapp@k8s -node2 ~/redis]$ mkdir logs [testapp@k8s -node2 ~/redis]$ touch logs/ redis_run.logs [testapp@k8s -node2 ~/redis]$ cp /redis- 5.0 . 2 /redis.conf . [testapp@k8s -node1 ~/ redis]$ ll 总用量 1908 drwxrwxr -x 2 testapp testapp 77 8月 14

redis-6.0.1 docker下安装

眉间皱痕 提交于 2020-05-06 23:22:33
1. 下载最新 redis image ( 此处为Redis server v=6.0.1 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=0 ) docker pull redis:latest 2.运行 redis 服务 docker run -itd -v /usr/local/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf -v /usr/local/redis/data:/data --name mh-redis redis:latest redis-server /usr/local/etc/redis/redis.conf 3.添加 redis 配置文件 #bind 127.0.0.1 //允许远程连接 #daemonize yes #redis3.2版本后新增protected-mode配置,默认是yes #关闭protected-mode模式,此时外部网络可以直接访问 #开启protected-mode保护模式,需配置bind ip或者设置访问密码 protected-mode yes #持久化 appendonly yes #密码 requirepass 123456 #日志 #logfile "/data/redis6/logs/redis.log