elasticsearch部署

2022年01月16日 阅读数:3
这篇文章主要向大家介绍elasticsearch部署,主要内容包括基础应用、实用技巧、原理机制等方面,希望对大家有所帮助。

elasticsearch下载html

yum源安装
https://www.elastic.co/guide/en/elasticsearch/reference/7.16/rpm.html#rpm-repo
rpm下载
https://www.elastic.co/cn/downloads/past-releases#elasticsearch

安装jdk 和elasticsearchjava

yum localinstall *.rpm -y

修改主机名node

hostnamectl set-hostname es1
hostnamectl set-hostname es2

增长hosts解析linux

192.168.1.10 es2
192.168.1.9 es1

elasticsearch配置文件说明:git

/etc/elasticsearch/jvm.options   #elasticsearch调优的能够调整内存
/etc/elasticsearch/elasticsearch.yml #elasticsearch主配置文件
建立数据存储目录
mkdir /elk

注释:github

9200服务端口,9300是集群间通信用的
cluster.name: elk-cluster1 #集群的名称
node.name: elk-node-1 #当前节点的名称
path.data: /elk #数据存储目录
path.logs: /elk #log存储目录
network.host: 192.168.1.9 #监听的地址,0.0.0.0监听当前全部网卡
http.port: 9200 #端口
discovery.zen.ping.unicast.hosts: ["192.168.1.9", "192.168.1.10"] #广播地址,若是不写,广播255个地址
[root@es1 ~]# cat /etc/elasticsearch/elasticsearch.yml | grep -v '^#'
cluster.name: elk-cluster1
node.name: elk-node-1
path.data: /elk
path.logs: /elk
network.host: 192.168.1.9
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.1.9", "192.168.1.10"]

es2docker

[root@es2 ~]# cat /etc/elasticsearch/elasticsearch.yml | grep -v '^#'
cluster.name: elk-cluster1
node.name: elk-node-2
path.data: /elk
path.logs: /elk
network.host: 192.168.1.10
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.1.9", "192.168.1.10"]

修改数据目录权限,服务启动脚本定义的服务启动用户是elasticsearchnpm

/usr/lib/systemd/system/elasticsearch.service启动脚本能够修改bootstrap

User=elasticsearch
Group=elasticsearch

修改数据目录权限vim

chown elasticsearch.elasticsearch /elk/

启动服务

systemctl start elasticsearch

查看服务端口

[root@es2 ~]# ss -antlp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:* users:(("sshd",pid=1008,fd=3))
LISTEN 0 128 [::ffff:192.168.1.10]:9200 [::]:* users:(("java",pid=3502,fd=140))
LISTEN 0 128 [::ffff:192.168.1.10]:9300 [::]:* users:(("java",pid=3502,fd=106))
LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=1008,fd=4))

安装elasticsearch-head

https://github.com/mobz/elasticsearch-head
yum install wget git -y
cd /usr/local/
wget https://nodejs.org/dist/v10.16.3/node-v10.16.3-linux-x64.tar.xz
tar -xJf node-v10.16.3-linux-x64.tar.xz
vim /etc/profile
export NODE_HOME=/usr/local/node-v10.16.3-linux-x64
export PATH=$NODE_HOME/bin:$PATH
source /etc/profile

es-head源码安装以下:

  1. 下面源码安装须要访问外网,网络不稳定。
[root@es1 local]# node -v
v10.16.3
[root@es1 local]# npm -v
6.9.0
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head/
npm install
  1. docker安装

文档采用docker安装,简单快捷。

docker run -d -p 9100:9100 mobz/elasticsearch-head:5

修改elasticsearch配置文件

vim /etc/elasticsearch/elasticsearch.yml 
http.cors.enabled: true
http.cors.allow-origin: "*"

浏览器访问,谷歌能够,火狐的一直链接失败,不知道咋回事?

http://192.168.1.9:9100/

开启锁定内存[Service]下增长/usr/lib/systemd/system/elasticsearch.service

LimitMEMLOCK=infinity

elasticsearch配置文件开启,内存满时不会占用swap交换内存

bootstrap.memory_lock: true

重启服务:

[root@es1 elasticsearch-head]# systemctl restart elasticsearch
[root@es1 elasticsearch-head]# systemctl daemon-reload
[root@es1 elasticsearch-head]# systemctl restart elasticsearch
[root@es1 elasticsearch-head]# ss -anlt | grep java
[root@es1 elasticsearch-head]# ss -anlt | grep 9200
LISTEN 0 128 [::ffff:192.168.1.9]:9200 [::]:*

浏览器访问效果:

elasticsearch部署_elasticsearch部署

上一篇: Logstash部署