elasticsearch 7.6.2 xpack认证部署

先看我遇到的问题,再部署,不走弯路。

一:xpack ca证书不加密部署

1.  环境准备:centos 7.7 ELK 7.6.2

[root@es_master kibana]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 

禁用防火墙。或者配置防火墙策略


2. 机器准备

机器ip 安装应用
192.168.186.132 es master x-pack
192.168.186.130 es datanode x-pack
192.168.186.131 es datenode x-pack

3. 下载安装包

下载安装包(三台都需要安装解压)
[root@es_master ]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-linux-x86_64.tar.gz  #下载es
[root@es_master ]#scp elasticsearch-7.6.2-linux-x86_64.tar.gz root@192.168.186.130:/root/
[root@es_master ]#scp elasticsearch-7.6.2-linux-x86_64.tar.gz root@192.168.186.131:/root/
[root@es_master ]# tar -xf elasticsearch-7.6.2-linux-x86_64.tar.gz -C /usr/local/  

4. 创建es用户以及目录

创建目录以及用户(三台)
[root@es_node1 ~]#useradd elastic
[root@es_node1 ]# mkdir -p /data/elastic/data
[root@es_node1 ]# mkdir -p /data/elastic/logs
[root@es_node1 ]# chown -R elastic:elastic /data/elastic/data/
[root@es_node1 ]# chown -R elastic:elastic /data/elastic/logs/

给es安装目录授权

[root@es_master local]# pwd
/usr/local
[root@es_master local]# chown -R elastic:elastic elasticsearch-7.6.2

5. 生成ca证书(master节点)

[root@es_master elasticsearch-7.6.2]# pwd
/usr/local/elasticsearch-7.6.2
[elastic@es_master elasticsearch-7.6.2]$ bin/elasticsearch-certutil ca      #生成ca证书颁发机构
This tool assists you in the generation of X.509 certificates and certificate 
signing requests for use with SSL/TLS in the Elastic stack.

The 'ca' mode generates a new 'certificate authority'
This will create a new X.509 certificate and private key that can be used
to sign certificate when running in 'cert' mode.

Use the 'ca-dn' option if you wish to configure the 'distinguished name'
of the certificate authority

By default the 'ca' mode produces a single PKCS#12 output file which holds:
    * The CA certificate
    * The CA's private key

If you elect to generate PEM format certificates (the -pem option), then the output will
be a zip file containing individual files for the CA certificate and private key

Please enter the desired output file [elastic-stack-ca.p12]:         #回车默认证书名为elastic-stack-ca.p12
Enter password for elastic-stack-ca.p12 :     #是否设置密码  回车为空在下面的配置文件中就不需要添加ca证书的密码
[elastic@es_master elasticsearch-7.6.2]$ 
[elastic@es_master elasticsearch-7.6.2]$ 
[elastic@es_master elasticsearch-7.6.2]$ bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
This tool assists you in the generation of X.509 certificates and certificate
signing requests for use with SSL/TLS in the Elastic stack.

The 'cert' mode generates X.509 certificate and private keys.
    * By default, this generates a single certificate and key for use
       on a single instance.
    * The '-multiple' option will prompt you to enter details for multiple
       instances and will generate a certificate and key for each one
    * The '-in' option allows for the certificate generation to be automated by describing
       the details of each instance in a YAML file

    * An instance is any piece of the Elastic Stack that requires an SSL certificate.
      Depending on your configuration, Elasticsearch, Logstash, Kibana, and Beats
      may all require a certificate and private key.
    * The minimum required value for each instance is a name. This can simply be the
      hostname, which will be used as the Common Name of the certificate. A full
      distinguished name may also be used.
    * A filename value may be required for each instance. This is necessary when the
      name would result in an invalid file or directory name. The name provided here
      is used as the directory name (within the zip) and the prefix for the key and
      certificate files. The filename is required if you are prompted and the name
      is not displayed in the prompt.
    * IP addresses and DNS names are optional. Multiple values can be specified as a
      comma separated string. If no IP addresses or DNS names are provided, you may
      disable hostname verification in your SSL configuration.

    * All certificates generated by this tool will be signed by a certificate authority (CA).
    * The tool can automatically generate a new CA for you, or you can provide your own with the
         -ca or -ca-cert command line options.

By default the 'cert' mode produces a single PKCS#12 ou
下面是在 CentOS 上单机部署 Elasticsearch 和 X-Pack 的步骤: 1. 首先下载 Elasticsearch 和 X-Pack 的安装包。可以到官网下载最新版本,也可以使用 yum 安装。 2. 安装 Java 环境。Elasticsearch 需要 Java 环境的支持。可以使用以下命令安装 OpenJDK: ``` sudo yum install java-1.8.0-openjdk ``` 3. 解压 Elasticsearch 和 X-Pack 的安装包,并将其移动到 /usr/share 目录下: ``` sudo tar -zxvf elasticsearch-7.6.2-linux-x86_64.tar.gz sudo mv elasticsearch-7.6.2 /usr/share/elasticsearch sudo tar -zxvf x-pack-7.6.2-linux-x86_64.tar.gz sudo mv x-pack-7.6.2 /usr/share/x-pack ``` 4. 创建一个新用户来运行 Elasticsearch。可以使用以下命令创建一个名为 elasticsearch 的用户: ``` sudo useradd elasticsearch ``` 5.Elasticsearch 和 X-Pack 相应的目录设置权限: ``` sudo chown -R elasticsearch:elasticsearch /usr/share/elasticsearch sudo chown -R elasticsearch:elasticsearch /usr/share/x-pack ``` 6. 修改 Elasticsearch 的配置文件。编辑 /usr/share/elasticsearch/config/elasticsearch.yml 文件,修改以下配置项: ``` cluster.name: my_cluster node.name: node1 network.host: 0.0.0.0 http.port: 9200 xpack.security.enabled: true xpack.security.transport.ssl.enabled: true xpack.security.transport.ssl.verification_mode: certificate xpack.security.transport.ssl.keystore.path: /usr/share/x-pack/elastic-certificates.p12 xpack.security.transport.ssl.truststore.path: /usr/share/x-pack/elastic-certificates.p12 xpack.security.http.ssl.enabled: true xpack.security.http.ssl.keystore.path: /usr/share/x-pack/http.p12 xpack.security.http.ssl.truststore.path: /usr/share/x-pack/http.p12 ``` 注意:xpack.security.enabled 设置为 true 是启用 X-Pack 的关键。xpack.security.transport.ssl.enabled 和 xpack.security.http.ssl.enabled 分别启用 Elasticsearch 和 HTTP 安全性。 7. 启动 Elasticsearch。使用以下命令启动 Elasticsearch: ``` sudo -u elasticsearch /usr/share/elasticsearch/bin/elasticsearch ``` 8. 验证 Elasticsearch 是否正常运行。在浏览器中访问 http://your_ip_address:9200,如果能够看到 Elasticsearch 的版本信息,则表示 Elasticsearch 已经成功运行。 至此,Elasticsearch 和 X-Pack 的单机部署就完成了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值