12

I'm trying to start up a docker image that runs cassandra. I need to use thrift to communicate with cassandra, but it looks like that's disabled by default. Checking out the cassandra logs shows:

INFO  21:10:35 Not starting RPC server as requested. 
  Use JMX (StorageService->startRPCServer()) or nodetool (enablethrift) to start it

My question is: how can I enable thrift when starting this cassandra container?

I've tried to set various environment variables to no avail:

docker run --name cs1 -d -e "start_rpc=true" cassandra
docker run --name cs1 -d -e "CASSANDRA_START_RPC=true" cassandra
docker run --name cs1 -d -e "enablethrift=true" cassandra
cscan
  • 3,265
  • 5
  • 38
  • 72
  • 1
    Apparently, thrift RPC server was disabled since Cassandra 2.2, you need to set start_rpc=true, nodetool enablethrift for newer versions so clients can use thrift. https://issues.apache.org/jira/browse/CASSANDRA-9319 – kisna Jan 16 '16 at 00:08

3 Answers3

27

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
Les Hazlewood
  • 16,224
  • 12
  • 58
  • 69
18

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 
JimTheDev
  • 3,399
  • 1
  • 21
  • 26
  • 2
    THANKS! I had the same issue. But instead of using your fork (which likely will eventually be abandonned :-( ), I am simply running `docker exec -it cass1 sed -i 's/^start_rpc.*$/start_rpc: true/' /etc/cassandra/cassandra.yaml` after running the official container. That works too! – Niclas Hedhman Dec 12 '15 at 01:52
2

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.

0x7d7b
  • 41,374
  • 7
  • 39
  • 55