Apache Solr3.4.0のマルチコア機能で嵌った時のメモ
CentOS5.7で全文検索エンジンApache Solr3.4.0のインストールからMySQLデータのインポートまで
Apache Solr入門 ―オープンソース全文検索エンジン
- 作者: 関口宏司,三部靖夫,武田光平,中野猛,大谷純
- 出版社/メーカー: 技術評論社
- 発売日: 2010/02/20
- メディア: 大型本
- 購入: 18人 クリック: 567回
- この商品を含むブログ (22件) を見る
の記事の続きです。
マルチコア化作業を進めた時に嵌ったことをメモしました。
Solrのマルチコア機能
通常1つのSolrをサーブレットコンテナにデプロイすると、1つのインデックスとそれに対応するインタフェースが提供されます。
マルチコアを利用すると、1つのsolr上に複数のインデックスとそれに対応するインタフェースを利用することができます。
インストールされたSolrのexampleには、multicoreというディレクトリがありますのでこれを利用します。
マルチコアの準備
先ほどの作成した設定をコピーします。
cd /usr/local/apache-solr/example/ cp -Rp solr/conf/* multicore/core0/conf/ cp -Rp solr/conf/* multicore/core1/conf/
マルチコアの有効化
solrを起動する際にmulticore設定ファイルであるsolr.xmlが置かれたディレクトリを指定します。
solr.xmlはコアの入れ替え処理を行うリクエストハンドラとコア名、設定ファイルの場所などが指定されています。
example/multicoreのsolr.xml
<?xml version="1.0" encoding="UTF-8" ?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- All (relative) paths are relative to the installation path persistent: Save changes made via the API to this file sharedLib: path to a lib directory that will be shared across all cores --> <solr persistent="false"> <!-- adminPath: RequestHandler path to manage cores. If 'null' (or absent), cores will not be manageable via request handler --> <cores adminPath="/admin/cores"> <core name="core0" instanceDir="core0" /> <core name="core1" instanceDir="core1" /> </cores> </solr>
先ほどの起動スクリプトの場合、13行目のCORE=solr
を以下のように変更します。
vi /etc/init.d/solr
CORE=multicore
Solrの再起動
/etc/init.d/solr restart
管理画面にアクセス
http://localhost:8983/solr/core0/admin/
それぞれのコアの管理画面には/solr/コア名/adminという形でアクセスできます。
しかしここで問題発生。
HTTP ERROR 500 Problem accessing /solr/core0/admin. Reason: Severe errors in solr configuration. Check your log files for more detailed information on what may be wrong. If you want solr to continue after configuration errors, change: <abortOnConfigurationError>false</abortOnConfigurationError> in solr.xml ------------------------------------------------------------- org.apache.solr.common.SolrException: Error loading class 'org.apache.solr.handler.dataimport.DataImportHandler'
DataImportHandlerクラスが見つからないというエラーが出ました。
マルチコア前はちゃんとデータインポーターは起動できていたので、マルチコア化した際に何か問題があったようです。
調べてみると以下のフォーラム記事が参考になりました。
dist/apache-solr-dataimporthandler-3.4.0.jarが相対パスで見つからなかったのが原因だったようです。
マルチコア化前のsolr/conf/solrconfig.xmlでは、
<lib dir="../../dist/" regex="apache-solr-dataimporthandler-\d.*\.jar" />
となっていました。これは/usr/local/apache-solr/example/solrから見てdistディレクトリが2つ上にあったので問題なかったのですが、マルチコア化することによりコアのディレクトリが、/usr/local/apache-solr/example/multicore/{core0,core1}になるため、下記のように変更する必要がありました。
<lib dir="../../../dist/" regex="apache-solr-dataimporthandler-\d.*\.jar" />
core0、core1のsolrconfig.xml両方を変更してから、solrの再起動を行いましょう。