elasticsearch学习(1)-安装elasticsearch和集群

安装elasticsearch

下载es

  1. 从官网下载es官网
  2. 点击下载
  3. 点击esdownload
  4. 选择最新版本tar右键选择复制链接地址
  5. 创建文件夹
  6. 在文件夹中打开命令行窗口输入下面代码下载
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.1.2.tar.gz

注意:wget工具需要在电脑上安装点击查看安装方法wget

  1. 下载后解压
  2. 双击elasticsearch.bat 运行
  3. es 默认端口9200
  4. 在游览器输入localhost:9200
  5. 如果显示下面内容说明安装成功
// 20180130103313
// http://localhost:9200/

{
  "name": "rXo5BsL",
  "cluster_name": "elasticsearch",
  "cluster_uuid": "U13rjr8qSaqzEIBazPd63g",
  "version": {
    "number": "6.1.2",
    "build_hash": "5b1fea5",
    "build_date": "2018-01-10T02:35:59.208Z",
    "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"
}

安装elasticsearch-head

  1. 打开GitHub
  2. 搜索elasticsearch-head
  3. 选择mobz/elasticsearch-head
  4. 在这个网站上下载node安装https://npm.taobao.org/
  5. 安装 grunt
npm install grunt-cli -g
  1. 在es-head 文件夹下打开命令窗口
  2. 运行npm install 下载所需要的包
  3. 运行 es-head
  4. 在文件夹命令行输入 grunt server
  5. 默认端口920
  6. 在浏览器输入http://localhost:9100访问

es 配置es-head 插件

  1. 修改 config文件夹下的elasticsearch.yml文件
  2. 在最后面添加
http.cors.enabled: true
http.cors.allow-origin: "*"
  1. 从新运行启动

es配置分布式集群

配置一个master

  1. 修改 config文件夹下的elasticsearch.yml文件
  2. 继续在后面添加
cluster.name: timou
node.name: master
node.master: true

network.host: 127.0.0.1

配置两个随从

  1. 创建一个master的平衡目录retinue
  2. 在目录中添加两个es解压文件
  3. 为没有文件命名为esr1和esr2
  4. 修改esr1文件的config/elasticsearch.yml文件
  5. 在文件的后面添加
cluster.name: timou
node.name: esr1

network.host: 127.0.0.1
http.port: 8100

discovery.zen.ping.unicast.hosts: ["127.0.0.1"]
  1. 修改esr1文件的config/elasticsearch.yml文件
  2. 在文件的后面添加
cluster.name: timou
node.name: esr2

network.host: 127.0.0.1
http.port: 8200

discovery.zen.ping.unicast.hosts: ["127.0.0.1"]

info

cluster.name: timou  # 集群名
node.name: master  # 节点名
node.master: true  # 指定节点为主节点
network.host: 127.0.0.1  # 网址
http.port: 8200  # 端口

# 自动发现(Discovery)单播配置下,节点向指定的主机发送单播请求

discovery.zen.ping.unicast.hosts: ["127.0.0.1"] 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值