Last active
February 7, 2017 08:19
-
-
Save DmitryBe/b6c516e23cc3a93dfc9c1ca334949d62 to your computer and use it in GitHub Desktop.
redis && spark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# docker image: https://hub.docker.com/_/redis/ | |
# start redis server with append | |
docker run -itd --name redis --net=host -v /docker/redis/data:/data redis redis-server --appendonly yes | |
# start redis cli (localhost) | |
docker run -it --net=host --rm redis redis-cli -h localhost -p 6379 | |
# get multiple values | |
MGET key1, keyN | |
# spark to redis | |
# dependencies (upload to local repo): | |
RedisLabs:spark-redis:0.3.2 | |
redis.clients:jedis:2.9.0 | |
# add to spark config(as zeppelin param) | |
redis.host=host_ip | |
# check sc params | |
sc.getConf.getAll.foreach(println) | |
# import | |
import com.redislabs.provider.redis._ | |
# read from redis | |
sc.fromRedisKV(Array("key-1", "key-200")).collect() | |
# save to redis | |
sc.toRedisKV(pairRdd[String, String]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment