您的位置:首页 > 其它

elasticsearch插件 x-pack.security组件的使用

2017-12-25 15:00 405 查看
离线安装x-pack:

下载es对应的相应版本的x-pack,修改版本号即可通过官方链接下载:

https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-6.1.1.zip


下载后放到指定位置如/usr/
x-pack-6.1.1.zip
并到es安装目录下运行:


./bin/elasticsearch-plugin install file://
/usr/x-pack-6.1.1.zip


安装完重启即可,默认用户 elasitc:changeme
[/code]

restful访问方式改为 curl -u elastic:changeme -XGET .......
[/code]

安装后使用head修改yml文件:

  head需要:

  http.cors.enabled: true

  http.cors.allow-origin:’*’

  安装x-pack后需要:

  http.cors.allow-headers: “Authorization”

访问head格式更改为:

http://localhost:9100/?auth_user=elastic&auth_password=changeme




破解x-pack参考:

http://blog.csdn.net/mvpboss1004/article/details/65445023


http://blog.csdn.net/qq_20641565/article/details/78286894




java客户端api

maven pom.xml导入(maven库里没有xpack包则需要用es官网的maven库):

  <repositories>

        <repository>

            <id>elasticsearch-releases</id>

            <url>https://artifacts.elastic.co/maven</url>

            <releases>

                <enabled>true</enabled>

            </releases>

            <snapshots>

                <enabled>false</enabled>

            </snapshots>

        </repository>

   </repositories>    

  <dependencies>

    <dependency>

      <groupId>junit</groupId>

      <artifactId>junit</artifactId>

      <version>3.8.1</version>

      <scope>test</scope>

    </dependency>

    <dependency>

            <groupId>org.elasticsearch</groupId>

        <artifactId>elasticsearch</artifactId>

        <version>5.1.2</version>

    </dependency>

    <dependency>

        <groupId>org.elasticsearch.client</groupId>

        <artifactId>transport</artifactId>

        <version>5.1.2</version>

    </dependency>

    <dependency>

        <groupId>org.apache.logging.log4j</groupId>

        <artifactId>log4j-core</artifactId>

        <version>2.7</version>

    </dependency>

    <dependency>

        <groupId>org.apache.logging.log4j</groupId>

        <artifactId>log4j-api</artifactId>

        <version>2.7</version>

    </dependency>

    <dependency>

        <groupId>org.elasticsearch.client</groupId>

        <artifactId>x-pack-transport</artifactId>

        <version>5.2.0</version>

    </dependency>

  </dependencies>

连接es集群:

Settings settings = Settings.builder()

                .put("cluster.name", "my-application")

                .put("xpack.security.transport.ssl.enabled", false)

                .put("xpack.security.user", "elastic:changeme")

                .put("client.transport.sniff", true)

                .build();

client = new PreBuiltXPackTransportClient(settings)

                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("127.0.0.1"), 9300));

XPackClient xClient = new XPackClient(client);

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: