YDOOK-Jinwei Lin
平台:腾讯云-轻量应用服务器-ubuntu24.04 LTS
首先更新软件列表:
安装Java运行时环境(JRE)或开发工具包(JDK)- V17
- sudo apt install openjdk-17-jdk -y
复制代码 添加Elastic官方的GPG密钥到体系以验证下载的软件包
- wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elastic-keyring.gpg
复制代码 添加Elastic的APT源
- echo "deb [signed-by=/usr/share/keyrings/elastic-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
复制代码 再次更新软件列表:
开始安装 Elasticsearch
- sudo apt install elasticsearch -y
复制代码 修改/etc/elasticsearch/elasticsearch.yml文件:
启动 Elasticsearch 服务,并设置该服务开机自动启动:
- sudo systemctl start elasticsearch
- sudo systemctl enable elasticsearch
复制代码 检察 Elasticsearch 当前的状态:
- sudo systemctl status elasticsearch
复制代码 修改 Elasticsearch 运行时间JVM的内存大小:
- /etc/elasticsearch# /etc/elasticsearch/jvm.options
复制代码
修改配置后重新启动 Elasticsearch:
- sudo systemctl restart elasticsearch
复制代码 假如使用下面命令仍旧无法测试:
- curl -X GET "localhost:9200/"
复制代码 应该为服务器中需要通过Elasticsearch的默认用户名与暗码进行访问,
因为安装时没有给出,以是通过下面命令,修改Elasticsearch默认暗码:
- sudo /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic -i
复制代码 上述命令需要在 Elasticsearch 运行的时间进行:
修改暗码乐成后,使用下面命令测试:
- curl -u elastic:<password> -X GET "https://10.1.12.16:9200/_cluster/health?pretty"
复制代码
输出测试结果:
- ubuntu@VM-12-16-ubuntu:/etc/elasticsearch$ curl -k -u elastic:<password> -X GET "https://10.1.12.16:9200/_cluster/health?pretty"
- {
- "cluster_name" : "elasticsearch",
- "status" : "green",
- "timed_out" : false,
- "number_of_nodes" : 1,
- "number_of_data_nodes" : 1,
- "active_primary_shards" : 3,
- "active_shards" : 3,
- "relocating_shards" : 0,
- "initializing_shards" : 0,
- "unassigned_shards" : 0,
- "unassigned_primary_shards" : 0,
- "delayed_unassigned_shards" : 0,
- "number_of_pending_tasks" : 0,
- "number_of_in_flight_fetch" : 0,
- "task_max_waiting_in_queue_millis" : 0,
- "active_shards_percent_as_number" : 100.0
- }
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |