Elasticsearch安装踩坑总结

Elasticsearch安装命令及其问题解决如下:

tar -zxvf elasticsearch.tar.gz

cd elasticsearch

vi ./config/elasticsearch.yml

# elasticsearch.yml 文件简单配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
cluster.name: cluster-test #集群名称,每个节点集群名称一样
node.name: test-1 #节点名称,每个节点设置唯一的名称
path.data: /data/elasticsearch/data #数据存储路径
path.logs: /data/elasticsearch/logs #日志文件存放路径
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.2.211", "192.168.2.212"] #节点列表
discovery.zen.minimum_master_nodes: 2 #候选主节点数量
gateway.recover_after_nodes: 1 #集群中只要有1个节点就正常工作
\# 跨域
http.cors.enabled: true
http.cors.allow-origin: "*"

./bin/elasticsearch -d

vim /etc/security/limits.conf #添加以下内容

* soft nofile 65536

* hard nofile 65536

vim /etc/sysctl.conf #添加以下内容

vm.max_map_count=262144

sysctl -p

# 添加用户(elasticsearch不能在root用户启动)

useradd es

passwd es es

su es

# head插件 phantomjs-prebuilt问题解决

npm install phantomjs-prebuilt@2.1.13 –ignore-scripts

# 关闭指定端口的防火墙

firewall-cmd –permanent –add-port=9200/tcp

firewall-cmd –permanent –add-port=9300/tcp

firewall-cmd –reload

# 安装java11

yum search jdk

yum install java-11-openjdk.x86_64

vi /etc/profile

1
2
3
4
5
6
7
8
9
10
\#set java environment
JAVA_HOME=/usr/lib/jvm/jre-11-openjdk-11.0.6.10-1.el7_7.x86_64
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME CLASSPATH PATH

source /etc/profile

java -version

# 安装npm

cd /usr/local/node

wget https://npm.taobao.org/mirrors/node/v10.14.1/node-v10.14.1-linux-x64.tar.gz

tar -xvf node-v10.14.1-linux-x64.tar.xz

mv node-v10.14.1-linux-x64 node

vim /etc/profile

1
2
3
4
5
6
\#set for nodejs
export NODE_HOME=/usr/local/node
export PATH=$NODE_HOME/bin:$PATH

source /etc/profile

node -v

npm -v

# 不在sudoers

vi /etc/sudoers

1
2
3
4
5
6
\# User privilege specification
root ALL=(ALL:ALL) ALL
username ALL=(ALL:ALL) ALL
您的支持将鼓励我努力创作!