Skip to content

Instantly share code, notes, and snippets.

@seanorama
Created December 20, 2017 10:27
Show Gist options
  • Save seanorama/bf24599f28982f42515c7a6cdc32f069 to your computer and use it in GitHub Desktop.
Save seanorama/bf24599f28982f42515c7a6cdc32f069 to your computer and use it in GitHub Desktop.

The managed-schema for Ranger Audits needs to be changed by default. But until then, we can replace the existing configuration and collection with the commands below.

Credit:


Commands below assume kerberos is used.


  1. SSH to ambari-infra-solr host.

  2. Authenticate

sudo -u infra-solr -i

keytab=/etc/security/keytabs/ambari-infra-solr.service.keytab
kinit -kt ${keytab} $(klist -kt ${keytab}| awk '{print $NF}'|tail -1)
source /etc/ambari-infra-solr/conf/infra-solr-env.sh
export SOLR_ZK_CREDS_AND_ACLS="${SOLR_AUTHENTICATION_OPTS}"
  1. Edit the managed schema:
# Download from zookeeper and edit
  #/usr/lib/ambari-infra-solr/server/scripts/cloud-scripts/zkcli.sh --zkhost "${ZK_HOST}" -cmd getfile /configs/ranger_audits/managed-schema managed-schema
  # edits required:
    # schema version to 1.6
    # For the following fieldTypes add 'docValues="true"': date, double, float, int, long, tdate, tdates, tdouble, tdoubles, tfloat, tfloats, tint, tints, tlong, tlongs
    # For `_version_` fieldType, set indexed=”false” 

## Or Download pre-edited
  #wget -O managed-schema https://gist.githubusercontent.com/risdenk/8cc8f722e200468f9aa536cee7979d06/raw/aa61053847b84e40c3bae8adf806e68b5a1408d3/managed-schema.xml
  1. Upload configuration back to Zookeeper
/usr/lib/ambari-infra-solr/server/scripts/cloud-scripts/zkcli.sh --zkhost "${ZK_HOST}" -cmd putfile /configs/ranger_audits/managed-schema managed-schema
  1. Delete and recreate the ranger_audits collection
curl -u : --negotiate -i "http://$(hostname -f):8886/solr/admin/collections?action=DELETE&name=ranger_audits"
curl -u : --negotiate -i "http://$(hostname -f):8886/solr/admin/collections?action=CREATE&name=ranger_audits&numShards=5&maxShardsPerNode=10&replicationFactor=2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment