nodetool invalidatejmxpermissionscache
Cassandra 4.1+
This command is available in Cassandra 4.1 and later.
Invalidates the JMX permissions cache on the node.
Synopsis
Section titled “Synopsis”nodetool [connection_options] invalidatejmxpermissionscacheSee connection options for connection options.
Description
Section titled “Description”nodetool invalidatejmxpermissionscache clears all cached JMX authorization information on the node. The JMX permissions cache stores authorization decisions for JMX (Java Management Extensions) operations, allowing Cassandra to determine whether a user can execute specific nodetool commands or access MBeans without querying the auth tables for every JMX call.
JMX authentication and authorization control access to administrative operations through nodetool and other JMX clients. When enabled, users must be granted specific JMX permissions to execute management commands.
JMX Authorization Required
This cache is only relevant when JMX authentication and authorization are enabled. If JMX is configured without authorization (the default), this cache is not used.
Examples
Section titled “Examples”Basic Usage
Section titled “Basic Usage”nodetool invalidatejmxpermissionscacheAfter JMX Permission Grant
Section titled “After JMX Permission Grant”# After granting JMX permissions to a rolecqlsh -e "GRANT EXECUTE ON ALL MBEANS TO ops_team;"
# Invalidate JMX cachenodetool invalidatejmxpermissionscacheJMX Permissions Cache Overview
Section titled “JMX Permissions Cache Overview”What the Cache Stores
Section titled “What the Cache Stores”| Cached Data | Description |
|---|---|
| Role | The authenticated JMX user |
| MBean | The target MBean or MBean pattern |
| Permission | Allowed JMX operations (EXECUTE, DESCRIBE) |
| Method | Specific MBean methods if restricted |
How It Improves Performance
Section titled “How It Improves Performance”Without JMX Permissions Cache: nodetool Command → JMX Call → Query auth tables → Check permission → Execute MBean operation
With JMX Permissions Cache: nodetool Command → JMX Call → Check cached permission → Execute MBean operation (Avoids auth table queries for every JMX call)JMX Permission Types
Section titled “JMX Permission Types”| Permission | Description | Example Operations |
|---|---|---|
EXECUTE | Invoke MBean methods | nodetool commands |
DESCRIBE | Read MBean attributes | Monitoring, metrics |
SELECT | Read MBean values | JMX console access |
MODIFY | Write MBean attributes | Configuration changes |
When to Use
Section titled “When to Use”After JMX Permission Changes
Section titled “After JMX Permission Changes”When JMX access is granted or revoked:
# Grant JMX permissionscqlsh -e "GRANT EXECUTE ON MBEAN 'org.apache.cassandra.db:*' TO dba_role;"
# Invalidate JMX cachenodetool invalidatejmxpermissionscacheAfter Role Changes Affecting JMX
Section titled “After Role Changes Affecting JMX”When role memberships that include JMX permissions change:
# Revoke role that had JMX permissionscqlsh -e "REVOKE admin_role FROM former_dba;"
# Invalidate both roles and JMX cachesnodetool invalidaterolescachenodetool invalidatejmxpermissionscacheSecurity Incident Response
Section titled “Security Incident Response”When immediate JMX access revocation is critical:
#!/bin/bashUSER="$1"
echo "=== Emergency JMX Access Revocation ==="
# 1. Revoke all JMX permissionscqlsh -e "REVOKE ALL PERMISSIONS ON ALL MBEANS FROM $USER;"
# 2. Invalidate JMX cache on all nodesfor node in $(nodetool status | grep "^UN" | awk '{print $2}'); do echo "Processing $node..." ssh "$node" "nodetool invalidatejmxpermissionscache"done
echo "JMX access revoked for user: $USER"Troubleshooting JMX Access Issues
Section titled “Troubleshooting JMX Access Issues”When nodetool commands fail with permission errors:
# Clear JMX permissions cachenodetool invalidatejmxpermissionscache
# Verify JMX permissionscqlsh -e "LIST ALL PERMISSIONS ON ALL MBEANS OF problem_user;"After JMX Configuration Changes
Section titled “After JMX Configuration Changes”When JMX authorization configuration changes:
# After modifying jmx authorization settingsnodetool invalidatejmxpermissionscacheImpact Assessment
Section titled “Impact Assessment”Immediate Effects
Section titled “Immediate Effects”| Aspect | Impact |
|---|---|
| Cached JMX permissions | All cleared |
| Next JMX operations | Require auth table lookups |
| nodetool command latency | Slight increase until cache warms |
| Existing JMX sessions | May require re-authorization |
Security Effects
Section titled “Security Effects”| Scenario | Behavior |
|---|---|
| JMX permission revoked | Access denied immediately |
| New JMX permission granted | Access allowed immediately |
| Role with JMX removed | Access revoked immediately |
Recovery Timeline
Section titled “Recovery Timeline”| Phase | Duration | Cache State |
|---|---|---|
| Immediately after | 0 | Empty |
| First commands | Milliseconds | Being populated |
| Normal operations | Seconds | Active users cached |
Minimal Performance Impact
JMX permissions cache invalidation typically has minimal impact since JMX authorization lookups are fast and most environments have few JMX users.
Configuration
Section titled “Configuration”JMX Authorization Settings
Section titled “JMX Authorization Settings”JMX authorization is configured in multiple files:
cassandra-env.sh:
# Enable JMX authenticationJVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=true"
# Enable JMX authorizationJVM_OPTS="$JVM_OPTS -Dcassandra.jmx.authorizer=org.apache.cassandra.auth.jmx.AuthorizationProxy"jmxremote.access (traditional JMX):
monitorRole readonlycontrolRole readwriteCassandra Native JMX Auth (cassandra.yaml):
# Use Cassandra's internal authorization for JMXjmx_authorizer: CassandraJMXAuthorizerCache Settings
Section titled “Cache Settings”# cassandra.yaml - JMX cache settings (when using native auth)jmx_permissions_validity_in_ms: 2000jmx_permissions_update_interval_in_ms: 1000jmx_permissions_cache_max_entries: 1000Cluster-Wide Operations
Section titled “Cluster-Wide Operations”Invalidate on All Nodes
Section titled “Invalidate on All Nodes”For JMX permission changes to take effect cluster-wide:
#!/bin/bashecho "Invalidating JMX permissions cache cluster-wide..."# Get list of node IPs from local nodetool status
nodes=$(nodetool status | grep "^UN" | awk '{print $2}')
for node in $nodes; do echo -n "$node: " ssh "$node" "nodetool invalidatejmxpermissionscache 2>/dev/null && echo "invalidated" || echo "FAILED""done
echo "JMX permissions cache cleared on all nodes."Complete JMX Access Refresh
Section titled “Complete JMX Access Refresh”Clear all JMX-related caches:
#!/bin/bashecho "Refreshing JMX access caches cluster-wide..."# Get list of node IPs from local nodetool status
nodes=$(nodetool status | grep "^UN" | awk '{print $2}')
for node in $nodes; do echo "Processing $node..." ssh "$node" "nodetool invalidatejmxpermissionscache 2>/dev/null" ssh "$node" "nodetool invalidatecredentialscache 2>/dev/null" ssh "$node" "nodetool invalidaterolescache 2>/dev/null" echo " Done"done
echo "All JMX access caches cleared."JMX Permission Management
Section titled “JMX Permission Management”Granting JMX Permissions
Section titled “Granting JMX Permissions”-- Grant access to all MBeansGRANT EXECUTE ON ALL MBEANS TO admin_role;
-- Grant access to specific MBeanGRANT EXECUTE ON MBEAN 'org.apache.cassandra.db:type=StorageService' TO ops_role;
-- Grant access to MBean patternGRANT EXECUTE ON MBEAN 'org.apache.cassandra.db:*' TO dba_role;
-- Grant read-only accessGRANT DESCRIBE ON ALL MBEANS TO monitoring_role;Revoking JMX Permissions
Section titled “Revoking JMX Permissions”-- Revoke specific permissionREVOKE EXECUTE ON ALL MBEANS FROM former_admin;
-- Revoke all JMX permissionsREVOKE ALL PERMISSIONS ON ALL MBEANS FROM user_role;Listing JMX Permissions
Section titled “Listing JMX Permissions”-- List all JMX permissions for a roleLIST ALL PERMISSIONS ON ALL MBEANS OF admin_role;
-- List all JMX permissionsLIST ALL PERMISSIONS ON ALL MBEANS;Workflow: JMX Permission Change with Validation
Section titled “Workflow: JMX Permission Change with Validation”#!/bin/bashROLE="$1"ACTION="$2" # grant or revokeMBEAN="$3" # MBean pattern or "ALL MBEANS"
echo "=== JMX Permission Change Workflow ==="
# 1. Show current permissionsecho "1. Current JMX permissions for $ROLE:"cqlsh -e "LIST ALL PERMISSIONS ON ALL MBEANS OF $ROLE;"
# 2. Perform actionecho ""echo "2. Action: $ACTION EXECUTE ON $MBEAN"if [ "$ACTION" = "grant" ]; then cqlsh -e "GRANT EXECUTE ON $MBEAN TO $ROLE;"else cqlsh -e "REVOKE EXECUTE ON $MBEAN FROM $ROLE;"fi
# 3. Invalidate cacheecho ""echo "3. Invalidating JMX permissions cache..."nodetool invalidatejmxpermissionscache
# 4. Verify changeecho ""echo "4. JMX permissions after change:"cqlsh -e "LIST ALL PERMISSIONS ON ALL MBEANS OF $ROLE;"
# 5. Test access (optional)echo ""echo "5. Testing JMX access..."# This would require the user to attempt a nodetool commandecho " Test by running: nodetool -u $ROLE status"
echo ""echo "=== Complete ==="Troubleshooting
Section titled “Troubleshooting”nodetool Command Fails with Permission Error
Section titled “nodetool Command Fails with Permission Error”# Check JMX permissions for the usercqlsh -e "LIST ALL PERMISSIONS ON ALL MBEANS OF username;"
# Check role membershipcqlsh -e "SELECT role, member_of FROM system_auth.roles WHERE role = 'username';"
# Clear caches and retrynodetool invalidatejmxpermissionscachenodetool invalidaterolescacheJMX Permission Grant Not Taking Effect
Section titled “JMX Permission Grant Not Taking Effect”# Invalidate on all nodesfor node in $(nodetool status | grep "^UN" | awk '{print $2}'); do ssh "$node" "nodetool invalidatejmxpermissionscache"done
# Verify the grant was recordedcqlsh -e "SELECT * FROM system_auth.role_permissions WHERE role = 'the_role';"User Has Too Much JMX Access
Section titled “User Has Too Much JMX Access”# List all permissionscqlsh -e "LIST ALL PERMISSIONS ON ALL MBEANS OF overprivileged_user;"
# Revoke excessive permissionscqlsh -e "REVOKE EXECUTE ON ALL MBEANS FROM overprivileged_user;"
# Grant only needed permissionscqlsh -e "GRANT EXECUTE ON MBEAN 'org.apache.cassandra.db:type=StorageService' TO overprivileged_user;"
# Invalidate cachenodetool invalidatejmxpermissionscacheCannot Access JMX After Invalidation
Section titled “Cannot Access JMX After Invalidation”# Check if JMX authentication is workingnodetool -u admin_user -pw password status
# Check for auth errorsgrep -i "jmx\|auth" /var/log/cassandra/system.log | tail -20
# Verify JMX configurationgrep -i "jmx" /etc/cassandra/cassandra-env.shBest Practices
Section titled “Best Practices”JMX Permissions Cache Guidelines
- Invalidate after permission changes - Always invalidate when modifying JMX access
- Cluster-wide for security - Invalidate all nodes when revoking JMX access
- Least privilege - Grant only necessary JMX permissions
- Use role hierarchy - Create JMX permission roles and grant to users
- Audit JMX access - Regularly review who has JMX permissions
Security Considerations
- JMX access provides powerful administrative control over Cassandra
EXECUTE ON ALL MBEANSis equivalent to full cluster administration- Always invalidate cluster-wide when revoking JMX access
- Consider separate JMX credentials from CQL credentials
- Monitor JMX access in audit logs
JMX vs CQL Permissions
JMX and CQL permissions are separate:
- CQL permissions: Control data access and DDL operations
- JMX permissions: Control administrative operations (nodetool)
A user may need both depending on their role:
- DBAs typically need both CQL and JMX permissions
- Application users typically need only CQL permissions
- Operators may need only JMX permissions for monitoring
Common MBean Patterns
Section titled “Common MBean Patterns”| MBean Pattern | Description |
|---|---|
org.apache.cassandra.db:* | Database operations |
org.apache.cassandra.db:type=StorageService | Cluster management |
org.apache.cassandra.db:type=CompactionManager | Compaction operations |
org.apache.cassandra.db:type=StreamManager | Streaming operations |
org.apache.cassandra.net:* | Network operations |
org.apache.cassandra.metrics:* | Metrics access |
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| invalidatepermissionscache | Clear CQL permissions cache |
| invalidatecredentialscache | Clear credentials cache |
| invalidaterolescache | Clear roles cache |
| getauthcacheconfig | View auth cache settings |
| setauthcacheconfig | Modify auth cache settings |