centos7环境下ELK部署之elasticsearch

es部署:es只能用普通用户启动

博客园首发,转载请注明出处:https://www.cnblogs.com/tzxxh/p/9435318.html

一、环境准备:

安装jdk1.8、创建普通用户

二、安装:

方法一:tar包的形式

1.登陆普通用户

2.下载elasticsearch tar包

3.解压elasticsearch包

4.配置$ES_HOME/config 下的

elasticsearch.yml 
  cluster.name: TestELK
  node.name: spark7              #当前节点的hostname
  path.data: /home/xxh/elasticsearch/data    #数据目录,自定义
  path.logs: /home/xxh/elasticsearch/data/log   #日志目录,自定义
  network.host: 0.0.0.0
  http.port: 9200
  discovery.zen.ping.unicast.hosts: ["spark5","spark6", "spark7"]
  discovery.zen.minimum_master_nodes: 2      #至少要发现集群可做master的候选节点数,向下取整

jvm.options   #这个文件下的参数根据自己的服务器硬件条件进行配置
  -Xms512m
  -Xmx512m

5.启动es

报错:ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决:参考---http://www.cnblogs.com/sloveling/p/elasticsearch.html

切换到root用户

vi /etc/security/limits.conf

   添加如下内容:

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

vi /etc/sysctl.conf

   添加下面配置:

    vm.max_map_count=262144

sysctl -p

6.普通用户启动es

7.配置开机自启(systemd的方式)

在/lib/systemd/system 目录下新增一个service

vi /lib/systemd/system/es.service 

  增加下面内容。 具体关于systemd参看:http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html

[Unit]
Description=Elasticsearch
Wants=network-online.target
After=network-online.target

[Service]
Environment=JAVA_HOME=/usr/java/jdk1.8.0_91
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:${JAVA_HOME}/bin
User=xxh
Group=common
ExecStart=/home/xxh/elasticsearch-5.6.3/bin/elasticsearch
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

   执行:

systemctl daemon-reload
systemctl enable es.service
systemctl start es.service

 

 

方法二:yum安装   

  1. 导入官方PGP-Key  

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch 

  2. 建立下载rpm包的repo    

vim /etc/yum.repos.d/elk.repo 

[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md 

  3. 安装elasticsearch包   

yum install elasticsearch -y

4. 启动es 

systemctl daemon-reload 
systemctl start elasticsearch 
systemctl status elasticsearch 


启动错误,需要:

  vi /lib/systemd/system/elasticsearch.service
添加:
  Environment=JAVA_HOME=/usr/java/jdk1.8.0_91
  Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:${JAVA_HOME}/bin

posted @ 2018-08-07 10:02  许新浩  阅读(262)  评论(0编辑  收藏  举报