这篇文章主要介绍“Linux系统怎么安装ES”,在日常操作中,相信很多人在Linux系统怎么安装ES问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Linux系统怎么安装ES”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
直接访问es官网,
上传到/home/software/
解压压缩包
tar -zxvf elasticsearch-7.5.1-linux-x86_64.tar.gz
移动解压后的es文件夹
mv elasticsearch-7.5.1 /usr/local/
bin:可执行文件在里面,运行es的命令就在这个里面,包含了一些脚本文件等
config:配置文件目录
JDK:java环境
lib:依赖的jar,类库
logs:日志文件
modules:es相关的模块
plugins:可以自己开发的插件
data:这个目录没有,自己新建一下,后面要用 -> mkdir data,这个作为索引目录
修改集群名称
修改当前的es节点名称
修改data数据保存地址和日志数据保存地址
绑定es网络ip
集群节点修改为之前的节点名称
打开 jvm.options 文件 这里使用的是虚拟机
## JVM configuration
################################################################
## 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
# 修改这里的配置
-Xms128m
-Xmx128m
ES不允许使用root操作es,需要添加用户,操作如下:
useradd esuser
chown -R esuser:esuser /usr/local/elasticsearch-7.5.1
su esuser
./elasticsearch 如果出现如下错误:
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [3795] for user [esuser] 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]
需要切换到root用户修改配置
修改/etc/security/limits.conf 文件
增加下面内容
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
修改 /etc/sysctl.conf 增加 vm.max_map_count=262145
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
vm.max_map_count=262145
修改完后 sysctl -p 刷新一下
再次切换到esuser 进行启动
运行 ./elasticsearch 看到运行结果
[2020-02-02T01:09:51,843][INFO ][o.e.h.AbstractHttpServerTransport] [es-node0] publish_address {192.168.247.8:9200}, bound_addresses {[::]:9200}
[2020-02-02T01:09:51,844][INFO ][o.e.n.Node ] [es-node0] started
[2020-02-02T01:09:52,199][INFO ][o.e.l.LicenseService ] [es-node0] license [9614ee2b-6350-4f99-ad43-5ec0d632f93c] mode [basic] - valid
[2020-02-02T01:09:52,200][INFO ][o.e.x.s.s.SecurityStatusChangeListener] [es-node0] Active license is now [BASIC]; Security is disabled
[2020-02-02T01:09:52,222][INFO ][o.e.g.GatewayService ] [es-node0] recovered [0] indices into cluster_state
访问 192.168.247.8:9200 这里换成你的ip
访问结果
{
"name": "es-node0",
"cluster_name": "kevin-elasticsearch",
"cluster_uuid": "sSzLTAt-SDiCbQ57WMPqlg",
"version": {
"number": "7.5.1",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "3ae9ac9a93c95bd0cdc054951cf95d88e1e18d96",
"build_date": "2019-12-16T22:57:37.835892Z",
"build_snapshot": false,
"lucene_version": "8.3.0",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}
当前启动方式时前端启动。停止服务的话直接ctrl+c 就好了
我们可以后端启动
./elasticsearch -d
稍等片刻,再次访问地址,还是相同结果
此时,如果想关闭服务
[esuser@localhost bin]$ ps -ef|grep elasticsearch
esuser 3318 3007 0 Feb01 pts/1 00:00:00 vi elasticsearch.yml
esuser 3856 1 21 01:15 pts/0 00:00:18 /usr/local/elasticsearch-7.5.1/jdk/bin/java -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=COMPAT -Xms128m -Xmx128m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Djava.io.tmpdir=/tmp/elasticsearch-9874251960424438570 -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 -XX:MaxDirectMemorySize=67108864 -Des.path.home=/usr/local/elasticsearch-7.5.1 -Des.path.conf=/usr/local/elasticsearch-7.5.1/config -Des.distribution.flavor=default -Des.distribution.type=tar -Des.bundled_jdk=true -cp /usr/local/elasticsearch-7.5.1/lib/* org.elasticsearch.bootstrap.Elasticsearch -d
esuser 3871 3856 0 01:15 pts/0 00:00:00 /usr/local/elasticsearch-7.5.1/modules/x-pack-ml/platform/linux-x86_64/bin/controller
esuser 3921 3521 0 01:16 pts/0 00:00:00 grep --color=auto elasticsearch
[esuser@localhost bin]$ jps
3856 Elasticsearch
3922 Jps
[esuser@localhost bin]$ kill 3856
[esuser@localhost bin]$ jps
3940 Jps
[esuser@localhost bin]$
Elasticsearch Head Plugin:head插件是一个ES集群的web前端工具,它提供可视化的页面方便用户查看节点信息,对ES进行各种操作,如查询、删除、浏览索引等。
1、安装相关依赖包
(1)安装head
由于head插件本质上还是一个nodejs的工程,因此需要安装node,使用
来安装依赖的包。(npm可以理解为maven) wget https://nodejs.org/dist/v9.3.0/node-v9.3.0-linux-x64.tar.xz # 下载nodejs最新的bin包
xz -d node-v9.3.0-linux-x64.tar.xz # 解压包
tar -xf node-v9.3.0-linux-x64.tar # 解压包
ln -s ~/node-v9.3.0-linux-x64/bin/node /usr/bin/node # 部署bin文件,先确定nodejs的bin路径
ln -s ~/node-v9.3.0-linux-x64/bin/npm /usr/bin/npm
测试:
node -v npm
npm加速 全局安装cnpm 指定来源淘宝镜像
npm install -g cnpm –registry=
(2)安装grunt(安装完elasticsearch-head后安装)
grunt是一个很方便的构建工具,可以进行打包压缩、测试、执行等等的工作,5.0里的head插件就是通过grunt启动的。因此需要安装一下grunt:
cd /usr/local/elasticsearch-head
npm install -g grunt-cli //执行后会生成node_modules文件夹
npm install
注:
(1)5.0以上,elasticsearch-head 不能放在elasticsearch的 plugins、modules 目录下,否则elasticsearch启动会报错。
(2)这里如果grunt没有安装成功也无所谓,可以通过其他方式启动elasticsearch-head插件(npm run start)。
2、安装elasticsearch-head
另外:5.0以前的版本可以通过elasticseach自带的 命令 安装elasticsearch-head,5.0以后不支持了。只可以去下载elasticsearch-head对应的源码包去安装。
cd /usr/local/ git clone git://github.com/mobz/elasticsearch-head.git cd elasticsearch-head
npm install
配置:
vi _site/app.js
# 修改 this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200"; # 在文件的4354行附近
# 这里的 localhost 是指进入elasticsearch-head页面时默认访问的ES集群地址,把她修改为其中一台ES节点的地址即可
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.60.200:9200";
还要修改Head主目录下的Gruntfile.js,由于默认文件中是没有hostname属性的,我们需要手动添加:
为什么需要修改配置文件:
head插件连接elasticsearch需要注意的点:
因为head插件是一个独立进程,启动后是一个独立的服务器外加端口,比如我的虚拟机ip地址:http://192.168.0.111:9100/
而elasticsearch启动后也是一个独立的进程,ip地址:http://192.168.0.111:9200/
这样两个独立进程,虽然服务器ip地址相同,但是端口不同,此时会发生跨域的情况。。
于是官方给出这样一段话,我们在对elasticsearch启动的时候追加两个配置文件属性即可防止跨域。
即:在elasticsearch.yml文件的最后,添加如下内容:
http.cors.enabled: true
http.cors.allow-origin: "*"
配置完毕。
3、启动elasticsearch集群
在三台机器上,分别启动elasticsearch即可。
./bin/elasticsearch
4、启动elasticsearch-head
cd /usr/local/elasticsearch-head //先跳转到head目录下
grunt server //若想在后台运行,结尾追加“&”,也可以使用 npm run start启动
5、访问elasticsearch-head界面
http://192.168.60.200:9100
到此,关于“Linux系统怎么安装ES”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。