Elasticsearch to install Linux (source)

Operating Environment

System version: CentOS Linux release 7.3.1611 (Core)
software version: Elasticsearch-7.1.0
Hardware Requirements: Minimum 2 nuclear 4GB

Installation process

1, install JDK source code

1.1, from the official website to download the source package

Download the official website address: https: //www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html.
Oracle may need to register an account.

root@localhost:~# wget https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz?AuthParam=1555053295_8cf8b2b24ab4f6973dcc2a05d83be26d

1.2, extract the source directory to the installation package

root@localhost:~# mv jdk-8u201-linux-x64.tar.gz* jdk-8u201-linux-x64.tar.gz
root@localhost:~# mkdir /usr/local/jdk
root@localhost:~# tar xzvf jdk-8u201-linux-x64.tar.gz -C /usr/local/jdk/

1.3, configure the environment variables

Configuration environment variable, so that command takes effect globally.

root@localhost:~# vim /etc/profile
export JAVA_HOME=/usr/local/jdk/jdk1.8.0_201
export PATH=$JAVA_HOME/bin:$PATH
root@ubuntu:~# source /etc/profile

1.4, check the version

root@localhost:~# java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

2, System Configuration

Once configured, because the maximum number of processes the user to modify the service can be opened, so the need to restart the server.

[root@localhost ~]# vim /etc/security/limits.conf
root soft nofile 65536
root hard nofile 65536
* soft nofile 65536
* hard nofile 65536
[root@localhost ~]# vim /etc/security/limits.d/20-nproc.conf
*          soft    nproc     65536
root       soft    nproc     unlimited
[root@localhost ~]# vim /etc/sysctl.conf
vm.max_map_count=262144
#Elasticsearch默认使用mmapfs来存储索引,mmap计数可能由于系统限制值太低了,可能会导致ES出现内存不足的一场,我们需要将其设置为更大。
[root@localhost ~]# sysctl -p
[root@localhost ~]# swapoff -a
[root@localhost ~]# reboot

3, download Elasticsearch package

Elasticsearch package provided by ELK official website.

[root@localhost ~]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.0-linux-x86_64.tar.gz

4, installation Elasticsearch

[root@localhost ~]# mkdir /usr/local/elk
[root@localhost ~]# tar xzvf elasticsearch-7.1.0-linux-x86_64.tar.gz -C /usr/local/elk/

5, configuration Elasticsearch

We constructed a single-node cluster of Elasticsearch, stand-alone operation.

[root@localhost ~]# vim /usr/local/elk/elasticsearch-7.1.0/config/elasticsearch.yml
cluster.name: my-application
# Elasticsearch集群名
node.name: node-1
# 该主机节点名
path.data: /data/elasticsearch/data
# 数据存储目录路径
path.logs: /data/elasticsearch/logs
# 日志存储目录路径
# bootstrap.memory_lock: true
network.host: 0.0.0.0
# 监听的主机地址
http.port: 9200
# 监听的主机端口,用于接收客户端HTTP请求的端口
transport.port: 9300
# 监听的主机端口,用于集群内主机传输通信所使用的端口
discovery.seed_hosts: ["172.16.254.129"]
# 集群内发现发送主机列表
cluster.initial_master_nodes: ["node-1"]
# 用于集群初始化所指定的master节点主机
#gateway.recover_after_nodes: 3
#action.destructive_requires_name: true
cluster.routing.allocation.disk.threshold_enabled: false
#关闭ES根据磁盘使用率分配分片(副本)数据功能,避免由于磁盘可用空间低于默认值而导致的ES自动停止。
#cluster.routing.allocation.disk.watermark.low: 10gb
#cluster.routing.allocation.disk.watermark.high: 20gb

6, create the relevant storage directory

[root@localhost ~]# mkdir -p /data/elasticsearch/data
[root@localhost ~]# mkdir -p /data/elasticsearch/logs

7, create a user to run, and to authorize the relevant directory

Elasticsearch default ROOT users are not allowed to run the service.

[root@localhost ~]# useradd -M elk
[root@localhost ~]# chown -R elk.elk /data/elasticsearch/
[root@localhost ~]# chown -R elk.elk /usr/local/elk/elasticsearch-7.1.0

8, start Elasticsearch service

[root@localhost ~]# sudo -u elk /usr/local/elk/elasticsearch-7.1.0/bin/elasticsearch -d
[root@localhost ~]# tail -n 200 -f /data/elasticsearch/logs/my-application.log
[root@localhost ~]# netstat -lnupt |grep 9200
tcp6       0      0 :::9200                 :::*                    LISTEN      2481/java
tcp6       0      0 :::9300                 :::*                    LISTEN      9932/java

Guess you like

Origin www.cnblogs.com/network-ren/p/12377146.html