Get solr and save it locally, and untar it
mkdir ~/solr_install
cd ~/solr_install
wget http://apache.claz.org/lucene/solr/7.2.1/solr-7.2.1.tgz
tar xzf solr-7.2.1.tgz solr-7.2.1/bin/install_solr_service.sh --strip-components=2
run the installer – note the -u specifies that solr runs as the mdid user which hopefully has more advantages than disadvantages (for me it was not having to switch so many accounts)
sudo ./install_solr_service.sh solr-7.2.1.tgz -f -u mdid
edit the solr config, it should be 100% commented – add the following at the bottom of the file (or the top, whatever you want) changing the paths if you installed somewhere else… now that I think about it, you may be simply confirming the following is in the file I can’t remember:
SOLR_PID_DIR="/var/solr"
SOLR_HOME="/var/solr/data"
LOG4J_PROPS="/var/solr/log4j.properties"
SOLR_LOGS_DIR="/var/solr/logs"
SOLR_PORT="8983"
SOLR_LOG_LEVEL=INFO
SOLR_JAVA_MEM="-Xms2048m -Xmx2048m"
these steps only possibly necessary for systemd
configure the service, assuming you’re using systemd (e.g. sudo systemctl solr restart)
sudo nano /etc/systemd/system/solr.service
paste contents of /etc/systemd/system/solr.service:
# as root, save this file to /etc/systemd/system/solr.service
# below paths assume solr installed in /var/solr, SOLR_PID_DIR is /data
# and that all configuration exists in /etc/default/solr.in.sh which is the case if previously installed as an init.d service
# change port in pid file if differs
# note that it is configured to auto restart solr if it fails (Restart=on-faliure) and that's the motivation indeed :)
# to switch from systemv (init.d) to systemd, do the following after creating this file:
# sudo systemctl daemon-reload
# sudo service solr stop # if already running
# sudo systemctl enable solr
# systemctl start solr
# this was inspired by https://confluence.t5.fi/display/~stefan.roos/2015/04/01/Creating+systemd+unit+(service)+for+Apache+Solr
[Unit]
Description=Apache SOLR
After=syslog.target network.target remote-fs.target nss-lookup.target systemd-journald-dev-log.socket
Before=multi-user.target graphical.target nginx.service
Conflicts=shutdown.target
[Service]
User=mdid
PIDFile=/var/solr/solr-8983.pid
Environment=SOLR_INCLUDE=/etc/default/solr.in.sh
ExecStart=/opt/solr/bin/solr start
ExecStop=/opt/solr/bin/solr stop
Restart=on-failure
[Install]
WantedBy=multi-user.target graphical.target
save the above as /etc/systemd/system/solr.service
un/re/load the solr service
chkconfig --list solr
if there’s a chkconfig and you want to use system
chkconfig --del solr
sudo systemctl daemon-reload
sudo service solr stop if already running
sudo systemctl enable solr
sudo systemctl start solr
create an alias for solr commands
alias solr=/opt/solr/bin/solr
this might be a little off – – let me know if this isn’t correct
basically you need to create a solr collection and then
copy the config files from rooibos/solr7/ to the right place
solr create -c mdid
# you may need to stop solr here? I forget – might as well anyway
sudo systemctl stop solr
cp /opt/mdid/rooibos
side note – once you have things running you can add something like this to your nginx.conf file so you can run solr on http://localhost:8983/solr and use the web interface of solr – just don’t leave it in on the open internet without securing it – in some cases the port I pseudo-randomly chose (8080) won’t be open in your data center:
server {
listen 8008 ssl http2; the port is not important, you just have to pick one not being used on your server
server_name _;
keepalive_timeout 70;
access_log /opt/log/nginx_solr.log upstreamlog;
error_log /opt/log/nginx_solr_err.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://localhost:8983/solr/;
}
}