Spark學習筆記(18)—— Elasticsearch 安裝
阿新 • • 發佈:2018-11-06
1 解壓
[[email protected] ~]$ ll
total 42708
drwxrwxr-x. 9 hadoop hadoop 180 Oct 24 21:33 apps
-rw-r--r--. 1 hadoop hadoop 27540442 Jun 10 2017 elasticsearch-2.3.1.tar.gz
drwxrwxr-x. 4 hadoop hadoop 28 Sep 14 19:02 hbase
drwxrwxr-x. 4 hadoop hadoop 32 Sep 14 14:44 hdfsdir
-rw-r--r--. 1 hadoop hadoop 16162559 Jun 24 12:55 kafka_2.10-0.8.2.1.tgz
drwxrwxrwx. 3 hadoop hadoop 18 Oct 24 21:45 kafkaData
-rw-rw-r--. 1 hadoop hadoop 0 Oct 24 21:58 log-cleaner.log
drwxrwxr-x. 5 hadoop hadoop 133 Oct 23 14:40 metastore_db
drwxrwxr-x. 3 hadoop hadoop 63 Oct 24 21:21 zookeeperData
-rw-rw-r--. 1 hadoop hadoop 26108 Oct 25 17:54 zookeeper.out
[ [email protected] ~]$ tar -zxvf elasticsearch-2.3.1.tar.gz -C /home/hadoop/apps/
2 修改配置檔案 elasticsearch.yml
/home/hadoop/apps/elasticsearch-2.3.1/config
#叢集名稱,通過組播的方式通訊,通過名稱判斷屬於哪個叢集 cluster.name: TzbBigData #節點名稱,要唯一 node.name: node-1 #資料存放位置 path.data: /home/hadoop/elasticsearchData/data #日誌存放位置 path.logs: /home/hadoop/elasticsearchData/logs #es繫結的ip地址 network.host: 192.168.30.131 #初始化時可進行選舉的節點 discovery.zen.ping.unicast.hosts: ["node1", "node2","node3"]
3 拷貝到其他節點
scp -r /home/hadoop/apps/elasticsearch-2.3.1/ node2:/home/hadoop/apps
scp -r /home/hadoop/apps/elasticsearch-2.3.1/ node3:/home/hadoop/apps
修改node2,node3 的配置檔案的 node.name和network.host
4 啟動
es 啟動時要求非 root 使用者
三個節點同時操作
/home/hadoop/apps/elasticsearch-2.3.1/bin/elasticsearch -d
瀏覽器訪問 http://node1:9200/
5 測試
RESTful介面URL的格式:
http://localhost:9200/<index>/<type>/[<id>]
其中index、type是必須提供的。
id是可選的,不提供es會自動生成。
index、type將資訊進行分層,利於管理。
index可以理解為資料庫;type理解為資料表;id相當於資料庫表中記錄的主鍵,是唯一的。
在命令列用 curl ,新增資料
curl -XPUT 'http://node1:9200/store/books/1' -d '{
"title": "Elasticsearch: The Definitive Guide",
"name" : {
"first" : "Zachary",
"last" : "Tong"
},
"publish_date":"2018-10-25",
"price":"49.99"
}'
5.1 獲取資料
瀏覽器訪問 http://node1:9200/store/books/1
curl -XGET 'http://node1:9200/store/books/1'
6 es 離線安裝外掛
[[email protected] ~]$ ll
total 908
drwxrwxr-x. 10 hadoop hadoop 207 Oct 25 21:49 apps
drwxrwxr-x. 4 hadoop hadoop 30 Oct 25 21:59 elasticsearchData
-rw-r--r--. 1 hadoop hadoop 899399 Jun 10 2017 elasticsearch-head-master.zip
drwxrwxr-x. 4 hadoop hadoop 28 Sep 14 19:02 hbase
drwxrwxr-x. 4 hadoop hadoop 32 Sep 14 14:44 hdfsdir
drwxrwxrwx. 3 hadoop hadoop 18 Oct 24 21:45 kafkaData
-rw-rw-r--. 1 hadoop hadoop 0 Oct 24 21:58 log-cleaner.log
drwxrwxr-x. 5 hadoop hadoop 133 Oct 23 14:40 metastore_db
drwxrwxr-x. 3 hadoop hadoop 63 Oct 24 21:21 zookeeperData
-rw-rw-r--. 1 hadoop hadoop 26108 Oct 25 17:54 zookeeper.out
[[email protected] ~]$ cd /home/hadoop/apps/elasticsearch-2.3.1/bin
[[email protected] bin]$ ./plugin install file:///home/hadoop/elasticsearch-head-master.zip
-> Installing from file:/home/hadoop/elasticsearch-head-master.zip...
Trying file:/home/hadoop/elasticsearch-head-master.zip ...
Downloading .........DONE
Verifying file:/home/hadoop/elasticsearch-head-master.zip checksums if available ...
NOTE: Unable to verify checksum for downloaded plugin (unable to find .sha1 or .md5 file to verify)
Installed head into /home/hadoop/apps/elasticsearch-2.3.1/plugins/head
[[email protected] bin]$
瀏覽器訪問 http://node1:9200/_plugin/head/