1、CentOS 7.6 64位(
2、jdk1.8
3、直接从官网上面下载elasticsearch6.5源码(下载地址:https://www.elastic.co/downloads/past-releases/elasticsearch-6-5-1)
1、jdk自行安装
2、将下载的elasticsearch-6.5.1.tar.gz上传至centos服务器/home/es/文件夹下面(l路径根据自己喜好)
3、解压elasticsearch-6.5.1.tar.gz,命令tar -zxvf elasticsearch-6.5.1.tar.gz
4、修改访问es的ip及端口如下:vi /home/es/elasticsearch-6.5.1/config/elasticsearch.yml
5.启动es
前台启动: ./bin/elasticsearch
后台启动: ./elasticsearch-5.3.0/bin/elasticsearch -d
启动成功后,在web浏览器中输入http://192.168.31.235:9200/,如果返回以下页面,则说明成功。
{
name: "YoXmVYH",
cluster_name: "elasticsearch",
cluster_uuid: "Yw8f033SSb6_oc5o2v1r7w",
version: {
number: "5.3.0",
build_hash: "3adb13b",
build_date: "2017-03-23T03:31:50.652Z",
build_snapshot: false,
lucene_version: "6.4.1"
},
tagline: "You Know, for Search"
}
1、centos7开放9200端口
查看firewall是否运行,下面两个命令都可以
systemctl status firewalld.service
firewall-cmd --state
查看端口
firewall-cmd --zone=public --query-port=9200/tcp
添加端口
firewall-cmd --zone=public --add-port=9200/tcp --permanent (--permanent永久生效,没有此参数重启后失效)
重新载入,添加端口后重新载入才能起作用
firewall-cmd --reload
查看开启了哪些端口
firewall-cmd --list-ports
2、JVM内存问题
如果遇到
说明jvm启动内存太大,机器内存不足(如果按照之前虚拟机配置中的1G来配置,则会出现此问题,因为es默认jvm启动内存是2g,所以我们需要配置一下es的启动内存)
编辑/home/es/elasticsearch-6.5.1/config/jvm.options文件,修改以下两个参数:
#-Xms2g
#-Xmx2g
-Xms512m
-Xmx512m
3、根权限执行问题
如果遇到
根据提示,无法以根权限启动es程序,所以我们创建一个非根用户,并给它赋予目录该用户权限。es 无法以root用户启动
# groupadd estest
# useradd estest -g estest -p estest
# chown -R estest:estest /home/es
# sudo su es
用root用户给estest用户赋权时没有完全将es目录的所有文件权限给estest,重新用root用户身份执行:(-R参数不要掉,表示递归将es目录下所有文件权限给es用户)
4、内存问题:
有[1][2][3]三个问题,逐一解决:
1]: initial heap size [16777216] not equal to maximum heap size [257949696]; this can cause resize pauses and prevents mlockall from locking the entire heap
第一个问题还是jvm内存问题,请重新检查可能碰到的问题(1)JVM内存问题,按照步骤重新检查一遍。
[2]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
Es进程设置的最大文件描述符太小,需要增加。
编辑/etc/security/limits.conf,最后加上:
estest soft nofile 65536
estest hard nofile 65536
然后重新连接shell,切换到es用户,再尝试启动es。
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
是因为操作系统的vm.max_map_count参数设置太小导致的,有两种方式解决,
1、请使用root用户登录系统,执行以下命令:
sysctl -w vm.max_map_count=262144
2、 或使用如下方法:切换到root用户修改配置sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
用以下命令查看是否修改成功
sysctl -a | grep “vm.max_map_count”
如果能正常输出262144,则说明修改成功
一、安装nodejs和rpm
1. su - root
2. yum install epel-release
3. yum install nodejs npm
注意:如果失败请检查CDN配置
$: vi /etc/resole.conf
添加:
nameserver: 8.8.8.8
nameserver: 114.114.114.114
重启网络,service network restart
二、下载并安装elasticsearch-head (yum install git安装Git)
1.cd /home
2. git clone https://github.com/mobz/elasticsearch-head.git
3. cd elasticsearch-head
4. npm install
------------------------------------------------------------------------------
如果出现如下错误:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN [email protected] license should be a valid SPDX license expression
npm ERR! Linux 3.10.0-693.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v6.14.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the phantomjs-prebuilt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs phantomjs-prebuilt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls phantomjs-prebuilt
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/elasticsearch-head/npm-debug.log
------------------------------------------------------------------------------
没有问题直接运行
5. npm run start
6. curl http://localhost:9100 or http://you IP Address:9100 能正常打开说明head插件安装正确
三、如果想查询集群健康信息,那么需要在elasticsearch配置文件中授权
1. 在elasticsearch下的elasticsearch.yml下新增一下两行:
http.cors.enabled: true # elasticsearch中启用CORS
http.cors.allow-origin: "*" # 允许访问的IP地址段,* 为所有IP都可以访问
2. 重启elastsearch
systemctl restart elasticsearch.service
或者
cd /es
./bin/elasticsearch
四、修改es-head的localhost地址
1. cd ./elasticsearch-head #(elasticsearch-head源码文件夹)
2. vim Gruntfile.js
3. Add hostname
connect: {
server: {
options: {
hostname: '0.0.0.0',
port: 9100,
base: '.',
keepalive: true
}
}
}
五、修改head的连接地址
1. cd ./elasticsearch-head #(elasticsearch-head源码文件夹)
2. vim ./_site/app.js
3. 将localhost修改为ESdeIP地址
将this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";中的localhost修改成你es的服务器地址
六、启动elasticsearch-head
./node_modules/grunt/bin/grunt server
后台启动 > nohup ./node_modules/grunt/bin/grunt server >1.out &
关闭:ps -ef| grep grunt kill -9 $pid
参考文献:https://blog.csdn.net/david_snjly/article/details/83017632
https://www.jianshu.com/p/d1c3e2b1df27
https://blog.csdn.net/zyjavaweb/article/details/80023624