centos7 安装 elasticsearch-6.2.4

本文介绍如何安装Java环境及Elasticsearch,并提供详细的步骤说明,包括配置环境变量、安装中文分词插件、安装Kibana DevTools等。

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

 

其他

---------------------------------------------------------------

安装中文分词插件 elasticsearch-analysis-ik

cd /usr/local/elasticsearch-6.2.4/plugins

wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.4/elasticsearch-analysis-ik-6.2.4.zip

unzip elasticsearch-analysis-ik-6.2.4.zip

systemctl restart elasticsearch.service

#查看插件是否安装上
./elasticsearch-plugin list

 

---------------------------------------------------------------

安装kibana   Dev Tools工具方便测试 curl命令写的麻烦

下载地址 https://www.elastic.co/cn/downloads/kibana

wget https://artifacts.elastic.co/downloads/kibana/kibana-6.2.4-linux-x86_64.tar.gz
tar xzvf kibana-6.2.4-linux-x86_64.tar.gz
cd kibana-6.2.4-linux-x86_64/bin

#启动
./kibana

外网访问需要修改kibana绑定ip,默认是绑定localhost

vim config/kibana.yml

#修改为ip地址如 (写成0.0.0.0没用)
server.host:  192.168.1.11

浏览器访问 http://192.168.1.11:5601

如果有防火墙或者不对外开放,可以用ssh代理。参见文章

 

---------------------------------------------------------------

安装mysql同步工具 go-mysql-elasticsearch

转载于:https://my.oschina.net/jszhang/blog/1799862

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值