LoginSignup
7
9

More than 5 years have passed since last update.

Solr 6.0.1 インストールしてからコアの追加まで

Posted at

まとめ

vagrant で作った仮想マシン(CentOS 6系)にとりあえず入れてみました。
- solr-6.0.1 をインストールした
- 今時の Solr はインストールスクリプトで service に登録までしてくれる
- /etc/default/solr.in.sh を弄って設定変更できる
- デフォルトの solr.solr.home/var/solr/data で、これは solr ユーザの配下。

後は読まなくても大丈夫です。

インストール

$ curl -O http://ftp.jaist.ac.jp/pub/apache/lucene/solr/6.0.1/solr-6.0.1.tgz
$ tar xvzf solr-6.0.1.tgz
$ sudo sh solr-6.0.1/bin/install_solr_service.sh solr-6.0.1.tgz
id: solr: そのようなユーザは存在しません
Creating new user: solr

Extracting solr-6.0.1.tgz to /opt


Installing symlink /opt/solr -> /opt/solr-6.0.1 ...


Installing /etc/init.d/solr script ...


Installing /etc/default/solr.in.sh ...

NOTE: Please install lsof as this script needs it to determine if Solr is listening on port 8983.

Started Solr server on port 8983 (pid=2752). Happy searching!


Found 1 Solr nodes:

Solr process 2752 running on port 8983
{
  "solr_home":"/var/solr/data",
  "version":"6.0.1 c7510a0fdd93329ec04c853c8557f4a3f2309eaf - sarowe - 2016-05-23 19:40:37",
  "startTime":"2016-06-15T01:34:23.106Z",
  "uptime":"0 days, 0 hours, 0 minutes, 17 seconds",
  "memory":"79 MB (%16.1) of 490.7 MB"}

Service solr installed.

最近の solr にはインストールスクリプトが用意されているんですね。無事インストールされてしまいました。インストールスクリプトの出力から、だいたい以下のことが読み取れます。
- solr ユーザで動く
- ソースコードは /opt/solr-{version} に入り、シンボリックリンクが /opt/solr
- $SOLR_HOME/var/solr/data になった

インストールスクリプトを使うために solr-6.0.1.tgz が必要なので、残しておきましょう。

オプションを変えたい

とりあえず走ったプロセスを確かめてみます。

$ ps aux | grep solr

solr      1222  0.9 17.7 2612080 181344 ?      Sl   10:36   0:05 java -server -Xms512m -Xmx512m -XX:NewRatio=3 -XX:SurvivorRatio=4 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=8 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ConcGCThreads=4 -XX:ParallelGCThreads=4 -XX:+CMSScavengeBeforeRemark -XX:PretenureSizeThreshold=64m -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=50 -XX:CMSMaxAbortablePrecleanTime=6000 -XX:+CMSParallelRemarkEnabled -XX:+ParallelRefProcEnabled -verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/var/solr/logs/solr_gc.log -Djetty.port=8983 -DSTOP.PORT=7983 -DSTOP.KEY=solrrocks -Duser.timezone=UTC -Djetty.home=/opt/solr/server -Dsolr.solr.home=/var/solr/data -Dsolr.install.dir=/opt/solr -Dlog4j.configuration=file:/var/solr/log4j.properties -Xss256k -XX:OnOutOfMemoryError=/opt/solr/bin/oom_solr.sh 8983 /var/solr/logs -jar start.jar --module=http

いろいろとパラメータが設定されている。どこでパラメータが設定されているのかよくわかんないですね。/etc/init.d/solr を覗いてみます。

SOLR_ENV="/etc/default/solr.in.sh"

とか

if [ -n "$RUNAS" ]; then
    su -c "SOLR_INCLUDE=\"$SOLR_ENV\"\"$SOLR_INSTALL_DIR/bin/solr\" $SOLR_CMD" - "$RUNAS"
else
    SOLR_INCLUDE="$SOLR_ENV" "$SOLR_INSTALL_DIR/bin/solr" "$SOLR_CMD"
fi

とか書いてある。起動オプションは /etc/default/solr.in.sh に書かれているようです。中身を見て

# Increase Java Heap as needed to support your indexing / query needs
SOLR_HEAP="512m"

# Expert: If you want finer control over memory options, specify them directly
# Comment out SOLR_HEAP if you are using this though, that takes precedence
# SOLR_JAVA_MEM="-Xms512m -Xmx512m"

とか書いてありました。この辺を修正して、

# SOLR_HEAP="512m"
SOLR_JAVA_MEM="-Xms512m -Xmx1024m"

にして

$ sudo service solr restart
$ ps aux | grep solr

solr      3111 20.0 13.0 3137708 133248 ?      Sl   15:40   0:02 java -server -Xms512m -Xmx1024m -XX:NewRatio=3 -XX:SurvivorRatio=4 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=8 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ConcGCThreads=4 -XX:ParallelGCThreads=4 -XX:+CMSScavengeBeforeRemark -XX:PretenureSizeThreshold=64m -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=50 -XX:CMSMaxAbortablePrecleanTime=6000 -XX:+CMSParallelRemarkEnabled -XX:+ParallelRefProcEnabled -verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/var/solr/logs/solr_gc.log -Djetty.port=8983 -DSTOP.PORT=7983 -DSTOP.KEY=solrrocks -Duser.timezone=UTC -Djetty.home=/opt/solr/server -Dsolr.solr.home=/var/solr/data -Dsolr.install.dir=/opt/solr -Dlog4j.configuration=file:/var/solr/log4j.properties -Xss256k -XX:OnOutOfMemoryError=/opt/solr/bin/oom_solr.sh 8983 /var/solr/logs -jar start.jar --module=http

変わりました。

コアを追加したい

solr.solr.home がデフォルトでは /var/solr/data になってるので、普通に /var/solr/data/new_core とかに必要なコアの情報を置いてCREATEする。/var/solr のディレクトリ配下は solr ユーザが権限を持っているので、中に入ってる基本的なコンフィグ詰め合わせからサンプルを持ってきます。

$ sudo -i -u solr
$ mkdir -p /var/solr/data/new_core/conf
$ cp -r solr-6.0.1/server/solr/configsets/basic_configs/conf/* /var/solr/data/new_core/conf

Web版のGUIも用意されていますが、個人的な趣味の問題で Web API をそのまま叩きます。

curl -s 'http://localhost:8983/solr/admin/cores?action=CREATE&name=new_core&instanceDir=new_core-0&wt=json&indent=4'

とか。

{
  "responseHeader":{
    "status":0,
    "QTime":2039},
  "core":"new_core"}

コアできた。

続きは次回。

7
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
9