{"id":15056727,"url":"https://github.com/pokle/cassandra","last_synced_at":"2025-04-09T15:06:48.508Z","repository":{"id":12902489,"uuid":"15579619","full_name":"pokle/cassandra","owner":"pokle","description":"A Docker Cassandra container","archived":false,"fork":false,"pushed_at":"2021-04-28T18:06:40.000Z","size":516,"stargazers_count":198,"open_issues_count":8,"forks_count":92,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-04-09T15:06:43.933Z","etag":null,"topics":["cassandra","docker"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pokle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-02T08:56:02.000Z","updated_at":"2024-03-08T19:26:49.000Z","dependencies_parsed_at":"2022-09-17T05:41:17.711Z","dependency_job_id":null,"html_url":"https://github.com/pokle/cassandra","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokle%2Fcassandra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokle%2Fcassandra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokle%2Fcassandra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokle%2Fcassandra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pokle","download_url":"https://codeload.github.com/pokle/cassandra/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248055284,"owners_count":21040157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cassandra","docker"],"created_at":"2024-09-24T21:55:52.336Z","updated_at":"2025-04-09T15:06:48.487Z","avatar_url":"https://github.com/pokle.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"Cassandra on Docker\n===================\n\nThis is a collection of images and scripts to help you run Cassandra in Docker containers.\nThese images are great to provision ephemeral Cassandra topologies for testing and development purpose.\n\n- Currently supported:\n    - A single Cassandra node\n    - A client container to run tools such as cqlsh, nodetool, etc.\n    - A multi-node cluster - running on a single Docker host\n    - Monitored cluster using OpsCenter\n\nIf you'd like to help, please get in touch with me, and/or send me pull requests.\n\n\nPrerequisites\n-------------\n\n- A recent version of Docker - See [https://www.docker.com](https://www.docker.com)\n- Verify that the docker command works. Try running 'docker ps' for example.\n- Build the cassandra and opscenter images (optional)\n\n        ./cassandra/build.sh\n        ./opscenter/build.sh\n\nThe last step is optional because Docker will automatically pull the images from [index.docker.io](https://index.docker.io) if you don't already have them. The build process needs an Internet connection, but it is executed only once and then cached on Docker. If you modify the scripts, this is also how you can re-build the images with your changes.\n\n\nSingle Cassandra node\n-----------------------------------\nHere's how to start a Cassandra cluster with a single node, and run some CQL on it. These instructions use the docker command directly to demonstrate what's happening behind the scenes. \n\n\n1. Launch a container running Cassandra called cassone:\n\n        docker run --detach --name cassone poklet/cassandra\n\n2. Connect to it using cqlsh\n\n        docker run -it --rm --net container:cassone poklet/cassandra cqlsh\n\n    You should see something like:\n\n        [cqlsh 5.0.1 | Cassandra 2.2.0 | CQL spec 3.3.0 | Native protocol v4]\n\t\tUse HELP for help.\n\t\tcqlsh\u003e quit\n\n\tIf not, then try it again in a few seconds - cassandra might still be starting up.\n\n\n3. Lets try some CQL\n\n\tPaste the following into your cqlsh prompt to create a test keyspace, and a test table:\n\n\t\tCREATE KEYSPACE test_keyspace WITH REPLICATION = \n\t\t{'class': 'SimpleStrategy', 'replication_factor': 1};\n\t\t\n\t\tUSE test_keyspace;\n\t\t\n\t\tCREATE TABLE test_table (\n\t\t  id text,\n\t\t  test_value text,\n\t\t  PRIMARY KEY (id)\n\t\t);\n\t\t\n\t\tINSERT INTO test_table (id, test_value) VALUES ('1', 'one');\n\t\tINSERT INTO test_table (id, test_value) VALUES ('2', 'two');\n\t\tINSERT INTO test_table (id, test_value) VALUES ('3', 'three');\n\t\t\n\t\tSELECT * FROM test_table;\n\n\n\tIf that worked, you should see:\n\t\n\t\t id | test_value\n\t\t----+------------\n\t\t  3 |      three\n\t\t  2 |        two\n\t\t  1 |        one\n\t\t\n\t\t(3 rows)\n\n\n3-node Cassandra cluster\n------------------------\n\n1. Launch three containers (one seed plus two more)\n\n        docker run -d --name cass1 poklet/cassandra start\n        docker run -d --name cass2 --link cass1:seed poklet/cassandra start seed\n        docker run -d --name cass3 --link cass1:seed poklet/cassandra start seed\n\n\n    Note: The poklet/cassandra docker image contains a shell script called `start` that takes an optional seed host. We use `--link cass1:seed` to name the cass1 host as our seed host.\n\n2. Run `nodetool status` on cass1 to check the cluster status:\n\n        docker run -it --rm --net container:cass1 poklet/cassandra nodetool status\n\n3. Create some data on the first container:\n\n    Launch `cqlsh`:\n\n        docker run -it --rm --net container:cass1 poklet/cassandra cqlsh\n\n    Paste this in:\n\n        create keyspace demo with replication = {'class':'SimpleStrategy', 'replication_factor':2};\n        use demo;\n        create table names ( id int primary key, name text );\n        insert into names (id,name) values (1, 'gibberish');\n        quit;\n        \n\n4. Connect to the second container, and check if it can see your data:\n\n    Start up `cqlsh` (on cass2 this time):\n\n        docker run -it --rm --net container:cass2 poklet/cassandra cqlsh\n\n    Paste in:\n\n        select * from demo.names;\n\n    You should see:\n\n        cqlsh\u003e select * from demo.names;\n\n         id | name\n        ----+-----------\n          1 | gibberish\n\n        (1 rows)\n\n\n10-node Cassandra cluster (scripted!)\n-------------------------------------\n\n1. Right, lets dive right in with some shell scripts in the scripts directory to help us:\n\n        ./scripts/run.sh 10\n\n2. That will start 10 nodes. Lets see what they're called:\n\n        ./scripts/ips.sh\n\n        172.17.0.10 cass6\n        172.17.0.12 cass4\n        172.17.0.11 cass5\n        172.17.0.6 cass10\n        172.17.0.7 cass9\n        172.17.0.9 cass7\n        172.17.0.8 cass8\n        172.17.0.4 cass2\n        172.17.0.3 cass3\n        172.17.0.2 cass1\n\n3. Same, but with the nodetool:\n\n        ./scripts/nodetool.sh cass1 status\n\n        Datacenter: datacenter1\n        =======================\n        Status=Up/Down\n        |/ State=Normal/Leaving/Joining/Moving\n        --  Address      Load       Tokens  Owns (effective)  Host ID                               Rack\n        UN  172.17.0.11  74.19 KB   256     21.4%             dfd44ca5-bf73-4487-bcb2-db882d0a9231  rack1\n        UN  172.17.0.10  74.21 KB   256     19.6%             f479a4e6-55ac-4533-8ce5-d137a93f2cc4  rack1\n        UN  172.17.0.9   74.34 KB   256     20.4%             0bb389a0-f111-459c-9620-0faccc75cbc0  rack1\n        UN  172.17.0.8   74.19 KB   256     20.1%             2eb4a4dd-2bbc-46a3-9f64-4e761509307d  rack1\n        UN  172.17.0.12  74.14 KB   256     20.2%             a2547289-0c6a-458f-b982-823711c5293e  rack1\n        UN  172.17.0.3   74.19 KB   256     20.3%             3667cc1a-1f63-4cd1-bebc-841f428a0f4d  rack1\n        UN  172.17.0.2   74.24 KB   256     20.3%             2b48c8ac-ad68-48a0-9c41-c8f2fb7f38e6  rack1\n        UN  172.17.0.7   67.7 KB    256     19.2%             e361f6d8-28ef-4cf8-baa1-88c2d1fec094  rack1\n        UN  172.17.0.6   74.15 KB   256     19.6%             230f13b1-a27b-44e8-9b51-5ebdb1c4cb13  rack1\n        UN  172.17.0.4   74.18 KB   256     18.8%             6c90cbaa-e5b3-41de-a160-3ecaf59b8856  rack1\n\n4. When you're tired of your cluster, nuke it with:\n\n        ./scripts/nuke.sh 10\n\nSet snitch and node location\n----------------------------\n\nThe snitch type and node location information can be configured with environment variables.\nThe datacenter and rack configuration is only valid if using the GossipingPropertyFileSnitch type snitch.\nFor example:\n\n        docker run -d --name cass1 -e SNITCH=GossipingPropertyFileSnitch -e DC=SFO -e RACK=RAC3 poklet/cassandra\n\nThis will set the snitch type and set the datacenter to **SFO** and the rack to **RAC3**\n\nAuto-detect seeds\n-----------------\n\nAny containers linked in the run command will also be added to the seed list.  The 3-node cluster example above may also be written as:\n\n        docker run -d --name cass1 poklet/cassandra\n        docker run -d --name cass2 --link cass1:cass1 poklet/cassandra\n        docker run -d --name cass3 --link cass1:cass1 poklet/cassandra\n        # and so on...\n\nSpecifying clustering parameters\n--------------------------------\n\nWhen starting a container, you can pass the SEEDS, LISTEN_ADDRESS environment variables to override the defaults:\n\n    docker run -e SEEDS=a,b,c... -e LISTEN_ADDRESS=10.2.1.4 poklet/cassandra\n\nNote that listen_address will also be used for broadcast_address\n\nCassandra cluster + OpsCenter monitoring\n----------------------------------------\n\n1. Start a Cassandra cluster with 3 nodes:\n\n        ./scripts/run.sh 3\n\n2. Start the OpsCenter container:\n\n        docker run -d --name opscenter poklet/opscenter\n\n    You can also add the `-p 8888:8888` option to bind container's 8888 port to host's 8888 port\n\n3. Connect and configure OpsCenter:\n\n    - Open a browser and connect to [http://replace.me:8888](http://replace.me:8888) - replace the host by the result returned by `./scripts/ipof.sh opscenter`.\n    - Click on the \"Use Existing Cluster\" button and put at least the IP of one node in the cluster in the host text box. The result of `./scripts/ipof.sh cass1` is a good candidate. Click \"Save Cluster\" button. OpsCenter start gathering data from the cluster but you do not get full-set metrics yet.\n    - You should see a \"0 of 3 agents connected\" message on the top of the GUI. Click the \"Fix\" link aside.\n    - In the popup, click \"Enter Credentials\" link and fill form with username `opscenter` and password `opscenter`. Click \"Done\".\n    - Click \"Install on all nodes\" and then \"Accept Fingerprints\". OpsCenter installs agent on cluster'snodes remotly.\n    - Once done, you should see the \"All agents connected\" message.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpokle%2Fcassandra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpokle%2Fcassandra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpokle%2Fcassandra/lists"}