cockroach node command provides tools for managing nodes in a CockroachDB cluster.
Synopsis
Description
Thenode command supports several subcommands for cluster node management:
ls- List node IDsstatus- Show detailed node statusdecommission- Safely remove nodes from clusterrecommission- Cancel node decommissioningdrain- Prepare node for shutdown
Subcommands
node ls
List IDs of all active nodes in the cluster.Only shows active (non-decommissioned) nodes. Use
node status --decommission to see all nodes.node status
Display detailed status information for one or all nodes.Flags
Include decommissioning and decommissioned nodes in output.
Include range distribution information.
Include storage statistics.
Include all information (ranges, stats, decommission status).
Examples
Sample Output
node decommission
Safely remove one or more nodes from the cluster by transferring their range replicas to other nodes.Flags
Decommission the node you’re connected to.
How long to wait for decommissioning to complete.Options:
all- Wait until fully decommissioned (default)none- Start decommissioning and return immediately
Pre-decommission readiness checks.Options:
skip- No pre-checks (default)enabled- Run checks, warn on issuesstrict- Run checks, fail if issues detected
Show decommission status without actually decommissioning.
Examples
Decommissioning Process
The decommissioning process involves several stages:- Pre-checks (if enabled): Verify cluster can handle node removal
- Replica transfer: Move range replicas to other nodes
- Drain: Close SQL connections and reject new ones
- Mark decommissioned: Finalize node removal
Progress Output
Dots (
.) indicate progress without status changes. The process completes when replica count reaches zero.node recommission
Cancel decommissioning for nodes that haven’t fully decommissioned yet.Examples
node drain
Prepare a node for shutdown by draining client connections and transferring range leases.Draining prepares for shutdown but doesn’t stop the process. Use your service manager or send SIGTERM to actually stop the node.
Flags
Drain the node you’re connected to.
Shutdown the node after draining completes.
Maximum time to wait for drain to complete.
Examples
What Draining Does
- Stop accepting new SQL connections
- Close existing SQL connections gracefully
- Transfer range leases to other nodes
- Wait for in-flight operations to complete
Output
--shutdown:
Connection Flags
Allnode subcommands support standard connection flags:
Node to connect to (can be any node in cluster).
Certificate directory for secure connections.
Connect without encryption.
Best Practices
Decommissioning Best Practices:
- Run
--checks=strictbefore decommissioning production nodes - Monitor cluster health during decommissioning
- Ensure sufficient capacity on remaining nodes
- Decommission nodes one at a time for safety
- Verify with
node status --decommissionafter completion
Troubleshooting
Decommissioning Stalled
If replica count stops decreasing:- Check cluster health:
cockroach node status --all - Review logs for errors
- Verify remaining nodes have capacity
- Check network connectivity between nodes
- Review range allocation with
--rangesflag
Cannot Drain Node
- Ensure node is still responsive
- Check for long-running transactions
- Verify cluster settings for drain timeouts
- Review server logs for detailed errors
Recommission Failed
- Verify node hasn’t fully decommissioned
- Check node is still in cluster membership
- Ensure node process is still running