最近因为工作需要, 又使用到了es, 版本已经从当年的2.4 更新到了6.3
基本上解压即用,
elasticsearch 5.x 版本, 在 centos6下, 很多性能不能够发挥, 建议 centos 7+ 使用, 需要jdk1.8+
1, es
修改配置文件, 注意, 不能使用root用户
集群通过cluster.name进行发现
[root@--- config]# cat elasticsearch.yml | grep -v ^# | grep -v ^$
cluster.name: my-es
node.name: node-
path.data: /data/elastic/data
path.logs: /data/elastic/logs
network.host: 10.110.122.172
http.port:
bootstrap.system_call_filter: false
## 非常重要, 防脑裂配置, 服务发现, 哪些可以成为 master
discovery.zen.ping.unicast.hosts: ["node1", "node2", "node3"]
## 有权利成为master的数量,
discovery.zen.minimum_master_nodes:3
分发, 并且分别启动
./bin/elasticsearch &
后台启动
./bin/elasticsearch -d -p pid
使用nohup启动不了, 原因未寻找
nohup ./bin/elasticsearch >/dev/null >& &
停止
kill -SIGTERM
可能会出错, 需要修改kernel的内容
https://github.com/DimonHo/DH_Note/issues/3
1), vi /etc/security/limits.conf
用户可创建文件数太少
* soft nofile
* hard nofile
* soft nproc
* hard nproc
查看: ulimit -Hn
2), vi /etc/security/limits.d/90-nproc.conf
* soft nproc
3), vi /etc/sysctl.conf
虚拟内存大小
vm.max_map_count=
查看: sudo sysctl -p
线上环境安装es需要注意的问题:
https://www.elastic.co/guide/cn/kibana/current/production.html
2, docker 启动 elasticsearch
未实验..
1), pull
docker pull docker.elastic.co/elasticsearch/elasticsearch:6.3.
2), 启动
docker run -p : -p : -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.3.
4, 使用docker-compose 启动集群
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.
container_name: elasticsearch
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -
hard: -
volumes:
- esdata1:/usr/share/elasticsearch/data
ports:
- :
networks:
- esnet
elasticsearch2:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.
container_name: elasticsearch2
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch"
ulimits:
memlock:
soft: -
hard: -
volumes:
- esdata2:/usr/share/elasticsearch/data
networks:
- esnet volumes:
esdata1:
driver: local
esdata2:
driver: local networks:
esnet:
启动
docker-compose up
遇到的问题: https://github.com/DimonHo/DH_Note/issues/3