|
采用yum安装1、rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
2、cd /etc/yum.repos.d/
vim elasticsearch.repo 打开文件后写入如下内容
- [elasticsearch-7.x]
- name=Elasticsearch repository for 7.x packages
- baseurl=https://mirror.tuna.tsinghua.edu.cn/elasticstack/7.x/yum/
- gpgcheck=1
- gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
- enabled=1
- autorefresh=1
- type=rpm-md
复制代码 3、安装ES
yum install elasticsearch 如果你想指定ES版本可以使用:- yum install --enablerepo=elasticsearch elasticsearch-7.17.6-1.x86_64
- 如果搜索不到包尝试执行 yum install elasticsearch-7.17.6-1.x86_64
复制代码 3、添加es用户
- # 添加用户,我这里叫es
- adduser es
- # 给用户设置密码
- passwd 123456
- # 切换到es用户下
- su es
复制代码
4、已切换到es用户下,加上权限- chown -R es /etc/sysconfig/elasticsearch
- chown -R es /etc/elasticsearch
- chown -R es /var/lib/elasticsearch
- #将整个elasticsearch目录权限给它
- chown -R es /var/log/elasticsearch
- chown -R es /usr/share/elasticsearch
复制代码
5、配置es.yml文件 开启用户名密码 vim /etc/elasticsearch/elasticsearch.yml
- http.cors.enabled: true
- http.cors.allow-origin: "*"
复制代码
6、修改其它配制 vim /etc/security/limits.conf,必须切换到root用户下执行
- #es是自己的用户名,其他的照写
- es hard nofile 65536
- es soft nofile 65536
复制代码
vim /etc/elasticsearch/jvm.options 默认4g,已经远远超出了范围,所以这里改为1g,可按照自己实际情况修改
7、再su es 进入 cd /usr/share/elasticsearch/bin
./elasticsearch
浏览器输入 ip:9200看到有反回值就表示ES安装成功了
- {
- "name" : "es-node1",
- "cluster_name" : "my-rztx",
- "cluster_uuid" : "TCtIEXh9TDKyvr6wNDgakQ",
- "version" : {
- "number" : "7.17.15",
- "build_flavor" : "default",
- "build_type" : "rpm",
- "build_hash" : "0b8ecfb4378335f4689c4223d1f1115f16bef3ba",
- "build_date" : "2023-11-10T22:03:46.987399016Z",
- "build_snapshot" : false,
- "lucene_version" : "8.11.1",
- "minimum_wire_compatibility_version" : "6.8.0",
- "minimum_index_compatibility_version" : "6.0.0-beta1"
- },
- "tagline" : "You Know, for Search"
- }
复制代码
最后设置es的用户名与密码
bin>elasticsearch-setup-passwords interactive
|
|