1 elasticsearch 安装
前提条件jdk环境
1.1 安装ElasticSearch
1.1.0.1 mkdir -p /usr/local/java
1.1.0.2 tar -xzvf jdk-8u131-linux-x64.tar.gz -C /usr/local/java/
1.1.1 vi /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_131
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
1.1.2 source /etc/profile
1.1.3 创建用户组和用户
[root@localhost jdk1.8.0_131]# groupadd esuser
[root@localhost jdk1.8.0_131]# useradd esuser -g esuser -p 123456
[root@localhost ~]# tar xzvf elasticsearch-6.4.3.tar.gz -C /usr/local/
[root@localhost local]# cd /usr/local/
[root@localhost local]# chown -R esuser:esuser ./elasticsearch-6.4.3
[root@localhost local]# cd elasticsearch-6.4.3/bin/
内存至少要1g
[root@localhost bin]# vim elasticsearch
ES_JAVA_OPTS="-Xms1g –Xmx1g"
[esuser@localhost config]$ vim elasticsearch.yml
[root@localhost bin]# vim /etc/security/limits.conf
esuser soft nofile 65536
esuser hard nofile 65536
esuser soft nproc 4096
esuser hard nproc 4096
[root@localhost bin]# vim /etc/security/limits.d/20-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
esuser soft nproc 4096
root soft nproc unlimited
[root@localhost bin]# vim /etc/sysctl.conf vm.maxmapcount=655360
[root@localhost bin]# sysctl -p vm.maxmapcount = 655360
[root@localhost bin]# systemctl stop firewalld.service
1.1.4 后台运行
./bin/elasticsearch –d
打开浏览器输入如下:
9300 与 9200 区别
9300端口:ES节点之间通讯使用
9200端口:ES节点与外部通讯使用
1.2 安装elasticsearch-head
前提安装npm nodejs
curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -
yum install -y nodejs
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install
npm –v
node -v
git://github.com/mobz/elasticsearch-head.git
1.2.1 安装elasticsearch-head 依赖包
[root@bogon ~]# cnpm install -g grunt-cli
[root@bogon ~]# mv elasticsearch-head-master elasticsearch-head
[root@bogon ~]# mv elasticsearch-head /usr/local/
[root@bogon ~]# cd /usr/local/elasticsearch-head
[root@bogon elasticsearch-head]# vim Gruntfile.js
如下图增加,允许所有ip可以访问 hostname: ‘*’,
1.2.2 修改elasticsearch-head默认连接地址
[root@bogon elasticsearch-head]# cd /usr/local/elasticsearch-head/_site/
[root@bogon _site]# vim app.js 将下图的localhost修改成es服务器地址
1.2.3 配置elasticsearch允许跨域访问
[root@bogon config]# cd /usr/local/elasticsearch-6.4.3/config
[root@bogon config]# vim elasticsearch.yml
在文件最后面加上:
http.cors.enabled: true
http.cors.allow-origin: "*"
1.2.4 打开9100端口
[root@bogon config]# firewall-cmd --zone=public --add-port=9100/tcp –permanent Firewall-cmd –reload
1.2.5 启动elasticsearch
./bin/elasticsearch –d
1.2.6 启动elasticsearch-head
[root@bogon elasticsearch-6.4.3]# cd /usr/local/elasticsearch-head/
1.3 Kibana安装步骤
解压:
[root@localhost local]# tar xzvf kibana-6.4.3-linux-x86_64.tar.gz
[root@localhost local]# mv kibana-6.4.3-linux-x86_64 /usr/local/
修改配置文件:
[esuser@localhost config]$ vim kibana.yml
启动
nohup /usr/local/kibana-6.4.3-linux-x86_64/bin/kibana &
1.3.1 安装elasticsearch-analysis-ik
[root@bogon ~]# mv elasticsearch-analysis-ik-6.4.3.zip /usr/local/
elasticsearch-6.4.3/plugins/ik
[root@bogon ~]# cd /usr/local/elasticsearch-6.4.3/plugins/ik
[root@bogon plugins]# unzip elasticsearch-analysis-ik-6.4.3.zip