Redis(6)Clients - Scala Clients
Upgrade the Redis to latest
>wget http://download.redis.io/releases/redis-2.8.7.tar.gz
Unzip it
>cd redis-2.8.7
>make
>mkdir /Users/carl/tool/redis-2.8.7
>cd src/
>cp redis-server /Users/carl/tool/redis-2.8.7/
>cp redis-benchmark /Users/carl/tool/redis-2.8.7/
>cp redis-cli /Users/carl/tool/redis-2.8.7/
>cd ..
>cp redis.conf /Users/carl/tool/redis-2.8.7/
>pwd
/Users/carl/tool/redis-2.8.7
5. Scala Client
Here is the official website of jedis https://github.com/xetorthio/jedis
5.1 Simple Usage
"redis.clients" % "jedis" % "2.4.1"
package com.sillycat.easynosqlscala.app
import redis.clients.jedis.Jedis
object TestRedisDBConnectionApp extends App{
val jedis = new Jedis("localhost")
jedis.set("name","sillycat")
println(jedis.get("name"))
}
5.2 Working with Cluster
There should be not only the redis-server file, but also this file under the src directory,
>cp redis-sentinel /Users/carl/tool/redis-2.8.7/
Here is the configuration file
>cp /Users/carl/data/redis-2.8.7/sentinel.conf /opt/redis/
Prepare all these configuration files.
>vi redis-0/redis.conf
port 6379
>vi redis-1/redis.conf
port 6479
slaveof 127.0.0.1 6379
>vi sentinel-0/sentinel.conf
port 26379
>vi sentinel-1/sentinel.conf
port 26479
Start Commands
>./redis-server redis-0/redis.conf
>./redis-server redis-1/redis.conf
>./redis-sentinel sentinel-0/sentinel.conf
>./redis-sentinel sentinel-1/sentinel.conf
Then I have 1 master of Redis instance on 6379, 1 slave of Redis instance on 6479.
1 Sentinel on 26379, 1 sentinel on 26479.
Information
>./redis-cli -h 127.0.0.1 -p 26379 info Sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
master0:name=mymaster,status=ok,address=127.0.0.1:6479,slaves=1,sentinels=2
>./redis-cli -h 127.0.0.1 -p 6479
redis>info
This seems to be only the master-slave mode.
Try to Connect the server with this Jedis Client
package com.sillycat.easynosqlscala.app
import redis.clients.jedis.{JedisCluster, HostAndPort, Jedis}
import java.util.HashSet
object TestRedisDBConnectionApp extends App{
val jedis = new Jedis("localhost")
jedis.set("name","sillycat")
println(jedis.get("name"))
val jedisClusterNodes = new HashSet[HostAndPort]
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 6379))
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 6479))
val jc = new JedisCluster(jedisClusterNodes)
jc.set("age","32")
println("name = " + jedis.get("name") + " age = " + jc.get("age"))
}
Tips:
Error Message:
sbt.ResolveException: download failed: javax.jms#jms;1.1!jms.jar
Solution:
add this to the resolvers
"MIT repo" at "http://simile.mit.edu/maven/"
Error Message:
Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: ERR unknown command 'CLUSTER'
at redis.clients.jedis.Protocol.processError(Protocol.java:100)
Solution:
It seems to me that I am not running Redis under cluster mode.
References:
https://github.com/debasishg/scala-redis
https://github.com/top10/scala-redis-client
https://github.com/alphazero/jredis
https://github.com/xetorthio/jedis
Redis 1~5
http://sillycat.iteye.com/blog/1549504 installation
http://sillycat.iteye.com/blog/1553507 Different Types
http://sillycat.iteye.com/blog/1553508 Different Types
http://sillycat.iteye.com/blog/1553509 Example Operations
http://sillycat.iteye.com/blog/2028180 HA and Setup on MAC
- 浏览: 2487676 次
- 性别:
- 来自: 成都
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
相关推荐
redis-5.0.14-1.el7.remi.x86_64.rpm安装包(含有部署手册) redis-5.0.14-1.el7.remi.x86_64.rpm安装包(含有部署手册) redis-5.0.14-1.el7.remi.x86_64.rpm安装包(含有部署手册) redis-5.0.14-1.el7.remi.x86_64.rpm...
windows环境 redis服务免安装 附带redis客户端 redis-desktop-manager-0.8.8.384
tomcat-redis-session-manager-1.2-tomcat-7-java-7tomcat-redis-session-manager-1.2-tomcat-7-java-7tomcat-redis-session-manager-1.2-tomcat-7-java-7tomcat-redis-session-manager-1.2-tomcat-7-java-7tomcat-...
redis++使用说明,windows下编译redis-plus-plus
该包中包括 linux 环境的安装包; 桌面管理工具 redis-desktop-manager ; 学习笔记; redis.conf 中文文档
redis校验工具redis-full-check,配合redis-shake使用!!!
赠送jar包:flink-connector-redis_2.10-1.1.5.jar; 赠送原API文档:flink-connector-redis_2.10-1.1.5-javadoc.jar; 赠送源代码:flink-connector-redis_2.10-1.1.5-sources.jar; 赠送Maven依赖信息文件:flink-...
压缩文件包括tomcat-redis-session-manager-master-2.0.0.jar、jedis-2.7.3.jar、commons-pool2-2.3.jar三个jar包使用方法请参照https://github.com/jcoleman/tomcat-redis-session-manager。apache-tomcat-8.5.33....
tomcat-redis-session-manager-2.0.0.jar
tomcat-redis-session-manager-2.0.0.jar jedis-2.5.2.jar commons-pool2-2.2.jar 2.修改 conf 目录下的 context.xml 文件 host="localhost" port="6379" database="0" maxInactiveInterval="60" /> ...
用于配置 tomcat-redis-session-manager
Tomcat8亲测可用 tomcat-redis-session-manager的jar包 修改了tomcat-redis-session-manager源码进行的编译生成的jar包
session 共享 tomcat-redis-session-manager 所需要的jar 和 redis-data-cache.properties文件 (绝对可用) 已经完整测试
redis-desktop-manager-2019.4.0.exe
redis-desktop-manager-0.9.1.37.dmg Redis管理工具 0.9.1
所需的tomcat-redis-session-manager所有的jar包下载。测试环境JDK1.8,Tomact8
redis可视化工具redis-desktop-manager-0.8.8.384。。。。
使用tomcat-redis-session-manager进行统一session管理所需jar包,包括tomcat6-jdk6、tomcat7-jdk7、tomcat8-jdk8