Cassandra2.0 JNA配置

Cassandra中通过JNA可以调用Native方法优化Jvm内存,大概意思就是不让操作系统将jvm内存置换到系统swap分区,从而提升jvm内存性能。它有两个用处:

  • Since 0.6.2: JNA for mlockall. This prevents Linux from swapping out parts of the JVM that aren't accessed frequently. Chris Goffinet reported a 13% performance improvement in his tests from this change. CASSANDRA-1214

  • Since 0.6.6: JNA for hard links, improving snapshots. Previously Cassandra would use the /bin/ln binary to create hard links to SSTables when creating a snapshot. On nodes with thousands of SSTables, this would take a very long time, because it had to fork+exec the JVM to run the new process. With JNA, Cassandra uses the link call directly. CASSANDRA-1371

P.S. JNA配置不是必须的,但官方建议生成环境下使用JNA。

我的软件环境:CentOS6 64bit + Cassandra2.0(DataStax社区版,通过YUM安装的)

开启方法如下:

1. 下载并放置JNA

wget https://maven.java.net/content/repositories/releases/net/java/dev/jna/jna/4.0.0/jna-4.0.0.jar
cp jna-4.0.0.jar /usr/share/cassandra/lib/

2. 开启JNA

vi /etc/security/limits.d/cassandra.conf

cassandra soft memlock unlimited
cassandra hard memlock unlimited

注意: 通过yum安装的dsc是通过cassandra用户启动的,所以我配置上面为cassandra用户。

3. 验证安装

如果没有配置JNA,cassandra log将会打印如下信息:

INFO 12:17:58,616 JNA not found. Native methods will be disabled.

 配置成功后,会出现如下log:

INFO 09:59:59,184 JNA mlockall successful

4. 错误诊断

将JNA jar包放置后,但如果没有配置好系统limit的话,将会出现如下log:

WARN 10:49:53,587 Unable to lock JVM memory (ENOMEM). This can result in part of the JVM being swapped out, especially with mmapped I/O enabled. Increase RLIMIT_MEMLOCK or run Cassandra as root.

 完成步骤2配置,就可以解决这个警告。

参考:

https://journal.paul.querna.org/articles/2010/11/11/enabling-jna-in-cassandra/

--end

猜你喜欢

转载自heipark.iteye.com/blog/2004831
jna
今日推荐