$ sudo useradd solr
$ sudo chown -R solr:solr /opt/solr /var/solr
$ ls -ld /opt/solr
drwxrwxr-x 9 solr solr 201 Feb 7 08:15 /opt/solr
$ ls -ld /var/solr
drwxr-xr-x 3 solr solr 18 Feb 7 08:22 /var/solr
Solr Serviceの自動起動設定とサービス起動
$ sudo vi /usr/lib/systemd/system/solr.service
-----
[Unit]
Description=Apache Solr Service
[Service]
Type=forking
User=solr
EnvironmentFile=/opt/solr/bin/solr.in.sh
ExecStart=/opt/solr/bin/solr start
ExecStop=/opt/solr/bin/solr stop
[Install]
WantedBy=multi-user.target
-----
$ ls -l /usr/lib/systemd/system/solr.service
-rw-r--r-- 1 root root 220 Feb 7 08:31 /usr/lib/systemd/system/solr.service
$ sudo systemctl daemon-reload
$ systemctl status solr.service
● solr.service - Apache Solr Service
Loaded: loaded (/usr/lib/systemd/system/solr.service; disabled; vendor preset: disabled)
Active: inactive (dead)
$ sudo systemctl enable solr.service
Created symlink from /etc/systemd/system/multi-user.target.wants/solr.service to /usr/lib/systemd/system/solr.service.
$ sudo systemctl start solr.service
$ systemctl status solr.service
● solr.service - Apache Solr Service
Loaded: loaded (/usr/lib/systemd/system/solr.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2020-02-07 08:33:03 UTC; 3s ago
Process: 15321 ExecStart=/opt/solr/bin/solr start (code=exited, status=0/SUCCESS)
Main PID: 15362 (java)
CGroup: /system.slice/solr.service
mq15362 java -server -Xms512m -Xmx512m -XX:+UseG1GC -XX:+PerfDisab...
Feb 07 08:32:59 ec2-solr01 systemd[1]: Starting Apache Solr Servic...
Feb 07 08:32:59 ec2-solr01 solr[15321]: *** [WARN] *** Your open f...
Feb 07 08:32:59 ec2-solr01 solr[15321]: It should be set to 65000 ...
Feb 07 08:32:59 ec2-solr01 solr[15321]: If you no longer wish to s...
Feb 07 08:32:59 ec2-solr01 solr[15321]: *** [WARN] *** Your Max P...
Feb 07 08:32:59 ec2-solr01 solr[15321]: It should be set to 65000 ...
Feb 07 08:32:59 ec2-solr01 solr[15321]: If you no longer wish to s...
Feb 07 08:33:03 ec2-solr01 solr[15321]: [146B blob data]
Feb 07 08:33:03 ec2-solr01 solr[15321]: Started Solr server on por...
Feb 07 08:33:03 ec2-solr01 systemd[1]: Started Apache Solr Service.
Hint: Some lines were ellipsized, use -l to show in full.
$
下記URL にアクセスし、Solrがインストールされ、起動していることを確認
http://<IPアドレス>:8983/solr
コア作成とスキーマ定義
コアの作成
$ sudo su - solr
$ /opt/solr/bin/solr create -c TestDB
WARNING: Using _default configset with data driven schema functionality. NOT RECOMMENDED for production use.
To turn off: bin/solr config -c TestDB -p 8983 -action set-user-property -property update.autoCreateFields -value false
Created new core 'TestDB'
コアの設定ファイル(solrconfig.xml)配置
$ cd /var/solr/data/TestDB/conf
$ ls -l
total 120
drwxrwxr-x 2 solr solr 4096 Feb 7 08:15 lang
-rw-rw-r-- 1 solr solr 55659 Jan 10 06:54 managed-schema
-rw-rw-r-- 1 solr solr 873 Jan 10 06:50 protwords.txt
-rw-rw-r-- 1 solr solr 49058 Jan 10 06:54 solrconfig.xml
-rw-rw-r-- 1 solr solr 781 Jan 10 06:50 stopwords.txt
-rw-rw-r-- 1 solr solr 1124 Jan 10 06:50 synonyms.txt
$ mv solrconfig.xml solrconfig.xml.backup
$ cp /tmp/solrconfig.xml .
$ /opt/solr/bin/solr restart
*** [WARN] *** Your open file limit is currently 1024.
It should be set to 65000 to avoid operational disruption.
If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
*** [WARN] *** Your Max Processes Limit is currently 4096.
It should be set to 65000 to avoid operational disruption.
If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
Sending stop command to Solr running on port 8983 ... waiting up to 180 seconds to allow Jetty process 5327 to stop gracefully.
Waiting up to 180 seconds to see Solr running on port 8983 [\]
Started Solr server on port 8983 (pid=6001). Happy searching!
$