How does a server become part of a distributed system? - gemfire

The GemFire tutorial shows that a locator is started with
gfsh>start locator --name=locator1 --port=55221
In some parts of the tutorial the command to start a server is shown as
gfsh>start server --name=server1 --J=-Dgemfire.jmx-manager=true --J=-Dgemfire.jmx-manager-start=true --J=-Dgemfire.http-port=8080
In this case, how does the server know the locator on which it will get registered?

A server always joins a distributed system (DS) by connecting to a locator. [*]
If you start a locator from within gfsh and then, in the same session, start a server, gfsh will know to use the existing locator connection for the new server you are starting. In this case you don't need to explicitly provide a --locator option. This is also true when running gfsh with multiple start commands from a script. For example: gfsh -e "start locator --name=locator1 --port=19991" -e "start server --name=server1" -e "list members"
[*] Not true for versions of GemFire/Geode < 9.x as older versions can also join a DS using a multicast address/port combo. See the --mcast-port option in the docs. However that functionality is deprecated and will not be available in GemFire/Geode >= 9.x so it

Related

How to setup multiple gemfire/geode WAN clusters on one machine for testing?

What's needed to run multiple gemfire/geode clusters on one machine? I'm trying to test using WAN gateways locally, before setting it up on servers.
I have one cluster (i.e. gemfire.distributed-system-id=1) up and running with one locator and one server.
I am trying to setup a second cluster (i.e. gemfire.distributed-system-id=2), but receive the following error when attempting to connect to the locator in cluster 2:
Exception caused JMX Manager startup to fail because: 'HTTP service
failed to start'
I assume the error is due to a JMX Manager already running in cluster 1, so I'm guessing I need to start a second JMX Manager on a different port in cluster 2. Is this a correct assumption? If so, how do I setup the second JMX Manager?
Your assumption is correct, the exception is being thrown because the first members started some services (PULSE, jmx-manager, etc.) using the default ports already
You basically want to make sure the properties http-service-port and jmx-manager-port (non an extensive list, there are other properties you need to look at), are different in the second cluster.
Hope this helps.
Cheers.

How to use GFSH to connect peer to peer environment?

I am running Gemfire HTTP session management model within my application as P2P on a WebSphere. I can see the session logs on WAS. However, I could not find a way to connect it through gfsh from my desktop. I am using default seeting without locator. I would like to monitor Gemfire status, how?
Cache_Peer.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cache PUBLIC
"-//GemStone Systems, Inc.//GemFire Declarative Caching 6.5//EN"
"http://www.gemstone.com/dtd/cache6_6.dtd">
<cache>
<!-- This is the definition of the default session region -->
<region name="gemfire_modules_sessions">
<region-attributes scope="distributed-ack" enable-gateway="false" data-policy="replicate" statistics-enabled="false">
</region-attributes>
</region>
</cache>
As mentioned by Jens, Locator by defaults is a JMX manager. Any locator can become a JMX Manager when started. When you start up a locator, if no other JMX Manager is detected in the distributed system, the locator starts one automatically. If you start a second locator, it will detect the current JMX Manager and will not start up another JMX Manager unless the second locator's gemfire.jmx-manager-start property is set to true.
To turn any other member (p2p server) to JMX manager, set jmx-manager=true and jmx-manager-start=true in the server's gemfire.properties file.
To start the member as a JMX Manager node on the command line, provide --J=-Dgemfire.jmx-manager-start=true and --J=-Dgemfire.jmx-manager=true as arguments to either the start server command.
For example, to start a server as a JMX Manager on the gfsh command line:
gfsh>start server --name=<server-name> --J=-Dgemfire.jmx-manager=true \
--J=-Dgemfire.jmx-manager-start=true
Refer http://gemfire80.docs.pivotal.io/7.0.2/userguide/index.html#managing/management/jmx_manager_operations.html for more details.
By default, the locator in a client-server environment, would be a JMX manager. In a p2p setup you need to enable the JMX manager in one of your servers. You can do this by setting the GemFire properties: jmx-manager-enable=true and jmx-manager-start=true. It is also possible to have multiple JMX managers. If your p2p setup only consists of 2 servers, then having both be JMX managers would be OK.
You can use connect command from gfsh, it connects to the jmx manager.
If you have locator, then connect it using connect --locator=host[port] command, the jmx-manager automatically starts on locator. However, if you don't have locator, then you need to explicitly start jmx-manager on servers and connect it using connect --jmx-manager=host[port] command.
Refer http://gemfire.docs.pivotal.io/latest/userguide/index.html#tools_modules/gfsh/command-pages/connect.html for more details.
If the Gemfire cluster is running behind firewall, then use HTTP to connect, refer http://gemfire.docs.pivotal.io/latest/userguide/index.html#deploying/gfsh/gfsh_remote.html

How do I check migratable target status with weblogic scripting tool (wlst)?

I have configured a weblogic cluster that consists of two servers configured as migratable targets. This way I can use wlst to migrate the services that run in one of the servers to the other with the command `migrate('serverX', 'serverX').
But before run migrate command I'd like to check if each migratable target is running in its preferred server so I run migrate only if needed.
Does anyone know how to check it?
Regards
You can definitely do this with wlst, here are some steps:
connect('weblogic','weblogic','http://myserver:7701')
cd('MigratableTargets')
ls() #this will list out all migratable objects
cd('<migratable name>')
ls('UserPreferredServer')
ls('HostingServer')
That will list your preferred server and the currently hosted server. You can use the current management object cmo and check to see if they are equal:
cd('<migratable name>')
if(cmo.getUserPreferredServer() == cmo.getHostingServer())
...
migrate('serverX', 'servery')
You can see some of the calls that are available in the Oracle Weblogic API docs.

Gemfire client server topology throws NoAvailableLocatorsException

I have gemfire client server configured via gfe based xml. The locator, cache server and client cache start through these xml configurations. I populate my Region by getting data from database. The client uses data from this Region. It works very well for about 2 hours but after that the client starts throwing following exception and trace.
I don't do any changes to running application. That means the locator and cache server should be running at all times. Any help would be great. Thanks.
com.gemstone.gemfire.cache.client.NoAvailableLocatorsException: Unable to connect to any locators in the list [/locator-host:locator-port]
at com.gemstone.gemfire.cache.client.internal.AutoConnectionSourceImpl.findServer(AutoConnectionSourceImpl.java:132)
at com.gemstone.gemfire.cache.client.internal.ConnectionFactoryImpl.createClientToServerConnection(ConnectionFactoryImpl.java:205)
at com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.exchangeConnection(ConnectionManagerImpl.java:418)
at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:173)
at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:114)
at com.gemstone.gemfire.cache.client.internal.PoolImpl.execute(PoolImpl.java:638)
at com.gemstone.gemfire.cache.client.internal.GetOp.execute(GetOp.java:89)
at com.gemstone.gemfire.cache.client.internal.ServerRegionProxy.get(ServerRegionProxy.java:126)
at com.gemstone.gemfire.internal.cache.LocalRegion.findObjectInSystem(LocalRegion.java:2767)
at com.gemstone.gemfire.internal.cache.LocalRegion.nonTxnFindObject(LocalRegion.java:1605)
at com.gemstone.gemfire.internal.cache.LocalRegionDataView.findObject(LocalRegionDataView.java:133)
at com.gemstone.gemfire.internal.cache.LocalRegion.get(LocalRegion.java:1489)
at com.gemstone.gemfire.internal.cache.LocalRegion.get(LocalRegion.java:1451)
at com.gemstone.gemfire.internal.cache.AbstractRegion.get(AbstractRegion.java:278)
Do you have anything in your locator or server logs? That exception indicates the client is trying to create a new connection and can't connect to a locator.
If your locator goes down, the client might still be able to work for a while using it's existing connections because it doesn't need to go back to the locator until it needs a new connection.

Remotely start stop jboss server

I have a requirement to write a java program to remotely start stop a jboss server on request. Can anyone please suggest how could it be done? One option could be invoke start/stop script but this java program(may be servlet or jsp) exists on different machine. We are using jboss server 7.
A simple method to start and stopping Jboss remotely can be done with the run.sh and shutdown.sh script, by pointing to the right host and port. If you are on Linux you can run:
rsh user#host /path/to/jboss/bin/run.sh
rsh user#host /path/to/jboss/bin/shutdown.sh
You can also execute a Shell command with Java, you can use Runtime exec mewthod:
Runtime.getRuntime().exec("shell command here");
See this complete answer for more details on Java exec method.
A better alternative I would suggest, is to use JMX-console programmatically, you can stop/restart a Jboss intance by invoking the shutdown method on the Server MBean. JMX approach is more powerful because you can monitor and manage every aspect of the Jboss runinng instanace (like logging, memory or cpu). See this to start.
I've created a snippet to ease your start, see this working solution http://snipt.org/Ahhjh4
Remember:
create a Jboss user on the Jboss instance using add-user.sh (JBOSS_HOME/bin)
include the jboss-client.jar in your client class-path (the jar is in JBOSS_HOME/bin/client)
Good luck!