1.所有节点都安装:
yum -y install java-1.8.0-openjdk
yum -y install elasticsearch
2.主机名解析:
vim /etc/hosts
192.168.1.11 es1
192.168.1.12 es2
192.168.1.13 es3
192.168.1.14 es4
192.168.1.15 es5
for i in {11..15}
>do
>scp /etc/hosts 192.168.1.$i:/etc/hosts
>done
3.修改配置文件:
vim /etc/elasticsearch/elasticsearch.yml
cluster.name: nsd1804 //集群名
node.name: es1 //主机在集群的名称
network.host: 0.0.0.0 //主机的网络
discovery.zen.ping.unicast.hosts: ["es1", "es2","es3"] //集群的成员
4.同步配置文件:
[root@es1 ~]# for i in {11..15}
> do
> scp /etc/elasticsearch/elasticsearch.yml 192.168.1.$i:/etc/elasticsearch/elasticsearch.yml
> done
for i in es{1..5}
>do
>ssh es$i systemctl restart elasticsearch
>done
修改node.name: 主机名(vim /etc/elasticsearch/elasticsearch.yml)
5.测试集群状态:
[root@es1 ~]# curl http://192.168.1.11:9200/_cluster/health?pretty
{
"cluster_name" : "nsd1804",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 5,
"number_of_data_nodes" : 5,
"active_primary_shards" : 0,
"active_shards" : 0,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
– 返回字段解析
– status“ : ”green“ 集群状态,绿色为正常,黄色表示有问题但不是很严重,红色表示严重故障
– “number_of_nodes” : 5, 表示集群中节点的数量
– "number_of_data_nodes" : 5,
http的协议:
http 的请求三部分:
– 分别是:请求行、消息报头、请求正文
– 请求行以一个方法符号开头,以空格分开,后面跟着请求的URI和协议的版本,格式如下:
Method Request-URI HTTP-Version CRLF
ES 常用
– PUT--- 改
– DELETE --- 删
– POST --- 增
– GET --- 查
系统命令 curl
• curl 常用参数介绍
– -A 修改请求 agent
– -X 设置请求方法
– -i 显示返回头信息
[root@es1 ~]# curl -I http://www.taobao.com
HTTP/1.1 302 Found
Server: Tengine
Date: Tue, 28 Aug 2018 02:35:46 GMT
Content-Type: text/html
Content-Length: 258
Connection: keep-alive
Location: https://www.taobao.com/
Set-Cookie: thw=cn; Path=/; Domain=.taobao.com; Expires=Wed, 28-Aug-19 02:35:46 GMT;
Strict-Transport-Security: max-age=31536000
[root@es1 ~]# curl -I www.cnithr.com
HTTP/1.1 302 Found
Date: Tue, 28 Aug 2018 02:36:28 GMT
Server: Apache
Set-Cookie: Webtrends=58.62.92.41.1535423788575741; path=/; expires=Mon, 26-Nov-18 02:36:28 GMT
location: http://it.800hr.com/
Cache-Control: max-age=0
Expires: Tue, 28 Aug 2018 02:36:28 GMT
Cluster_id: IDC_WEB_246
Vary: User-Agent,Accept-Encoding
Content-Type: text/html
Content-Language: zh-CN