Mar 6, 2017 Cassandra 中文版
There are various ways to improve the performance of Cassandra. Using JNA (Java Native Access) is one way to improve Cassandra memory usage. Thus, this tutorial is about how to install and set JNA for Cassandra.
Luckily, the Spotify team already made a great Dockerfile for Cassandra, and I’m going to use it as a sandbox environment in this tutorial. So, make sure you have Docker installed.
Let’s run a Cassandra container:
# Run Cassandra as a standalone service, and open the port 9160 and 9042
docker run -d \
-p 9160:9160 \
-p 9042:9042 \
--ulimit memlock=-1:-1
--name cassandra spotify/cassandra
Use apt-get to install JNA:
# Install JNA
apt-get install -y libjna-java
# Create a symbolic link
ln -s /usr/share/java/jna.jar /usr/share/cassandra/lib/
To make sure JNA will work correctly, restart the Cassandra container:
# Command: docker restart [container-name]
docker restart cassandra
If everything goes well, you will get a message (JNA mlockall successful) means JNA is enabled successfully. To view Cassandra’s log:
# Command: docker logs -f [container-name]
docker logs -f cassandra
If you have any suggestions, questions or even find some typos, feel free to contact me. Thank you! :)
zeckli.devforgalaxy@gmail.com © 2015-2019 zeckli, thanks to Jekyll and GitHub.