java环境安装
http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html
选择linux-x64
tar zxvf jdk-8u171-linux-x64.tar.gz
mv jdk1.8.0_171 /usr/local/jdk1.8
配置环境变量
vim /etc/profile
export PATH=/usr/local/jdk1.8/bin:$PATH
export JAVA_HOME=/usr/local/jdk1.8
export CLASSPATH=.:/usr/local/jdk1.8/lib:/usr/local/jdk1.8/jre/lib
启用配置
source /etc/profile
安装elasticsearch
---------------------------------------------------
https://www.elastic.co/downloads/elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.zip
unzip elasticsearch-6.2.4.zip
mv elasticsearch-6.2.4 /usr/local/elasticsearch-6.2.4
5.0.0版本后禁止用root账号启动,所以测试时要换成非root账号
> bin/elasticsearch
测试下
curl http://127.0.0.1:9200
systemd服务配置
---------------------------------------------------
创建服务账号
useradd -M -s /sbin/nologin elasticsearch
提取官网的rpm安装包中配置文件并上传服务器
elasticsearch-6.2.4-1.noarch/usr/lib/systemd/system/elasticsearch.service
elasticsearch-6.2.4-1.noarch/etc/sysconfig/elasticsearch
修改 /etc/sysconfig/elasticsearch
################################
# Elasticsearch
################################
# Elasticsearch home directory
#ES_HOME=/usr/share/elasticsearch
# Elasticsearch Java path
JAVA_HOME=/usr/local/jdk1.8
CLASSPATH=.:/usr/local/jdk1.8/lib:/usr/local/jdk1.8/jre/lib
# Elasticsearch configuration directory
ES_PATH_CONF=/usr/local/elasticsearch-6.2.4/config
# Elasticsearch PID directory
#PID_DIR=/var/run/elasticsearch
# Additional Java OPTS
#ES_JAVA_OPTS=
# Configure restart on package upgrade (true, every other setting will lead to not restarting)
#RESTART_ON_UPGRADE=true
################################
# Elasticsearch service
################################
# SysV init.d
#
# The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process
ES_STARTUP_SLEEP_TIME=5
################################
# System properties
################################
# Specifies the maximum file descriptor number that can be opened by this process
# When using Systemd, this setting is ignored and the LimitNOFILE defined in
# /usr/lib/systemd/system/elasticsearch.service takes precedence
#MAX_OPEN_FILES=65536
# The maximum number of bytes of memory that may be locked into RAM
# Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option
# in elasticsearch.yml.
# When using systemd, LimitMEMLOCK must be set in a unit file such as
# /etc/systemd/system/elasticsearch.service.d/override.conf.
#MAX_LOCKED_MEMORY=unlimited
# Maximum number of VMA (Virtual Memory Areas) a process can own
# When using Systemd, this setting is ignored and the 'vm.max_map_count'
# property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf
#MAX_MAP_COUNT=262144
修改 /usr/lib/systemd/system/elasticsearch.service
[Unit]
Description=Elasticsearch
Documentation=http://www.elastic.co
Wants=network-online.target
After=network-online.target
[Service]
#RuntimeDirectory=elasticsearch
Environment=ES_HOME=/usr/local/elasticsearch-6.2.4
Environment=ES_PATH_CONF=/usr/local/elasticsearch-6.2.4/config
Environment=PID_DIR=/var/run/elasticsearch
EnvironmentFile=/etc/sysconfig/elasticsearch
WorkingDirectory=/usr/local/elasticsearch-6.2.4
User=elasticsearch
Group=elasticsearch
ExecStart=/usr/local/elasticsearch-6.2.4/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid
# StandardOutput is configured to redirect to journalctl since
# some error messages may be logged in standard output before
# elasticsearch logging system is initialized. Elasticsearch
# stores its logs in /var/log/elasticsearch and does not use
# journalctl by default. If you also want to enable journalctl
# logging, you can simply remove the "quiet" option from ExecStart.
StandardOutput=journal
StandardError=inherit
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536
# Specifies the maximum number of processes
LimitNPROC=4096
# Specifies the maximum size of virtual memory
LimitAS=infinity
# Specifies the maximum file size
LimitFSIZE=infinity
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=0
# SIGTERM signal is used to stop the Java process
KillSignal=SIGTERM
# Send the signal only to the JVM rather than its control group
KillMode=process
# Java process is never killed
SendSIGKILL=no
# When a JVM receives a SIGTERM signal it exits with code 143
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
# Built for distribution-6.2.4 (distribution)
添加到systemd
systemctl daemon-reload
systemctl enable elasticsearch.service
systemctl start elasticsearch.service
查看启动状态
systemctl status elasticsearch.service
ps aux | grep java
如果出错了查看日志
journalctl -u elasticsearch.service