1.准备工作
确保系统已经安装jdk1.8及以上版本
2.下载es
下载地址:wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.0.0.tar.gz
3.解压安装
添加用户
useradd
elasticsearch
解压
tar
xf elasticsearch-5.6.3.
tar
.gz -C
/usr/local
cd
/usr/local
ln
-sv elasticsearch-5.6.3 elasticsearch
mkdir
-pv
/data/elasticsearch/
{data,logs}
chown
-R elasticsearch.elasticsearch
/data/elasticsearch
mkdir -p /usr/local/elasticsearch/plugins
mkdir -p /usr/local/elasticsearch/config/scripts
/usr/local/elasticsearch/config/elasticsearch
.yml
# 换个集群的名字,免得跟别人的集群混在一起 cluster.name: wlt-es5.0-application # 换个节点名字 node.name: node-1 path.data: /data/elasticsearch/data path.logs: /data/elasticsearch/logs # 修改一下ES的监听地址,这样别的机器也可以访问 network.host: 0.0.0.0 # 默认的就好 http.port: 9200 # 增加新的参数,这样head插件可以访问es #http.cors.enabled: true #http.cors.allow-origin: “*"
5.修改系统参数
编辑limit.conf文件 /etc/security/limits
.conf
内容如下
* soft nproc 65536 * hard nproc 65536 * soft nofile 65536 * hard nofile 65536
继续编辑sysctl
.conf文件
/etc/sysctl
.conf
内容如下
vm.max_map_count= 262144
编辑完成后执行指令 sysctl -p 使配置生效
注:如果遇到limit.conf文件没有生效的情况下,可执行命令 ulimit -n 65536 临时添加limit.conf中最大打开文件数配置
6.启动es服务
进入/usr/local 路径下,切换至上面添加的elasticsearch用户
指令如下
cd /usr/local
su elasticsearch
启动es
cd /elasticsearch/bin
./elasticsearch
启动完成
启动可能会遇到的问题:
1.elasticsearch安装目录权限不对
遇到启动elasticsearch失败,使用的是专门的用户elasticsearch来启动的,启动日志提示不能加载配置文件:
[elasticsearch@docker bin]$ ./elasticsearch Exception in thread "main" 2018-06-03 17:36:23,881 main ERROR No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property ‘log4j2.debug‘ to show Log4j2 internal initialization logging. 2018-06-03 17:36:24,113 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register") at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) at java.lang.SecurityManager.checkPermission(SecurityManager.java:585) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.checkMBeanTrustPermission(DefaultMBeanServerInterceptor.java:1848) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:322) at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522) at org.apache.logging.log4j.core.jmx.Server.register(Server.java:389) at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:167) at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:140) at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:556) at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:617) at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:634) at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:229) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:242) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45) at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174) at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:618) at org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:54) at org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:62) at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:101) at org.elasticsearch.ExceptionsHelper.<clinit>(ExceptionsHelper.java:42) at org.elasticsearch.ElasticsearchException.toString(ElasticsearchException.java:663) at java.lang.String.valueOf(String.java:2994) at java.io.PrintStream.println(PrintStream.java:821) at java.lang.Throwable$WrappedPrintStream.println(Throwable.java:748) at java.lang.Throwable.printStackTrace(Throwable.java:655) at java.lang.Throwable.printStackTrace(Throwable.java:643) at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1061) at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1052) at java.lang.Thread.dispatchUncaughtException(Thread.java:1959) SettingsException[Failed to load settings from /usr/local/elasticsearch-5.6.0/config/elasticsearch.yml]; nested: AccessDeniedException[/usr/local/elasticsearch-5.6.0/config/elasticsearch.yml]; at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:102) at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:72) at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67) at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) at org.elasticsearch.cli.Command.main(Command.java:90) at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) Caused by: java.nio.file.AccessDeniedException: /usr/local/elasticsearch-5.6.0/config/elasticsearch.yml at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214) at java.nio.file.Files.newByteChannel(Files.java:361) at java.nio.file.Files.newByteChannel(Files.java:407) at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384) at java.nio.file.Files.newInputStream(Files.java:152) at org.elasticsearch.common.settings.Settings$Builder.loadFromPath(Settings.java:1032) at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:100) ... 6 more
解决方案
看到“Caused by: java.nio.file.AccessDeniedException: /usr/local/elasticsearch-5.6.3/config/elasticsearch.yml”的提示,
就去检查目录的权限,果然是root:root权限,
使用elasticsearch用户去启动,就报错了。
将目录的权限改成elasticsearch:elasticsearch就好了。
[root@docker ~]# ll /usr/local/ drwxr-xr-x 7 root root 123 9月 7 2017 elasticsearch-5.6.3 [root@docker local]# chown -R elasticsearch: elasticsearch elasticsearch-5.6.3 [root@docker local]# ll drwxr-xr-x 7 elasticsearch elasticsearch 123 9月 7 2017 elasticsearch-5.6.3
head插件安装教程 https://www.cnblogs.com/vicF/p/9718430.html
文末小福利免费视频资源网站:www.sousuohou.com