Can I start a node through ignite.sh and run it in the background? What is the specific operation method?
If it is started in the background, how can I correctly close this node?
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
nohup bash ./ignite.sh ../config/default-config.xml &
fg%<process_ID>
, where process_ID can be found with jobs
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...
./control.sh --set-state INACTIVE