How Do You Install Apache Cassandra on Linux SUSE?

Problem scenario
You are running Linux SUSE and want to install Apache Cassandra.  How do you install Apache Cassandra on Linux SUSE?

Solution
Prerequisites
i.  This solution assumes that you have Java installed.  If you need assistance, see this link.

ii.  This solution assumes your server has a total of 2.5 GB of memory (a combination of either virtual memory or RAM).  If you need to create virtual memory (aka swap space), see this article.  (Less that 2.5 GB may work.  We experienced trouble with 0.5 GB of RAM.)  If you want to upgrade your AWS server (and do not mind paying more for RAM because you need the hard drive space to not be allocated to virtual memory), see this posting.  If you want to resize your GCP server (and do not mind paying more for RAM because you need the hard drive space to not be allocated to virtual memory), see this posting.

iii.  This assumes that you have installed Apache Ant.  If you need directions, see this posting.

iv. This solution assumes that you have installed screen (the command line utility), Git and Apache Ant.  To install screen and Git, use this command:  sudo zypper -n install git screen
If you need directions for Ant, see this posting.  If you cannot install screen, you will need to create a duplicate terminal instead of using the screen command.   If you cannot install screen, you will skip step 6.b after you do 6.a.  With two terminal sessions, in one terminal you can start one process and allow the logging to stream to the screen.  With the second terminal you can do the steps in #4 in the procedures below.  If you did install screen, follow the directions as they are written.

Procedures
(If you are using non-AWS Linux server you will have to change the "ec2-user" in the script.)

1.  Run this script (e.g., create /tmp/precas.sh and run it with bash /tmp/precas.sh):

usr=ec2-user  # replace "ec2-user" with the username who will run cassandra
cd /var/lib/
git clone http://git-wip-us.apache.org/repos/asf/cassandra.git
mkdir -p /var/log/cassandra/log
mkdir /var/lib/cassandra/{data,saved_caches,commitlog}
groupadd cassandra
usermod -aG cassandra $usr
usermod -aG cassandra root
chown -R root:cassandra /var/lib/cassandra/
chown -R root:cassandra /var/log/cassandra/
chmod 777 /var/lib/cassandra/data/
chmod 777 /var/lib/cassandra/saved_caches/
chmod 777 /var/lib/cassandra/commitlog/
chmod 770 /var/log/cassandra/log/
mkdir /var/lib/cassandra/logs
chown $usr:cassandra *  
echo "log4j.appender.R.file=/var/lib/cassandra/log/system.log" >> /var/lib/cassandra/conf/log4j-server.properties

2.  Manually modify cassandra.yaml.  Run this:

sudo vi /var/lib/cassandra/conf/cassandra.yaml

Uncomment these four stanzas; there should be no leading space either (space on far left) for the data... committ... and saved... lines. (There can be a space with the "- /var/lib"...)

data_file_directories:
   - /var/lib/cassandra/data

commitlog_directory: /var/lib/cassandra/commitlog

saved_caches_directory: /var/lib/cassandra/saved_caches

Comment out this stanza:
cluster_name: 'Test Cluster'

It will look like this when you are done:
#cluster_name: 'Test Cluster'

Save the changes (with "ZZ").

3.  Run these two commands:

cd /var/lib/cassandra
sudo /usr/local/apache-ant/bin/ant release
# "sudo ant release" with no quotes may be necessary

Ignore the output about eclipse-warnings such as "Potential resource leak" or
"[java] 4 problems (4 errors)" or "BUILD FAILED /var/lib/cassandra/build.xml:1820: Java returned: 255."

4.a.  Run these commands:  
screen
./bin/cassandra

4.b. Hold control and tap "a" and then "d".  (Ctrl-a, Ctrl-d.) Now go to step #5. (If you did not install screen or run the screen command, create a duplicate terminal session and skip to step #5 without doing step 4.b.)

5.  Wait 30 seconds, and then run these two commands:  

cd /var/lib/cassandra
./bin/cqlsh

Leave a comment

Your email address will not be published. Required fields are marked *