http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html
https://github.com/elastic/elasticsearchhtml
一:ES的安裝
###【在多臺機器上執行下面的命令】###
#es啓動時須要使用非root用戶,全部建立一個bigdata用戶:
useradd bigdata
#爲hadoop用戶添加密碼:
echo 123456 | passwd --stdin bigdata
#將bigdata添加到sudoers
echo "bigdata ALL = (root) NOPASSWD:ALL" | tee /etc/sudoers.d/bigdata
chmod 0440 /etc/sudoers.d/bigdata
#解決sudo: sorry, you must have a tty to run sudo問題,在/etc/sudoer註釋掉 Default requiretty 一行
sudo sed -i 's/Defaults requiretty/Defaults:bigdata !requiretty/' /etc/sudoersjava
#建立一個bigdata目錄
mkdir /{bigdata,data}
#給相應的目錄添加權限
chown -R bigdata:bigdata /{bigdata,data}node
-------------------------------------------------------------------------------------------------
We recommend installing the Java 8 update 20 or later, or Java 7 update 55 or later.
Previous versions of Java 7 are known to have bugs that can cause index corruption and data loss.
Elasticsearch will refuse to start if a known-bad version of Java is used.
###【切換到bigdata用戶安裝】###
1.安裝jdk(jdk要求1.8.20或1.7.55以上)git
2.上傳es安裝包github
3.解壓es
tar -zxvf elasticsearch-2.3.1.tar.gz -C /bigdata/數據庫
4.修改配置
vi /bigdata/elasticsearch-2.3.1/config/elasticsearch.yml
#集羣名稱,經過組播的方式通訊,經過名稱判斷屬於哪一個集羣
cluster.name: bigdata
#節點名稱,要惟一
node.name: es-1
#數據存放位置
path.data: /data/es/data
#日誌存放位置
path.logs: /data/es/logs
#es綁定的ip地址
network.host: 172.16.0.14
#初始化時可進行選舉的節點
discovery.zen.ping.unicast.hosts: ["node-4.itcast.cn", "node-5.itcast.cn", "node-6.itcast.cn"]瀏覽器
5.使用scp拷貝到其餘節點
scp -r elasticsearch-2.3.1/ node-5.itcast.cn:$PWD
scp -r elasticsearch-2.3.1/ node-6.itcast.cn:$PWDelasticsearch
6.在其餘節點上修改es配置,須要修改的有node.name和network.hostide
7.啓動es(/bigdata/elasticsearch-2.3.1/bin/elasticsearch -h查看幫助文檔)
/bigdata/elasticsearch-2.3.1/bin/elasticsearch -doop
8.用瀏覽器訪問es所在機器的9200端口
http://172.16.0.14:9200/
{
"name" : "es-1",
"cluster_name" : "bigdata",
"version" : {
"number" : "2.3.1",
"build_hash" : "bd980929010aef404e7cb0843e61d0665269fc39",
"build_timestamp" : "2016-04-04T12:25:05Z",
"build_snapshot" : false,
"lucene_version" : "5.5.0"
},
"tagline" : "You Know, for Search"
}
kill `ps -ef | grep Elasticsearch | grep -v grep | awk '{print $2}'`
------------------------------------------------------------------------------------------------------------------
#es安裝插件下載es插件
/bigdata/elasticsearch-2.3.1/bin/plugin install mobz/elasticsearch-head
#本地方式安裝head插件
./plugin install file:///home/bigdata/elasticsearch-head-master.zip
#訪問head管理頁面
http://172.16.0.14:9200/_plugin/head
RESTful接口URL的格式:
http://localhost:9200/<index>/<type>/[<id>]
其中index、type是必須提供的。
id是可選的,不提供es會自動生成。
index、type將信息進行分層,利於管理。
index能夠理解爲數據庫;type理解爲數據表;id至關於數據庫表中記錄的主鍵,是惟一的。
//關於在安裝es的過程當中出現的問題
Exception in thread "main" BindTransportException[Failed to bind to [9300-9400]]; nested: ChannelException[Failed to bind to: /192.168.0.1:9400]; nested: BindException[Cannot assign requested address];
Likely root cause: java.net.BindException: Cannot assign requested address
解決方案:
打開配置文件elasticsearch.yml 將 network.host: 192.168.0.1 修改成本機IP 0.0.0.0
經過root用戶啓動elasticsearch而且在後臺運行./elasticsearch -Des.insecure.allow.root=true -d