ES 部署流程

1. 添加用户 ( root 权限下执行 )

[root@dev15 ~]# adduser elastic
[root@dev15 ~]# passwd elastic      // 给 elastic用户设置密码

2. 创建外部 log, data 路径 ( root 权限下执行 )

[root@dev15 ~]# mkdir -p /data/log/elastic
[root@dev15 ~]# mkdir -p /data/lib/elastic
[root@dev15 ~]# mkdir -p /data/tmp/elastic
[root@dev15 ~]# chown -R elastic:elastic /data/log/elastic
[root@dev15 ~]# chown -R elastic:elastic /data/lib/elastic
[root@dev15 ~]# chown -R elastic:elastic /data/tmp/elastic

3. 切换用户 ( root 权限下执行 )

[root@dev15 ~]# su - elastic

4. 建立 elastic 工程目录 ( elastic 权限下执行 )

[elastic@dev15 ~]$ mkdir package
[elastic@dev15 ~]$ mkdir app

5. 下载安装包 ( elastic 权限下执行 )

[elastic@dev15 ~]$ cd package/
[elastic@dev15 package]$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz

6. 解压安装包 ( elastic 权限下执行 )

[elastic@dev15 package]$ tar -zxvf elasticsearch-6.2.4.tar.gz
[elastic@dev15 package]$ mv elasticsearch-6.2.4 ../app

7. 配置文件 ( elastic 权限下执行 )

[elastic@dev15 package]$ cd /home/elastic/app/elasticsearch-6.2.4/config
[elastic@dev15 config]$ ls      // 会看到 3 个文件:elasticsearch.yml; jvm.options; log4j2.properties

vim elasticsearch.yml

# ---------------------------------- Cluster -----------------------------------
- cluster.name: zhangfang
# ------------------------------------ Node ------------------------------------
- node.name: node-1
# ----------------------------------- Paths ------------------------------------
- path.data: /data/lib/elastic
- path.logs: /data/log/elastic
# ----------------------------------- Memory -----------------------------------
- bootstrap.memory_lock: false
- bootstrap.system_call_filter: false
# ---------------------------------- Network -----------------------------------
- network.host: 172.28.15.19
- http.port: 9200
- transport.tcp.port: 9300
# --------------------------------- Discovery ----------------------------------
- discovery.zen.ping.unicast.hosts: ["172.28.15.19:9300", "172.28.15.29:9300","172.28.15.14:9300"]
- discovery.zen.minimum_master_nodes: 2
# ---------------------------------- Various -----------------------------------
- action.destructive_requires_name: true

[elastic@dev15 config]$ vim jvm.options

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
--  -Xms2g      // 一般选择机器内存的一半
--  -Xmx2g    // 一般选择机器内存的一半

# log4j 2
--  -Djava.io.tmpdir=/data/tmp/elastic

# ensure the directory exists and has sufficient space
--  -XX:HeapDumpPath=/data/lib/elastic

## JDK 8 GC logging
--  8:-Xloggc:/data/log/elastic/gc.log

# JDK 9+ GC logging
--  9-:-Xlog:gc*,gc+age=trace,safepoint:file=/data/log/elastic/gc.log:utctime,pid,tags:filecount=32,filesize=64m

8. 把 elasticsearch-6.2.4 文件夹拷贝至集群其他机器 ( elastic 权限下执行 )

[elastic@dev15 config]$ scp -r /home/elastic/app/elasticsearch-6.2.4/ [email protected]:~/app

9. 启动 elasticsearch 服务 ( elastic 权限下执行 )

[elastic@dev15 config]$ cd ../bin
[elastic@dev15 bin]$ nohup ./elasticsearch > /data/log/elastic/es.out 2>&1 &

10. 集群内其他机器,进入 /home/elastic/app/elasticsearch-6.2.4/bin 目录下,同样执行

[elastic@dev16 bin] nohup ./elasticsearch > /data/log/elastic/es.out 2>&1 &

ElasticSearch启动错误处理方法

执行 ./elasticsearch 命令后,可能出现如下情况:

... ...

[3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [1024] for user [elastic] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

... ...

针对错误 [1]、 [2], 可以采用如下方法:

  • 修改/etc/security/limits.conf配置文件: ( root 权限下执行 )

    [root@dev15 ~]# vim /etc/security/limits.conf
    
    添加如下配置项:
    
    * - nproc 65535
    * - nofile 409600
    elastic - memlock unlimited
    
  • 修改/etc/security/limits.d/90-nproc.conf配置文件: ( root 权限下执行 )

    [root@yqtrack-elk03 /]# vim /etc/security/limits.d/90-nproc.conf
    
    修改如下配置项目:
    
    * soft nproc unlimited
    root soft nproc unlimited 
    
  • 修改完成后,重新登录elk账户,查看设置是否生效。 ( elastic 权限下执行 )

    [elk@yqtrack-elk03 /]$ ulimit -n
    409600
    [elk@yqtrack-elk03 /]$ ulimit -u
    65535
    

针对错误[3],可以采取如下方式:

  • 修改/etc/sysctl.conf文件配置项: ( root 权限下执行 )
    [root@localhost /]# vim /etc/sysctl.conf
    
    vm.max_map_count=262144
    
    [root@localhost /]# sysctl -p
    

你可能感兴趣的:(ES 部署流程)