环境配置
opensearch2.9.0
腾讯云ES 7.14.2白金版
腾讯云logstash 7.14.2 Xpack版
opensearch安装
代码语言:javascript复制//下载安装包
wget https://artifacts.opensearch.org/releases/bundle/opensearch/2.9.0/opensearch-2.9.0-linux-x64.tar.gz
tar -zxf opensearch-2.9.0-linux-x64.tar.gz
cd opensearch-2.9.0/config
代码语言:javascript复制vim opensearch.yml
#使用如下配置
# 指定集群名称和主机名
cluster.name: opensearch
node.name: node-01
# 禁用交换内存
bootstrap.memory_lock: true
# 修改监听地址,外部机器也可以访问
network.host: 0.0.0.0
# 默认的端口号
http.port: 9200
# 设置单机模式运行
discovery.type: single-node
代码语言:javascript复制//进入opensearch安装目录启动opensearch
./opensearch-tar-install.sh
curl -XGET https://localhost:9200 -u 'admin:admin' --insecure
//返回如下则表示启动成功
代码语言:javascript复制//创建索引
curl -XPUT https://localhost:9200/test -u 'admin:admin' --insecure
//添加数据
curl -u 'admin:admin' -XPUT "https://localhost:9200/test/_doc/1" -H 'Content-Type: application/json' -d'
{
"data":100
}'
代码语言:javascript复制//更换认证协议
vim config/opensearch.yml
将plugins.security.ssl.http.enabled参数改为false后重启opensearch
此时可以使用http协议访问,且无需使用--insecure参数跳过证书认证
logstash管道配置
使用如下配置同步数据,Logstash需要能访问Opensearch和ES
代码语言:javascript复制input {
elasticsearch {
hosts => ["http://10.0.2.20:9200"]
user => "admin"
password => "passwd"
index => "*"
docinfo => "true"
}
}
output {
elasticsearch {
hosts => ["http://10.0.2.111:9200"]
user => "elastic"
password => "passwd"
index => "%{[@metadata][_index]}"
document_id => "%{[@metadata][_id]}"
}
}
Elasticdump同步索引属性
Elasticdump工具只能同步index mapping,settings无法同步。
1. 安装elasticdump工具,版本建议6.76.0及更高版本
代码语言:javascript复制[root@tencentos ~]# yum install -y npm
[root@tencentos ~]# npm install -g elasticdump
elasticdump安装细节问题移步:Elasticdump安装问题
2. 仅能同步mapping,settings同步index.replication.type配置不支持报错
代码语言:javascript复制elasticdump --input=http://source_ip:9200/test --output=http://elastic:passwd@target_ip:9200/test --type=mapping --timeout=30
elasticdump --input=http://admin:admin@10.0.2.195:9200/test --output=http://elastic:password@10.0.2.95:9200/test --type=settings --timeout=30
报错信息
代码语言:javascript复制Thu, 30 Nov 2023 08:30:14 GMT | Error Emitted => {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"unknown setting [index.replication.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"}],"type":"illegal_argument_exception","reason":"unknown setting [index.replication.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"},"status":400}
3. settings可通过创建模版同步
代码语言:javascript复制PUT /_index_template/template1
{
"index_patterns" : ["*"],
"priority" : 10,
"template": {
"settings": {
"number_of_shards": "3",
"number_of_replicas" : "1"
}
}
}
我正在参与2023腾讯技术创作特训营第四期有奖征文,快来和我瓜分大奖!