redhat 9.2 安装 elasticsearch-7.17.3 过程记录

1. 确认 redhat 版本号:

 > cat /etc/redhat-release:
 > Red Hat Enterprise Linux release 9.2 (Plow)

2. 新建 elasticsearch 目录:

 > cd /data/software && mkdir  elasticsearch && cd elasticsearch

3. 下载 elasticsearch-7.17.3-linux-x86_64.tar.gz:

> wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.3-linux-x86_64.tar.gz

 下载失败也可以去其他地方下载( 比如迅雷 ),然后上传到该目录。

4. 解压 elasticsearch-7.17.3-linux-x86_64.tar.gz:

> tar -xzf elasticsearch-7.17.3-linux-x86_64.tar.gz

5. 

> cd elasticsearch-7.17.3 && mkdir data && mkdir tmpdir

6.  cd config &&  vim elasticsearch.yml,添加如下内容:

 cluster.initial_master_nodes: ["es-node-1"]  	// 不加启动 es 会报错 the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
 path.data: /data/software/elasticsearch/elasticsearch-7.17.3/data
 path.logs: /data/software/elasticsearch/elasticsearch-7.17.3/logs
 network.host: 0.0.0.0 							// 不加只能使用 http://127.0.0.1:9200 访问,不能用 具体 ip 访问
 ingest.geoip.downloader.enabled: false   		// 不加可能如果网络不好,java 调用 es api 会超时,然后 es 日志会发现类似 "error downloading geoip database [GeoLite2-Country.mmdb]" 的错误

7. 修改 es 的默认 /tmp 目录:

有时候启动 es 会报类似 "Exception in thread “main” java.nio.file.AccessDeniedException: /tmp/elasticsearch-8523317643108022907..." 的错误,因为 No space left 或者 no permission 等,可以手动修改 es 默认使用的 /tmp 目录:

    1. vim  /data/software/elasticsearch/elasticsearch-7.17.3/bin/elasticsearch,在 "if [ -z "$ES_TMPDIR" ]; then" 上一行新增 ES_TMPDIR="/data/software/elasticsearch/elasticsearch-7.17.3/tmpdir"
    2. vim /data/software/elasticsearch/elasticsearch-7.17.3/bin/elasticsearch-env,在 "if [ ! -z "$ES_JAVA_HOME" ]; then" 上一行新增 ES_JAVA_HOME="/data/software/elasticsearch/elasticsearch-7.17.3/jdk"
	

8. 启动 es:

    1. cd /data/software/elasticsearch/elasticsearch-7.17.3/bin && ./elasticsearch        // 前台启动 
	2. cd /data/software/elasticsearch/elasticsearch-7.17.3/bin && ./elasticsearch -d     // 后台启动 

9. 安装 ik分词器:
            1. 下载 elasticsearch-analysis-ik-7.17.3.zip( 下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.3/elasticsearch-analysis-ik-7.17.3.zip )
            2. cd /data/software/elasticsearch/elasticsearch-7.17.3/plugins && mkdir analysis-ik
            3. 将下载好的 elasticsearch-analysis-ik-7.17.3.zip 上传到 analysis-ik 目录
            4. unzip elasticsearch-analysis-ik-7.17.3.zip
            5. 重启 elasticSearch

10. elasticSearch 常见 API:
            1. http://127.0.0.1:9200/_cat/nodes?v       # 查看所有节点
            2. http://127.0.0.1:9200/_cat/health?v      # 查看 elasticSearch 健康状况
            3. http://127.0.0.1:9200/_cat/indices?v     #  查看所有索引信息
            4. http://127.0.0.1:9200/index_article       #  查看索引 index_article 的信息
            5. http://127.0.0.1:9200/index_article  DELETE        #  删除索引 index_article
            6. http://127.0.0.1:9200/index_article/_mapping  DELETE        #  删除索引 index_article
            7. http://127.0.0.1:9200/index_article/_search          #  查询索引 index_article 中的全部数据
            8. http://127.0.0.1:9200/_analyze               # 测试分词器分词效果
                POST
                {
                    "text":"I prefer having your accompanying for life-long time to the short-time tenderness",
                    "analyzer":"standard"
                }

11. 设置用户名、密码:
            1. 修改 /data/software/elasticsearch/elasticsearch-7.17.3/config/elasticsearch.yml,添加 "xpack.security.enabled: true"
            2. cd  /data/software/elasticsearch/elasticsearch-7.17.3/bin  执行 ./elasticsearch-certutil cert -out config/elastic-certificates.p12 -pass "",发现证书 elastic-certificates.p12 生成到了 /data/software/elasticsearch/elasticsearch-7.17.3/config 中
            3. 修改 /data/software/elasticsearch/elasticsearch-7.17.3/config/elasticsearch.yml,添加以下4行:
                

    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


            4. 重启 es,浏览器请求 http://127.0.0.1:9200/ 提示让输入用户名和密码了
            5. 设置密码:
                cd  /data/software/elasticsearch/elasticsearch-7.17.3/bin 执行 ./elasticsearch-setup-passwords interactive,选择 y,根据提示为分别为用户 elastic、apm_system、kibana_system、logstash_system、beats_system、remote_monitoring_user 设置密码

  • 8
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值