[关闭]
@zhangyy 2021-01-27T17:53:02.000000Z 字数 3792 阅读 117

ElasticSearch 单机部署

ElasticSearch系列



一: 系统环境初始化

1.1 系统主机名

  1. 系统:CentOS8.3x64
  2. cat /etc/hosts
  3. -----
  4. 192.168.100.11 centos01.flyfish.cn
  5. 192.168.100.12 centos02.flyfish.cn
  6. 192.168.100.13 centos03.flyfish.cn
  7. 192.168.100.14 centos04.flyfish.cn
  8. 192.168.100.15 centos05.flyfish.cn
  9. 192.168.100.16 centos06.flyfish.cn
  10. 192.168.100.17 centos07.flyfish.cn
  11. 192.168.100.18 centos08.flyfish.cn
  12. -----

  1. 系统语言:
  2. echo "export LANG=en_US.UTF8" >> ~/.bash_profile
  3. cat ~/.bash_profile
  4. ---
  5. 分区:
  6. pvcreate /dev/sdb
  7. vgcreate esdatavg /dev/sdb
  8. lvcreate -n esdatalv -L 100000M esdatavg
  9. mkfs.xfs /dev/esdatavg/esdatalv
  10. ---
  11. vi /etc/fstab
  12. ---
  13. /dev/esdatavg/esdatalv /esdb xfs defaults 0 0
  14. ---
  15. mkdir /esdb
  16. mount /esdb

  1. mkdir /esdb/soft
  2. groupadd -g 60001 esadmin
  3. useradd -u 61001 -g esadmin esadmin
  4. chown -R esadmin:esadmin /esdb
  5. chmod -R 775 /esdb
  6. echo "esadmin" | passwd --stdin esadmin
  7. systemctl set-default multi-user.target
  8. cat >> /etc/security/limits.conf << EOF
  9. root soft nofile 1048576
  10. root hard nofile 1048576
  11. esadmin soft nproc 1048576
  12. esadmin hard nproc 1048576
  13. esadmin soft nofile 1048576
  14. esadmin hard nofile 1048576
  15. esadmin soft stack 10240
  16. esadmin hard stack 32768
  17. esadmin hard memlock unlimited
  18. esadmin soft memlock unlimited
  19. EOF
  20. ---
  21. ---
  22. cat >> /etc/sysctl.conf << EOF
  23. fs.aio-max-nr = 1048576
  24. fs.file-max = 6815744
  25. net.ipv4.ip_local_port_range = 1024 65535
  26. net.ipv4.tcp_mem = 786432 2097152 3145728
  27. net.ipv4.tcp_rmem = 4096 4096 16777216
  28. net.ipv4.tcp_wmem = 4096 4096 16777216
  29. net.ipv4.tcp_tw_reuse = 1
  30. net.ipv4.tcp_tw_recycle = 1
  31. vm.swappiness=1
  32. vm.min_free_kbytes=204800
  33. vm.max_map_count=2048000
  34. kernel.pid_max=819200
  35. vm.zone_reclaim_mode=0
  36. #vm.nr_hugepages = 0
  37. EOF
  38. sysctl -p

  1. ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  2. hwclock
  3. echo "SELINUX=disabled" > /etc/selinux/config
  4. echo "#SELINUXTYPE=targeted " >> /etc/selinux/config
  5. cat /etc/selinux/config
  6. setenforce 0
  7. systemctl stop firewalld.service
  8. systemctl disable firewalld.service
  9. cat >> /home/esadmin/.vimrc << EOF
  10. map <F10>:set paste<CR>
  11. map <F11>:set nopaste<CR>
  12. EOF
  13. shutdown -r now

1.2 es 单机安装

  1. su - esadmin
  2. cd /esdb/
  3. tar zxvf soft/jdk-14.0.2_linux-x64_bin.tar.gz
  4. export LANG=en_US.UTF8
  5. cat >> ~/.bash_profile << EOF
  6. export JAVA_HOME=/esdb/jdk-14.0.2
  7. export PATH=/esdb/jdk-14.0.2/bin:$PATH
  8. export LANG=en_US.UTF8
  9. EOF
  10. source ~/.bash_profile
  11. java -version

image_1et1ef17912112m35pu1ssq1jkf9.png-75.5kB


  1. mkdir -p /esdb/esapp/esapp9200
  2. mkdir -p /esdb/esdata/esdata9200
  3. mkdir -p /esdb/eslog/eslog9200
  4. cd /esdb/soft/
  5. tar zxvf elasticsearch-7.9.0-linux-x86_64.tar.gz
  6. mv elasticsearch-7.9.0/* /esdb/esapp/esapp9200/*

image_1et1esl71b3irpq1ucj1l1g1ltmm.png-66.6kB

image_1et1f33o31lep10jg1pnknp84lq1g.png-57.5kB

  1. vim /esdb/esapp/esapp9200/bin/elasticsearch-env
  2. ----
  3. export JAVA_HOME=/esdb/jdk-14.0.2
  4. export PATH=$JAVA_HOME/bin:$PATH
  5. ----
  6. vim /esdb/esapp/esapp9200/config/elasticsearch.yml
  7. ----
  8. path.data: /esdb/esdata/esdata9200
  9. path.logs: /esdb/eslog/eslog9200
  10. bootstrap.memory_lock: true
  11. bootstrap.system_call_filter: false
  12. network.host: 0.0.0.0
  13. http.port: 9200
  14. node.name: 192.168.100.31
  15. cluster.initial_master_nodes: ["192.168.100.31"]
  16. ----
  1. vim jvm.options
  2. ----
  3. -Xms6G
  4. -Xmx6G
  5. -Xmn2G
  6. -Xss228k
  7. -XX:+DisableExplicitGC
  8. 14-:-XX:+UseG1GC
  9. 14-:-XX:G1ReservePercent=25
  10. 14-:-XX:InitiatingHeapOccupancyPercent=30
  11. -Djava.io.tmpdir=${ES_TMPDIR}
  12. -XX:+HeapDumpOnOutOfMemoryError
  13. -XX:HeapDumpPath=/esdb/eslog/eslog9200
  14. -XX:ErrorFile=/esdb/eslog/eslog9200/hs_err_pid%p.log
  15. 9-:-Xlog:gc*,gc+age=trace,safepoint:file=/esdb/eslog/eslog9200/gc.log:utctime,pid,tags:filecount=32,filesize=64m

image_1et1fk0p71ncg3fipnh9b411aa1t.png-60.7kB


  1. es 的启动:
  2. cd /esdb/esapp/esapp9200/bin
  3. ./elasticsearch

image_1et1ft75467njo7b2esq117kb2a.png-338.1kB


  1. 停掉:
  2. ps -ef |grep java
  3. kill -9 5853

image_1et1g38pt125m19u71rcb122f1ctp2n.png-245.2kB

  1. 放到后台启动:
  2. nohup /esdb/esapp/esapp9200/bin/elasticsearch > /esdb/eslog/eslog9200/nohup.es &
  3. cd /esdb/eslog/eslog9200/
  4. tail -f nohup.es

image_1et1gcf8j1vcn1alodq11uajaab4e.png-385kB

  1. 测试健康程度:
  2. curl http://192.168.100.31:9200

image_1et1galno18fmbfi5kb1fit11kn41.png-137kB


  1. jvm.options:
  2. es: jvm 生产环境不超过32G 内存,不要超过物理内存的50% ,单台主机最大配置64G 物理内存 生产环境一般建议JVM 内存 6G

  1. -server
  2. -Xms6G
  3. -Xmx6G
  4. -Xmn2G (新生代 一般是内存的3/8左右)
  5. -Xss128M (线程池)
  6. -XX:DisableExplicitGC
  7. ----
  8. oracle java = sun java
  9. sun: 4
  10. -XX:+UseSerialGC 串行回收
  11. -XX:+UseParllelGC 并行回收
  12. -XX:+UseConcMarkSweepGC 并发
  13. -XX:+UseG1GC 并发(新的)

  1. jdk 版本:8-13
  2. 8-13:-XX:+UseConcMarkSweepGC
  3. 8-13:-XX:CMSInitiatingOccupancyFraction=75
  4. 8-13:-XX:+UseCMSInitiatingOccupancyOnly
  5. ---
  6. jdk 版本:14
  7. 14-:-XX:+UseG1GC
  8. 14-:-XX:G1ReservePercent=25
  9. 14-:-XX:InitiatingHeapOccupancyPercent=30
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注