基于Linux安装ES
# 基于Linux安装ES
转载自02-Elasticsearch-基于Linux安装ES - 腾讯云开发者社区-腾讯云 (tencent.com) (opens new window)
# 下载官网
https://www.elastic.co/cn/downloads/past-releases#elasticsearch
1
复制
使用7.4.2
# 安装
上传到Linux
# 解压
tar -zxvf elasticsearch-7.4.2-linux-x86_64.tar.gz
# 移动到别处
mv elasticsearch-7.4.2 /usr/local/es
# 切换到目录
cd /usr/local/es/
# 创建数据存储位置
mkdir data
# 修改配置文件
vi config/elasticsearch.yml
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
复制
配置文件
cluster.name: es
node.name: node-1
path.data: /usr/local/es/data
path.logs: /usr/local/es/logs
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["node-1"]
1
2
3
4
5
6
7
2
3
4
5
6
7
复制
修改jvm配置
vi config/jvm.options
1
复制
配置文件(不要修改为小于1g, 我碰见了一个特别坑的问题, 就是应为修改为了128m内存, 导致一直报错, 就是使用Kibana连接ES的时候, 有时候能行,有时候就不能行, 有时候突然Kibana直接宕机)
-Xms1g
-Xmx1g
1
2
2
复制
创建用户并授权
# 创建es用户
useradd es
# 授权
chown -R es /usr/local/es/
1
2
3
4
2
3
4
复制
# 启动
# 进入脚本目录
cd bin
# 切换用户
su es
# 启动
./elasticsearch
1
2
3
4
5
6
2
3
4
5
6
复制
# 修改配置
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [3766] for user [es] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
1
2
3
2
3
复制
启动时遇到三个错误
修该配置文件
vi /etc/security/limits.conf
* soft nofile 65535
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
vi /etc/sysctl.conf
vm.max_map_count=262145
1
2
3
4
5
6
7
2
3
4
5
6
7
复制
刷新配置文件
sysctl -p
1
复制
重新启动,
# 前台启动
./elasticsearch
# 后台启动
./elasticsearch -d
# 后台启动可以通过命令查看
[es@localhost bin]$ ps -aux|grep elasticsearch
es 9997 77.0 36.8 2441428 366928 pts/1 Sl 00:57 0:16 /usr/local/es/jdk/bin/java -Xms128m -Xmx128m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -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.io.tmpdir=/tmp/elasticsearch-15183704503458131076 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m -Djava.locale.providers=COMPAT -Dio.netty.allocator.type=unpooled -XX:MaxDirectMemorySize=67108864 -Des.path.home=/usr/local/es -Des.path.conf=/usr/local/es/config -Des.distribution.flavor=default -Des.distribution.type=tar -Des.bundled_jdk=true -cp /usr/local/es/lib/* org.elasticsearch.bootstrap.Elasticsearch -d
es 10062 0.0 0.0 112708 980 pts/1 R+ 00:58 0:00 grep --color=auto elasticsearch
[es@localhost bin]$
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
复制
启动成功
# 访问
访问前记得关闭防火墙
访问成功
编辑 (opens new window)
上次更新: 2024/01/26, 05:03:22
- 01
- python使用生成器读取大文件-500g09-24
- 02
- Windows环境下 Docker Desktop 安装 Nginx04-10
- 03
- 使用nginx部署多个前端项目(三种方式)04-10