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

来源:互联网 发布:excel单元格数据分行 编辑:程序博客网 时间:2024/06/10 13:55

离线安装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

restful访问方式改为 curl -u elastic:changeme -XGET .......

安装后使用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);







阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 2018年回音壁音效对比评测 事事有着落件件有回音 件件有着落事事有回音 手机吃鸡带耳机回音怎么消除 回顾近义词 系统回顾 回顾 回顾的意思 回顾的近义词 系统回顾模板 pawn职业生涯回顾 八周年趣味数据回顾 诺基亚全部机型回顾 国剧盛典2018颁奖晚会全程回顾 回馈 回馈制动 爱回馈 回馈的意思 回馈是什么意思 爱回馈商城app 回馈新老客户广告语 2018回馈新老客户广告语 为回馈新老顾客广告语 拼多多回馈领现金是真的吗 老玩家感恩回馈 感恩回馈大礼包 回馈老顾客的促销语言 客户回馈活动方案 360元50gb客户回馈流量包是什么 蓦然回首 再回首 再回首歌词 回首 回首歌词 再回首原唱 回首掏 暮然回首 回首而已 不等你回首 在回首 愿岁月可回首