2016-10-17 37 views
1

我不能索引我的mysql數據庫與solr(4.0)。我總是得到Indexing failed. Rolled back all changes.我已經檢查了以前的答案,我無法弄清楚它是什麼問題。我在一個Docker(乘客phusion和ubuntu 14.04)容器中運行它。有任何想法嗎?我已經花了幾天的時間來弄清楚這一點。我不能索引我的數據庫索爾。我總是得到`索引失敗。回滾所有更改。

泊塢COMPOSE

version: '2' 

services: 
    search: 
    env_file: .env 
    build: . 
    ports: 
     - "8080:8080" 
    volumes: 
     - ~/.m2:/root/.m2 
     # - ~/.solr:/data/solr/ 
     - ./docker:/home/app/docker 
    db: 
    env_file: .env 
    image: mysql:5.6 
    ports: 
     - "3307:3306" 

SOLR_HOME

ls -l /data/solr/collection1/conf/ 
-rw-r--r-- 1 tomcat7 tomcat7 7601 Oct 17 15:35 data-config.xml 
-rw-r--r-- 1 tomcat7 tomcat7  0 Oct 17 15:35 dataimport.properties 
-rw-r--r-- 1 tomcat7 tomcat7 561 Oct 17 15:35 log4j.properties 
-rw-r--r-- 1 tomcat7 tomcat7 707 Oct 17 15:35 log4j.xml 
-rw-r--r-- 1 tomcat7 tomcat7 12302 Oct 17 15:35 schema.xml 
-rw-r--r-- 1 tomcat7 tomcat7 479 Oct 17 15:35 solrconfig-qf.xml 
-rw-r--r-- 1 tomcat7 tomcat7 41383 Oct 17 15:35 solrconfig.xml 
-rw-r--r-- 1 tomcat7 tomcat7 148 Oct 17 15:35 solrcore.properties 
-rw-r--r-- 1 tomcat7 tomcat7 138 Oct 17 15:35 solrcore.properties.template 

Solr管理

Solr Admin

數據-config.xml中https://gist.github.com/anonymous/ce99aa9277f0295a2a52768fb7866e6a

<dataConfig> 
    <dataSource name="db" type="JdbcDataSource" driver="com.mysql.jdbc.Driver" 
    url="jdbc:mysql://localhost:3306/datacite" user="root" 
    password="" readonly="true" 
    batchSize="-1" /> 
    <!-- for batchSize=-1 see DIH FAQ --> 
    <dataSource name="field" type="FieldReaderDataSource" /> 
    <document> 
    <!-- SOLR-2104 --> 
    <!-- using delta import as proposed in http://wiki.apache.org/solr/DataImportHandlerDeltaQueryViaFullImport --> 

SORL核心屬性

mds.db.url=jdbc:mysql://localhost:3306/datacite?useUnicode=true&characterEncoding=UTF8 
mds.db.user=datacite 
mds.db.password= 
mds.testprefix=10.5072 

solrconfig.xml中

<!-- AutoCommit 

    Perform a hard commit automatically under certain conditions. 
    Instead of enabling autoCommit, consider using "commitWithin" 
    when adding documents. 

    http://wiki.apache.org/solr/UpdateXmlMessages 

    maxDocs - Maximum number of documents to add since the last 
       commit before automatically triggering a new commit. 

    maxTime - Maximum amount of time in ms that is allowed to pass 
       since a document was added before automaticly 
       triggering a new commit. 
    openSearcher - if false, the commit causes recent index changes 
    to be flushed to stable storage, but does not cause a new 
    searcher to be opened to make those changes visible. 
    --> 
<autoCommit> 
    <maxTime>15000</maxTime> 
    <openSearcher>false</openSearcher> 
</autoCommit> 

<!-- softAutoCommit is like autoCommit except it causes a 
    'soft' commit which only ensures that changes are visible 
    but does not ensure that data is synced to disk. This is 
    faster and more near-realtime friendly than a hard commit. 
    --> 
<!-- 
    <autoSoftCommit> 
    <maxTime>1000</maxTime> 
    </autoSoftCommit> 
    --> 

<!-- Update Related Event Listeners 

    Various IndexWriter related events can trigger Listeners to 
    take actions. 

    postCommit - fired after every commit or optimize command 
    postOptimize - fired after every optimize command 
    --> 
<!-- The RunExecutableListener executes an external command from a 
    hook such as postCommit or postOptimize. 

    exe - the name of the executable to run 
    dir - dir to use as the current working directory. (default=".") 
    wait - the calling thread waits until the executable returns. 
      (default="true") 
    args - the arguments to pass to the program. (default is none) 
    env - environment variables to set. (default is none) 
    --> 
<!-- This example shows how RunExecutableListener could be used 
    with the script based replication... 
    http://wiki.apache.org/solr/CollectionDistribution 
    --> 
<!-- 
    <listener event="postCommit" class="solr.RunExecutableListener"> 
    <str name="exe">solr/bin/snapshooter</str> 
    <str name="dir">.</str> 
    <bool name="wait">true</bool> 
    <arr name="args"> <str>arg1</str> <str>arg2</str> </arr> 
    <arr name="env"> <str>MYVAR=val1</str> </arr> 
    </listener> 
    --> 

<!-- Enables a transaction log, currently used for real-time get. 
    "dir" - the target directory for transaction logs, defaults to the 
     solr data directory. --> 
<updateLog> 
    <str name="dir">/data/solr/collection1/data</str> 
</updateLog> 

<dataDir>/data/solr/collection1/data</dataDir> 


    <lib dir="../../../contrib/dataimporthandler/lib/" regex=".*\.jar" /> 

    <lib dir="../../../dist/" regex="solr-dataimporthandler-\d.*\.jar" /> 

    <lib dir="../../../lib/" regex="mysql-connector-java-5.0.8-bin.jar" /> 

    <requestHandler name="/admin/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> 
    <lst name="defaults"> 
     <str name="config">data-config.xml</str> 
    </lst> 
    <lst name="invariants"> 
     <str name="db.url">jdbc:mysql://localhost:3306/datacite?useUnicode=true&amp;amp;characterEncoding=UTF8</str> 
     <str name="db.user">root</str> 
     <str name="db.password"></str> 
     <str name="testprefix">10.5072</str> 
    </lst> 
    </requestHandler> 
+1

你能提供更多的信息嗎? 1.記錄(整個錯誤堆棧跟蹤,而不僅僅是錯誤消息)。 2.您的SQL查詢3.您要遵循哪些步驟來導入數據? 4.它是否立即失敗? 5.您期望導入多少條記錄。自從批量插入後,禁用'autoSoftCommit'(現在每隔一秒執行一次softCommit)。 – jay

+0

查看您的物理內存,您的第二張圖片,Solr管理界面。磁盤快滿了。 – cheffe

+0

@jay(1)其實我一直無法找到關於錯誤的更多信息。 tomcat日誌(catalina。)不會顯示任何錯誤,並且solr管理界面中的日誌總是顯示空白,僅僅是一個旋轉的輪子。我提到的信息是我得到的唯一反饋。你有什麼建議我可以研究的地方嗎? (3)對不起,我不確定你在這個問題上的含義是什麼? (4)每次運行solr'full import'時都會失敗。它沒有索引,索引是空的。 (5)1000s的mysql數據庫大小爲500Mb。謝謝 – kriztean

回答

0

的問題是,我沒有連接到MySQL數據庫。 mysql數據庫主機錯誤。我明白了@MatsLindh。

泊塢窗組成services的名字是他們主機的名稱。所以,在我的情況下,mysql數據庫主機的名稱是db(請參閱docker在上面的問題中)。我的錯誤是我的環境變量中的mysql數據庫主機的名稱爲$ DB_HOST = localhost。

我意識到當我試圖從solr容器連接到mysql容器。我不得不這樣做

mysql --host=db --user=root --password= datacite 

因爲

mysql --host=localhost --user=root --password= datacite 

不能正常工作。

就是這樣。 在Docker撰寫過程中檢查數據庫主機的名稱。