1. 下载es
https://pan.baidu.com/s/1SioDFInSHe7UpcvJM72D4Q
提取码:irem
也可以搜索国内镜像网站。
2. 解压es压缩包
tar -zxvf elasticsearch-7.9.1.tar.gz

3. 修改配置
elasticsearch-7.9.1/config/elasticsearch.yml
cluster.name: my-application
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["2xx.xx.xx.x7", "[::1]"]
cluster.initial_master_nodes: ["node-1"]
http.cors.enabled: true
http.cors.allow-origin: /.*/
4. 运行
./elasticsearch

报错是因为elasticsearch不刻意用root账号登录。
5. 创建es用户
adduser es #新建一个es用户
passwd es #给 es 设置密码
修改 /etc/sudoers 文件

给es用户添加root权限
usermod -g root es
切换账号
su es

5. 启动elasticsearch

发现报错,去搜了一下原因。
解决的办法是用root 用户设置一下该目录的权限
sudo chmod -R 777 某一目录
其中
-R 是指级联应用到目录里的所有子目录和文件
777 是所有用户都拥有最高权限
然后在切换 es用户,启动,但还是失败了。

先设置下max_map_count值
sudo sysctl -w vm.max_map_count=262144
再修改文件
/etc/security/limits.conf
es hard nofile 65536 #es是之前新建的用户
es soft nofile 65536
又双叒叕启动elasticsearch
访问ip:9200

终于OJBK了
网友评论