nodetool enablebinary
Enables the CQL native transport, allowing client connections.
Synopsis
Section titled “Synopsis”nodetool [connection_options] enablebinarySee connection options for connection options.
Description
Section titled “Description”nodetool enablebinary enables the CQL native transport protocol, which handles all CQL client connections. When enabled, the node accepts connections on the native transport port (default: 9042) from CQL drivers and tools like cqlsh.
The native transport is Cassandra's primary client interface, supporting:
- CQL queries - SELECT, INSERT, UPDATE, DELETE operations
- Prepared statements - Pre-compiled queries for performance
- Batch operations - Atomic multi-statement execution
- Streaming results - Pagination for large result sets
- Event notifications - Schema change and topology events
Behavior
Section titled “Behavior”When the native transport is enabled:
- Cassandra begins listening on the configured native transport port
- New client connections are accepted
- The node can serve as a coordinator for CQL requests
- Event listeners receive topology and schema notifications
Connection Handling
Existing connections established before a disable/enable cycle may need to reconnect. Most CQL drivers handle this automatically through their connection pooling logic.
Examples
Section titled “Examples”Basic Usage
Section titled “Basic Usage”nodetool enablebinaryVerify Enabled
Section titled “Verify Enabled”nodetool enablebinarynodetool statusbinary# Expected output: runningTest Client Connectivity
Section titled “Test Client Connectivity”# Enable binarynodetool enablebinary
# Verify with cqlshcqlsh localhost 9042 -e "SELECT now() FROM system.local"When to Use
Section titled “When to Use”After Maintenance
Section titled “After Maintenance”Re-enable client connections after maintenance:
# Maintenance completenodetool enablebinary
# Verifynodetool statusbinaryRecovery from Accidental Disable
Section titled “Recovery from Accidental Disable”If binary was accidentally disabled:
# Check statusnodetool statusbinary# Output: not running
# Enable immediatelynodetool enablebinary
# Verify clients can connectcqlsh localhostAfter Node Restart Issues
Section titled “After Node Restart Issues”If binary transport failed to start automatically:
# Check current statenodetool statusbinary
# Enable if not runningnodetool enablebinary
# Check logs if it failstail -100 /var/log/cassandra/system.log | grep -i nativeControlled Traffic Restoration
Section titled “Controlled Traffic Restoration”Restore client traffic after a controlled outage:
# Verify cluster state firstnodetool status
# Enable binary to accept trafficnodetool enablebinary
# Monitor for issueswatch nodetool tpstatsWorkflow: Complete Node Recovery
Section titled “Workflow: Complete Node Recovery”After full node isolation, restore in the correct order:
# 1. Check current statenodetool statusgossip # Verify gossip is runningnodetool statusbinary # Verify binary is not running
# 2. Ensure gossip is running firstif [ "$(nodetool statusgossip)" != "running" ]; then nodetool enablegossip sleep 5 # Wait for cluster syncfi
# 3. Verify node is seen as UP by clusternodetool status | grep $(hostname -i)# Should show "UN" (Up/Normal)
# 4. Enable binary transportnodetool enablebinary
# 5. Verify operationalnodetool statusbinary # running
# 6. Test client connectivitycqlsh localhost -e "SELECT * FROM system.local"Order of Operations
Section titled “Order of Operations”Restoring a Node
Section titled “Restoring a Node”Always follow this order when restoring from isolation:
| Step | Command | Reason |
|---|---|---|
| 1 | enablegossip | Node must be in cluster first |
| 2 | Wait 5-10 seconds | Allow cluster state sync |
| 3 | enablebinary | Now safe to accept clients |
Enable Gossip First
Never enable binary while gossip is disabled. The node would accept requests but cannot coordinate properly with other nodes, leading to potential consistency issues.
Isolating a Node
Section titled “Isolating a Node”The reverse order for isolation:
| Step | Command | Reason |
|---|---|---|
| 1 | disablebinary | Stop new client connections |
| 2 | Wait for operations | Allow in-flight requests to complete |
| 3 | disablegossip | Then isolate from cluster |
Port and Configuration
Section titled “Port and Configuration”Default Configuration
Section titled “Default Configuration”| Setting | Default | Description |
|---|---|---|
native_transport_port | 9042 | Standard CQL port |
native_transport_port_ssl | 9142 | SSL-enabled CQL port |
start_native_transport | true | Auto-start on boot |
native_transport_max_threads | 128 | Max client handler threads |
native_transport_max_frame_size_in_mb | 256 | Max request size |
Verifying Port Binding
Section titled “Verifying Port Binding”# Check if port is listeningnetstat -tlnp | grep 9042
# Or with ssss -tlnp | grep 9042Verification
Section titled “Verification”Command Verification
Section titled “Command Verification”nodetool statusbinary# Expected: runningPort Verification
Section titled “Port Verification”# Verify port is listeningnetstat -tlnp | grep 9042# tcp 0 0 0.0.0.0:9042 0.0.0.0:* LISTEN <pid>/javaClient Connection Test
Section titled “Client Connection Test”# Test with cqlshcqlsh localhost 9042 -e "DESCRIBE KEYSPACES"
# Test with simple querycqlsh localhost -e "SELECT cluster_name FROM system.local"Driver Connection Test
Section titled “Driver Connection Test”# Python driver testpython3 -c "from cassandra.cluster import Clustercluster = Cluster(['localhost'])session = cluster.connect()print('Connected:', session.execute('SELECT now() FROM system.local').one())cluster.shutdown()"Troubleshooting
Section titled “Troubleshooting”Binary Won't Enable
Section titled “Binary Won't Enable”If enablebinary doesn't work:
# Check JMX connectivitynodetool info
# Check logs for errorstail -100 /var/log/cassandra/system.log | grep -i "native\|binary"
# Check for port conflictsnetstat -tlnp | grep 9042Port Already in Use
Section titled “Port Already in Use”# Find process using portlsof -i :9042
# Check if another Cassandra process is runningpgrep -f CassandraDaemonConnection Refused After Enable
Section titled “Connection Refused After Enable”If clients get connection refused:
# Verify statusnodetool statusbinary
# Check listening addressgrep native_transport /etc/cassandra/cassandra.yaml
# Verify firewall allows connectionsiptables -L -n | grep 9042SSL Configuration Issues
Section titled “SSL Configuration Issues”If using SSL and connections fail:
# Check SSL configuration in cassandra.yamlgrep -A20 client_encryption /etc/cassandra/cassandra.yaml
# Verify certificate files exist and are readablels -la /path/to/keystore.jks
# Check SSL portnetstat -tlnp | grep 9142Monitoring After Enable
Section titled “Monitoring After Enable”Watch Thread Pools
Section titled “Watch Thread Pools”# Monitor for request handlingwatch -n 2 'nodetool tpstats | head -20'Check Client Connections
Section titled “Check Client Connections”# Count active connectionsnetstat -an | grep 9042 | grep ESTABLISHED | wc -lMonitor Latency
Section titled “Monitor Latency”# Watch coordinator latenciesnodetool proxyhistogramsClient Behavior
Section titled “Client Behavior”Connection Pooling
Section titled “Connection Pooling”Most CQL drivers maintain connection pools. After enabling binary:
- Existing pooled connections may be stale
- Drivers typically detect this and reconnect
- Some drivers may need explicit reconnection
Retry Policies
Section titled “Retry Policies”Client retry policies determine behavior when binary is toggled:
| Policy | Behavior |
|---|---|
| Default | Retry on same/next coordinator |
| Fallthrough | Fail immediately |
| DowngradingConsistency | Retry with lower CL |
Driver Reconnection
Section titled “Driver Reconnection”Most drivers handle reconnection automatically:
# Python driver example - automatic reconnectionfrom cassandra.cluster import Clusterfrom cassandra.policies import ConstantReconnectionPolicy
cluster = Cluster( ['node1', 'node2'], reconnection_policy=ConstantReconnectionPolicy(delay=5.0))Automation Script
Section titled “Automation Script”#!/bin/bash# enable_client_access.sh - Safely enable client access
echo "=== Pre-checks ==="
# Verify gossip is runningif [ "$(nodetool statusgossip)" != "running" ]; then echo "ERROR: Gossip not running. Enable gossip first." echo "Run: nodetool enablegossip" exit 1fi
# Check node status in clusterstatus=$(nodetool status | grep "$(hostname -i)" | awk '{print $1}')if [ "$status" != "UN" ]; then echo "WARNING: Node status is '$status', expected 'UN'" echo "Wait for node to be fully recognized before enabling binary"fi
echo ""echo "=== Enabling Binary Transport ==="
# Enable binarynodetool enablebinary
# Verifysleep 2if [ "$(nodetool statusbinary)" = "running" ]; then echo "Binary transport enabled successfully"else echo "ERROR: Failed to enable binary transport" exit 1fi
# Test connectivityecho ""echo "=== Testing Connectivity ==="if cqlsh localhost -e "SELECT now() FROM system.local" 2>/dev/null; then echo "CQL connection test: PASSED"else echo "CQL connection test: FAILED" echo "Check logs: tail /var/log/cassandra/system.log"fi
echo ""echo "=== Current State ==="echo "Gossip: $(nodetool statusgossip)"echo "Binary: $(nodetool statusbinary)"echo "Port 9042: $(netstat -tlnp 2>/dev/null | grep 9042 | awk '{print $4}')"Best Practices
Section titled “Best Practices”Binary Transport Guidelines
- Enable gossip first - Always ensure cluster communication before client access
- Verify before enabling - Check node is healthy and in cluster
- Test after enabling - Verify clients can actually connect
- Monitor thread pools - Watch for request handling issues
- Gradual traffic restoration - Use load balancer to slowly add node back
- Document in runbooks - Include enable/disable in maintenance procedures
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| disablebinary | Disable CQL transport |
| statusbinary | Check transport status |
| enablegossip | Enable gossip (do first) |
| statusgossip | Check gossip status |
| tpstats | Monitor thread pools |
| status | Check cluster status |