下载地址:Download Elasticsearch | Elastic
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.0.1-linux-x86_64.tar.gz
tar -zxvf elasticsearch-8.0.1-linux-x86_64.tar.gz
2.启动部署elasticsearch不能使用root账户使用,所以新建一个账户进行启动
创建名为 admin的用户
adduser elasticsearch
初始化elas的密码
passwd elasticsearch
首先查找sudoers文件路径(root账号下操作)
[root@master ~]# whereis sudoers sudoers: /etc/sudoers.d /etc/sudoers /usr/share/man/man5/sudoers.5.gz
查看权限
[root@master ~]# ls -l /etc/sudoers -r--r-----. 1 root root 4328 10月 30 2018 /etc/sudoers #显示只有读权限
赋予读写权限
[root@master ~]# chmod -v u+w /etc/sudoers mode of "/etc/sudoers" changed from 0440 (r--r-----) to 0640 (rw-r-----)
修改sudoers文件
vim /etc/sudoers
在root下添加 (elas是用户名)
elas ALL=(ALL) ALL
加了之后 wq! 进行保存
执行以下命令,执行完之后需要在切换到原来的账号
chown -R elasticsearch:elasticsearch /application/common/elasticsearch-8.0.1/
其中,elasticsearch:elasticsearch 是用户名 后面是elasticsearch文件路径
3.配置在开发使用过程中,我们可以限制elasticsearch使用的内存大小
进入elasticsearch的目录下config文件夹
cd config
vim jvm.options
找到改行,设置启动大小 ,之后保存
现在默认我们只能在linux服务器上访问elasticsearch ,如果要使得我们在外网也能访问 elasticsearch ,需要修改配置文件
进入elasticsearch文件目录下的config文件夹中
vim elasticsearch.yml
修改ip地址和端口号
将上一步中的elasticsearch.yml 的network.host改成0.0.0.0,修改后保存推出
启动elasticsearch(切换到启动elasticsearch账户)
cd /application/common/elasticsearch-8.0.1/bin
./elasticsearch
出现以下报错 说明现在的环境不符合elasticsearch的要求
| 1 2 3 4 5 6 | ERROR: [1] bootstrap checks failed [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] [2020-04-04T17:47:27,880][INFO ][o.e.n.Node ] [5GagyKc] stopping ... [2020-04-04T17:47:27,965][INFO ][o.e.n.Node ] [5GagyKc] stopped [2020-04-04T17:47:27,965][INFO ][o.e.n.Node ] [5GagyKc] closing ... [2020-04-04T17:47:27,979][INFO ][o.e.n.Node ] [5GagyKc] closed |
(1)、修改系统配置文件 (切换到root用户)
| 1 | vim /etc/security/limits.conf |
增加以下内容,如图所示
| 1 2 3 4 | * hard nofile 655360 * soft nofile 131072 * hard nproc 65535 * soft nproc 65535 |
其中:
nofile - 打开文件的最大数目
noproc - 进程的最大数目
soft 指的是当前系统生效的设置值
hard 表明系统中所能设定的最大值
(2)修改系统最大内存数,进入
| 1 | vim /etc/sysctl.conf |
修改为
如果没有上述内容,直接添加以下内容进去即可
| 1 2 | vm.max_map_count=655360 fs.file-max=655360 |
修改好之后,保存退出
使的我们修改的配置文件生效
| 1 | sysctl -p |
访问地址:http://服务器地址:9200/
发现有用户名密码
是因为开启了 ssl 认证。
在 ES/config/elasticsearch.yml 文件中把 xpack.security.http.ssl:enabled 设置成 false 即可
重新启动。切换到普通账号启动elasticsearch,启动成功后,我们可以使用 -d 命令进行后台启动,进入elasticsearch文件夹目录的bin文件夹
| 1 | ./elasticsearch -d |
或者
| 1 | nohup ./elasticsearch & |
访问地址:http://服务器地址:9200/



