步骤一.在没一台上解压安装ES后,进入config中修改elasticsearch.yml
由于需要多实例:比如在192.168.17.234上装两台data节点,所以在/etc/elasticsearch目录下创建两个目录分别为instance1和instance2分别拷贝主目录下config中的配置文件,并修改成如下模板。
模板:
# ======================== Elasticsearch Configuration =========================
# ---------------------------------- Cluster -----------------------------------
# Use a descriptive name for your cluster:
cluster.name: es-test
# ------------------------------------ Node ------------------------------------
# Use a descriptive name for the node:
node.name: node-data1
# 设置不充当master节点,默认为true
node.master: false
# 设置充当data节点,默认为true
node.data: true
# Add custom attributes to the node:
#node.attr.rack: r1
# ----------------------------------- Paths ------------------------------------
# Path to directory where to store the data (separate multiple locations by comma):
path.data: /opt/data
# Path to log files:
path.logs: /opt/logs
# ----------------------------------- Memory -----------------------------------
# Lock the memory on startup:
#bootstrap.memory_lock: true
# ---------------------------------- Network -----------------------------------
# Set the bind address to a specific IP (IPv4 or IPv6):
network.host: 192.168.17.234
#同一台host上的该端口号从9200开始每增加一台加1
http.port: 9200
#同一台host上的该端口号从9300开始每增加一台加1
transport.tcp.port: 9300
# For more information, consult the network module documentation.
# --------------------------------- Discovery ----------------------------------
# Pass an initial list of hosts to perform discovery when new node is started:
discovery.zen.ping.unicast.hosts: ["192.168.17.232:9300","192.168.17.234:9300","192.168.17.234:9301","192.168.17.235:9300"]
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
discovery.zen.minimum_master_nodes: 1
# ---------------------------------- Gateway -----------------------------------
# Block initial recovery after a full cluster restart until N nodes are started:
#gateway.recover_after_nodes: 3
# ---------------------------------- Various -----------------------------------
# Require explicit names when deleting indices:
#action.destructive_requires_name: true
步骤二、创建es用户组合es用户,并更改ES主目录权限。
# groupadd es
# useradd es -g es -p es
# chown -R es:es elasticsearch-6.2.4
步骤三:
多实例启动时,前面需要加入环境。
ES_PATH_CONF=/opt/elasticsearch-6.5.1/config/instance1 ./elasticsearch -d -Ecluster.name=es-test -Enode.name=node-data1
日志报错 max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解决:vi /etc/security/limits.conf
添加如下
* soft nofile 65536
* hard nofile 131072
*为es用户
修改后要退出es用户连接在登录生效
报错: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
[2018-12-13T04:37:53,657][WARN ][o.e.d.z.ZenDiscovery ] [node-data1] not enough master nodes discovered during pinging (found [[Candidate{node={node-master}{nKV9YKaZTuqM78nC7jwelA}{jMGhXIqWTw6MmWUsglaa2g}{192.168.17.232}{192.168.17.232:9300}{ml.machine_memory=2968797184, ml.max_open_jobs=20, xpack.installed=true, ml.enabled=true}, clusterStateVersion=-1}]], but needed [3]), pinging again
解决:es.yml 文件中discovery.zen.minimum_master_nodes: 3修改成1