1. ES主体安装

1.1. 获取ES

下载ES,拷贝至目录 /opt

1.2. 安装es

1.2.1. 解压

1
tar -zxvf es.tar.gz

1.2.2. 创建用户用户组,修改文件权限

由于ElasticSearch可以接收用户输入的脚本并且执行,为了系统安全考虑,需要创建一个单独的用户用来运行ElasticSearch

1
2
3
4
groupadd elastic
useradd elastic -g elastic -p 123456
# 修改权限
chown -R elsearch:elsearch elasticsearch-7.13.4

1.2.3. 启动es

切换到es目录,启动

1
2
3
cd /opt/elasticsearch-7.13.4/bin
# -d参数为后台启动
./elasticsearch -d

1.2.4. 检查

  • 本地检查

    1
    curl 127.0.0.1:9200
  • 外网检查
    浏览器访问 {ip}:9200

1.2.5. 问题解决

启动可能遇到的问题

1.2.5.1. 未使用ES_JAVA_HOME 变量

JAVA_HOME 不行的

1
2
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/opt/jdk1.8/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.

解决方案:环境变量中加入ES_JAVA_HOME

1
2
3
4
5
6
7
8
vim /etc/profile
#----------------------
# 在文件中加入
#es
export ES_JAVA_HOME=/opt/jdk1.8
#----------------------
source /etc/profile

1.2.5.2. 内存不对

1
2
JVM arguments [-Xshare:auto, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dio.netty.allocator.numDirectArenas=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.locale.providers=SPI,JRE, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Djava.io.tmpdir=/tmp/elasticsearch-3461752725857884135, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Xms1024m, -Xmx1024m, -XX:MaxDirectMemorySize=536870912, -Des.path.home=/opt/elasticsearch-7.13.4, -Des.path.conf=/opt/elasticsearch-7.13.4/config, -Des.distribution.flavor=default, -Des.distribution.type=tar, -Des.bundled_jdk=true

解决方案: 修改Java虚拟机内存

1
2
3
4
vim config/jvm.options
#-------------------------

#-------------------------

1.2.5.3. 外网无法访问

修改配置文件 config/elasticsearch.yml 中的 network.host 重启

1
2
3
4
5
6
vim config/elasticsearch.yml

#-----------------------------
network.host: 0.0.0.0
#-----------------------------

1.2.5.4. 启动报内存不足

1
2
bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决:

内存太小了,需要修改vm.max_map_count的内存大小

切换到root账户 命令 su root 修改sysctl.conf文件

1
2
3
4
5
6
7
8
9
su root
vim /etc/sysctl.conf
#-------------------------
#添加内存
vm.max_map_count=655360
#-------------------------

sysctl -p

1.2.5.5. 启动报hosts

1
2
bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

解决

1
2
3
4
5
6
7
vim config/elasticsearch.yml
#-------------------------
node.name: node-1
cluster.initial_master_nodes: ["node-1"]
# discovery.seed_hosts: ["127.0.0.1", "[::1]"]
#-------------------------

2. kibana安装

2.1. 获取Kibana

下载ES,拷贝至目录 /opt

2.2. 安装Kibana

2.2.1. 解压

1
tar -zxvf kibana.tar.gz

2.2.2. 修改配置

修改 config/kibana.yml

1
2
3
4
5
vim kibana.yml
#---------------------
# 开放外部端口
server.host: "0.0.0.0"
#---------------------

2.2.3. 启动

1
nohup ./kibana &

yum方式安装

https://blog.csdn.net/smxalong/article/details/103568418#:~:text=%E4%BA%8C%E3%80%81yum%E5%AE%89%E8%A3%85ES%201%E3%80%81%E6%9B%B4%E6%96%B0yum%E7%9A%84%E7%BC%93%E5%AD%98%20%23%20yum%20makecache,2%E3%80%81%E5%AE%89%E8%A3%85ES%20%23%20yum%20install%20elasticsearch

docker 方式安装

https://blog.csdn.net/Acloasia/article/details/130683934