ElasticSearch在CentOS的安装
一、tar包安装
单机安装
- 创建elastic用户,ElasticSearch不支持root用户运行
useradd elastic
- 上传文件到 /softwares ,并解压tar包
cd /softwares/ # 切换到 /softwares 目录
tar -xvf elasticsearch-7.0.0-linux-x86_64.tar.gz # 解压
chown -R elastic:elastic /softwares/elasticsearch-7.0.0 # 目录赋权
- 修改配置文件
vim config/elasticsearch.yml # 修改配置文件
cluster.name: elasticsearch # 集群名称
node.name: node-1 # 节点名称
path.data: /softwares/elasticsearch-7.0.0/data # 数据存储位置
path.logs: /softwares/elasticsearch-7.0.0/logs # 日志存储位置
network.host: 0.0.0.0 # 设置ip地址,任意网络均可访问
http.port: 9200 # 默认端口
cluster.initial_master_nodes: ["node-1"] # 设置在集群中所有节点名称
# 在Elasticsearch中如果,network.host不是localhost或者127.0.0.1的话,就会认为是生产环境,会对环境的要求比较高,一般情况下需要修改 JVM启动参数 和 内存映射最大数量
vim config/jvm.options # 修改JVM启动参数
-Xms128m
-Xmx128m
vim /etc/sysctl.conf
vm.max_map_count=655360 # 进程在VMAs(虚拟内存区域)创建内存映射最大数量
sysctl -p # 生效配置
- 问题解决ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [3766] for user [elastic] is too low, increase to at least [4096]
limits.conf文件限制着用户可以使用的最大文件数,最大线程,最大内存等资源使用量。
vim /etc/security/limits.conf # 修改limits.conf文件以符合启动elasticsearch的要求
elastic soft nofile 65536
elastic hard nofile 65536
elastic soft nproc 4096
elastic hard nproc 4096
- 检验
ps -ef | grep elasticsearch # 查看进程状态
curl localhost:9200 # 查看elasticsearch状态