java - 数据未与 Elastic Search 6.5.1 同步

标签 java mysql elasticsearch logstash

数据库Mysql

我引用了这些链接:

配置文件

logstash-sample.conf

                # Sample Logstash configuration for creating a simple
                # Beats -> Logstash -> Elasticsearch pipeline.

                                            jdbc {
                jdbc_driver_library => "C:/logstash-6.5.1/logstash-core/lib/jars/x-pack-sql-jdbc-6.5.1.jar"
                jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
                jdbc_connection_string => "jdbc:mysql://localhost:3306/test"
                jdbc_user => "root"
                jdbc_password => ""
                statement => "SELECT * FROM persons"
                jdbc_paging_enabled => "true"
                jdbc_page_size => "50000"
                }

                }

                output{
                elasticsearch { codec => json hosts => ["localhost:9200"] index => "persons" }
                stdout { codec => rubydebug }
                }

数据库名称测试

数据表人员

人物索引

日志

            C:\logstash-6.5.1\bin>logstash -f logstash-sample.conf
            Sending Logstash logs to C:/logstash-6.5.1/logs which is now configured via log4j2.properties
            [2018-11-30T18:10:52,868][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
            [2018-11-30T18:10:52,883][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"6.5.1"}
            [2018-11-30T18:10:53,550][INFO ][logstash.config.source.local.configpathloader] No config files found in path {:path=>"C:/logstash-6.5.1/bin/logstash-sample.conf"}
            [2018-11-30T18:10:53,559][ERROR][logstash.config.sourceloader] No configuration found in the configured sources.
            [2018-11-30T18:10:53,894][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}

请求获取

http://localhost:9200/persons/_search/?pretty

            {
                "error": {
                    "root_cause": [
                        {
                            "type": "index_not_found_exception",
                            "reason": "no such index",
                            "resource.type": "index_or_alias",
                            "resource.id": "persons",
                            "index_uuid": "_na_",
                            "index": "persons"
                        }
                    ],
                    "type": "index_not_found_exception",
                    "reason": "no such index",
                    "resource.type": "index_or_alias",
                    "resource.id": "persons",
                    "index_uuid": "_na_",
                    "index": "persons"
                },
                "status": 404
            }

欢迎任何建议

最佳答案

好的,因为您位于 logstash/bin 文件夹中,并且您的 logstash-sample.conf 文件位于 logstash/config 中> 文件夹,您需要像这样运行logstash:

C:\logstash-6.5.1\bin> logstash -f ../config/logstash-sample.conf
                                        ^
                                        |
                               add this relative path

关于java - 数据未与 Elastic Search 6.5.1 同步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53557868/

相关文章:

java - 使用 Spring 实现工厂方法模式

java - java 随机字节转int

mysql - 使用按另一列排序的列值计算第一次出现的次数

php - CodeIgniter:表单的时间选择器

elasticsearch - Elasticsearch同义词中的逗号

elasticsearch - 为什么我的Elasticsearch查询检索所有索引文档

java - 在间隔的随机分钟内运行程序

java - 我需要将instanceof与来自不同类的arraylist一起使用

mysql - SQL 查询错误#1064,没有任何明显错误

ElasticSearch - 映射中的日期时间格式无效