252. 二进制安装Elasticsearch

tech2026-08-15  3

二进制安装Elasticsearch

Elasticsearch 是一个有状态的服务,不建议部署在Kubernetes集群中,本次采用单节点部署Elasticsearch,部署节点为 k8s7-12.host.com 官网传送门—》https://www.elastic.co/cn/

1. 下载二进制文件

[root@hdss7-12 src]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.6.tar.gz [root@k8s7-12.host.com /opt/src]# tar xf elasticsearch-6.8.6.tar.gz -C /opt/ [root@hdss7-12 src]# ln -s /opt/elasticsearch-6.8.6 /opt/elasticsearch # 调整以下配置 [root@hdss7-12 ~]# grep -Ev "^$|^#" /opt/elasticsearch/config/elasticsearch.yml cluster.name: elasticsearch.od.com node.name: hdss7-12.host.com path.data: /data/elasticsearch/data path.logs: /data/elasticsearch/logs bootstrap.memory_lock: true network.host: 10.4.7.12 http.port: 9200 优化jvm内存 [root@hdss7-12 ~]# vim /opt/elasticsearch/config/jvm.options # 默认1g ...... # 生产中一般不超过32G -Xms512m -Xmx512m 创建普通用户 [root@hdss7-12 ~]# useradd -M es [root@hdss7-12 ~]# mkdir -p /data/elasticsearch/{logs,data} [root@hdss7-12 ~]# chown -R es.es /data/elasticsearch /opt/elasticsearch-6.8.6

文件描述符优化

[root@hdss7-12 ~]# vim /etc/security/limits.conf ...... es hard nofile 65536 es soft fsize unlimited es hard memlock unlimited es soft memlock unlimited [root@k8s7-12.host.com ~]# echo "vm.max_map_count=262144" >> /etc/sysctl.conf [root@k8s7-12.host.com ~]# sysctl -p vm.max_map_count = 262144

2. 启动Elasticsearch

[root@hdss7-12 ~]# su es -c "/opt/elasticsearch/bin/elasticsearch -d" # 启动 [root@hdss7-12 ~]# su es -c "/opt/elasticsearch/bin/elasticsearch -d -p /data/elasticsearch/logs/pid" # 指定pid记录的文件 [root@k8s7-12.host.com ~]# sudo -ues "whoami" es [root@hdss7-12 ~]# netstat -lntp | grep 9200 tcp6 0 0 10.4.7.12:9200 :::* LISTEN 69352/java tcp6 0 0 10.4.7.12:9300 :::* LISTEN 69352/java [root@hdss7-12 ~]# su es -c "ps aux|grep -v grep|grep java|grep elasticsearch|awk '{print \$2}'|xargs kill" # kill Pid [root@hdss7-12 ~]# pkill -F /data/elasticsearch/logs/pid

3. 添加es日志索引模板

[root@hdss7-12 ~]# curl -H "Content-Type:application/json" -XPUT http://10.4.7.12:9200/_template/k8s -d '{ "template" : "k8s*", "index_patterns": ["k8s*"], "settings": { "number_of_shards": 5, "number_of_replicas": 0 } }'
最新回复(0)