Last active
December 16, 2016 17:51
-
-
Save irvingpop/a9d0855bb5f335800d84d8f827644192 to your computer and use it in GitHub Desktop.
Tuning Chef ElasticSearch Index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Tune the elasticsearch shard and replica count after chef-backend has been setup, but before any Frontends have been configured | |
# based on the following docs: | |
# https://www.elastic.co/guide/en/elasticsearch/guide/current/replica-shards.html | |
# https://www.elastic.co/guide/en/elasticsearch/guide/current/_scale_horizontally.html | |
# https://www.elastic.co/blog/clustering_across_multiple_data_centers | |
# | |
# This process will change once this Chef Server PR has been accepted: | |
# https://github.com/chef/chef-server/pull/988 | |
# Depending on where this script is run, the following variable can be localhost (if running on any backend) | |
# or any of the Chef Backend nodes | |
ELASTICSEARCH_HOST=anychefbackend.mycompany.com | |
ES_SHARD_COUNT=3 | |
ES_REPLICA_COUNT=2 | |
cat > /tmp/index_create.json <<EOF | |
{ | |
"settings": { | |
"analysis": { | |
"analyzer": { | |
"default": { | |
"type": "whitespace" | |
} | |
} | |
}, | |
"number_of_shards": ${ES_SHARD_COUNT}, | |
"number_of_replicas": ${ES_REPLICA_COUNT} | |
}, | |
"mappings": { | |
"object": { | |
"_source": { | |
"enabled": false | |
}, | |
"_all": { | |
"enabled": false | |
}, | |
"properties": { | |
"X_CHEF_database_CHEF_X": { | |
"type": "string", | |
"index": "not_analyzed", | |
"norms": { | |
"enabled": false | |
} | |
}, | |
"X_CHEF_type_CHEF_X": { | |
"type": "string", | |
"index": "not_analyzed", | |
"norms": { | |
"enabled": false | |
} | |
}, | |
"X_CHEF_id_CHEF_X": { | |
"type": "string", | |
"index": "not_analyzed", | |
"norms": { | |
"enabled": false | |
} | |
}, | |
"data_bag": { | |
"type": "string", | |
"index": "not_analyzed", | |
"norms": { | |
"enabled": false | |
} | |
}, | |
"content": { | |
"type": "string", | |
"index": "analyzed" | |
} | |
} | |
} | |
} | |
} | |
EOF | |
curl -XPUT http://${ELASTICSEARCH_HOST}:9200/chef/ -d @/tmp/index_create.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment