elasticsearch摸石头过河——基本安装应用(三)
首先从官网下载elasticsearch:https://www.elastic.co/downloads/elasticsearch
需要jdk版本1.8:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
1.先解压安装 JDK(如果已有可忽略)
tar -zxvf jdk-8u131-linux-x64.tar.gz
2.yum安装各种需要的命令插件(如果已有可忽略)
yum -y install nodejs npm git wget vim
安装npm出现过问题
npm install
出现license问题
npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression
进入 package.json文件,修改
Apache 改为:Apache-2.0
3.配置JDK环境变量
添加环境变量 etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_131
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
让环境变量立即生效需要执行如下命令:
source /etc/profile
4.解压 并启动elasticsearch
由于不能使用root用户启动,创建用户
adduser es1
passwd 12345678
授权root用户组
usermod -g root es1
添加:与root相同的权限
所有用户 目录授权:chmod -R 777 目录PATH
切换用户:su es1
切换到elasticsearch目录,nohup./bin/elasticsearch& 后台启动
遇到错误: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
修改文件:
[root@localhost ~]# cp /etc/security/limits.conf /etc/security/limits.conf.bak [root@localhost ~]# cat /etc/security/limits.conf | grep -v "es1" > /tmp/system_limits.conf [root@localhost ~]# echo "es1 hard nofile 65536" >> /tmp/system_limits.conf [root@localhost ~]# echo "es1 soft nofile 65536" >> /tmp/system_limits.conf [root@localhost ~]# mv /tmp/system_limits.conf /etc/security/limits.conf
一定要重新登录用户才会生效
再次启动:
遇到错误: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
或者:
1 解决:切换到root用户,编辑limits.conf 添加类似如下内容 2 vi /etc/security/limits.conf 3 添加如下内容: 4 * soft nofile 65536 5 * hard nofile 131072 6 * soft nproc 2048 7 * hard nproc 4096
1 sudo gedit /etc/sysctl.conf 2 在该文件任意地方加入:vm.max_map_count=655360 3 sudo sysctl -p
然后重启ES
es会默认分配1G或者2G内存,可以在config/jvm.options 中修改内存大小
################################################################ ## IMPORTANT: JVM heap size ################################################################ ## ## You should always set the min and max JVM heap ## size to the same value. For example, to set ## the heap to 4 GB, set: ## ## -Xms4g ## -Xmx4g ## ## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html ## for more information ## ################################################################ # Xms represents the initial size of total heap space # Xmx represents the maximum size of total heap space -Xms3g -Xmx3g ################################################################ ## Expert settings ################################################################ ## ## All settings below this section are considered ## expert settings. Don't tamper with them unless
5.安装elasticsearch-head(前端控制)
下载:
git clone git://github.com/mobz/elasticsearch-head.git
elasticsearch-head 依赖nodejs,
修改: elasticsearch-head/_site/app.js this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200"; 将其中的"http://localhost:9200"; 改为"http://公网IP:9200";
这样其他都可以访问
npm run start 启动elasticsearch-head
然后输入:http://xxx.xxx.x.xx:9100/ 就可呈现
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从二进制到误差:逐行拆解C语言浮点运算中的4008175468544之谜
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· C# 13 中的新增功能实操
· Ollama本地部署大模型总结
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(4)
· langchain0.3教程:从0到1打造一个智能聊天机器人
· 2025成都.NET开发者Connect圆满结束