手搓
步骤
- 修改模板分词
- 计算新的索引名称
- 删除之前索引别名
- 新建索引
修改模板分词器类型并根据索引名称重新生成新索引
#!/bin/bash
red_text() {
echo -e "\033[31m$1\033[0m"
}
# 定义一个显示绿色文本的函数
green_text() {
echo -e "\033[32m$1\033[0m"
}
echo " ===========开始初始化ES 7.6.x==========="
#address="http://172.30.3.226:9200"
address="http://10.11.55.53:9200"
# 账号和密码
username="elastic"
password="Esb@123"
#msg_trace esb-m-trace-logs
#msg_sendlog esb-m-produce-logs
#msg_recvlog esb-m-consume-logs
#msg_systemapplog esb-middleware-app-monitor-logs
#msg_sendersituation esb-statistics-logs
non_body_index_list=("esb-m-produce-logs")
index_list=()
#是否删除存在的index 0表示不删除,1表示删除
delete_index=1
#es配置文件是否配置node.attr.box_type,配置了是1,不配置是0。
node_attr_box_type_config=0
# 设置max_size变量 gb 建议25gb
max_size=25
#天 建议30
max_age=30
max_docs_non_message_body=200000000
max_docs=50000000
max_result_window=1000000
echo "address: ${address}"
echo "username: ${username}"
echo "password: ${password}"
echo "non_body_index_list: ${non_body_index_list}"
echo "index_list: ${index_list}"
echo "max_size: ${max_size}gb"
echo "max_age: ${max_age}gb"
echo "max_docs_non_message_body: ${max_docs_non_message_body}"
echo "max_docs: ${max_docs}"
echo "---------------------------------------------------------------------------"
echo ""
echo ""
echo ""
echo ""
echo ""
echo " ===========2. 开始创建 ES索引模版 ==========="
echo "正在创建ES索引模版(${non_body_index_list}):"
for item in "${non_body_index_list[@]}"; do
url=${address}"/_template/${item}_template"
echo "url >>>> "$url
data=$(cat <<EOF
{
"order": 0,
"index_patterns": [
"${item}-*"
],
"settings": {
"index": {
"lifecycle": {
"name": "ilm-fm",
"rollover_alias": "${item}"
},
"max_result_window": "${max_result_window}",
"refresh_interval": "10s",
"analysis": {
"analyzer": {
"oap_log_analyzer": {
"type": "ik_max_word"
},
"oap_log_search_analyzer": {
"type": "ik_smart"
}
}
},
"number_of_shards": "1",
"number_of_replicas": "1"
}
},
"mappings": {
"_source": {},
"_meta": {},
"properties": {}
}
}
EOF
)
result=$(c

最低0.47元/天 解锁文章
926

被折叠的 条评论
为什么被折叠?



