1.安裝
#下載
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-linux-x86_64.tar.gz
#解壓
$ tar -xzf elasticsearch-7.0.0-linux-x86_64.tar.gz
2.配置更改(后續(xù)補充,重要)
./config/elasticsearch.yml es配置
./config/jvm.options 內(nèi)存配置
./config/log4j2.properties 日志配置
2.1.es集群配置(/config/elasticsearch.yml)
- node95
#集群名稱
cluster.name: elasticsearch
#節(jié)點名稱
node.name: node-a
#是不是有資格競選主節(jié)點
node.master: true
#是否存儲數(shù)據(jù)
node.data: true
#最大集群節(jié)點數(shù)
node.max_local_storage_nodes: 3
#網(wǎng)關地址
network.host: 192.168.10.95
#端口
http.port: 9200
#內(nèi)部節(jié)點之間溝通端口
transport.tcp.port: 9300
#es7.x 之后新增的配置笤闯,寫入候選主節(jié)點的設備地址巷帝,在開啟服務后可以被選為主節(jié)點
discovery.seed_hosts: ["node95:9300","node94:9300","node93:9300"]
#es7.x 之后新增的配置,初始化一個新的集群時需要此配置來選舉master
cluster.initial_master_nodes: ["node-a", "node-b","node-c"]
#數(shù)據(jù)存儲路徑
path.data: /home/bigdata/es/data
#日志存儲路徑
path.logs: /home/bigdata/es/logs
- node94
#集群名稱
cluster.name: elasticsearch
#節(jié)點名稱
node.name: node-b
#是不是有資格競選主節(jié)點
node.master: true
#是否存儲數(shù)據(jù)
node.data: true
#最大集群節(jié)點數(shù)
node.max_local_storage_nodes: 3
#網(wǎng)關地址
network.host: 192.168.10.94
#端口
http.port: 9200
#內(nèi)部節(jié)點之間溝通端口
transport.tcp.port: 9300
#es7.x 之后新增的配置,寫入候選主節(jié)點的設備地址济欢,在開啟服務后可以被選為主節(jié)點
discovery.seed_hosts: ["node95:9300","node94:9300","node93:9300"]
#es7.x 之后新增的配置,初始化一個新的集群時需要此配置來選舉master
cluster.initial_master_nodes: ["node-a", "node-b","node-c"]
#數(shù)據(jù)存儲路徑
path.data: /home/bigdata/es/data
#日志存儲路徑
path.logs: /home/bigdata/es/logs
- node93
#集群名稱
cluster.name: elasticsearch
#節(jié)點名稱
node.name: node-c
#是不是有資格競選主節(jié)點
node.master: true
#是否存儲數(shù)據(jù)
node.data: true
#最大集群節(jié)點數(shù)
node.max_local_storage_nodes: 3
#網(wǎng)關地址
network.host: 192.168.10.93
#端口
http.port: 9200
#內(nèi)部節(jié)點之間溝通端口
transport.tcp.port: 9300
#es7.x 之后新增的配置,寫入候選主節(jié)點的設備地址,在開啟服務后可以被選為主節(jié)點
discovery.seed_hosts: ["node95:9300","node94:9300","node93:9300"]
#es7.x 之后新增的配置违寞,初始化一個新的集群時需要此配置來選舉master
cluster.initial_master_nodes: ["node-a", "node-b","node-c"]
#數(shù)據(jù)存儲路徑
path.data: /home/bigdata/es/data
#日志存儲路徑
path.logs: /home/bigdata/es/logs
3.啟動命令
$ nohup ./bin/elasticsearch &
4.節(jié)點驗證
$ curl -XGET 'http://localhost:9200'
{
"name": "master-node95",
"cluster_name": "search7",
"cluster_uuid": "V7ZVyFNeRc29om2md1jU3A",
"version": {
"number": "7.0.0",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "b7e28a7",
"build_date": "2019-04-05T22:55:32.697037Z",
"build_snapshot": false,
"lucene_version": "8.0.0",
"minimum_wire_compatibility_version": "6.7.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}
5.檢查集群
我配置的時候由于有臺機器網(wǎng)卡不止一張,并且把network.host配置成了0.0.0.0,導致沒有通信成功,沒有加入集群
$ curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'
{
"cluster_name" : "elasticsearch",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 2,
"number_of_data_nodes" : 2,
"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
}
notes.
- 檢查集群情況
- ES服務器搭建以及常遇問題處理
集群某個節(jié)點通信問題,導致只有2個節(jié)點
master not discovered or elected yet, an election requires 2
org.elasticsearch.transport.RemoteTransportException: [node-a]
檢查網(wǎng)卡配置,network.host
參數(shù)不要配成0.0.0.0
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
修改但對于已建好的用戶不生效的解決方案- 首先切root賬號,再執(zhí)行
ulimit -SHn 65535 && echo "ulimit -SHn 65535" >> /etc/profile && source /etc/profile
- 然后切換至普通用戶再執(zhí)行啟動命令
- 首先切root賬號,再執(zhí)行