Cassandra JMX 監控配置

來源:互聯網
上載者:User

最近安裝cassandra到產品伺服器,很多東西要求就嚴格了很多,比如perf中使用的JMX,以前是只要知道ip就能訪問,但是產品伺服器就不行了,這樣存在安全隱患,nodetool -h host 可以添加和刪除節點。所以今天要講的東西就是cassandra jmx的授權和存取控制。


這裡講的是第一種,最常用的使用密碼和存取控制檔案方式,其他方式後面有時間再跟進。


1 修改$CASSANDRA_HOME/conf/cassandra-env.sh 檔案

設定你的伺服器(需要監控的機器)IP

JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=172.29.1.18"

cassandra預設是啟用本地無需授權方式訪問,這裡我們需要遠程監控就需要改變下方式:修改LOCAL_JMX為no

LOCAL_JMX=no

2 設定JMX中authentication需要用到的檔案

## Basic file based authn & authzJVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.password.file=/etc/cassandra/jmxremote.password"JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.access.file=/etc/cassandra/jmxremote.access"

建立檔案 /etc/cassandra/jmxremote.password,添加角色和密碼:(這裡的cassandra是使用者名稱,密碼是後面的cassandra,可以改為你自己的)

monitorRole QEDcontrolRole R&Dcassandra cassandra


修改jmxremote.password存取權限:(cassandra:cassandra  只是個例子,填入你自己的啟動cassandra的使用者和使用者組)

chown cassandra:cassandra /etc/cassandra/jmxremote.passwordchmod 400 /etc/cassandra/jmxremote.password

建立檔案 /etc/cassandra/jmxremote.access, 添加角色許可權控制:

monitorRole readonlycassandra readwritecontrolRole readwrite \create javax.management.monitor.*,javax.management.timer.* \unregister

說明: 

readonly 是智能讀取MBean中的唯讀屬性。

readwrite 是可以使用MBean進行程式的參數修改和控製程序行為。


3 啟動cassandra, 使用nodetool訪問:

nodetool status -u cassandra -pw cassandra


參考材料:

1  Cassandra Wiki JMX security

2  Monitoring and Management using JMX

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.