Centos7 搭建 ElasticSearch 7.3.2

先推荐几个链接,网上讲的ELK都非常的棒,自己就不介绍了,但是搭建问题上,网上前篇一律,几乎都不能搭建成功。

说说ELK火热的原因

ELK 下载地址

nodejs下载地址(安装elasticsearch-head插件需要配置nodejs环境)

ELK学习博客

ELK问题集锦

Bootstrap问题

不能以root用户启动

max file descriptors [65535] for elasticsearch process is too low(句柄数问题,第三种解决方案可以使用)

如何完全删除Linux用户

 

 

安装流程

1.elasticsearch是基于java环境编写的一个开源的搜索引擎工具,在安装之前首先需要配置JDK环境变量,具体详情请看

Linux虚拟机安装Jenkins并实现部署(注意,Es7.3.2版本需要的是JDK11,环境配置完成后,记得执行source  /etc/profile  命令,让环境生生效)

2.解压

# tar zxvf elasticsearch-7.0.0-linux-x86_64.tar.gz

3.集群配置 —定位到安装包config路径下,进行集群配置

vi elasticsearch.yml
#这里指定的是集群名称,需要修改为对应的,开启了自发现功能后,ES会按照此集群名称进行集群发现
cluster.name: my-application
node.name: node-1

#ES监听地址任意IP都可访问,也可以是自己服务器的IP
network.host: 0.0.0.0
http.port: 9200

#解决跨域问题
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, X-User"

#设置在集群中的所有节点名称,这个节点名称就是之前所修改的,当然你也可以采用默认的也行,目前是单机,放入一个节点即可
cluster.initial_master_nodes: ["node-1"]

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

4.定位到root根目录,修改sysctl.conf 配置文件

vi /etc/sysctl.conf

如下所示 

fs.file-max=65536
vm.max_map_count=262144

5.修改系统参数

vi /etc/security/limits.conf

 定位到配置文件最后,添加一下内容

*               soft    nofile          65536
*               hard    nofile          65536
*               soft    nproc           65536
*               hard    nproc           65536

Centos7 搭建 ElasticSearch 7.3.2_第1张图片

5.修改句柄数

Centos7 搭建 ElasticSearch 7.3.2_第2张图片

环境配置完成后,记得执行source  /etc/profile  命令,让环境生生效) 

6.设置组和用户

添加组
groupadd elkgroup   
      
在elkgroup下添加elkuser用户,并设密码
useradd elkuser -g elkgroup -p elkuser

定位到elasticsearch安装目录下为elkuser用户设置访问权限
chown -R esuser /usr/local/elasticsearch/elasticsearch-7.3.2

7.关闭虚拟机防火墙

查看防火墙状态: 绿的running表示防火墙开启
systemctl status firewalld.service

执行关闭命令: 
systemctl stop firewalld.service

再次执行查看防火墙命令:
systemctl status firewalld.service

执行开机禁用防火墙自启命令 : 
systemctl disable firewalld.service

8.切换到elkuser用户下,定位到bin目录下并启动

切换用户
Su elkuser 
 
定位到bin目录启动
./elasticsearch 

 

9.Linux中访问或者浏览器中访问

Linux中日志访问

Centos7 搭建 ElasticSearch 7.3.2_第3张图片

浏览器中访问 

Centos7 搭建 ElasticSearch 7.3.2_第4张图片

10.安装客户端插件elasticsearch-head (谷歌浏览器可以直接安装,这里展示的是在服务器中安装)

 下载node js ,解压(看看下载的node是不是以 tar.xz结尾,so使用 tar -xvf 命令解压)

tar -xvf 文件

11.配置环境变量

vi etc/profile

  具体配置(tips:有没有发现,只要是配置了环境变量,最后都要执行以下source /etc/profile命令让文件生效)

export NODE_HOME=/usr/local/node/node-v10.16.3-linux-x64
export PATH=$NODE_HOME/bin:$PATH

 检查是否配置成功

 

12.解压elasticsearch-head.zip ,需要unzip命令,我们先安装一下该命令

yum install unzip

Centos7 搭建 ElasticSearch 7.3.2_第5张图片

 13.解压完成后,进入elasticsearch-head-master目录安装 grunt 和依赖

npm install grunt
npm install

14.修改head插件的连接地址,vim _site/app.js 文件(超级难找),记得修改此处的地址为自己的IP地址

Centos7 搭建 ElasticSearch 7.3.2_第6张图片

15.安装目录下启动 (npm run start)

Centos7 搭建 ElasticSearch 7.3.2_第7张图片

16.浏览器中访问

Centos7 搭建 ElasticSearch 7.3.2_第8张图片

这个过程中遇到很多问题,可参考文章头部,有具体的解决方案,如遇其它问题,欢迎评论。及时与伙伴交流! 

 

你可能感兴趣的:(▶运维)