node1 | 192.168.4.192 | es:7.10.2 jdk:1.8 |
node2 | 192.168.4.193 | es:7.10.2 jdk:1.8 |
node3 | 192.168.4.194 | es:7.10.2 jdk:1.8 |
hostnamectl set-hostname node1
hostnamectl set-hostname node2
hsotnamectl set-hostname node3
vim /etc/hosts
192.168.4.192 node1
192.168.4.193 node2
192.168.4.194 node3
tar xf jdk-8u151-linux-x64.gz -C /usr/local/java
vim /etc/profile
export JAVA_HOME=/usr/local/java
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
source /etc/profile
useradd es
mkdir /home/es
tar xf elasticsearch-7.10.2-linux-x86_64.tar.gz -C /home/es
切换目录修改配置文件(三台机器都操作)
cd /home/es/config
#节点 1 的配置信息:
#集群名称,节点之间要保持一致
cluster.name: my-elasticsearch
#节点名称,集群内要唯一
node.name: node1
node.master: true
node.data: true
#ip 地址
network.host: 0.0.0.0
#http 端口
http.port: 9200
#tcp 监听端口
transport.tcp.port: 9201
discovery.seed_hosts: ["192.168.4.192:9201", "192.168.4.193:9201","192.168.4.194:9201"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
#集群内的可以被选为主节点的节点列表
cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
#跨域配置
action.destructive_requires_name: true
http.cors.enabled: true
http.cors.allow-origin: "*"
#节点 2 的配置信息:
#集群名称,节点之间要保持一致
cluster.name: my-elasticsearch
#节点名称,集群内要唯一
node.name: node2
node.master: true
node.data: true
#ip 地址
network.host: 0.0.0.0
#http 端口
http.port: 9200
#tcp 监听端口
transport.tcp.port: 9201
discovery.seed_hosts: ["192.168.4.192:9201", "192.168.4.193:9201","192.168.4.194:9201"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
#集群内的可以被选为主节点的节点列表
cluster.initial_master_nodes: ["node1", "node2","node3"]
action.destructive_requires_name: true
http.cors.enabled: true
http.cors.allow-origin: "*"
#节点 3 的配置信息:
#集群名称,节点之间要保持一致
cluster.name: my-elasticsearch
#节点名称,集群内要唯一
node.name: node3
node.master: true
node.data: true
#ip 地址
network.host: 0.0.0.0
#http 端口
http.port: 9200
#tcp 监听端口
transport.tcp.port: 9201
#候选主节点的地址,在开启服务后可以被选为主节点
discovery.seed_hosts: ["192.168.4.192:9201", "192.168.4.193:9201","192.168.4.194:9201"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
#集群内的可以被选为主节点的节点列表
cluster.initial_master_nodes: ["node1", "node2","node3"]
#跨域配置
action.destructive_requires_name: true
http.cors.enabled: true
http.cors.allow-origin: "*"
chown -R es:es /home/es
su - es
bash /home/es/bin/elasticsearch -d
[elk@node1 analysis-ik]$ ss -tnlp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 [::]:9200 [::]:* users:(("java",pid=5401,fd=287))
LISTEN 0 50 [::]:8080 [::]:*
LISTEN 0 128 [::]:9301 [::]:* users:(("java",pid=5401,fd=285))
LISTEN 0 128 [::]:22 [::]:*
尝试访问集群在浏览器输入
http://192.168.4.192:9200/_cluster/health
#### 返回信息为一下时表示集群搭建成功######
cluster_name "my-elasticsearch"
status "green"
timed_out false
number_of_nodes 3
number_of_data_nodes 3
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
在线安装es的中文分词切换换到/home/es目录下
cd /home/es
[elk@node1 es]$ ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.10.2/elasticsearch-analysis-ik-7.10.2.zip
future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/java/jre] does not meet this requirement
-> Installing https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.10.2/elasticsearch-analysis-ik-7.10.2.zip
-> Downloading https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.10.2/elasticsearch-analysis-ik-7.10.2.zip
[=================================================] 100%
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: plugin requires additional permissions @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.net.SocketPermission * connect,resolve
See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.
Continue with installation? [y/N]y
-> Installed analysis-ik
杀掉相应的端口重新启动查看集群是否正常
[root@node2 plugins]# kill -9 12149
[root@node2 plugins]# su - elk
Last login: Thu Nov 10 21:44:31 EST 2022 on pts/0
[elk@node2 ~]$ bash /home/elk/es/bin/elasticsearch -d
http://192.168.4.192:9200/_cluster/health