【centos 7】 安装 ElasticSearch

1、安装jdk

// 默认安装java 8
yum install java 

2、到官网下载对应版本的安装包

3、创建es用户组,添加用户( es不能以root身份启动,必须创建普通用户)

groupadd es
useradd es -g es
passwd es

切换到普通用户,上传安装包

su es

解压包

tar -zxvf elasticsearch-6.8.0.tar.gz

给es用户添加 es 文件夹的权限
chown -R es:es elasticsearch-6.8.0

4、启动elasticSearch

cd bin
./elasticsearch

测试客户端

- curl http://localhost:9200

在这里插入图片描述

5、开启远程链接

cd config
vi elasticsearch.yml

将原来的

#network.host: 192.168.0.1

修改成

network.host: 0.0.0.0

重启es

./elasticsearch &

可以看到运行之后的报错

ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [3795] for user [es] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决错误[1]
以root用户的身份,修改系统配置

vim /etc/security/limits.conf

在最下面的地方追加

*            soft     nofile            65536
*            hard     nofile            65536
*            soft     nproc             4096
*            hard     nproc             4096

重新登录root用户

exit
su - root

检测配置是否生效

ulimit -Hn
ulimit -Sn
ulimit -Hu
ulimit -Su

解决错误[2]
以root用户的身份,修改系统配置

vim /etc/security/limits.d/20-nproc.conf

把原来的

*          soft    nproc     4096

修改为

es          soft    nproc     4096

(*号改为ES启动用户名)

解决错误[3]
以root用户的身份,修改系统配置

vim /etc/sysctl.conf 

在最下面追加

vm.max_map_count=655360

检测是否生效

sysctl -p

退出重新登录root,杀掉es进程

ps -aux|grep java
kill 进程号

关闭防火墙

systemctl stop firewalld.service

查看防火墙开启状态

firewall-cmd --state

禁止开机自启动防火墙

systemctl disable firewalld.service

进入es用户,启动es

./elasticsearch

6、通过浏览器访问 http://服务器的ip地址:9200/

{
  "name" : "FheC05p",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "6ohStK80SmGKikLcxErp-Q",
  "version" : {
    "number" : "6.8.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "65b6179",
    "build_date" : "2019-05-15T20:06:13.172855Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

显示上面的信息即为部署成功



在7版本的ES中,如果启动报错

就修改 elasticsearch.yml 配置文件中的

# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
.....
.....
# --------------------------------- 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: ["host1","host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.

修改为:

# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# Add custom attributes to the node:
#
node.attr.rack: r1
#
.....
.....
# --------------------------------- 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"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.

更换ES分词器

因为ES的默认分词器对中文不是很友好,所以这里更换成国内常用的分词器IK。到github上下载对应版本的安装包,然后上传到服务器。

注意:要下载对应的ES版本,我这里是 6.8.0

切换到root用户,安装zip、unzip

yum install -y zip unzip

到es的plugin文件夹创建文件夹 ik

mkdir ik

解压 ik.zip 到es的plugin文件夹里

unzip elasticsearch-analysis-ik-6.8.0.zip -d ./elasticsearch-6.8.0/plugins/ik

切换成普通用户,启动ES。可以看到启动信息中,ik分词器被加载出来了
在这里插入图片描述
测试使用,用浏览器打开kibana的开发工具
在这里插入图片描述
在这里插入图片描述

参考:https://www.bilibili.com/video/BV1FK4y1x7Dr?p=16&spm_id_from=pageDriver

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值