当前位置: 首页 > 后端技术 > PHP

Centos7安装配置Elasticsearch

时间:2023-03-30 00:23:31 PHP

安装java环境这里使用yum安装,前提是必须有网络yuminstalljava-1.8.0-openjdk安装完成,查看java版本【root@localhost~]#java-versionopenjdkversion"1.8.0_151"OpenJDKRuntimeEnvironment(build1.8.0_151-b12)OpenJDK64-BitServerVM(build25.151-b12,mixedmode)安装ElasticsearchElasticsearch的安装非常简单,下载解压即可,这里使用wget下载,当然也可以通过网页https://www.elastic.co/downlo...下载,然后复制。wgethttps://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.tar.gz解压到/usr/local/tar-zxvfelasticsearch-5.6.3.tar.gz-C/usr/local/运行ElasticsearchElasticsearch要求不能使用超级用户root运行,所以我们创建一个testuser账号#创建testuser账号addusertestuser#修改密码passwdtestuser然后,授权testuser用户elasticsearch目录。chown-Rtestuser/usr/local/elasticsearch-5.6.3/切换到elasticsearch目录,以testuser用户运行cd/usr/local/elasticsearch-5.6.3/sutestuser运行elasticsearch,如果要运行在后台添加-d[testuser@localhostelasticsearch-5.6.3]$./bin/elasticsearch[2017-10-31T16:07:09,445][INFO][o.e.n.Node][]initializing...[2017-10-31T16:07:09,662][INFO][o.e.e.NodeEnvironment][oDFU6c3]使用[1]数据路径,安装[[/(rootfs)]],净可用空间[45.4gb],净总空间[49.9gb],自旋?[未知],类型[rootfs][2017-10-31T16:07:09,662][INFO][o.e.e.NodeEnvironment][oDFU6c3]堆大小[1.9gb],压缩的普通对象指针[true][2017-10-31T16:07:09,663][INFO][o.e.n.Node]节点名称[oDFU6c3]来自节点ID[oDFU6c3UT6ORC2p0CKBeLA];将[node.name]设置为覆盖[2017-10-31T16:07:09,663][INFO][o.e.n.Node]version[5.6.3],pid[11484],build[1a2f265/2017-10-06T20:33]:39.012Z]、操作系统[Linux/3.10.0-514.26.2.el7.x86_64/amd64]、JVM[或acleCorporation/OpenJDK64位服务器VM/1.8.0_151/25.151-b12][2017-10-31T16:07:09,664][INFO][o.e.n.Node]JVM参数[-Xms2g,-Xmx2g,-XX:+UseConcMarkSweepGC,-XX:CMSInitiatingOccupancyFraction=75,-XX:+UseCMSInitiatingOccupancyOnly,-XX:+AlwaysPreTouch,-Xss1m,-Djava.awt.headless=true,-Dfile.encoding=UTF-8,-Djna.nosys=true,-Djdk.io.permissionsUseCanonicalPath=true,-Dio.netty.noUnsafe=true,-Dio.netty.noKeySetOptimization=true,-Dio.netty.recycler.maxCapacityPerThread=0,-Dlog4j.shutdownHookEnabled=false,-Dlog4j2.disable.jmx=真,-Dlog4j.skipJansi=true,-XX:+HeapDumpOnOutOfMemoryError,-Des.path.home=/usr/local/elasticsearch-5.6.3][2017-10-31T16:07:10,723][INFO][o.e.p.PluginsService][oDFU6c3]加载模块[aggs-matrix-stats][2017-10-31T16:07:10,724][INFO][o.e.p.PluginsService][oDFU6c3]加载模块[ingest-common][2017-10-31T16:07:10,724][INFO][o.e.p.PluginsService][oDFU6c3]加载模块[lang-expression][2017-10-31T16:07:10,724][INFO][o.e.p.PluginsService][oDFU6c3]加载模块[lang-groovy][2017-10-31T16:07:10,724][INFO][o.e.p.PluginsService][oDFU6c3]加载模块[lang-mustache][2017-10-31T16:07:10,724][INFO][o.e.p.PluginsService][oDFU6c3]加载模块[lang-painless][2017-10-31T16:07:10,724][INFO][o.e.p.PluginsService][oDFU6c3]加载模块[parent-join][2017-10-31T16:07:10,724][INFO][o.e.p.PluginsService][oDFU6c3]加载模块[percolator][2017-10-31T16:07:10,724]][INFO][o.e.p.PluginsService][oDFU6c3]加载模块[reindex][2017-10-31T16:07:10,724][INFO][o.e.p.PluginsService][oDFU6c3]加载模块[transport-netty3][2017-10-31T16]:07:10,724][信息][o.e.p.PluginsService][oDFU6c3]加载模块[transport-netty4][2017-10-31T16:07:10,725][信息][o.e.p.PluginsService][oDFU6c3]未加载插件[2017-10-31T16:07:12,622][INFO][o.e.d.DiscoveryModule][oDFU6c3]使用dis覆盖类型[zen][2017-10-31T16:07:13,133][INFO][o.e.n.Node]初始化[2017-10-31T16:07:13,133][INFO][o.e.n.Node][oDFU6c3]开始...[2017-10-31T16:07:13,306][INFO][o.e.t.TransportService][oDFU6c3]publish_address{127.0.0.1:9300},bound_addresses{[::1]:9300},{127.0.0.1:9300}[2017-10-31T16:07:13,318][WARN][o.e.b.BootstrapChecks][oDFU6c3]elasticsearch进程的最大文件描述符[65535]太低,增加到至少[65536][2017-10-31T16:07:16,372][INFO][o.e.c.s.ClusterService][oDFU6c3]new_master{oDFU6c3}{oDFU6c3UT6ORC2p0CKBeLA}{olaY-n5LTpCUpzrhU3joVw}{127.0.0.1}{127.0.0.1:9300},原因:zen-disco-elected-as-master([0]节点加入)[2017-10-31T16:07:16,398][信息][o.e.h.n.Netty4HttpServerTransport][oDFU6c3]发布地址{127.0.0.1:9200},绑定地址{[::1]:9200},{127.0.0.1:9200}[2017-10-31T16:07:16,399][INFO][o.e.n.Node][oDFU6c3]开始[2017-10-31T16:07:17,242][INFO][o.e.g.GatewayService][oDFU6c3]recovered[0]indicesintocluster_state如果没有错误,操作成功。打开一个新终端,使用curl访问[root@localhost~]#curl'http://localhost:9200/?pretty'{"name":"oDFU6c3","cluster_name":"elasticsearch","cluster_uuid":“v2mGsAuuTsqIzzm8CZcW5w”,“版本”:{“数字”:“5.6.3”,“build_hash”:“1a2f265”,“build_date”:“2017-10-06T20:33:39.012Z”,“build_snapshot”:假,"lucene_version":"6.6.1"},"tagline":"YouKnow,forSearch"}其他配置elasticsearch指定ip地址编辑es配置文件[testuser@localhostelasticsearch-5.6.3]$vim./config/elasticsearch.yml找到network.host:行,去掉#,修改为:network.host:[_local_,172.30.6.1]172.30.6.1是指定的ip地址,可以多个,这样可以在浏览器打开http://172.30.6.1:9200/?prettypossibleproblems问题一maxvirtualmemoryareasvm.max_map_count[65530]太低,至少增加到[262144]max_map_count的值指的是内存映射区(memorymap一个进程最多可以使用的区域),whichwi将在调用malloc时使用并由mmap/mprotect生成。解决方法:切换到root用户修改配置/etc/sysctl.confsurootvim/etc/sysctl.conf添加vm.max_map_count=655360并使其生效sysctl-p问题二[1]:maxfiledescriptors[65535]forelasticsearchprocessistoolow,increasetoatleast[65536]filedescriptoristoolow解决方法:切换到root用户修改/etc/security/limits.confsurootvim/etc/security/limits.confadd*softnofile65536*hardnofile131072*softnproc2048*hardnproc4096问题3使用supervisor启动时,日志中仍然报如下错误[1]:maxfiledescriptors[65535]forelasticsearchprocessistoolow,增加到至少[65536]解决方法:切换到root用户修改vim/etc/supervisord.d/elasticsearch.conf[supervisord]minfds=65536minprocs=32768[program:es]process_name=%(program_name)s_%(process_num)02dd目录=/usr/local/elasticsearch-5.6.3/command=/usr/local/elasticsearch-5.6.3/bin/elasticsearch;autostart=trueautorestart=falseuser=testusernumprocs=1原文https://www.tech1024.cn/origi...