centos7下elasitcsearch7安装

Posted loswing

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7下elasitcsearch7安装相关的知识,希望对你有一定的参考价值。

1、下载
oracle java11.rpm
es7.2.rpm
kibana.rpm
下载个: https://github.com/lmenezes/cerebro 后面配置要简单的多
chrome 下载个 header插件,

 

 
2、准备环境
#追加 /etc/security/limits.conf
echo " " >> /etc/security/limits.conf
echo "#elasticsearch bootstrap lock" >> /etc/security/limits.conf
echo "elasticsearch soft memlock unlimited" >> /etc/security/limits.conf
echo "elasticsearch hard memlock unlimited" >> /etc/security/limits.conf
echo "#下面这个可以替代下面2个" >> /etc/security/limits.conf
echo "elasticsearch - memlock unlimited" >> /etc/security/limits.conf
echo "#elasticsearch limit file" >> /etc/security/limits.conf
echo "* soft nofile 65536" >> /etc/security/limits.conf
echo "* hard nofile 65536" >> /etc/security/limits.conf

 

 
# 追加
echo "#elasticsearch counts" >> /etc/sysctl.conf
echo "vm.max_map_count = 262144" >> /etc/sysctl.conf
 
#修改 用户的limit
cd /etc/security/limits.d
ls
##看看,数字开头的。。。xx-nproc.conf 把下面改下
echo "#elasticsearch thread limit"
echo "elasticsearch - nproc 2048" >> /etc/security/limits.d/20-nproc.conf
#生效
sysctl
-p

 

#修改下 这个不然rpm 安装的还是报错 bootstrap lock xxx
## 细节看https://www.elastic.co/guide/en/elasticsearch/reference/current/setting-system-settings.html#systemd
 
在/etc/systemd/system/elasticsearch.service.d目录下创建一个文件override.conf,(或者sudo systemctl edit elasticsearch ,我用了这个)并添加下列内容
[Service]
LimitMEMLOCK=infinity
生效 
sudo systemctl daemon-reload 
 
#创建目录
mkdir /opt/hdisk/es72/data
mkdir /opt/hdisk/es72/logs
chown -R elasticsearch:elasticsearch /opt/hdisk/es72
 
3、安装
#java
rpm -ivh java11.rpm
 
#看看安装在哪里
cd /usr/java .
ll -s

一般default 会已经指向你新安装的java11了

 
vi /etc/profile
##最后追加环境
export JAVA_HOME=/usr/java/default
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib
export PATH=:$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
 
#es7
rpm -ivh es72.rpm
##自动启动
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service

 

 
#在master 上安装 kibana
rpm -ivh kibana.rpm
##自动启动
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable kibana.service

  

4、配置
#es
1个主,2个数据节点
 
##master
 
vi /etc/elasticsearch/elasticsearch.conf
#
# ---------------------------------- Cluster -----------------------------------
#
cluster.name: es72clt
#
# ------------------------------------ Node ------------------------------------
#
node.name: node237
#主节点,
node.master: true
#主节点,就不要存数据了
node.data: false
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
path.data: /opt/hdisk/es72/data
path.logs: /opt/hdisk/es72/logs
#
# ----------------------------------- Memory -----------------------------------
#
bootstrap.memory_lock: true
#
#
# ---------------------------------- Network -----------------------------------
#
network.host: 0.0.0.0
#http.port: 9200
#
# --------------------------------- Discovery ----------------------------------
#
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#主节点才有这行
cluster.initial_master_nodes: ["192.168.1.237:9300"]
#7.2,是数据节点自己去主节点上注册,和以前不一样
discovery.seed_hosts: ["192.168.1.237:9300"]
#
#
# ---------------------------------- Gateway -----------------------------------
#
#
#gateway.recover_after_nodes: 3
#
#
# ---------------------------------- Various -----------------------------------
#
#action.destructive_requires_name: true
# ---------------------------------- xpack -----------------------------------
#
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
 

 

 
##node1
vi /etc/elasticsearch/elasticsearch.conf
#
# ---------------------------------- Cluster -----------------------------------
#
cluster.name: es72clt
#
# ------------------------------------ Node ------------------------------------
#
node.name: node238
#主节点,
node.master: false
#主节点,就不要存数据了
node.data: true
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
path.data: /opt/hdisk/es72/data
path.logs: /opt/hdisk/es72/logs
#
# ----------------------------------- Memory -----------------------------------
#
bootstrap.memory_lock: true
#
#
# ---------------------------------- Network -----------------------------------
#
network.host: 0.0.0.0
#http.port: 9200
#
# --------------------------------- Discovery ----------------------------------
#
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#主节点才有这行
#cluster.initial_master_nodes: ["192.168.1.237:9300"]
#7.2,是数据节点自己去主节点上注册,和以前不一样
discovery.seed_hosts: ["192.168.1.237:9300"]
#
#
# ---------------------------------- Gateway -----------------------------------
#
#
#gateway.recover_after_nodes: 3
#
#
# ---------------------------------- Various -----------------------------------
#
#action.destructive_requires_name: true
# ---------------------------------- xpack -----------------------------------
#
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
 
##xpack 认证安装
###找到master (node237)
####执行
/usr/share/elasticsearch/bin/elasticsearch-certutil -out /etc/elasticsearch/elastic-certificates.p12 -pass ""
 
####拷贝认证到其他机器上
scp 192.168.1.237:/etc/elasticsearch/elastic-certificates.p12 /etc/elasticsearch/
 
####所有机器上改权限
chown -R /etc/elasticsearch/elastic-certificates.p12

 

 
#jvm 这个还没有测试
vi /etc/elasticsearch/jvm.opitons
 
##设置成为机器内存的一半,这个我一般怎么干,es7的版本不知道了
-Xms16g
-Xmx16g

 

 
4、启动
如果你运气够好
#sudo systemctl start elasticsearch.service
service elasticsearch start

如果运气一般么,自己google

tail -100 /opt/hdisk/es72/logs/es72ctl.log

 
5、设置密码
主机上
###到主机上,生成密码
####!!一旦主节点开始运行,便可以为集群设置密码了
/usr/share/elasticsearch/bin/elasticsearch-setup-passwords auto
#### !!拷贝下来

 

 主机上
vi /etc/kibana/ikbana.conf
##找到用户名密码哪里,把上面的生成的kibana密码输入到里面
#sudo systemctl start kibana.service
service kibana start

 

 自己机器上测试下
###登陆 http://192.168.1.237:5601
##输入 用户:elastic 密码: 生成的密码里面找 .
##进去以后就可以管理用户了
 

以上是关于centos7下elasitcsearch7安装的主要内容,如果未能解决你的问题,请参考以下文章

一文教你在 centos7 下安装 Oracle19 C(完整版)

centos7下安装ORACLE 12C-系统环境配置

CentOS7下Nginx的安装配置

Linux下vsftp的安装和使用:Centos7

centos7下 mapnik python-mapnk 环境准备及安装

centos7下 mapnik python-mapnk 环境准备及安装