@zhangyy
2021-01-27T17:53:02.000000Z
字数 3792
阅读 119
ElasticSearch系列
系统:CentOS8.3x64
cat /etc/hosts
-----
192.168.100.11 centos01.flyfish.cn
192.168.100.12 centos02.flyfish.cn
192.168.100.13 centos03.flyfish.cn
192.168.100.14 centos04.flyfish.cn
192.168.100.15 centos05.flyfish.cn
192.168.100.16 centos06.flyfish.cn
192.168.100.17 centos07.flyfish.cn
192.168.100.18 centos08.flyfish.cn
-----
系统语言:
echo "export LANG=en_US.UTF8" >> ~/.bash_profile
cat ~/.bash_profile
---
分区:
pvcreate /dev/sdb
vgcreate esdatavg /dev/sdb
lvcreate -n esdatalv -L 100000M esdatavg
mkfs.xfs /dev/esdatavg/esdatalv
---
vi /etc/fstab
---
/dev/esdatavg/esdatalv /esdb xfs defaults 0 0
---
mkdir /esdb
mount /esdb
mkdir /esdb/soft
groupadd -g 60001 esadmin
useradd -u 61001 -g esadmin esadmin
chown -R esadmin:esadmin /esdb
chmod -R 775 /esdb
echo "esadmin" | passwd --stdin esadmin
systemctl set-default multi-user.target
cat >> /etc/security/limits.conf << EOF
root soft nofile 1048576
root hard nofile 1048576
esadmin soft nproc 1048576
esadmin hard nproc 1048576
esadmin soft nofile 1048576
esadmin hard nofile 1048576
esadmin soft stack 10240
esadmin hard stack 32768
esadmin hard memlock unlimited
esadmin soft memlock unlimited
EOF
---
---
cat >> /etc/sysctl.conf << EOF
fs.aio-max-nr = 1048576
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_mem = 786432 2097152 3145728
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
vm.swappiness=1
vm.min_free_kbytes=204800
vm.max_map_count=2048000
kernel.pid_max=819200
vm.zone_reclaim_mode=0
#vm.nr_hugepages = 0
EOF
sysctl -p
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock
echo "SELINUX=disabled" > /etc/selinux/config
echo "#SELINUXTYPE=targeted " >> /etc/selinux/config
cat /etc/selinux/config
setenforce 0
systemctl stop firewalld.service
systemctl disable firewalld.service
cat >> /home/esadmin/.vimrc << EOF
map <F10>:set paste<CR>
map <F11>:set nopaste<CR>
EOF
shutdown -r now
su - esadmin
cd /esdb/
tar zxvf soft/jdk-14.0.2_linux-x64_bin.tar.gz
export LANG=en_US.UTF8
cat >> ~/.bash_profile << EOF
export JAVA_HOME=/esdb/jdk-14.0.2
export PATH=/esdb/jdk-14.0.2/bin:$PATH
export LANG=en_US.UTF8
EOF
source ~/.bash_profile
java -version
mkdir -p /esdb/esapp/esapp9200
mkdir -p /esdb/esdata/esdata9200
mkdir -p /esdb/eslog/eslog9200
cd /esdb/soft/
tar zxvf elasticsearch-7.9.0-linux-x86_64.tar.gz
mv elasticsearch-7.9.0/* /esdb/esapp/esapp9200/*
vim /esdb/esapp/esapp9200/bin/elasticsearch-env
----
export JAVA_HOME=/esdb/jdk-14.0.2
export PATH=$JAVA_HOME/bin:$PATH
----
vim /esdb/esapp/esapp9200/config/elasticsearch.yml
----
path.data: /esdb/esdata/esdata9200
path.logs: /esdb/eslog/eslog9200
bootstrap.memory_lock: true
bootstrap.system_call_filter: false
network.host: 0.0.0.0
http.port: 9200
node.name: 192.168.100.31
cluster.initial_master_nodes: ["192.168.100.31"]
----
vim jvm.options
----
-Xms6G
-Xmx6G
-Xmn2G
-Xss228k
-XX:+DisableExplicitGC
14-:-XX:+UseG1GC
14-:-XX:G1ReservePercent=25
14-:-XX:InitiatingHeapOccupancyPercent=30
-Djava.io.tmpdir=${ES_TMPDIR}
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/esdb/eslog/eslog9200
-XX:ErrorFile=/esdb/eslog/eslog9200/hs_err_pid%p.log
9-:-Xlog:gc*,gc+age=trace,safepoint:file=/esdb/eslog/eslog9200/gc.log:utctime,pid,tags:filecount=32,filesize=64m
es 的启动:
cd /esdb/esapp/esapp9200/bin
./elasticsearch
停掉:
ps -ef |grep java
kill -9 5853
放到后台启动:
nohup /esdb/esapp/esapp9200/bin/elasticsearch > /esdb/eslog/eslog9200/nohup.es &
cd /esdb/eslog/eslog9200/
tail -f nohup.es
测试健康程度:
curl http://192.168.100.31:9200
jvm.options:
es: jvm 生产环境不超过32G 内存,不要超过物理内存的50% ,单台主机最大配置64G 物理内存 生产环境一般建议JVM 内存 6G
-server
-Xms6G
-Xmx6G
-Xmn2G (新生代 一般是内存的3/8左右)
-Xss128M (线程池)
-XX:DisableExplicitGC
----
oracle java = sun java
sun: 4
-XX:+UseSerialGC 串行回收
-XX:+UseParllelGC 并行回收
-XX:+UseConcMarkSweepGC 并发
-XX:+UseG1GC 并发(新的)
jdk 版本:8-13
8-13:-XX:+UseConcMarkSweepGC
8-13:-XX:CMSInitiatingOccupancyFraction=75
8-13:-XX:+UseCMSInitiatingOccupancyOnly
---
jdk 版本:14
14-:-XX:+UseG1GC
14-:-XX:G1ReservePercent=25
14-:-XX:InitiatingHeapOccupancyPercent=30