ElasticSearchUtil.java

 

ElasticSearchUtil.java_第1张图片

 

[root@localhost ~]# ifconfig
ens33: flags=4163  mtu 1500
        inet 192.168.8.150  netmask 255.255.255.0  broadcast 192.168.8.255
        inet6 fe80::729c:baa8:8a34:128e  prefixlen 64  scopeid 0x20
        ether 00:0c:29:81:1d:06  txqueuelen 1000  (Ethernet)
        RX packets 53  bytes 13455 (13.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 100  bytes 10999 (10.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:2c:4e:0c  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]# jps
7137 -- process information unavailable
3400 Jps
[root@localhost ~]# cd /opt/elasticsearch-7.8.0/bin
[root@localhost bin]# ll
total 20408
-rwxr-xr-x. 1 es es     2877 Jun 15  2020 elasticsearch
-rwxr-xr-x. 1 es es      491 Jun 15  2020 elasticsearch-certgen
-rwxr-xr-x. 1 es es      483 Jun 15  2020 elasticsearch-certutil
-rwxr-xr-x. 1 es es      996 Jun 15  2020 elasticsearch-cli
-rwxr-xr-x. 1 es es      433 Jun 15  2020 elasticsearch-croneval
-rwxr-xr-x. 1 es es     4459 Jun 15  2020 elasticsearch-env
-rwxr-xr-x. 1 es es     1828 Jun 15  2020 elasticsearch-env-from-file
-rwxr-xr-x. 1 es es      184 Jun 15  2020 elasticsearch-keystore
-rwxr-xr-x. 1 es es      440 Jun 15  2020 elasticsearch-migrate
-rwxr-xr-x. 1 es es      126 Jun 15  2020 elasticsearch-node
-rwxr-xr-x. 1 es es      172 Jun 15  2020 elasticsearch-plugin
-rwxr-xr-x. 1 es es      431 Jun 15  2020 elasticsearch-saml-metadata
-rwxr-xr-x. 1 es es      438 Jun 15  2020 elasticsearch-setup-passwords
-rwxr-xr-x. 1 es es      118 Jun 15  2020 elasticsearch-shard
-rwxr-xr-x. 1 es es      441 Jun 15  2020 elasticsearch-sql-cli
-rwxr-xr-x. 1 es es 20808142 Jun 15  2020 elasticsearch-sql-cli-7.8.0.jar
-rwxr-xr-x. 1 es es      426 Jun 15  2020 elasticsearch-syskeygen
-rwxr-xr-x. 1 es es      426 Jun 15  2020 elasticsearch-users
-rwxr-xr-x. 1 es es      346 Jun 15  2020 x-pack-env
-rwxr-xr-x. 1 es es      354 Jun 15  2020 x-pack-security-env
-rwxr-xr-x. 1 es es      353 Jun 15  2020 x-pack-watcher-env
[root@localhost bin]# ./elasticsearch
future versions of Elasticsearch will require Java 11; your Java version from [/opt/jdk1.8.0_281/jre] does not meet this requirement
future versions of Elasticsearch will require Java 11; your Java version from [/opt/jdk1.8.0_281/jre] does not meet this requirement
[2021-04-22T09:38:51,809][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-zengwenfeng] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:174) ~[elasticsearch-7.8.0.jar:7.8.0]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161) ~[elasticsearch-7.8.0.jar:7.8.0]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.8.0.jar:7.8.0]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127) ~[elasticsearch-cli-7.8.0.jar:7.8.0]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.8.0.jar:7.8.0]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126) ~[elasticsearch-7.8.0.jar:7.8.0]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.8.0.jar:7.8.0]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:111) ~[elasticsearch-7.8.0.jar:7.8.0]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:178) ~[elasticsearch-7.8.0.jar:7.8.0]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393) ~[elasticsearch-7.8.0.jar:7.8.0]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.8.0.jar:7.8.0]
	... 6 more
uncaught exception in thread [main]
java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:111)
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:178)
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393)
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
	at org.elasticsearch.cli.Command.main(Command.java:90)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
For complete error details, refer to the log at /opt/es/logs/es-zengwenfeng.log
2021-04-22 01:38:53,874816 UTC [3700] ERROR CNamedPipeFactory.cc@226 Unable to open named pipe /tmp/elasticsearch-5920437698050967258/controller_log_3560 for writing: Interrupted system call
2021-04-22 01:38:54,099434 UTC [3700] ERROR CLogger.cc@298 Cannot log to named pipe /tmp/elasticsearch-5920437698050967258/controller_log_3560 as it could not be opened for writing
2021-04-22 01:38:54,099507 UTC [3700] FATAL Main.cc@102 Could not reconfigure logging
[root@localhost bin]# su es
[es@localhost bin]$  bin/elasticsearch
bash: bin/elasticsearch: No such file or directory
[es@localhost bin]$ 
[es@localhost bin]$ 
[es@localhost bin]$ 
[es@localhost bin]$ 
[es@localhost bin]$ pwd
/opt/elasticsearch-7.8.0/bin
[es@localhost bin]$ pwd
/opt/elasticsearch-7.8.0/bin
[es@localhost bin]$ 

[es@localhost bin]$ 
[es@localhost bin]$ ./elasticsearch
future versions of Elasticsearch will require Java 11; your Java version from [/opt/jdk1.8.0_281/jre] does not meet this requirement
future versions of Elasticsearch will require Java 11; your Java version from [/opt/jdk1.8.0_281/jre] does not meet this requirement
2021-04-22 09:45:59,986 main ERROR RollingFileManager (/opt/es/logs/es-zengwenfeng_server.json) java.io.FileNotFoundException: /opt/es/logs/es-zengwenfeng_server.json (Permission denied) java.io.FileNotFoundException: /opt/es/logs/es-zengwenfeng_server.json (Permission denied)
	at java.io.FileOutputStream.open0(Native Method)
	at java.io.FileOutputStream.open(FileOutputStream.java:270)
	at java.io.FileOutputStream.(FileOutputStream.java:213)
	at java.io.FileOutputStream.(FileOutputStream.java:133)
	at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:640)
	at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:608)
	at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113)
	at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114)
	at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:188)
	at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:145)
	at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:61)
	at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
	at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:236)
	at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:129)
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:354)
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
	at org.elasticsearch.cli.Command.main(Command.java:90)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)

2021-04-22 09:46:00,447 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@792b749c] unable to create manager for [/opt/es/logs/es-zengwenfeng_server.json] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@23e84203[pattern=/opt/es/logs/es-zengwenfeng-%d{yyyy-MM-dd}-%i.json.gz, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true), SizeBasedTriggeringPolicy(size=134217728)]), strategy=DefaultRolloverStrategy(min=-2147483648, max=2147483647, useMax=false), advertiseURI=null, layout=ESJsonLayout{patternLayout={"type": "server", "timestamp": "%d{yyyy-MM-dd'T'HH:mm:ss,SSSZZ}", "level": "%p", "component": "%c{1.}", "cluster.name": "${sys:es.logs.cluster_name}", "node.name": "%node_name", "message": "%notEmpty{%enc{%marker}{JSON} }%enc{%.-10000m}{JSON}"%notEmpty{, %node_and_cluster_id }%exceptionAsJson }
}, filePermissions=null, fileOwner=null]] java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@792b749c] unable to create manager for [/opt/es/logs/es-zengwenfeng_server.json] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@23e84203[pattern=/opt/es/logs/es-zengwenfeng-%d{yyyy-MM-dd}-%i.json.gz, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true), SizeBasedTriggeringPolicy(size=134217728)]), strategy=DefaultRolloverStrategy(min=-2147483648, max=2147483647, useMax=false), advertiseURI=null, layout=ESJsonLayout{patternLayout={"type": "server", "timestamp": "%d{yyyy-MM-dd'T'HH:mm:ss,SSSZZ}", "level": "%p", "component": "%c{1.}", "cluster.name": "${sys:es.logs.cluster_name}", "node.name": "%node_name", "message": "%notEmpty{%enc{%marker}{JSON} }%enc{%.-10000m}{JSON}"%notEmpty{, %node_and_cluster_id }%exceptionAsJson }
}, filePermissions=null, fileOwner=null]]
	at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:115)
	at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114)
	at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:188)
	at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:145)
	at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:61)
	at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
	at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:236)
	at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:129)
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:354)
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
	at org.elasticsearch.cli.Command.main(Command.java:90)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)

2021-04-22 09:46:00,450 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender
	at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:235)
	at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:135)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
	at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:236)
	at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:129)
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:354)
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
	at org.elasticsearch.cli.Command.main(Command.java:90)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)

2021-04-22 09:46:01,176 main ERROR RollingFileManager (/opt/es/logs/es-zengwenfeng.log) java.io.FileNotFoundException: /opt/es/logs/es-zengwenfeng.log (Permission denied) java.io.FileNotFoundException: /opt/es/logs/es-zengwenfeng.log (Permission denied)
	at java.io.FileOutputStream.open0(Native Method)
	at java.io.FileOutputStream.open(FileOutputStream.java:270)
	at java.io.FileOutputStream.(FileOutputStream.java:213)
	at java.io.FileOutputStream.(FileOutputStream.java:133)
	at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:640)
	at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:608)
	at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113)
	at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114)
	at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:188)
	at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:145)
	at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:61)
	at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
	at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:236)
	at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:129)
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:354)
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
	at org.elasticsearch.cli.Command.main(Command.java:90)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)

2021-04-22 09:46:01,797 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@792b749c] unable to create manager for [/opt/es/logs/es-zengwenfeng.log] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@1fd14d74[pattern=/opt/es/logs/es-zengwenfeng-%d{yyyy-MM-dd}-%i.log.gz, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true), SizeBasedTriggeringPolicy(size=134217728)]), strategy=DefaultRolloverStrategy(min=-2147483648, max=2147483647, useMax=false), advertiseURI=null, layout=[%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %m%n, filePermissions=null, fileOwner=null]] java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@792b749c] unable to create manager for [/opt/es/logs/es-zengwenfeng.log] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@1fd14d74[pattern=/opt/es/logs/es-zengwenfeng-%d{yyyy-MM-dd}-%i.log.gz, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true), SizeBasedTriggeringPolicy(size=134217728)]), strategy=DefaultRolloverStrategy(min=-2147483648, max=2147483647, useMax=false), advertiseURI=null, layout=[%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %m%n, filePermissions=null, fileOwner=null]]
	at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:115)
	at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114)
	at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:188)
	at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:145)
	at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:61)
	at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
	at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:236)
	at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:129)
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:354)
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
	at org.elasticsearch.cli.Command.main(Command.java:90)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)

2021-04-22 09:46:01,799 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender
	at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:235)
	at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:135)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
	at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:236)
	at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:129)
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:354)
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
	at org.elasticsearch.cli.Command.main(Command.java:90)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)

2021-04-22 09:46:01,826 main ERROR Null object returned for RollingFile in Appenders.
2021-04-22 09:46:01,826 main ERROR Null object returned for RollingFile in Appenders.
2021-04-22 09:46:01,826 main ERROR Unable to locate appender "rolling" for logger config "root"
2021-04-22 09:46:01,998 main ERROR Unable to locate appender "rolling_old" for logger config "root"
[2021-04-22T09:46:15,959][INFO ][o.e.n.Node               ] [node-zengwenfeng] version[7.8.0], pid[3865], build[default/tar/757314695644ea9a1dc2fecd26d1a43856725e65/2020-06-14T19:35:50.234439Z], OS[Linux/3.10.0-1127.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_281/25.281-b09]
[2021-04-22T09:46:15,960][INFO ][o.e.n.Node               ] [node-zengwenfeng] JVM home [/opt/jdk1.8.0_281/jre]
[2021-04-22T09:46:15,960][INFO ][o.e.n.Node               ] [node-zengwenfeng] JVM arguments [-Xshare:auto, -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=SPI,JRE, -Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Djava.io.tmpdir=/tmp/elasticsearch-3670999045370116277, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -XX:MaxDirectMemorySize=536870912, -Des.path.home=/opt/elasticsearch-7.8.0, -Des.path.conf=/opt/elasticsearch-7.8.0/config, -Des.distribution.flavor=default, -Des.distribution.type=tar, -Des.bundled_jdk=true]
[2021-04-22T09:46:37,416][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [aggs-matrix-stats]
[2021-04-22T09:46:37,416][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [analysis-common]
[2021-04-22T09:46:37,416][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [constant-keyword]
[2021-04-22T09:46:37,416][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [flattened]
[2021-04-22T09:46:37,417][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [frozen-indices]
[2021-04-22T09:46:37,417][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [ingest-common]
[2021-04-22T09:46:37,417][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [ingest-geoip]
[2021-04-22T09:46:37,417][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [ingest-user-agent]
[2021-04-22T09:46:37,417][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [kibana]
[2021-04-22T09:46:37,417][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [lang-expression]
[2021-04-22T09:46:37,417][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [lang-mustache]
[2021-04-22T09:46:37,417][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [lang-painless]
[2021-04-22T09:46:37,417][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [mapper-extras]
[2021-04-22T09:46:37,417][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [parent-join]
[2021-04-22T09:46:37,417][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [percolator]
[2021-04-22T09:46:37,417][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [rank-eval]
[2021-04-22T09:46:37,418][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [reindex]
[2021-04-22T09:46:37,418][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [repository-url]
[2021-04-22T09:46:37,418][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [search-business-rules]
[2021-04-22T09:46:37,418][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [searchable-snapshots]
[2021-04-22T09:46:37,418][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [spatial]
[2021-04-22T09:46:37,418][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [tasks]
[2021-04-22T09:46:37,418][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [transform]
[2021-04-22T09:46:37,418][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [transport-netty4]
[2021-04-22T09:46:37,418][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [vectors]
[2021-04-22T09:46:37,418][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-analytics]
[2021-04-22T09:46:37,418][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-async-search]
[2021-04-22T09:46:37,418][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-autoscaling]
[2021-04-22T09:46:37,419][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-ccr]
[2021-04-22T09:46:37,419][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-core]
[2021-04-22T09:46:37,419][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-deprecation]
[2021-04-22T09:46:37,419][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-enrich]
[2021-04-22T09:46:37,419][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-eql]
[2021-04-22T09:46:37,419][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-graph]
[2021-04-22T09:46:37,419][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-identity-provider]
[2021-04-22T09:46:37,419][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-ilm]
[2021-04-22T09:46:37,419][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-logstash]
[2021-04-22T09:46:37,419][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-ml]
[2021-04-22T09:46:37,419][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-monitoring]
[2021-04-22T09:46:37,419][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-ql]
[2021-04-22T09:46:37,420][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-rollup]
[2021-04-22T09:46:37,420][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-security]
[2021-04-22T09:46:37,420][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-sql]
[2021-04-22T09:46:37,420][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-voting-only-node]
[2021-04-22T09:46:37,420][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] loaded module [x-pack-watcher]
[2021-04-22T09:46:37,420][INFO ][o.e.p.PluginsService     ] [node-zengwenfeng] no plugins loaded
[2021-04-22T09:46:38,154][INFO ][o.e.e.NodeEnvironment    ] [node-zengwenfeng] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [24.8gb], net total_space [36.9gb], types [rootfs]
[2021-04-22T09:46:38,154][INFO ][o.e.e.NodeEnvironment    ] [node-zengwenfeng] heap size [1015.6mb], compressed ordinary object pointers [true]
[2021-04-22T09:46:39,540][INFO ][o.e.n.Node               ] [node-zengwenfeng] node name [node-zengwenfeng], node ID [gZ2u7SIISpiNoZbkZE4ErQ], cluster name [es-zengwenfeng]
[2021-04-22T09:47:31,628][INFO ][o.e.x.s.a.s.FileRolesStore] [node-zengwenfeng] parsed [0] roles from file [/opt/elasticsearch-7.8.0/config/roles.yml]
[2021-04-22T09:48:15,334][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [node-zengwenfeng] [controller/4005] [Main.cc@110] controller (64 bit): Version 7.8.0 (Build 58ff6912e20047) Copyright (c) 2020 Elasticsearch BV
[2021-04-22T09:48:19,928][INFO ][o.e.d.DiscoveryModule    ] [node-zengwenfeng] using discovery type [zen] and seed hosts providers [settings]
[2021-04-22T09:48:25,687][INFO ][o.e.n.Node               ] [node-zengwenfeng] initialized
[2021-04-22T09:48:25,688][INFO ][o.e.n.Node               ] [node-zengwenfeng] starting ...
[2021-04-22T09:48:26,499][INFO ][o.e.t.TransportService   ] [node-zengwenfeng] publish_address {192.168.8.150:9300}, bound_addresses {192.168.8.150:9300}
[2021-04-22T09:48:28,266][INFO ][o.e.b.BootstrapChecks    ] [node-zengwenfeng] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2021-04-22T09:48:28,395][INFO ][o.e.c.c.Coordinator      ] [node-zengwenfeng] cluster UUID [RR1tuHTUQk2505NsO9WOrQ]
[2021-04-22T09:48:29,008][INFO ][o.e.c.s.MasterService    ] [node-zengwenfeng] elected-as-master ([1] nodes joined)[{node-zengwenfeng}{gZ2u7SIISpiNoZbkZE4ErQ}{5_HuWoGKSr6oW4u5ULvkMg}{192.168.8.150}{192.168.8.150:9300}{dilmrt}{ml.machine_memory=1562742784, xpack.installed=true, transform.node=true, ml.max_open_jobs=20} elect leader, _BECOME_MASTER_TASK_, _FINISH_ELECTION_], term: 8, version: 53, delta: master node changed {previous [], current [{node-zengwenfeng}{gZ2u7SIISpiNoZbkZE4ErQ}{5_HuWoGKSr6oW4u5ULvkMg}{192.168.8.150}{192.168.8.150:9300}{dilmrt}{ml.machine_memory=1562742784, xpack.installed=true, transform.node=true, ml.max_open_jobs=20}]}
[2021-04-22T09:48:29,342][INFO ][o.e.c.s.ClusterApplierService] [node-zengwenfeng] master node changed {previous [], current [{node-zengwenfeng}{gZ2u7SIISpiNoZbkZE4ErQ}{5_HuWoGKSr6oW4u5ULvkMg}{192.168.8.150}{192.168.8.150:9300}{dilmrt}{ml.machine_memory=1562742784, xpack.installed=true, transform.node=true, ml.max_open_jobs=20}]}, term: 8, version: 53, reason: Publication{term=8, version=53}
[2021-04-22T09:48:29,748][INFO ][o.e.h.AbstractHttpServerTransport] [node-zengwenfeng] publish_address {192.168.8.150:9200}, bound_addresses {192.168.8.150:9200}
[2021-04-22T09:48:29,749][INFO ][o.e.n.Node               ] [node-zengwenfeng] started
[2021-04-22T09:48:30,955][INFO ][o.e.l.LicenseService     ] [node-zengwenfeng] license [a20dbf39-7c8e-4988-a924-130d64b89fc3] mode [basic] - valid
[2021-04-22T09:48:30,957][INFO ][o.e.x.s.s.SecurityStatusChangeListener] [node-zengwenfeng] Active license is now [BASIC]; Security is disabled
[2021-04-22T09:48:31,050][INFO ][o.e.g.GatewayService     ] [node-zengwenfeng] recovered [1] indices into cluster_state
[2021-04-22T09:48:33,273][INFO ][o.e.c.r.a.AllocationService] [node-zengwenfeng] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[book][0]]]).
[2021-04-22T09:48:34,085][INFO ][o.e.m.j.JvmGcMonitorService] [node-zengwenfeng] [gc][8] overhead, spent [632ms] collecting in the last [1.2s]

 

 

-------

 

ElasticSearchUtil.java_第2张图片

 

 

import java.io.IOException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;

import org.apache.http.Header;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.apache.http.impl.nio.reactor.IOReactorConfig;
import org.apache.http.message.BasicHeader;
import org.apache.http.nio.entity.NStringEntity;
import org.elasticsearch.client.Node;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/**
 * ElasticSearch工具类
 * 
 * @author ZengWenfeng
 * @date 2021.04.22
 */
public class ElasticSearchUtil3
{
	public static  T pass(String str, Class clazz)
	{
		return JSON.parseObject(JSON.parseObject(str).getString("_source"), clazz);
	}
	
	public static RestClient getClient() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException
	{
		RestClientBuilder clientBuilder = RestClient.builder(new HttpHost("192.168.8.150", 9200, "http"));

		Header[] defaultHeaders = { new BasicHeader("header", "value") };
		clientBuilder.setDefaultHeaders(defaultHeaders);

		clientBuilder.setFailureListener(new RestClient.FailureListener()
		{
			public void onFailure(Node node)
			{
				super.onFailure(node);
			}
		});

		clientBuilder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback()
		{
			@Override
			public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpAsyncClientBuilder)
			{
				return httpAsyncClientBuilder.setDefaultIOReactorConfig(IOReactorConfig.custom().setIoThreadCount(1).build());
			}
		});

		clientBuilder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback()
		{
			public RequestConfig.Builder customizeRequestConfig(RequestConfig.Builder requestConfigBuilder)
			{
				// 连接5秒超时,套接字连接60s超时
				return requestConfigBuilder.setConnectTimeout(5000).setSocketTimeout(60000);
			}
		});
		
		return clientBuilder.build();
	}
	
	public static void main(String[] args) throws KeyManagementException, KeyStoreException, NoSuchAlgorithmException, IOException
	{
		Request request = new Request("POST", new StringBuilder("/book/_doc/_search").toString());

		JSONObject query = new JSONObject();
		JSONObject match = new JSONObject();
		JSONObject termName = new JSONObject();
		termName.put("name", "");
		match.put("match", termName);
		query.put("query", match);

		request.setEntity(new NStringEntity(JSON.toJSONString(query), ContentType.APPLICATION_JSON));

		Response response = getClient().performRequest(request);
		
		System.out.println(response);
	}

}

 

--

https://download.csdn.net/download/spencer_tseng/16809329

 

你可能感兴趣的:(java)