Hazelcast access using CLI

流过昼夜 提交于 2020-01-12 07:34:07

问题


Suppose I have instance of Hazelcast running somewhere on remote machine and it executed in official Docker image. So I wolud like to see some data that Hazelcast stores just like in the first video here. So I'm wondering is there any way to connect to existing Hazelcast instance from any CLI utility to get the data but without Management Center?


回答1:


Andrii,

You can take advantage of Hazelcast demo application. You can find here:

  • com.hazelcast.console.ConsoleApp member console, part of hazelcast*.jar. See GH
  • com.hazelcast.client.console.ClientConsoleApp client console, part of hazelcast-client*.jar. See GH

You can modify server.sh to run member / client in CLI mode

java -server $JAVA_OPTS com.hazelcast.console.ConsoleApp

or

java -server $JAVA_OPTS com.hazelcast.client.console.ClientConsoleApp

Let me know if you have any questions. Thank you




回答2:


Thanks to Viktor Gamov I have found the way to see the data from CLI with provided com.hazelcast.client.console.ClientConsoleApp that is part of hazelcast*.jar. Here is the small summary how to connect to existing instance using client:

  1. Modify clientConsole.sh (that is located under <hazelcast installation>/demo) script (or create new one if you want) and the line in it have to be like that: java -Djava.net.preferIPv4Stack=true -cp .:../lib/hazelcast-all-<version>.jar com.hazelcast.client.console.ClientConsoleApp
  2. Put your config file to the same directory with your script (possibly <hazelcast installation>/demo)
  3. Your config file should have the name exactly hazelcast-client.xml and may be look like the following:
<hazelcast-client xmlns="http://www.hazelcast.com/schema/client-config">
    <group>
        <name>dev</name>
        <password>dev-pass</password>
    </group>
    <network>
        <cluster-members>
            <address>localhost:5701</address>
        </cluster-members>
    </network>
</hazelcast-client>



回答3:


Best way is to write a Java utility that can run from CLI. It can make use of HazelcastClient to connect to the cluster, get hold of IMap and print however you need. Also IMap.getLocalMapStats gives stats related to local map for that node.



来源:https://stackoverflow.com/questions/41225625/hazelcast-access-using-cli

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!