시스템 제한을 ulimit에 매핑
Directive ulimit equivalent Unit
LimitCPU= ulimit -t Seconds
LimitFSIZE= ulimit -f Bytes
LimitDATA= ulimit -d Bytes
LimitSTACK= ulimit -s Bytes
LimitCORE= ulimit -c Bytes
LimitRSS= ulimit -m Bytes
LimitNOFILE= ulimit -n Number of File Descriptors
LimitAS= ulimit -v Bytes
LimitNPROC= ulimit -u Number of Processes
LimitMEMLOCK= ulimit -l Bytes
LimitLOCKS= ulimit -x Number of Locks
LimitSIGPENDING= ulimit -i Number of Queued Signals
LimitMSGQUEUE= ulimit -q Bytes
LimitNICE= ulimit -e Nice Level
LimitRTPRIO= ulimit -r Realtime Priority
LimitRTTIME= No equivalent
ulimit가 '무제한'으로 설정된 경우 systemd 구성에서 '무한대'로 설정하십시오.
ulimit -c unlimited
것과 동일 LimitCORE=infinity
ulimit -v unlimited
과 동일 LimitAS=infinity
ulimit -m unlimited
와 동일LimitRSS=infinity
따라서 최종 구성은 다음과 같습니다
[Unit]
Description=Apache Solr
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
WorkingDirectory=/opt/solr/server
User=solr
Group=solr
LimitAS=infinity
LimitRSS=infinity
LimitCORE=infinity
LimitNOFILE=65536
ExecStart=/opt/solr/bin/solr-foo
Restart=on-failure
SuccessExitStatus=143 0
SyslogIdentifier=solr
[Install]
WantedBy=multi-user.target
이 특별한 경우에는 전체 Java 경로를 알 수 없으며 (서버 유형에 따라 변경되기 때문에) systemd는 상대 경로에 만족하지 않습니다 .java 명령을에있는 간단한 bash 스크립트로 래핑하십시오. /opt/solr/bin/solr-foo
#!/bin/bash
. /opt/solr/bin/solr.in.sh
# Load $JAVA_HOME from 1 of 2 places where it could be defined
# Last one wins
if [[ -f "/etc/profile.d/jdk.sh" ]]; then
. /etc/profile.d/jdk.sh
fi
if [[ -f "/etc/profile.d/zing.sh" ]]; then
. /etc/profile.d/zing.sh
fi
exec ${JAVA_HOME}/bin/java -server \
-Djetty.port=${SOLR_PORT} \
${SOLR_JAVA_MEM} \
${GC_TUNE} \
${GC_LOG_OPTS} \
-DzkClientTimeout=${ZK_CLIENT_TIMEOUT} \
-DzkHost=${ZK_HOST} \
-DSTOP.PORT=7900 \
-DSTOP.KEY=foobar \
-Dhost=${SOLR_HOST} \
-Duser.timezone=${SOLR_TIMEZONE} \
-Djetty.home=/opt/solr/server \
-Dsolr.solr.home=${SOLR_HOME} \
-Dsolr.install.dir=/opt/solr \
-Dlog4j.configuration=file:/var/solr/log4j.properties \
-Xss256k \
-Dbootstrap_conf=true \
-Dbootstrap_confdir=/opt/solr/server/solr/configsets/foobar/conf \
-Dcollection.configName=foobar \
-jar start.jar --module=http
man 5 systemd.exec
.