系统版本:centos 7 es版本:elasticsearch6.3
一、下载安装es
1.先安装jdk
su -c "yum install java-1.8.0-openjdk"2.安装elasticsearch6.3
cd /usr/local/ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.0.tar.gz tar -zxf elasticsearch-6.3.0.tar.gz3.尝试运行
cd /usr/local/elasticsearch-6.3.0 ./bin/elasticsearch
应该会报错:can not run elasticsearch as root
意思是不能以root权限运行 那么我们添加一个新用户
# 以root用户来创建新的用户 , groupadd 添加一个用户组 [root@localhost local]# groupadd elasticsearch # 添加一个用户,-g是在用户组下 -p是密码 [root@localhost local]# useradd elasticsearch -g elasticsearch -p elasticsearch # 进入es的安装目录 [root@localhost local]# cd /elasticsearch-6.3.0 # 给用户elasticsearch 授权 [root@localhost local]# chown -R elasticsearch:elasticsearch elasticsearch-6.3.0/ # 切换到 elasticsearch 用户 [root@localhost elasticsearch]# su elasticsearch
不出意外 依然会报错:
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
max number of threads [3802] for user [elasticsearch] is too low, increase to at least [4096]
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决步骤:
cd /etc cp sysctl.conf sysctl.conf.bak 编辑sysctl.conf,增加如下内容 vim sysctl.conf # elasticsearch config start vm.max_map_count=262144 # elasticsearch config end
sysctl -p使生效
或者执行这个也可以:
sysctl -w vm.max_map_count=262144
下面我们来解决另一个问题
cd /etc/security/ cp limits.conf limits.conf.bak 然后编辑limits.conf增加如下配置: # elasticsearch config start * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096 # elasticsearch config end我这里用户重新登录才生效
4、修改配置文件
通过修改 elasticsearch.yml配置,我们来实现局域网内访问elasticsearch服务,将host和port相应配置修改成局域网的一个固定IP,然后重新启动
# ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): # network.host: 10.0.200.108 # # Set a custom port for HTTP: # http.port: 9200 # # For more information, consult the network module documentation.
记得防火墙打开9200端口
firewall-cmd --zone=public --permanent --add-port=9200/tcp
五、运行
执行启动命令 ./bin/elasticsearch ,会发现指定IP已经配置好了,也正常启动
那我们先利用curl在虚拟机本地测试一下,结果如下
curl "10.0.200.108:9200"
{
"name" : "bFPwhql",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "osOkw9z_RwC3pqN0Zx45nA",
"version" : {
"number" : "6.3.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "424e937",
"build_date" : "2018-06-11T23:38:03.357887Z",
"build_snapshot" : false,
"lucene_version" : "7.3.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
第二大项:安装kibana(es的可视化管理工具)
1.安装也很简单 下载回来解压 直接./bin/kibana即可 需要注意的是要下载和es相同的版本号
2.修改配置
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.url: "http://10.0.200.108:9200"
3.运行./bin/kibana