安装JDK
安装es
1. 下载
// 创建目录cd /usr/local/mkdir es// wget下载wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.1.tar.gz// 解压tar -zxvf elasticsearch-6.4.2.tar.gz
2. 修改es配置文件elasticsearch.yml
vim /usr/local/es/elasticsearch-6.6.2/config/elasticsearch.yml------------------------------------# 集群名称cluster.name: my-es# 主机名node.name: node-1// 数据文件及日志位置path.data: /usr/local/es/elasticsearch-6.6.2/datapath.logs: /usr/local/es/elasticsearch-6.6.2/logsbootstrap.memory_lock: falsebootstrap.system_call_filter: false// ipnetwork.host: 0.0.0.0// 端口号http.port: 9200------------------------------------:wq// 创建配置的数据文件及日志文件目录cd /usr/local/es/elasticsearch-6.6.2mkdir datamkdir logs
3. 创建用户
由于Elasticsearch可以接收用户输入的脚本并且执行,为了系统安全考虑,不允许root账号启动,所以建议给Elasticsearch单独创建一个用户来运行Elasticsearch。
// 创建用户testuseradd test// 为test分配密码testecho "password" |passwd test --test// 为新创建的用户test分配文件权限chown -R test:test /usr/local/es/elasticsearch-6.6.2// 验证用户1. su test2. 输入密码3. whoami4. 查看输出是否是test
4. 使用test用户运行es
cd /usr/local/es/elasticsearch-6.6.2/bin./elasticsearch
./elasticsearch -d 是后台运行
5. 可能出现的错误
max file descriptors [4096] for elasticsearch process is too low
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
原因:无法创建本地文件问题,用户最大可创建文件数太小
解决方案:切到root 用户下
$ vim /etc/security/limits.conf 在文件的末尾添加下面的参数值:* soft nofile 65536* hard nofile 131072* soft nproc 2048* hard nproc 4096
max virtual memory areas vm.max_map_count [65530] is too low
ERROR: [1] bootstrap checks failed[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]... ...[2018-10-30T11:41:51,807][INFO ][o.e.x.m.j.p.NativeController] Native controller process has stopped - no new native processes can be started
原因:最大虚拟内存太小,需要修改系统变量的最大值。
解决方案:切换到root用户,修改配置sysctl.conf 增加配置值: vm.max_map_count=262144
$ vim /etc/sysctl.confvm.max_map_count=262144
max number of threads [1024] for user [es] likely too low
原因:无法创建本地线程问题,用户最大可创建线程数太小
解决方案:切换到root用户,进入limits.d目录下,修改90-nproc.conf 配置文件。
vi /etc/security/limits.d/90-nproc.conf找到如下内容:* soft nproc 1024#修改为* soft nproc 2048
6. 验证
本地浏览器输入服务器ip:9200
