Help us understand the problem. What is going on with this article?

Solr5.5系インストール、ログ設定について

More than 1 year has passed since last update.

参考

https://qiita.com/n_slender/items/d980783b781325652506

構築した環境

  • CentOS 7
  • openjdk-1.8 (記載していないが予めインストール)
  • 日次ログローテーション
  • クエリログ出力

インストール

  • 配置
tar xvzf solr-5.5.5.tar.gz

cd /usr/local
ln -s solr-5.5.5 solr
  • systemd
cat <<'EOT' > /etc/systemd/system/solr.service
[Unit]
Description=Apache SOLR
After=syslog.target network.target

[Service]
User=root
Group=root
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/solr/bin/solr start
ExecStop=/usr/local/solr/bin/solr stop
LimitNOFILE=1048576
LimitNPROC=1048576

[Install]
WantedBy=multi-user.target
EOT

systemctl enable solr

設定(環境変数)

必要に応じて変更。とくに以下
SOLR_HEAP
SOLR_JAVA_HOME
SOLR_TIMEZONE
SOLR_HOME
SOLR_LOGS_DIR
SOLR_PORT

 diff -u solr.in.sh_org  solr.in.sh
--- solr.in.sh_org  2017-10-19 00:16:03.000000000 +0900
+++ solr.in.sh  2018-09-30 19:01:14.330983947 +0900
@@ -19,7 +19,7 @@
 #SOLR_JAVA_HOME=""

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

 # 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
@@ -27,7 +27,8 @@

 # Enable verbose GC logging
 GC_LOG_OPTS="-verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails \
--XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime"
+-XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime \
+-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=10M"

 # These GC settings have shown to work well for a number of common Solr workloads
 GC_TUNE="-XX:NewRatio=3 \
@@ -58,7 +59,7 @@
 #SOLR_HOST="192.168.1.1"

 # By default the start script uses UTC; override the timezone if needed
-#SOLR_TIMEZONE="UTC"
+SOLR_TIMEZONE="JST"

 # Set to true to activate the JMX RMI connector to allow remote JMX client applications
 # to monitor the JVM hosting Solr; set to "false" to disable that behavior
@@ -84,16 +85,16 @@

 # Path to a directory for Solr to store cores and their data. By default, Solr will use server/solr
 # If solr.xml is not stored in ZooKeeper, this directory needs to contain solr.xml
-#SOLR_HOME=
+SOLR_HOME=/data/solr/data

 # Solr provides a default Log4J configuration properties file in server/resources
 # however, you may want to customize the log settings and file appender location
 # so you can point the script to use a different log4j.properties file
-#LOG4J_PROPS=/var/solr/log4j.properties
+#LOG4J_PROPS=

 # Location where Solr should write logs to; should agree with the file appender
 # settings in server/resources/log4j.properties
-#SOLR_LOGS_DIR=
+SOLR_LOGS_DIR=/data/solr/logs

 # Sets the port Solr binds to, default is 8983
 #SOLR_PORT=8983

ログ出力

solr.log

コンソールログ抑制
日次ログローテーション
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.DatePattern='.'yyyy-MM-dd

diff -u log4j.properties_org log4j.properties

--- log4j.properties_org    2017-10-19 00:16:03.000000000 +0900
+++ log4j.properties    2018-09-30 21:41:56.053677683 +0900
@@ -1,16 +1,15 @@
 #  Logging level
-solr.log=logs
-log4j.rootLogger=INFO, file, CONSOLE
+solr.log=/data/solr/logs
+log4j.rootLogger=INFO, file

-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+#log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender

-log4j.appender.CONSOLE.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%-4r %-5p (%t) [%X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n
+#log4j.appender.CONSOLE.layout=org.apache.log4j.EnhancedPatternLayout
+#log4j.appender.CONSOLE.layout.ConversionPattern=%-4r %-5p (%t) [%X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n

 #- size rotation with log cleanup.
-log4j.appender.file=org.apache.log4j.RollingFileAppender
-log4j.appender.file.MaxFileSize=4MB
-log4j.appender.file.MaxBackupIndex=9
+log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.file.DatePattern='.'yyyy-MM-dd

 #- File to log to and log format
 log4j.appender.file.File=${solr.log}/solr.log

クエリログ出力

日次ローテーション
応答時間出力

diff -u jetty.xml_org jetty.xml

--- jetty.xml_org   2017-10-19 00:16:03.000000000 +0900
+++ jetty.xml   2018-09-30 19:07:12.121036117 +0900
@@ -119,7 +119,7 @@
     <!-- =========================================================== -->
     <!-- Configure Request Log                                       -->
     <!-- =========================================================== -->
-    <!--
+
     <Ref id="Handlers">
       <Call name="addHandler">
         <Arg>
@@ -127,21 +127,22 @@
             <Set name="requestLog">
               <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
                 <Set name="filename">
-                   logs/request.yyyy_mm_dd.log
+                   /data/solr/logs/request.yyyy_mm_dd.log
                 </Set>
                 <Set name="filenameDateFormat">yyyy_MM_dd</Set>
-                <Set name="retainDays">90</Set>
+                <Set name="retainDays">31</Set>
                 <Set name="append">true</Set>
                 <Set name="extended">false</Set>
                 <Set name="logCookies">false</Set>
-                <Set name="LogTimeZone">UTC</Set>
+                <Set name="LogTimeZone">JST</Set>
+                <Set name="LogLatency">true</Set>
               </New>
             </Set>
           </New>
         </Arg>
       </Call>
     </Ref>
-    -->
+

     <!-- =========================================================== -->
     <!-- extra options                                               -->
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした