Search code examples
ignite

How can I start an Ignite node in the background?How can I properly shut down the Ignite node?


  1. Can I start a node through ignite.sh and run it in the background? What is the specific operation method?

  2. If it is started in the background, how can I correctly close this node?

  3. If it is started in the foreground and ended by ctrl+c, can it ensure that the data in the cache is persisted to the database? If so, can the background startup do this?

system:Centos 7

background database: mongodb


Solution

    1. You can use the standard Linux mechanisms for running applications in the background: nohup bash ./ignite.sh ../config/default-config.xml &
    2. You can bring the app to the foreground with fg%<process_ID>, where process_ID can be found with jobs
    3. Graceful shutdown implies that Ignite will perform some additional cleanup and maintenance routines while stopping a node, this is called a shutdown hook. According to the docs, there are several ways of stopping a node gracefully:

    programmatically call Ignite.close()

    programmatically call System.exit()

    send a user interrupt signal. Ignite uses a JVM shutdown hook to execute custom logic before the JVM stops. If you start the node by running ignite.sh and don’t detach it from the terminal, you can stop the node by hitting Ctrl+C

    Killing a process by sending kill -9 sig will not trigger the shutdown hook and might cause some issues up to data corruption in some corner cases.

    Configuring J-DIGNITE_WAIT_FOR_BACKUPS_ON_SHUTDOWN=true or ShutdownPolicy.Graceful (which is the same) explicitly forces an additional backup consistency check to ensure that a node won't leave the cluster if this would lead to partition loss, i.e. if both primary and backup (if any) partitions left the grid, check this doc for a more detailed explanation. This is something that you won't turn off in most cases and I recommend you to keep this setting.

    But, if you don't need backups validation, you can just remove J-DIGNITE_WAIT_FOR_BACKUPS_ON_SHUTDOWN=true and send SIGINT to the Java process.

    In order to check that a node is stopping gracefully, you should see the following message in the log:

    [INFO][shutdown-hook] Invoking shutdown hook...
    
    1. To make sure that no data is being written to the cluster, you can also inactivate the cluster before stopping it with the following command: ./control.sh --set-state INACTIVE