2016-08-22 55 views
0

我有一个小问题需要将Solr带到生产环境。我使用Solr 5.3Apache solr启动脚本

我有一个bash脚本来启动Solr服务器。 Solr服务器应该作为非root用户solr运行。 我的bash脚本用我的配置和数据文件夹来运行solr服务器。

#!/usr/bin/env bash 

export SOLR_LOGS_DIR=/home/hybris/solr/log 
export LOG4J_PROPS=/home/hybris/solr/solr/conf/log4j.properties 
export SOLR_PID_DIR=/home/hybris/solr/data 

/home/hybris/solr/solr/bin/solr start -d /home/hybris/solr/solr/server -s /home/hybris/solr/solr/conf -p 8983 -m 7g -Dsolr.log.dir=/home/hybris/solr/log -DconfigSetBaseDir=/home/hybris/solr/solr/conf/configsets -DcoreRootDirectory=/home/hybris/solr/data/cores 

我想使用solr starup脚本来做到这一点。 在solr.in.sh我不能发现设置此变量

DconfigSetBaseDir=/home/hybris/solr/solr/conf/configsets 
DcoreRootDirectory=/home/hybris/solr/data/cores 

Solr的服务器正在启动非根用户solr的,没有配置和错误的数据文件夹。每个人都可以解释如何在solr.in.sh中使用这两个变量。

https://cwiki.apache.org/confluence/display/solr/Taking+Solr+to+Production 环境覆盖包括文件

现在从/etc/default/solr.in.sh

# 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. 

# By default the script will use JAVA_HOME to determine which java 
# to use, but you can set a specific path for Solr to use without 
# affecting other Java applications on your server/workstation. 
#SOLR_JAVA_HOME="" 

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

# 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" 

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

# These GC settings have shown to work well for a number of common Solr workloads 
GC_TUNE="-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" 

# Set the ZooKeeper connection string if using an external ZooKeeper ensemble 
# e.g. host1:2181,host2:2181/chroot 
# Leave empty if not using SolrCloud 
#ZK_HOST="" 

# Set the ZooKeeper client timeout (for SolrCloud mode) 
#ZK_CLIENT_TIMEOUT="15000" 

# By default the start script uses "localhost"; override the hostname here 
# for production SolrCloud environments to control the hostname exposed to cluster state 
#SOLR_HOST="192.168.1.1" 

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

# 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 
# (false is recommended in production environments) 
ENABLE_REMOTE_JMX_OPTS="false" 

# The script will use SOLR_PORT+10000 for the RMI_PORT or you can set it here 
# RMI_PORT=18983 

# Anything you add to the SOLR_OPTS variable will be included in the java 
# start command line as-is, in ADDITION to other options. If you specify the 
# -a option on start script, those options will be appended as well. Examples: 
#SOLR_OPTS="$SOLR_OPTS -Dsolr.autoSoftCommit.maxTime=3000" 
#SOLR_OPTS="$SOLR_OPTS -Dsolr.autoCommit.maxTime=60000" 
#SOLR_OPTS="$SOLR_OPTS -Dsolr.clustering.enabled=true" 
SOLR_OPTS="$SOLR_OPTS -DconfigSetBaseDir=/home/hybris/solr/solr/conf/configsets 
SOLR_OPTS="$SOLR_OPTS -DcoreRootDirectory=/home/hybris/solr/data/cores 

# Location where the bin/solr script will save PID files for running instances 
# If not set, the script will create PID files in $SOLR_TIP/bin 
SOLR_PID_DIR=/home/hybris/solr/data 

# 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=/home/hybris/solr/solr/conf 

# 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=/home/hybris/solr/solr/conf/log4j.properties 

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

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





# Uncomment to set SSL-related system properties 
# Be sure to update the paths to the correct keystore for your environment 
#SOLR_SSL_KEY_STORE=etc/solr-ssl.keystore.jks 
#SOLR_SSL_KEY_STORE_PASSWORD=secret 
#SOLR_SSL_TRUST_STORE=etc/solr-ssl.keystore.jks 
#SOLR_SSL_TRUST_STORE_PASSWORD=secret 
#SOLR_SSL_NEED_CLIENT_AUTH=false 
#SOLR_SSL_WANT_CLIENT_AUTH=false 

# Uncomment if you want to override previously defined SSL values for HTTP client 
# otherwise keep them commented and the above values will automatically be set for HTTP clients 
#SOLR_SSL_CLIENT_KEY_STORE= 
#SOLR_SSL_CLIENT_KEY_STORE_PASSWORD= 
#SOLR_SSL_CLIENT_TRUST_STORE= 
#SOLR_SSL_CLIENT_TRUST_STORE_PASSWORD= 

# Settings for authentication 
#SOLR_AUTHENTICATION_CLIENT_CONFIGURER= 
#SOLR_AUTHENTICATION_OPTS= 

回答

0

解决的方法很简单我的内容。

使用Monit。我的问题是,我使用自写的启动和停止shell脚本。

安装monit的,然后在

/etc/monit/conf.d

check process solr with pidfile /home/hybris/solr/data/solr-8983.pid 
    start program = "/home/hybris/solr/solr_start.sh" as uid hybris and gid hybris 
    stop program = "/home/hybris/solr/solr_stop.sh" as uid hybris and gid hybris 

现在SSE当你问monit的是所有运行会怎么样创建文件?

monit summary 
The Monit daemon 5.6 uptime: 7m 

Process 'solr'      Running