5 Replies Latest reply on Feb 18, 2012 11:30 AM by naren_kulkarni

    Need help for stop multiple instance in shell script

    bunphot.chup

      I'm runing jboss as 6.0 final on SLSE linux.

       

      So, I was modifired the jboss_init_suse.sh for start the 2 instance.

       

      Here is the code for the modifired.

      JBOSSSH1=${JBOSSSH1:-"$JBOSS_HOME/bin/run.sh -c node1 -g ewicluster -Djboss.messaging.ServerPeerID=1 
      -Djboss.service.binding.set=ports-default -Djboss.jvmRoute='node1' -Djboss.mod_cluster.proxyList='192.168.10.168:80' 
      -Djboss.modcluster.balancer='ewicluster' -Djboss.bind.address='192.168.10.168'"}
      
      JBOSSSH2=${JBOSSSH2:-"$JBOSS_HOME/bin//run.sh -c node2 -g ewicluster -Djboss.messaging.ServerPeerID=2 
      -Djboss.service.binding.set=ports-01 -Djboss.jvmRoute='node2' -Djboss.mod_cluster.proxyList='192.168.10.168:80'
      -Djboss.modcluster.balancer='ewicluster' -Djboss.bind.address='192.168.10.168'"}
      
      

       

      My problem is when I want to stop these 2 instance there is a error occur.

       

       

      ./shutdown.sh -S
      
      Exception in thread "main" java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
              java.net.ConnectException: Connection refused]
              at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:338)
              at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
              at org.jboss.Shutdown.main(Shutdown.java:235)
      Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
              java.net.ConnectException: Connection refused]
              at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:101)
              at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
              at javax.naming.InitialContext.lookup(InitialContext.java:392)
              at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1886)
              at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1856)
              at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:255)
              ... 2 more
      Caused by: java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
              java.net.ConnectException: Connection refused
              at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
              at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
              at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
              at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
              at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
              at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
              ... 7 more
      Caused by: java.net.ConnectException: Connection refused
              at java.net.PlainSocketImpl.socketConnect(Native Method)
              at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
              at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
              at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
              at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
              at java.net.Socket.connect(Socket.java:529)
              at java.net.Socket.connect(Socket.java:478)
              at java.net.Socket.<init>(Socket.java:375)
              at java.net.Socket.<init>(Socket.java:189)
              at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
              at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
              at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
              ... 12 more
      
      

       

      Could anyone give me a suggestion ?.

      thank you

        • 1. Re: Need help for stop multiple instance in shell script
          peterj

          You would be better off passing "-b xxx.xxx.xxx.xxx" rather that setting jboss.bind.address because the -b causes several properties to be set.

           

          Also, is your hosts file configured correctly? This blog and dicsussion might help with that:

          http://jblevins.org/computing/linux/hostname

          http://community.jboss.org/thread/120995?tstart=0

          • 2. Re: Need help for stop multiple instance in shell script
            ask4free

            Hi Bunphop!!

             

            I usually use a different shutdown script for each server instance. For example, I have 2 JBoss instances running so to stop them I need to call:

             

            >./shutdown.sh -s jnp://localhost:1099 -S     --> It will shutdown my first instance which is setup at port 1099 (RMI registry)

            >./shutdown.sh -s jnp://localhost:1199 -S     --> It will shutdown my second instance which is setup at port 1199 (RMI registry)

            Regards!

             

            • 3. Re: Need help for stop multiple instance in shell script
              bunphot.chup

              thank you Antonio . It's work !!!

              1 of 1 people found this helpful
              • 4. Re: Need help for stop multiple instance in shell script
                ask4free

                welcome dude!

                • 5. Re: Need help for stop multiple instance in shell script
                  naren_kulkarni

                  Bunphop

                   

                  In case of a multiple JBoss binding to more than one IP-addresses and each JBoss having multiple instances - the "shutdown.sh -s jnp://localhost:1099 -S"  does not work so well.

                   

                  In such cases you would need to identify the exact JBoss server/instance on the same hardware-machine  and find its proc-id [pid] to do a graceful shutdown.

                   

                  In most cases it's a good practice to start your JBoss instances with separate unique "conf"  i.e. the profile of JBoss under the "server directory should be given a unique name affiliated to the Application running e.g "FIN1" and the startup should refer to that as follows :

                   

                  FIN1=${JBOSSSH1:-"$JBOSS_HOME/bin/run.sh -c FIN1 -g ewicluster -Djboss.messaging.ServerPeerID=1
                  -Djboss.service.binding.set=ports-01 -Djboss.jvmRoute='FIN1' -Djboss.mod_cluster.proxyList='192.168.10.168:80'
                  -Djboss.modcluster.balancer='ewicluster' -Djboss.bind.address='192.168.10.168'"}

                   

                  As far as possible do not use ports-default

                   

                  The following is a sample shutdown to be modified for your individual situation :

                   

                  jbossstop.sh FIN1

                   

                  where jbossstop.sh looks like

                   

                  ps -aef | grep java | grep FIN1 | awk '{ print $2 }'  | xargs kill -15

                   

                  The above schema for a shutdown script works very well for a multi IP-address multi-instance per each IP-address [Enterprise deploy]

                   

                  Try it -    -  The kill -15  is for a graceful shutdown after all current sessions have been served out.

                   

                  Regards