安装elasticsearch-7.1.0(centos7.6)

云主机上需设置root密码

sudo passwd root 回车后出入密码两次

 

jdk11页面

https://www.oracle.com/technetwork/java/javase/downloads/index.html
https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html

安装jdk

mkdir /opt/downloads

 

jdk11
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" -P /opt/downloads http://download.oracle.com/otn-pub/java/jdk/11.0.2+9/f51449fcd52f4d52b93a989c5c56ed3c/jdk-11.0.2_linux-x64_bin.rpm

rpm -ivh /opt/downloads/jdk-11.0.2_linux-x64_bin.rpm

 

jdk1.8

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" -P /opt/downloads https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.rpm

rpm -ivh /opt/downloads/jdk-8u201-linux-x64.rpm

 

查看是否安装成功

java -version

 

安装elasticsearch

下载和安装前切换用户,root用户无法执行es

cat /etc/passwd 查看所有用户的列表

cat /etc/group 查看用户组

groupadd elasticsearch
userdel -r elasticsearch
useradd -s /bin/bash -g elasticsearch elasticsearch

添加权限

vim /etc/sudoers

root下添加 elasticsearch ALL=(ALL) ALL

:x!强制保存

另:避免输密码可以用 elasticsearch ALL=(ALL) NOPASSWD: ALL

passwd elasticsearch *****   设置你的密码

sudo chown -R elasticsearch /opt/downloads;sudo chgrp -R elasticsearch /opt/downloads;sudo chown -R elasticsearch /var/lib/rpm;sudo chgrp -R elasticsearch /var/lib/rpm;

sudo chown -R elasticsearch /opt/downloads/elasticsearch-7.1.0-x86_64.rpm;sudo chgrp -R elasticsearch /opt/downloads/elasticsearch-7.1.0-x86_64.rpm;

su elasticsearch

https://www.elastic.co/cn/downloads/elasticsearch
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" -P /opt/downloads https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.0-x86_64.rpm
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" -P /opt/downloads https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.0-linux-x86_64.tar.gz

sudo rpm -ivh /opt/downloads/elasticsearch-7.1.0-x86_64.rpm

 

卸载rpm -e elasticsearch

 

配置elasticsearch

vim /etc/elasticsearch/elasticsearch.yml
修改network.host的值
network.host: 192.168.x.x 自身ip,限制为内网访问
network.host: 0.0.0.0 也可以不限制ip
http.port: 9200

添加action.auto_create_index: .monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*

取消该注释 node.name: node-1 

修改cluster.initial_master_nodes: ["node-1"]

 

如果es是root用户安装的,文件归属于,root组和root用户,需要改变归属。

cat /etc/passwd 查看所有用户的列表

cat /etc/group 查看用户组

groupadd elasticsearch
userdel -r elasticsearch
useradd -s /bin/bash -g elasticsearch elasticsearch

sudo chown -R elasticsearch /usr/share/elasticsearch;sudo chgrp -R elasticsearch /usr/share/elasticsearch;sudo chown -R elasticsearch /etc/elasticsearch;sudo chgrp -R elasticsearch /etc/elasticsearch;sudo chown -R elasticsearch /etc/sysconfig/elasticsearch;sudo chgrp -R elasticsearch /etc/sysconfig/elasticsearch;sudo chown -R elasticsearch /var/log/elasticsearch;sudo chgrp -R elasticsearch /var/log/elasticsearch

切换回 root用户 su

sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
sudo systemctl start elasticsearch.service

 

注:es不能用root用户启动 

 

测试是否正常运行
curl http://localhost:9200/

 

关闭命令
netstat -anltp|grep 9200
显示LISTEN xxxx/java
kill -9 xxxx

 

 

安装Elasticsearch-head

先查看是否安装git
git --version
安装git
yum install -y git
卸载为
yum remove git

 

安装Elasticsearch-head
cd /opt
git clone git://github.com/mobz/elasticsearch-head.git

修改配置
vim /opt/elasticsearch-head/Gruntfile.js
在原有的connect:server:options节点上加上hostname: '*',

修改es配置
vim /etc/elasticsearch/elasticsearch.yml
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"

安装node和npm
查看安装最新版本命令:https://github.com/nodesource/distributions

curl -sL https://rpm.nodesource.com/setup_12.x | bash -

yum install -y nodejs

查看安装的版本
node -v
npm -v

 

cd /opt/elasticsearch

安装grunt和grunt-cli
sudo npm install -g grunt
sudo npm install -g grunt-cli
安装模块依赖
npm install -g
npm install grunt --save #安装grunt到模块中并保存

后台启动head
cd /opt/elasticsearch-head
nohup npm run start &
回车返回到shell

守护进程启动

vim /lib/systemd/system/elasticsearch-head.service

[Unit]
Description=Elasticsearch-head
After=network.target syslog.target

[Service]
Type=simple
WorkingDirectory=/opt/elasticsearch-head
ExecStart=/usr/bin/npm run start
Restart=always
StandardOutput=syslog
StandardError=syslog

[Install]
WantedBy=multi-user.target

[Unit]
Description=Elasticsearch-head
After=network.target syslog.target

[Service]
Type=simple
WorkingDirectory=/opt/elasticsearch-head
ExecStart=/opt/elasticsearch-head/node_modules/grunt/bin/grunt server
Restart=always
StandardOutput=syslog
StandardError=syslog

[Install]
WantedBy=multi-user.target

chmod 777 /lib/systemd/system/elasticsearch-head.service

systemctl enable elasticsearch-head.service
systemctl daemon-reload

运行
systemctl start elasticsearch-head.service


客户端浏览器打开x.x.x.x:9100
若显示未连接修改http://y.y.y.y:9200为es服务器ip:port


关闭
netstat -anltp|grep 9100
显示LISTEN xxxx/grunt
kill -9 xxxx

 

安装IK Analysis插件
/usr/share/elasticsearch/bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.1.0/elasticsearch-analysis-ik-7.1.0.zip
重启es服务
sudo systemctl restart elasticsearch.service

 

 

 

 

 

守护进程启动文件浏览

vim /usr/lib/systemd/system/elasticsearch.service

[Unit]
Description=Elasticsearch
Documentation=http://www.elastic.co
Wants=network-online.target
After=network-online.target

[Service]
RuntimeDirectory=elasticsearch
PrivateTmp=true
Environment=ES_HOME=/usr/share/elasticsearch
Environment=ES_PATH_CONF=/etc/elasticsearch
Environment=PID_DIR=/var/run/elasticsearch
EnvironmentFile=-/etc/sysconfig/elasticsearch

WorkingDirectory=/usr/share/elasticsearch

User=elasticsearch
Group=elasticsearch

ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet

# StandardOutput is configured to redirect to journalctl since
# some error messages may be logged in standard output before
# elasticsearch logging system is initialized. Elasticsearch
# stores its logs in /var/log/elasticsearch and does not use
# journalctl by default. If you also want to enable journalctl
# logging, you can simply remove the "quiet" option from ExecStart.
StandardOutput=journal
StandardError=inherit

# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65535

# Specifies the maximum number of processes
LimitNPROC=4096

# Specifies the maximum size of virtual memory
LimitAS=infinity

# Specifies the maximum file size
LimitFSIZE=infinity

# Disable timeout logic and wait until process is stopped
TimeoutStopSec=0

# SIGTERM signal is used to stop the Java process
KillSignal=SIGTERM

# Send the signal only to the JVM rather than its control group
KillMode=process

# Java process is never killed
SendSIGKILL=no

# When a JVM receives a SIGTERM signal it exits with code 143
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

# Built for packages-7.1.0 (packages)

转载于:https://www.cnblogs.com/wintersoft/p/10635284.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值