ELK实战-elasticsearch安装

操作系统:

centos版本7.4
防火墙关闭
selinux关闭
elasticsearch版本6.3.2
java版本1.8
server1192.168.10.126
server2192.168.10.127

[ ~]# wget -c https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.2.tar.gz

[ ~]# tar zxf elasticsearch-6.3.2.tar.gz -C /usr/local/

[ ~]# yum -y install java

[ ~]# vim /etc/hosts

192.168.10.126 server1

192.168.10.127 server2

192.168.10.128 server3

[ ~]# vim /etc/profile

export ELASTICSEARCH_HOME=/usr/local/elasticsearch-6.3.2

export PATH=$ELASTICSEARCH_HOME/bin:$PATH

[ ~]# source /etc/profile

[ ~]# useradd elasticsearch

[ ~]# chown elasticsearch.elasticsearch /usr/local/elasticsearch-6.3.2/ -R

[ ~]# vim /etc/security/limits.conf

#最大用户进程数

* soft nproc 20480

* hard nproc 20480

#调整进程最大打开文件描述符

* soft nofile 65536

* hard nofile 65536

#最大锁定内存地址空间

* soft memlock unlimited

* hard memlock unlimited

[ ~]# vim /etc/sysctl.conf

#配置系统最大打开文件描述符

fs.file-max=655360

#限制一个Java线程数量,进程可以拥有的VMA(虚拟内存区域)的大小

vm.max_map_count = 262144

[ ~]# vim /etc/security/limits.d/20-nproc.conf

* soft nproc 4096

#root soft nproc unlimited

* soft nproc 20480

[ ~]# vim /usr/local/elasticsearch-6.3.2/config/jvm.options

#设置java内存资源使用为物理内存的一半

-Xms1g

-Xmx1g

[ ~]# vim /usr/local/elasticsearch-6.3.2/config/elasticsearch.yml

#集群名称

cluster.name: esbigdata

#节点名

node.name: server1

#指定该节点是否有资格被选举为主,默认为true

node.master: true

#指定该节点是否存储索引数据

node.data: true

#设置索引数据的存储路径

path.data: /data/elasticsearch

#设置日志文件存储路径

path.logs: /usr/local/elasticsearch-6.3.2/logs

#设置为true用来锁住物理内存

bootstrap.memory_lock: true

#设置提供服务的ip地址

network.host: 0.0.0.0

#设置提供服务的http端口

http.port: 9200

#设置集群中最少的主节点数,默认为1

discovery.zen.minimum_master_nodes: 1

#设置集群中master节点的初始列表,master节点初始列表中对应的端口时9300,即为集群交互通信端口

discovery.zen.ping.unicast.hosts: ["192.168.10.126:9300", "192.168.10.127:9300"]

[ ~]# sysctl -p

[ ~]# mkdir -p /data/elasticsearch

[ ~]# chmod 755 /data/elasticsearch

[ ~]# chmod 755 /data/elasticsearch -R

[ ~]# chown elasticsearch.elasticsearch -R /data/elasticsearch

[ ~]# su - elasticsearch

[ ~]$ cd /usr/local/elasticsearch-6.3.2/bin/

#切换到elasticsearch用户启动服务,-d放到后台运行

[ bin]$ elasticsearch -d

[ ~]# curl http://192.168.10.126:9200

#############################################################################

[ro ~]# tar zxf elasticsearch-6.3.2.tar.gz -C /usr/local/

[ ~]# vim /etc/profile

export ELASTICSEARCH_HOME=/usr/local/elasticsearch-6.3.2

export PATH=$ELASTICSEARCH_HOME/bin:$PATH

[ ~]# source /etc/profile

[ ~]# vim /etc/hosts

192.168.10.126 server1

192.168.10.127 server2

192.168.10.128 server3

[ ~]# useradd elasticsearch

[ ~]# chown elasticsearch.elasticsearch /usr/local/elasticsearch-6.3.2/ -R

[ ~]# vim /etc/security/limits.conf

* soft nproc 20480

* hard nproc 20480

* soft nofile 65536

* hard nofile 65536

* soft memlock unlimited

* hard memlock unlimited

[ ~]# vim /etc/sysctl.conf

fs.file-max=655360

vm.max_map_count = 262144

[ ~]# vim /usr/local/elasticsearch-6.3.2/config/elasticsearch.yml

cluster.name: esbigdata

node.name: server1

node.master: true

node.data: true

path.data: /data/elasticsearch

path.logs: /usr/local/elasticsearch-6.3.2/logs

bootstrap.memory_lock: true

network.host: 0.0.0.0

http.port: 9200

discovery.zen.minimum_master_nodes: 1

discovery.zen.ping.unicast.hosts: ["192.168.10.126:9300", "192.168.10.127:9300"]

[ ~]# mkdir -p /data/elasticsearch

[ ~]# chmod 755 /data/elasticsearch

[ ~]# chmod 755 /data/elasticsearch -R

[ ~]# chown elasticsearch.elasticsearch -R /data/elasticsearch

[ ~]# chmod 755 -R /usr/local/elasticsearch-6.3.2

[ ~]# sysctl -p

[ ~]# curl http://192.168.10.126:9200

 ELK实战-elasticsearch安装

[ ~]# yum -y install nodejs npm git

[ ~]# git clone git://github.com/mobz/elasticsearch-head.git

#修改npm的源为淘宝国内镜像点

[ ~]# npm config set registry https://registry.npm.taobao.org/

[ local]# cd /usr/local/

[ local]# npm config set registry http://registry.npm.taobao.org/

[ local]# cd /usr/local/elasticsearch-head

[ elasticsearch-head]# npm install

[ _site]# cd /usr/local/elasticsearch-head/_site

[ _site]# vim app.js

4374 this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.10.126:9200";

[ _site]# vim /usr/local/elasticsearch-6.3.2/config/elasticsearch.yml

#表示开启跨域访问支持,默认为false

http.cors.enabled: true

#表示跨域访问允许的域名地址,可以使用正则表达式,这里的*表示允许所有域名访问

http.cors.allow-origin: "\*"

[ elasticsearch-head]# npm run start

浏览器里面输入:http://192.168.10.126:9100/

 ELK实战-elasticsearch安装