es7安装
一.安装es7
1.下载安装包
下载地址: https://www.elastic.co/guide/en/elasticsearch/reference/7.10/rpm.html#rpm-repo
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.2-x86_64.rpm
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.2-x86_64.rpm.sha512
2.centos 解决 -bash: shasum: command not found
yum install perl-Digest-SHA
3.安装
shasum -a 512 -c elasticsearch-7.10.2-x86_64.rpm.sha512
sudo rpm --install elasticsearch-7.10.2-x86_64.rpm
4.启动
systemctl start elasticsearch.service
5.修改端口
# 进入 /etc/elasticsearch
vi elasticsearch.yml
# 找到 network.host 改为
network.host: 0.0.0.0
# 找到 #http.port: 9200 改为
http.port: 7106
# 找到 #discovery.seed_hosts: ["host1", "host2"] 改为
discovery.seed_hosts: ["0.0.0.0", "[::1]"]
# 允许跨域请求
# 开启跨域
http.cors.enabled: true
# 允许所有
http.cors.allow-origin: "*"
二.安装head-es
1.下载资源
git clone git://github.com/mobz/elasticsearch-head.git
3.安装node环境
# centos8 安装npm
dnf install npm
# 查看版本
node -v
npm -v
# 更换源
npm config set registry https://registry.npm.taobao.org
4.安装head-es
注: 安装phantomjs慢,更换源
npm config set registry http://npm.taobao.org/dist/phantomjs/
# elasticsearch-head的文件目录下
cd elasticsearch-head
# 开始安装
> 安装phantomjs慢,更换源
> npm config set registry http://npm.taobao.org/dist/phantomjs/
npm install
# 运行
npm run start
5.设置启动项
注: 查看命令路径 type npm
# 到/lib/systemd/system 新增 head-es.service文件
[Unit]
Description=head-es
After=syslog.target
After=network.target
[Service]
#WorkingDirectory=/var/local/elasticsearch-head
ExecStart=/usr/bin/env npm -prefix=/var/local/elasticsearch-head run start
Restart=always
KillSignal=SIGQUIT
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
# 添加执行权限
chmod +x /lib/systemd/system/head-es.service
# 启动
systemctl start head-es
systemctl status head-es
systemctl restart head-es
systemctl enable head-es
6.修改head-es的启动端口
# 到elasticsearch-head目录下 找到9100,更改为自己需要设置的访问端口
vi Gruntfile.js
# 7105
# 修改访问es的服务端口 找到9200 更改为自己访问的端口
cd _site
vi app.js
# 7106
# 重启服务