Skip to content

3. Apache Cassandra

Fadhil Yori Hibatullah edited this page Sep 14, 2021 · 4 revisions

Back

Source : https://cassandra.apache.org/doc/latest/getting_started/installing.html

  1. Add Cassandra Debian Repository

    $ echo "deb http://www.apache.org/dist/cassandra/debian 36x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
    
  2. Import the Cassandra Repository key

    $ curl https://downloads.apache.org/cassandra/KEYS | sudo apt-key add -
    
  3. Update the APT index

    $ sudo apt update
    
  4. If there's an error "GPG error: http://www.apache.org 36x InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A278B781FE4B2BDA"

    $ sudo apt-key adv --keyserver pool.sks-keyservers.net --recv-key A278B781FE4B2BDA && sudo apt update
    
  5. Install Cassandra using APT

    $ sudo apt-get install cassandra
    
  6. Enable Cassandra Service

    $ sudo systemctl enable cassandra.service
    
  7. Start Cassandra Service

    $ sudo systemctl start cassandra.service
    
  8. Configuring Apache Cassandra, edit /etc/cassandra/cassandra.yaml file, change the authenticator, rpc_address, and broadcast_rpc_address like the following value below:

    authenticator: PasswordAuthenticator
    ...
    rpc_address: 0.0.0.0
    ...
    broadcast_rpc_address: localhost
    
  9. Restart Cassandra Service

    $ sudo systemctl restart cassandra.service
    
  10. Login to cassandra with default user

    $ cqlsh -u cassandra -p cassandra
    

    NB : when there is an error "Connection error: ('Unable to connect to any servers', {'127.0.0.1': TypeError ('ref () does not take keyword arguments',)})" please use the following syntax:

    $ sudo apt install python-pip
    $ pip install cassandra-driver
    $ export CQLSH_NO_BUNDLED=true
    
  11. Create new Apache Cassandra user with the following command:

    CREATE USER admin WITH PASSWORD 'password' SUPERUSER;
    
  12. Import Apache Cassandra keyspace, copy file cassandraQueryScript.cql to defense center. For the file, you can download it from here: https://raw.githubusercontent.com/dimasmamot/fp_work_dir/master/cassandraQueryScript.cql

  13. Run with the following command to import the keyspace:

    $ cqlsh -u admin -f cassandraQueryScript.cql
    
  14. Login using admin

    $ cqlsh -u admin
    
  15. Use kaspa keyspace

    use kaspa;
    
  16. Add a new account for kaspa

    INSERT INTO kaspa.user (username, company, email, first_name, group, last_name, password_hash, time_joined) VALUES ('admin', 'admin', '[email protected]', 'admin', 'admin', 'admin', '$6$rounds=656000$aS2RFKm/fkVcHWi1$QaltqzL92qlShWP9hG2vWIHZ1qCzRnIXApavcCBvaewGQGZArBNvQRazfMabJonZaXzmwMwuodGFYAV3h5Pzw0', toTimeStamp(now()));
    
  17. Done

Back