ElasticSearch Xpack集群認證和elasticsearch-head配置


#ES集群配置

- node.name : 各節點需要修改
- node.attr.rack: 各節點需要修改
- #bootstrap.memory_lock: true  :建議注釋,開啟會出現
cluster.name: Elasticsearch-Cluster
node.name: node-111
node.attr.rack: r111
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
#bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["192.168.0.14:9300","192.168.0.111:9300","192.168.0.153:9300"]
cluster.initial_master_nodes: ["192.168.0.111","192.168.0.14","192.168.0.153"]

#Xpack集群認證

部署參考鏈接

RPM包安裝路徑為 /usr/share/elasticsearch

  • 第一步 (一路回車,可不設密碼)

    bin/elasticsearch-certutil ca
    
  • 第二步 (一路回車,可不設密碼)

    bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
    
  • 第三步 拷貝至/etc/elasticsearch下(會在/usr/share/elasticsearch 目錄下生成2個文件 p12結尾的文件)

    cp /usr/share/elasticsearch/*.p12 /etc/elasticsearch
    chown elasticsearch.elasticsearch /etc/elasticsearch/*.p12
    
  • 第四步 修改配置文件

    [root@VM_0_111_centos ~]# vim /etc/elasticsearch/elasticsearch.yml 
    
    cluster.name: Elasticsearch-Cluster
    node.name: node-111
    node.attr.rack: r111
    path.data: /var/lib/elasticsearch
    path.logs: /var/log/elasticsearch
    #bootstrap.memory_lock: true
    network.host: 0.0.0.0
    http.port: 9200
    discovery.seed_hosts: ["192.168.0.14:9300","192.168.0.111:9300","192.168.0.153:9300"]
    cluster.initial_master_nodes: ["node-14","node-111","node-153"]
    
    
    # xpack配置 設置集群互信通信端口9300
    transport.port: 9300
    #head
    http.cors.enabled: true
    http.cors.allow-origin: "*"
    # xpack + head
    http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type  
    # 開啟X-Pack的安全認證
    xpack.security.enabled: true
    # 開啟X-Pack的集群內互信安全認證,與上面安全認證開關同步必開
    xpack.security.transport.ssl.enabled: true
    # 驗證模式為證書模式
    xpack.security.transport.ssl.verification_mode: certificate
    # 配置證書路徑
    xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
    xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
    
    
    #head配置
    http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
    
  • 第五步 重啟elasticsearch

    systemctl restart elasticsearch
    
  • 第六步 設置用戶密碼

    # cd /usr/share/elasticsearch
    bin/elasticsearch-setup-passwords interactive  #y,y之后 可設置相同密碼
    
  • 第七步 驗證

    curl -uelastic:設置的密碼 -XGET http://你的ip:9200/_cluster/health?pretty
    

#elasticsearch-head配置

部署參考鏈接

  • Node js 安裝

    curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -
    yum install -y nodejs
    npm config set registry https://registry.npm.taobao.org/
    npm config get registry
    
  • 安裝elasticsearch-head

    yum install -y git bzip2
    git clone https://github.com/mobz/elasticsearch-head.git
    cd elasticsearch-head/
    npm install 
    
  • 啟動訪問

    #啟動
    nohup npm start &
    #訪問
    http://ip:9100
    #認證訪問
    http://ip:9100/?auth_user=elastic&auth_password=密碼
    

mark

#報錯相關

#集群命令

  • 檢查集群狀態

    #沒設置密碼
    curl -XGET "http://localhost:9200/_cluster/health?pretty=true"
    #設置密碼
    curl -XGET -uelastic:elastic "http://localhost:9200/_cluster/health?pretty=true"
    
  • 查看索引狀態

    curl -XGET "http://localhost:9200/_cat/indices?v"
    

參考


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM