Cassandra2.0 JNA配置

标签: cassandra2 jna | 发表时间:2014-01-16 10:51 | 作者:
出处:http://heipark.iteye.com

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 directlyCASSANDRA-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/jna-4.0.0.jar

 

2. 开启JNA

 

vi /etc/security/limits.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

 

 

 



已有 0 人发表留言,猛击->> 这里<<-参与讨论


ITeye推荐



相关 [cassandra2 jna] 推荐:

Cassandra2.0 JNA配置

- - The Big Data Way,平凡但不乏味
Cassandra中通过JNA可以调用Native方法优化Jvm内存,大概意思就是不让操作系统将jvm内存置换到系统swap分区,从而提升jvm内存性能. 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.

JNA中内存处理-释放动态库中分配的内存(新)

- - CSDN博客推荐文章
前面已经介绍过一次JNA中内存释放方法,后经过实际分析,这样写的代码不是很优雅,实际项目中代码实现方法如下:. 如下是libvirt java binding实现代码存在内存泄露:. 如下是解决内存泄露的代码:. 作者:greencacti 发表于2012-11-16 21:56:05 原文链接.