centos7下 elasticsearch6.4.0安装,ik分词器的安装

1、首先安装jdk1.8以上的环境,这里不再赘述,自行百度

2、安装 elasticsearch6.4.0,es的启动环境不能是root超级管理员账户,所以我们需要创建一个普通用户

centos7创建普通用户流程:

[root@mysql ~]#   adduser  cloudes

[root@mysql ~]#   passwd  cloudes 

输入两次密码验证即可

用户密码创建完成后,对创建的账户进行授权,为什么要授权呢

答:由于新创建的用户并不能使用sudo命令,需要给他添加授权。

1)添加sudoers文件可写权限

chmod -v u+w /etc/sudoers

2)修改sudoers文件

 用vim命令打开sudoers文件,在sudoers文件中找到如下位置并添加如下内容:

cloudes    ALL=(ALL)    ALL(如需新用户使用sudo时不用输密码,把最后一个ALL改为NOPASSWD:ALL即可)

3)收回sudoers文件可写权限

chmod -v u-w /etc/sudoers

以上完成后我们进行elasticsearch6.4.0的安装正式开始:

# 官网下载压缩包
[root@localhost /home]#  wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.0.tar.gz
# 解压
[root@localhost /home]#  tar -zxvf elasticsearch-6.4.0.tar.gz

#修改配置文件

[root@localhost home]# cd cloudes
[root@localhostcloudes]# ls
elasticsearch-6.4.0  elasticsearch-6.4.0.tar.gz  logs
[root@localhost cloudes]# cd elasticsearch-6.4.0
[root@localhost elasticsearch-6.4.0]# ls
bin  config  elasticsearch-analysis-ik-6.4.0.zip  elasticsearch-analysis-ik-6.4.0.zip.1  lib  LICENSE.txt  logs  modules  NOTICE.txt  plugins  README.textile
[root@localhost  elasticsearch-6.4.0]# cd config/
[root@localhost  config]# ls
elasticsearch.keystore  elasticsearch.yml  jvm.options  log4j2.properties  role_mapping.yml  roles.yml  users  users_roles

编辑elasticsearch.yml中的配置
[root@mysql config]#vi elasticsearch.yml

 

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
# es 集群服务名称
 cluster.name: cloud-service           
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#配置节点名称
 node.name: esnode-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):
#配置 es的数据保存路径
 path.data: /home/elasticsearch/data
#
# Path to log files:
#配置 es的日志保存路径
 path.logs: /home/elasticsearch/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#配置 es的启动时内存锁定,官方建议线上生产环境设置为true,我这里没有启用
 bootstrap.memory_lock: false
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
# 修改网络监听地址  也可以是默认的  0.0.0.0 ,我这里是我的主机ip
 network.host: 192.168.1.20
#
# Set a custom port for HTTP:
#本机的es环境启动端口
 http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
# 可以不用配置如果单机版的可以默认,也可以配置如下,如果是集群模式,可以配置多个主机ip["192.168.1.20:9300,192.168.1.21:9300"]
 discovery.zen.ping.unicast.hosts: ["192.168.1.20:9300"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
 gateway.recover_after_nodes: 1
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
 action.destructive_requires_name: true
# 开启插件访问权限
 http.cors.enabled: true
 http.cors.allow-origin: "*"

修改完成进行esc 退出wq!保存

3、接下来切换到创建的普通用户下进行启动我们进行es的启动

[root@mysql elasticsearch-6.4.0]# cd bin/
[root@mysql bin]# ls
elasticsearch               elasticsearch-cli           elasticsearch-keystore      elasticsearch-saml-metadata      elasticsearch-setup-passwords.bat  elasticsearch-translog      x-pack-env.bat
elasticsearch.bat           elasticsearch-cli.bat       elasticsearch-keystore.bat  elasticsearch-saml-metadata.bat  elasticsearch-sql-cli              elasticsearch-translog.bat  x-pack-security-env
elasticsearch-certgen       elasticsearch-croneval      elasticsearch-migrate       elasticsearch-service.bat        elasticsearch-sql-cli-6.4.0.jar    elasticsearch-users         x-pack-security-env.bat
elasticsearch-certgen.bat   elasticsearch-croneval.bat  elasticsearch-migrate.bat   elasticsearch-service-mgr.exe    elasticsearch-sql-cli.bat          elasticsearch-users.bat     x-pack-watcher-env
elasticsearch-certutil      elasticsearch-env           elasticsearch-plugin        elasticsearch-service-x64.exe    elasticsearch-syskeygen            x-pack                      x-pack-watcher-env.bat
elasticsearch-certutil.bat  elasticsearch-env.bat       elasticsearch-plugin.bat    elasticsearch-setup-passwords    elasticsearch-syskeygen.bat        x-pack-env
[root@mysql bin]# ./elasticsearch

执行./elasticsearch  

如果后台进程模式运行执行  ./elasticsearch -d

启动后我们发现有报错,这时不要慌

[2019-10-09T10:35:29,459][INFO ][o.e.t.TransportService   ] [wVDAxQP] publish_address {192.168.1.20:9300}, bound_addresses {0.0.0.0:9300}

[2019-10-09T10:35:29,493][INFO ][o.e.b.BootstrapChecks    ] [wVDAxQP] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

[2019-10-09T10:35:29,617][INFO ][o.e.n.Node               ] [wVDAxQP] stopping ...

[2019-10-09T10:35:29,693][INFO ][o.e.n.Node               ] [wVDAxQP] stopped

[2019-10-09T10:35:29,693][INFO ][o.e.n.Node               ] [wVDAxQP] closing ...

[2019-10-09T10:35:29,719][INFO ][o.e.n.Node               ] [wVDAxQP] closed

主要有两处报错:
1、elasticsearch可以创建的文件描述(file descriptors)太少
2、虚拟内存太小

[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
 

解决办法

1)elasticsearch用户拥有的可创建文件描述的权限太低,至少需要65536

      处理办法:   #切换到root用户修改

                                  vim /etc/security/limits.conf   # 在最后面追加下面内容

                                   *** hard nofile 65536

                                  *** soft nofile 65536              #***  是启动ES的用户名
 

2)修改配置sysctl.conf 增加配置值: vm.max_map_count=262144

 vi /etc/sysctl.conf    增加

  vm.max_map_count=262144

  执行  sysctl  -p让文件生效,重新启动环境,即可启动成功

 

4、安装ik分词器

进入es目录下的plugins目录下,该目录是存放es插件的地方

[root@mysql cloudes]# cd elasticsearch-6.4.0
[root@mysql elasticsearch-6.4.0]# ls
bin  config  elasticsearch-analysis-ik-6.4.0.zip  elasticsearch-analysis-ik-6.4.0.zip.1  lib  LICENSE.txt  logs  modules  NOTICE.txt  plugins  README.textile
[root@mysql elasticsearch-6.4.0]# cd plugins/
[root@mysql plugins]# ls
ik  sql
[root@mysql plugins]# 

 执行  wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.0/elasticsearch-analysis-ik-6.4.0.zip

[root@mysql plugins]# wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.0/elasticsearch-analysis-ik-6.4.0.zip

  这样也可以下载,如果速度太慢的话,crt+c键中断多次重试的话,可以遇到比较快的镜像ip,下载速度秒下

也可以到git上下载离线包上传到服务器上

git上面下载ik分词器的压缩包,地址:

https://github.com/medcl/elasticsearch-analysis-ik/releases

与ES版本匹配的6.4.0版本:

下载完成后解压

[root@mysql plugins]# ls
elasticsearch-analysis-ik-6.4.0.zip  sql
[root@mysql plugins]# unzip elasticsearch-analysis-ik-6.4.0.zip 
Archive:  elasticsearch-analysis-ik-6.4.0.zip
  inflating: elasticsearch-analysis-ik-6.4.0.jar  
  inflating: httpclient-4.5.2.jar    
  inflating: httpcore-4.4.4.jar      
  inflating: commons-logging-1.2.jar  
  inflating: commons-codec-1.9.jar   
   creating: config/
  inflating: config/quantifier.dic   
  inflating: config/preposition.dic  
  inflating: config/extra_single_word_low_freq.dic  
  inflating: config/stopword.dic     
  inflating: config/suffix.dic       
  inflating: config/extra_main.dic   
  inflating: config/IKAnalyzer.cfg.xml  
  inflating: config/main.dic         
  inflating: config/extra_stopword.dic  
  inflating: config/extra_single_word_full.dic  
  inflating: config/surname.dic      
  inflating: config/extra_single_word.dic  
  inflating: plugin-descriptor.properties  
  inflating: plugin-security.policy  

我是直接将名称改成了ik

[root@mysql plugins]# ls
ik  sql
[root@mysql plugins]# ls
ik  sql
[root@mysql plugins]# cd ik
[root@mysql ik]# ls
commons-codec-1.9.jar  commons-logging-1.2.jar  config  elasticsearch-analysis-ik-6.4.0.jar  httpclient-4.5.2.jar  httpcore-4.4.4.jar  plugin-descriptor.properties  plugin-security.policy
[root@mysql ik]# 

然后重启es服务,大功告成

 

centos7下 elasticsearch6.4.0安装,ik分词器的安装_第1张图片

你可能感兴趣的:(架构)