安装elasticsearch
下载es
- 从官网下载es官网
- 点击下载
- 点击esdownload
- 选择最新版本tar右键选择复制链接地址
- 创建文件夹
- 在文件夹中打开命令行窗口输入下面代码下载
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.1.2.tar.gz
注意:wget工具需要在电脑上安装点击查看安装方法wget
- 下载后解压
- 双击elasticsearch.bat 运行
- es 默认端口9200
- 在游览器输入localhost:9200
- 如果显示下面内容说明安装成功
// 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
- 打开GitHub
- 搜索elasticsearch-head
- 选择mobz/elasticsearch-head
- 在这个网站上下载node安装https://npm.taobao.org/
- 安装 grunt
npm install grunt-cli -g
- 在es-head 文件夹下打开命令窗口
- 运行npm install 下载所需要的包
- 运行 es-head
- 在文件夹命令行输入 grunt server
- 默认端口920
- 在浏览器输入http://localhost:9100访问
es 配置es-head 插件
- 修改 config文件夹下的elasticsearch.yml文件
- 在最后面添加
http.cors.enabled: true
http.cors.allow-origin: "*"
- 从新运行启动
es配置分布式集群
配置一个master
- 修改 config文件夹下的elasticsearch.yml文件
- 继续在后面添加
cluster.name: timou
node.name: master
node.master: true
network.host: 127.0.0.1
配置两个随从
- 创建一个master的平衡目录retinue
- 在目录中添加两个es解压文件
- 为没有文件命名为esr1和esr2
- 修改esr1文件的config/elasticsearch.yml文件
- 在文件的后面添加
cluster.name: timou
node.name: esr1
network.host: 127.0.0.1
http.port: 8100
discovery.zen.ping.unicast.hosts: ["127.0.0.1"]
- 修改esr1文件的config/elasticsearch.yml文件
- 在文件的后面添加
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"]