设为首页 收藏本站
查看: 1350|回复: 0

[经验分享] 安装部署elasticsearch过程详解

[复制链接]

尚未签到

发表于 2019-1-29 09:14:10 | 显示全部楼层 |阅读模式
环境准备:
  服务器:centos7服务器1台,IP:10.0.0.103
安装包:
elasticsearch-6.1.1.tar.gz
jdk-8u151-linux-x64.tar.gz

[root@node2 ~]# ll
-rw-r--r--  1 root root  33783880 6月   3 11:18 elasticsearch-6.1.1.tar.gz
-rw-r--r--  1 root root 189736377 6月   3 11:23 jdk-8u151-linux-x64.tar.gz
[root@docker ~]#
安装JDK
  elasticsearch需要依赖JDK,因此首先要安装JDK:
1、解压安装包

[root@node2 ~]# tar xf jdk-8u151-linux-x64.tar.gz -C /usr/local/
  2、安装jdk修改/etc/profile,在文件末尾加入下面几句:

export JAVA_HOME=/usr/local/jdk1.8.0_151   #根据目录和版本修改
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export  PATH=${JAVA_HOME}/bin:$PATH
  3、source命令让修改后的/etc/profile生效:

[root@node2 ~]# source /etc/profile
  4、检查安装正确性:

[root@node2 ~]# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
[root@node2 ~]#
安装elasticsearch
  1、解压文件

[root@node2 ~]# tar -xf elasticsearch-6.1.1.tar.gz -C /usr/local  ##解压
[root@node2 ~]# cd /usr/local/elasticsearch-6.1.1
[root@node2 elasticsearch-6.1.1]# ls
bin  config  lib  LICENSE.txt  modules  NOTICE.txt  plugins  README.textile
  2、修改配置如下(根据实际情况调整)

[root@node2 config]# cat elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: mycluster   #配置ES集群名字
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1  #配置节点名字
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /opt/elk/data     #配置数据路径
#
# Path to log files:
#
path.logs: /opt/elk/logs     #配置日志路径
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 10.0.0.103     #配置为本地ip,监听主机
#
# Set a custom port for HTTP:
#
http.port: 9200   #设置对外服务的http端口
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
discovery.zen.minimum_master_nodes: 1    #设置这个参数来保证集群中的节点可以知道其它N个有master资格的节点。默认为1,对于大的集群来说,可以设置大一点的值(2-4)。我这里只有一台,所以设置为1
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
  3、修改系统配置文件:
修改之前最好先备份:

[root@node2 elasticsearch-6.1.1]# cp /etc/security/limits.conf  /etc/security/limits.conf.bak
[root@node2 elasticsearch-6.1.1]# cp /etc/sysctl.conf /etc/sysctl.conf.bak
  vi /etc/security/limits.conf 
在文件末尾添加如下内容:

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
  vi /etc/sysctl.conf 
添加下面配置:

vm.max_map_count=655360
  并执行命令sysctl -p让其修改生效:

[root@node2 elasticsearch-6.1.1]# sysctl -p
vm.max_map_count = 655360
  4、创建启动elasticsearch的用户和日志目录,修改权限:

[root@node2 elasticsearch-6.1.1]# cd /usr/local
[root@node2 local]# useradd elk
[root@node2 local]# mkdir /opt/elk/logs -p
[root@node2 local]# mkdir /opt/elk/data -p
[root@node2 local]# chown -R elk:elk /opt/elk/
[root@node2 local]# chown -R elk:elk /usr/local/elasticsearch-6.1.1
  5、启动服务

[root@node2 config]# su elk
[elk@node2 config]$ nohup /usr/local/elasticsearch-6.1.1/bin/elasticsearch >/dev/null 2>&1 &

  6、服务验证:
1)查看进程和端口号:

[root@node2 config]# netstat -tlunp|grep 9200
tcp6       0      0 10.0.0.103:9200         :::*                    LISTEN      6665/java           
[root@node2 config]# ps -ef|grep elasticsearch
elk        6665      1  4 15:10 pts/0    00:01:17 /usr/local/jdk1.8.0_151/bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -XX:+HeapDumpOnOutOfMemoryError -Des.path.home=/usr/local/elasticsearch-6.1.1 -Des.path.conf=/usr/local/elasticsearch-6.1.1/config -cp /usr/local/elasticsearch-6.1.1/lib/* org.elasticsearch.bootstrap.Elasticsearch
root       6769   3724  0 15:37 pts/0    00:00:00 grep --color=auto elas
  2)命令行验证:

[root@node2 config]# curl http://10.0.0.103:9200
{
"name" : "node-1",
"cluster_name" : "elk",
"cluster_uuid" : "gv8DzvZeR1W-aOM_UTEdVA",
"version" : {
"number" : "6.1.1",
"build_hash" : "bd92e7f",
"build_date" : "2017-12-17T20:23:25.338Z",
"build_snapshot" : false,
"lucene_version" : "7.1.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
[root@node2 config]#
  3)浏览器访问验证:

  看到上述的结果,一个elasticsearch就安装OK了




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-668988-1-1.html 上篇帖子: logstash日志收集分析系统elasticsearch&kibana 下篇帖子: elasticsearch 启动时指定jdk版本
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表