• ElasticSearch Error at 2019年06月14日

    执行

    $ sudo make console
    [sudo] password for aaron67:
    Starting homeland_redis ... done
    Starting homeland_postgresql ...
    Starting homeland_elasticsearch ... done
    Loading production environment (Rails 5.2.2.1)
    irb(main):001:0> Topic.__elasticsearch__.create_index!
    => nil
    irb(main):002:0> Topic.import
    Traceback (most recent call last):
            1: from (irb):2
    NoMethodError (undefined method `bytesize' for nil:NilClass)
    irb(main):003:0> User.__elasticsearch__.create_index!
    => {"acknowledged"=>true, "shards_acknowledged"=>true, "index"=>"users"}
    irb(main):004:0> User.import
    => 0
    irb(main):005:0> Page.__elasticsearch__.create_index!
    => {"acknowledged"=>true, "shards_acknowledged"=>true, "index"=>"pages"}
    irb(main):006:0> Page.import
    => 0
    irb(main):007:0>
    

    搜索功能已经 OK 了,感谢感谢

    等您有空的时候Fix了 我再更新一哈 😀

  • ElasticSearch Error at 2019年06月14日

    好的 十分感谢

  • ElasticSearch Error at 2019年06月14日

    是的 我觉得不是compose 端口的问题 原来搜索是可用的

  • ElasticSearch Error at 2019年06月14日

    另外,我加了 --trace 发现个挺神奇的地方

    rake aborted!
    Faraday::ConnectionFailed: Failed to open TCP connection to localhost:9200 (Network unreachable - connect(2) for "localhost" port 9200)
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:87:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:43:in `block in call'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:92:in `with_net_http_connection'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:38:in `call'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/rack_builder.rb:143:in `build_response'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/connection.rb:387:in `run_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-transport-5.0.5/lib/elasticsearch/transport/transport/http/faraday.rb:23:in `block in perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-transport-5.0.5/lib/elasticsearch/transport/transport/base.rb:262:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-transport-5.0.5/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-transport-5.0.5/lib/elasticsearch/transport/client.rb:131:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-api-5.0.5/lib/elasticsearch/api/namespace/common.rb:21:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-api-5.0.5/lib/elasticsearch/api/actions/indices/delete.rb:44:in `delete'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-model-5.0.2/lib/elasticsearch/model/indexing.rb:269:in `delete_index!'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-model-5.0.2/lib/elasticsearch/model/indexing.rb:229:in `create_index!'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-model-5.0.2/lib/elasticsearch/model/importing.rb:116:in `import'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-rails-5.0.2/lib/elasticsearch/rails/tasks/import.rb:63:in `block (3 levels) in <main>'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
    /usr/local/bundle/bin/bundle:23:in `load'
    /usr/local/bundle/bin/bundle:23:in `<main>'
    
    Caused by:
    Errno::ENETUNREACH: Failed to open TCP connection to localhost:9200 (Network unreachable - connect(2) for "localhost" port 9200)
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:87:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:43:in `block in call'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:92:in `with_net_http_connection'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:38:in `call'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/rack_builder.rb:143:in `build_response'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/connection.rb:387:in `run_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-transport-5.0.5/lib/elasticsearch/transport/transport/http/faraday.rb:23:in `block in perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-transport-5.0.5/lib/elasticsearch/transport/transport/base.rb:262:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-transport-5.0.5/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-transport-5.0.5/lib/elasticsearch/transport/client.rb:131:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-api-5.0.5/lib/elasticsearch/api/namespace/common.rb:21:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-api-5.0.5/lib/elasticsearch/api/actions/indices/delete.rb:44:in `delete'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-model-5.0.2/lib/elasticsearch/model/indexing.rb:269:in `delete_index!'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-model-5.0.2/lib/elasticsearch/model/indexing.rb:229:in `create_index!'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-model-5.0.2/lib/elasticsearch/model/importing.rb:116:in `import'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-rails-5.0.2/lib/elasticsearch/rails/tasks/import.rb:63:in `block (3 levels) in <main>'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
    /usr/local/bundle/bin/bundle:23:in `load'
    /usr/local/bundle/bin/bundle:23:in `<main>'
    
    Caused by:
    Errno::ENETUNREACH: Network unreachable - connect(2) for "localhost" port 9200
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:87:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:43:in `block in call'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:92:in `with_net_http_connection'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:38:in `call'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/rack_builder.rb:143:in `build_response'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/connection.rb:387:in `run_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-transport-5.0.5/lib/elasticsearch/transport/transport/http/faraday.rb:23:in `block in perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-transport-5.0.5/lib/elasticsearch/transport/transport/base.rb:262:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-transport-5.0.5/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-transport-5.0.5/lib/elasticsearch/transport/client.rb:131:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-api-5.0.5/lib/elasticsearch/api/namespace/common.rb:21:in `perform_request'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-api-5.0.5/lib/elasticsearch/api/actions/indices/delete.rb:44:in `delete'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-model-5.0.2/lib/elasticsearch/model/indexing.rb:269:in `delete_index!'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-model-5.0.2/lib/elasticsearch/model/indexing.rb:229:in `create_index!'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-model-5.0.2/lib/elasticsearch/model/importing.rb:116:in `import'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-rails-5.0.2/lib/elasticsearch/rails/tasks/import.rb:63:in `block (3 levels) in <main>'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
    /usr/local/bundle/bin/bundle:23:in `load'
    /usr/local/bundle/bin/bundle:23:in `<main>'
    Tasks: TOP => elasticsearch:import:model
    

    说连不上本地 9200 端口…

    我看了下compose file,对 elasticsearch 端口的写法是

    ports:
      - '9200'
      - '9300'
    

    并没有显示指定,我以为是这里的问题… 调整成了

    ports:
      - '9200:9200'
      - '9300:9300'
    

    但依旧报同样的错误,调整后的 container

    f34d63688977        elasticsearch:5-alpine     "/docker-entrypoint.…"   12 minutes ago       Up 12 minutes                    0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   homeland_elasticsearch
    

    app.local.env配置文件的内容

    #
    # Global settings
    #
    
    RAILS_ENV=production --trace
    SECRET_KEY_BASE=production
    
    DATABASE_URL=postgres://postgres@postgresql:5432/homeland
    
    REDIS_URL=redis://redis:6379/1
    ELASTICSEARCH_HOST=elasticsearch:9200
    
  • ElasticSearch Error at 2019年06月14日

    谢谢回复

    三条均报类似下面的错误

    $ docker-compose run app bundle exec rake elasticsearch:import:model CLASS=User FORCE=y
    Starting homeland_postgresql ... done
    Starting homeland_redis ...
    Starting homeland_elasticsearch ... done
    rake aborted!
    NameError: uninitialized constant User
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:74:in `block in load_missing_constant'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:74:in `rescue in load_missing_constant'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:56:in `load_missing_constant'
    (eval):1:in `block (3 levels) in <main>'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-rails-5.0.2/lib/elasticsearch/rails/tasks/import.rb:49:in `eval'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-rails-5.0.2/lib/elasticsearch/rails/tasks/import.rb:49:in `block (3 levels) in <main>'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
    /usr/local/bundle/bin/bundle:23:in `load'
    /usr/local/bundle/bin/bundle:23:in `<main>'
    
    Caused by:
    NameError: uninitialized constant User
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:58:in `block in load_missing_constant'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:57:in `load_missing_constant'
    (eval):1:in `block (3 levels) in <main>'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-rails-5.0.2/lib/elasticsearch/rails/tasks/import.rb:49:in `eval'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/elasticsearch-rails-5.0.2/lib/elasticsearch/rails/tasks/import.rb:49:in `block (3 levels) in <main>'
    /home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
    /usr/local/bundle/bin/bundle:23:in `load'
    /usr/local/bundle/bin/bundle:23:in `<main>'
    Tasks: TOP => elasticsearch:import:model
    (See full trace by running task with --trace)
    
  • 上传图片的相关问题 at 2019年05月09日

    测试图片上传

  • 收到 十分感谢 😂

  • 无耻的圈一下开发大佬… @huacnlee

  • 一个区块链的社区 at 2018年04月22日

    😀

  • 一个区块链的社区 at 2018年03月24日

    感谢分享