本文地址http://blog.csdn.net/makefriend7/article/details/60323717
首先放上官网地址https://www.elastic.co/guide/en/elasticsearch/plugins/5.2/index.html
一,插件介绍
插件,大家听名字就知道,就是在ES上插入一个东西,来增强ES的能力。
这里先简单介绍一下插件的分类
- API extension plugin(ActionPlugin): 就是扩展ES的API函数的。大部分是用来search和mapping, 比如 让ES支持SQL 语句
- Alerting plugins: 监控索引,当超越阈值的时候,则自动触发报警(代表插件X-PACK,在你设置了某种查询条件之后,他会周期性的去调用,如果满足条件,则做指定要求做的事)
- Analysis plugins:分析插件,简单说,就是制定建立索引规则的插件,比如SmartCN,就是一个中文分词插件,根据中文来建立索引(而不是英文的空格),以句,词发方式建立索引
- Discovery plugins:发现插件,简单的说。就是集群如何发现属于自己的服务器。按照官方的说法,就是在一个cluster中,如何选举出一个主要的node.
- The ingest plugins: 这个插件的主要功能就是增强每个节点的功能。比如Ingest Attcahment Processor Plugin 就可以让每个节点解压文件,处理诸如PPT ,XLD ,PDF的文件格式
- Management plugins: 管理插件,当然是对ES进行交互和管理(比如X-PACK)
- Mapper plugins: 这个插件主要就是增强ES的数据类型。比如增加一个attachment类型,里面可以放PDF或者WORD数据
- Scripting plugins:这个插件本质来说,就是会调用用户的脚本,所以可以执行任何的程序,举例的话,可以通过这个插件,支持javascript语言,python语言,也可以是用户自定义的任何语言或者程序。
- Security plugins:当然就是提供安全的控制,比如控制哪些用户可以使用ES的那些API
- Repository plugins:提供快照和恢复,简单的理解,就是你把数据放在了服务器上,别人可以通过共享文件夹访问你的数据,也可以通过共享文件夹恢复你的数据。目前ES的核心插件已经支持S3,HDFS等很多访问方式。
- Store plugins, 我们知道ES实际使用的是Lucene 来进行存储的。我们也可以采用Store SMB.(windows的共享文件协议)
1. 内容管理系统
- Drupal:Drupal是使用PHP语言编写的开源内容管理框架(CMF)
- Wp-Elasticsearch: ES的 WordPress 插件 即WordPress可以直接使用ES
- 还有Elasticsearch, Tiki Wiki Cms Groupware XWIKI Next Generation Wiki
2. 数据导入导出和校验
- LogStash output to ES 和ES input to LogStash
- ES event filtering in Logstash
- ES bulk codec
- JDBC importer : 将jdbc的源数据导入到ES
- Kafka Standalone consumer(Indexer) :将kafka数据导入ES
- Mongolastic : 将ES数据导入MongoDB
- Scrutineer: 索引和内容的校验工具
- IMAP/POP3/MAIL importer : 将IMAP POP3 的数据导入到ES(邮箱数据也能进ES啦)
- FS Crawler: 索引文件系统(如PDF ,OPEN OFFICE 。。。) 本地的,或者通过SSH
3. 部署
ES 提供Puppet 社区提供Chef
3. 框架整合
还是直接看官网吧https://www.elastic.co/guide/en/elasticsearch/plugins/5.2/integrations.html#data-integrations
4.Hadoop integrations
4.其他整合
pes : 支持JS 的 DSL查询 https://github.com/kodcu/pes
二,第一个PLUGIN程序
插件程序是非常简单的。代码如下
public class MyFirstPlugin extends Plugin{
private final static Logger LOGGER = LogManager.getLogger(MyFirstPlugin.class);
public MyFirstPlugin() {
super();
LOGGER.warn("This is my fisrt Plugin");
}
}
补上pomx.ml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mygroup1</groupId>
<artifactId>myart1</artifactId>
<version>5.2.2-SNAPSHOT</version>
<name>Plugin: Basic</name>
<description>Only for test</description>
<properties>
<elasticsearch.version>5.2.2</elasticsearch.version>
<lucene.version>6.4.1</lucene.version>
</properties>
<dependencies>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch.version}</version>
<scope>provided</scope>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.test</groupId>
<artifactId>framework</artifactId>
<version>${elasticsearch.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
<version>${lucene.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>*.properties</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>${project.build.directory}/releases/</outputDirectory>
<descriptors>
<descriptor>${basedir}/src/main/assemblies/plugin.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
运行命令 mvn clean install
在release目录下得到myart1-5.2.2-SNAPSHOT.zip文件
在ES目录运行
bin\elasticsearch-plugin install file:///D:/greesoft/elastic/myart1-5.2.2-SNAPSHOT.zip
就安装插件完成了,
此处有个小坑。在windows下。java安装的目录一般会有空格。此处简单的
修改
elasticsearch-plugin.bat文件 如下
set JAVA=D:\jdk1.8.0_102\bin\java.exe (我放的JAVA位置,省得处理空格了)
运行ES。就可以看到我们的打出的信息了。
补上pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mygroup1</groupId>
<artifactId>myart1</artifactId>
<version>5.2.2-SNAPSHOT</version>
<name>Plugin: Basic</name>
<description>Only for test</description>
<properties>
<elasticsearch.version>5.2.2</elasticsearch.version>
<lucene.version>6.4.1</lucene.version>
</properties>
<dependencies>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch.version}</version>
<scope>provided</scope>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.test</groupId>
<artifactId>framework</artifactId>
<version>${elasticsearch.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
<version>${lucene.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>*.properties</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>${project.build.directory}/releases/</outputDirectory>
<descriptors>
<descriptor>${basedir}/src/main/assemblies/plugin.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>