centos安装elasticsearch-7.6.1

由于想尝试下Spring Data Elasticsearch ,就决定安装下elastic search ,把我的两个环境都装上了,一个是阿里云64位的centos7.7,还有一个是32位的centos6.5.说实话32位的机子装es挺难的,要修改的点也多,所以记录下,感觉明天就要忘了.


安装配置es:端口9200 9300

  1. 添加新用户useradd 用户名
  2. 设置新用户密码:passwd lixiang 不管提示,重复2次
  3. 将安装包传到用户目录下
  4. 修改安装包所属: chown lixiang:lixiang elasticsearch-7.6.1-linux-x86_64.tar.gz
  5. 修改安装包权限:chmod 777 elasticsearch-7.6.1-linux-x86_64.tar.gz
  6. 选择操作用户:su - 用户名
  7. 解压文件:tar -zxvf elasticsearch-7.6.1-linux-x86_64.tar.gz
  8. 将解压后的文件更名:mv elasticsearch-7.6.1 elasticsearch
  9. 进入config目录修改配置: cd config/
  10. vim jvm.opions
  11. 修改运行时所占内存: -Xms512m -Xmx512m
  12. 修改配置vim elasticsearch.yml
  13. 修改Node中: node.master: true cluster.name: my-application node.name: node-1
  14. 更改数据目录(去掉#) 这里写自己的目录
    path.data: /home/lixiang/elasticsearch/data
    path.logs: /home/lixiang/elasticsearch/logs
  15. 配置任意ip可以访问:network.host: 0.0.0.0
  16. 在elasticsearch创建data目录: mkdir data
  17. 放行端口:
    9200作为Http协议,主要用于外部通讯
    9300作为Tcp协议,jar之间就是通过tcp协议通讯
    ES集群之间是通过9300进行通讯

可能发生的错误

  1. 提示内核版本过低 [ROG] unable to install syscall filter:
    去elasticsearch.yml禁用插件,尾部加一行:: bootstrap.system_call_filter: false

  2. 提示elasticsearch用户拥有的内存权限太小,至少需要262144;
    进入root用户:vim /etc/sysctl.conf
    末尾加上: vm.max_map_count=262144
    执行: sysctl -p
    返回lixiang用户 再次启动

  3. 提示: [1]: the default discovery settings are unsuitable for production use;
    at least one of [discovery.seed_hosts, discovery.seed_providers,
    cluster.initial_master_nodes] must be configured
    修改elasticsearch.yml: cluster.initial_master_nodes: [“node-1”]

  4. unable to load JNA native support library, native methods will be disabled.
    系统为32位: 进入es的lib目录,先删除 jna-4.5.1.jar
    通过命令wget https://repo1.maven.org/maven2/net/java/dev/jna/jna/4.5.1/jna-4.5.1.jar重新下载一个。
    再去运行es

  5. X-Pack is not supported and Machine Learning is not available for [linux-x86]; you can use the other X-Pack features
    进入config目录,修改elasticsearch.yml文件,
    在文件最下面添加: xpack.ml.enabled: false

  6. max number of threads [1024] for user [lixiang] is too low, increase to at least [4096]
    root下: vim /etc/security/limits.d/90-nproc.conf
    改为: * soft nproc 4096

  7. max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
    每个进程最大同时打开文件数太小,
    进入config目录,修改elasticsearch.yml文件,合并上个问题,改完后:
    *     hard nofile 65536
    *     soft nproc 4096
    *     hard nproc 4096
    root soft nproc unlimited

  8. JVM is using the client VM [Java HotSpot™ Client VM] but should be using a server VM for the best performance
    打开你安装的jdk找到里面的jre,进入jre下的lib/i386目录,修改jvm.cfg,找到:
    -server KNOWN
    -client IF_SERVER_CLASS -server
    -minimal KNOWN
    调换-server和-client的位置,最后变成上面这样即可。


运行elastic search

前台运行命令: ./elasticsearch
后台运行命令:./elasticsearch -d
这样就可以后台运行了,启动时看不到日志
之后如果要关闭es进程:
1.ps -ef | grep elastic
2.kill相应进程
kill -9 pid
例如:kill -9 987


安装配置kibana(需要node.js环境):端口5601

  1. 解压文件
  2. 修改config下的kibana.yml
    配置: elasticsearch.hosts: [“http://elasticsearch所在地址:9200”]
    server.host: “0.0.0.0”
    elasticsearch.requestTimeout: 90000
  3. 在bin下的kibana.bat启动

kibana启动失败no known master node, scheduling a retry或者master_not_discovered_exception

在es配置文件末尾加上: xpack.license.self_generated.type: basic
	discovery.seed_hosts: ["127.0.0.1:9300"]
	Node中添加:   node.master: true
	cluster.name: my-application
	node.name: node-1

给es添加ik分词器插件

1.将压缩包放到 plugins目录下
2.安装unzip: yum install -y unzip zip
3.解压 : unzip elasticsearch-analysis-ik-7.6.1.zip -d ik-analyer
4.回到bin目录重启es 之前别忘了关es

最后附上centos6.5的es的配置文件


# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: my-application
node.master: true
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /home/lixiang/elasticsearch/data
#
# Path to log files:
#
path.logs: /home/lixiang/elasticsearch/logs
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["127.0.0.1:9300"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1"]
cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
bootstrap.system_call_filter: false
xpack.ml.enabled: false
xpack.license.self_generated.type: basic 

简单的分词测试

GET /_search
POST _analyze
{
  "analyzer": "ik_max_word",
  "text":     "我是中国人"
}

最后说下,最好别用32位和低版本的centos,不然我上面列出的问题都得改一遍

发布了22 篇原创文章 · 获赞 0 · 访问量 584

猜你喜欢

转载自blog.csdn.net/lixiang19971019/article/details/104934181