前提
a.JDK8+
b.系统可用内存>2G
我自己使用的是centos7.2
1、下载elasticsearch
中文发行版
可以直接克隆
git clone https://github.com/medcl/elasticsearch-rtf.git
也可以百度云盘下载 https://pan.baidu.com/s/1pJNkrUV
2、安装
进入安装目录
[root@localhost elasticsearch]# ./bin/elasticsearch-plugin list // 查看插件列表
[root@localhost elasticsearch]# bin/elasticsearch-plugin list> /tmp/plugin.log // 打印到log
删除多余插件
[root@localhost elasticsearch]# vim /tmp/plugin.log
// 去除analysis-ik 很关键
[root@localhost elasticsearch]# cat /tmp/plugin.log|xargs -I {} bin/elasticsearch-plugin remove {}
3、启动
[root@localhost elasticsearch]# ./bin/elasticsearch -d
//这样会报错 ,root无法启动elasticsearch ,需要创建个新用户
[root@localhost elasticsearch]# adduser es
[root@localhost elasticsearch]# passwd es
......
[root@localhost elasticsearch]# chomd -R 777 /opt/elasticsearch
[root@localhost elasticsearch]# su es
[es@localhost elasticsearch]# ./bin/elasticsearch -d
这样就没错了
[root@localhost elasticsearch]# curl 127.0.0.1:9200
{
"name" : "v4cEn3-",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "dlWNa10MTai00Vx5fImHhw",
"version" : {
"number" : "5.1.1",
"build_hash" : "5395e21",
"build_date" : "2016-12-06T12:36:15.409Z",
"build_snapshot" : false,
"lucene_version" : "6.3.0"
},
"tagline" : "You Know, for Search"
}
配置外网访问
[root@localhost elasticsearch]# vim ./config/elasticsearch.yml
network.host: 0.0.0.0
也许会报错,如下解决办法
1、sudo vim /etc/sysctl.conf
加入:vm.max_map_count=262144 并执行命令:sysctl -p才生效
2、权限不够,导致/opt/elasticsearch/logs/elasticsearch.log日志文件以elasticsearch的文件没权限写入
解决:sudo chown -R es /opt/elasticsearch
3、ERROR: [4] bootstrap checks failed
[1]: initial heap size [264241152] not equal to maximum heap size [4215275520]; this can cause resize pauses and prevents mlockall from locking the entire heap
[2]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[3]: max number of threads [1024] for user [kedacom] is too low, increase to at least [4096]
[4]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决:切换到root用户,进入limits.d目录下修改配置文件。
vi /etc/security/limits.d/90-nproc.conf
修改如下内容:
* soft nproc 1024 #修改为* soft nproc 4096
切换到root用户,编辑limits.conf 添加类似如下内容
vi /etc/security/limits.conf
添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096