Enable Thrift in Cassandra Docker

故事扮演 提交于 2019-12-04 01:52:35

I've been having the same problem with the Docker Cassandra image. You can use my docker container on Github or on Docker hub instead of the default Cassandra image.

The problem is that the cassandra.yaml file has start_rpc set to false. We need to change that. To do that we can use the following Dockerfile (which is what my image does):

FROM cassandra
RUN sed -i 's/^start_rpc.*$/start_rpc: true/' /etc/cassandra/cassandra.yaml 

The sed workaround (and subsequent custom Dockerfiles that enable only this behavior) is no longer necessary.

Newer official Docker containers support a CASSANDRA_START_RPC environment variable using the -e flag. For example:

docker run --name cassandra1 -d -e CASSANDRA_START_RPC=true -p 9160:9160 -p 9042:9042 -p 7199:7199 -p 7001:7001 -p 7000:7000 cassandra

Don't forget to expose the thrift client API port with the run command to be able to access the container from outside like:

docker run --name cs1 -d .... -p 9160:9160 cassandra

You might also want to expose more ports, like for CQL port 9042, port 7199 for JMX, port 7000 and 7001 for internode communication.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!