search

Home  >  Q&A  >  body text

数据库 - redis clojure 新手问题

大家好:

我在虚拟机中安装了一台redis,并运行了起来。虚拟机的地址是 192.168.56.101.
之后我在我的真机上写了一个clojure的程序,使用了ptaoussanis/carmine 来链接虚拟机中的 redis.
代码如下:

(require '[taoensso.carmine :as car :refer (wcar)])
(def test-redis {:pool {} :spec {:host "192.168.56.101" :port 6379}})
(wcar test-redis (car/lpop "logstash-testlog")) ;logstash-testlog 是 redis 中的 key

但是提示

NoRouteToHostException 没有到主机的路由  java.net.PlainSocketImpl.socketConnect (PlainSocketImpl.java:-2)
阿神阿神2797 days ago639

reply all(2)I'll reply

  • PHPz

    PHPz2017-04-24 09:12:41

    Haha, it turns out that the virtual machine’s iptables doesn’t matter~

    reply
    0
  • 怪我咯

    怪我咯2017-04-24 09:12:41

    This doesn’t seem to have anything to do with clojure. Please try pinging your virtual machine. It should be impossible to connect. When you first start trying new things, it may be best not to use multiple ones at the same time. Try installing redis directly on your host, not through a virtual machine.

    reply
    0
  • Cancelreply