说明
- 基于Elasticsearch7.10.2 的 opensearch-1.1.0
硬件服务器
- 10.168.2.87
- 10.168.2.88
- 10.168.2.89
1.环境准备 (每台都需要做)
1.1创建用户(root用户操作)
- useradd top
1.2 修改用户密码(root用户操作)
- passwd top
1.3 赋予用户sudo权限(root用户操作)
-
修改命令
1chmod -v u+w /etc/sudoers 2sed -i 's#.*top.*##g' /etc/sudoers 3sed -i 's#root.*ALL=(ALL).*ALL#root ALL=(ALL) ALL \ntop ALL=(ALL) ALL#g' /etc/sudoers 4chmod -v u-w /etc/sudoers
1.4 安全limits文件限制
-
修改文件
1vim /etc/security/limits.conf
-
增加的内容
1* soft nofile 65536 2* hard nofile 65536
最后几行加上 需要增加的部分
1.5 系统文件限制
-
修改文件
1vim /etc/sysctl.conf
-
增加的内容
1vm.max_map_count=655360
最后几行加上 需要增加的部分(最后几行加上)
1.6 载入指定配置
-
修改文件
1[top@node85 .ssh]$ sudo sysctl -p 2[sudo] top 的密码: 3vm.max_map_count = 655360
-
结果如图
1.7 重启
-
执行命令
1sudo reboot
2.opensearch安装参考
2.1 下载安装包:
-
执行命令
1mkdir /home/top/opensearch 2cd /home/top/opensearch 3wget http://10.168.2.60:35000/opensearch-1.1.0-linux-x64.tar.gz
3.OpenS安装
3.1 解压OpenS安装包
-
执行命令
1cd /home/top/opensearch 2tar -xzvf opensearch-1.1.0-linux-x64.tar.gz
3.2 创建数据目录、日志目录
-
执行命令
1mkdir /home/top/opensearch/data -p 2mkdir /home/top/opensearch/logs -p
3.3 删除安装包
-
执行命令
1rm -rf opensearch-1.1.0-linux-x64.tar.gz 2ln -s opensearch-1.1.0/ opensearch
3.4分发配置及安装目录
-
执行命令
1rsync -avl /home/top/opensearch u86:/home/top 2rsync -avl /home/top/opensearch u87:/home/top
-
或者
1rsync -avl /home/top/opensearch top@10.168.2.86:/home/top/ 2rsync -avl /home/top/opensearch top@10.168.2.87:/home/top/
4. OpenS节点配置
4.1、 opensearch-master(10.168.2.85 )
-
cat /home/top/opensearch/opensearch/config/opensearch.yml
1# ---------------------------------- Cluster ----------------------------------- 2# 3# Use a descriptive name for your cluster: 4# 5cluster.name: opensearch-cluster 6# 7# ------------------------------------ Node ------------------------------------ 8# 9# Use a descriptive name for the node: 10# 11node.name: opensearch-master 12node.master: true #专用的主节点 13node.data: false # 不是子节点 14node.ingest: false # 不是摄取节点 (通道) 15# 16# Add custom attributes to the node: 17# 18#node.attr.rack: r1 19# 20# ----------------------------------- Paths ------------------------------------ 21# 22# Path to directory where to store the data (separate multiple locations by comma): 23# 24path.data: /home/top/opensearch/data 25# 26# Path to log files: 27# 28path.logs: /home/top/opensearch/logs 29 30#将集群绑定到特定的 IP 地址 31network.host: node85 32 33#为集群配置发现主机 34discovery.seed_hosts: ["node86","node87","node88"] 35cluster.initial_master_nodes: opensearch-master 36#禁用安全 37plugins.security.disabled: true 38 39#discovery.type: cluster
4.2、opensearch-d1 (10.168.2.86)
- cat /home/top/elasticsearch-7.10.2/config/elasticsearch.yml
1
2#
3# ---------------------------------- Cluster -----------------------------------
4#
5# Use a descriptive name for your cluster:
6#
7cluster.name: opensearch-cluster
8#
9# ------------------------------------ Node ------------------------------------
10#
11# Use a descriptive name for the node:
12#
13node.name: opensearch-d1
14node.master: true
15node.data: true
16node.ingest: true
17#
18# Add custom attributes to the node:
19#
20#node.attr.rack: r1
21#
22# ----------------------------------- Paths ------------------------------------
23#
24# Path to directory where to store the data (separate multiple locations by comma):
25#
26path.data: /home/top/opensearch/data
27# Path to log files:
28#
29path.logs: /home/top/opensearch/logs
30
31#将集群绑定到特定的 IP 地址
32network.host: node86
33
34
35#为集群配置发现主机
36discovery.seed_hosts: ["node85","node87","node88"]
37cluster.initial_master_nodes: opensearch-master
38#禁用安全
39plugins.security.disabled: true
4.3、opensearch-d2(10.168.2.87)
- cat /home/top/elasticsearch-7.10.2/config/elasticsearch.yml
1
2#
3# ---------------------------------- Cluster -----------------------------------
4#
5# Use a descriptive name for your cluster:
6#
7cluster.name: opensearch-cluster
8#
9# ------------------------------------ Node ------------------------------------
10#
11# Use a descriptive name for the node:
12#
13node.name: opensearch-d2
14node.master: true
15node.data: true
16node.ingest: true
17#
18# Add custom attributes to the node:
19#
20#node.attr.rack: r1
21#
22# ----------------------------------- Paths ------------------------------------
23#
24# Path to directory where to store the data (separate multiple locations by comma):
25#
26path.data: /home/top/opensearch/data
27#
28# Path to log files:
29#
30path.logs: /home/top/opensearch/logs
31
32
33#将集群绑定到特定的 IP 地址
34network.host: node87
35
36#为集群配置发现主机
37discovery.seed_hosts: ["node85", "node86","node88"]
38cluster.initial_master_nodes: opensearch-master
39#禁用安全
40plugins.security.disabled: true
4.4、opensearch-c1 (10.168.2.88)
- cat /home/top/elasticsearch-7.10.2/config/elasticsearch.yml
1
2#
3# ---------------------------------- Cluster -----------------------------------
4#
5# Use a descriptive name for your cluster:
6#
7cluster.name: opensearch-cluster
8#
9# ------------------------------------ Node ------------------------------------
10#
11# Use a descriptive name for the node:
12# 协调节点
13node.name: opensearch-c1
14node.master: false
15node.data: false
16node.ingest: false
17
18
19# Path to directory where to store the data (separate multiple locations by comma):
20#
21path.data: /home/top/opensearch/data
22#
23# Path to log files:
24#
25path.logs: /home/top/opensearch/logs
26
27#将集群绑定到特定的 IP 地址
28network.host: node88
29
30
31#为集群配置发现主机
32discovery.seed_hosts: ["node85","node86","node87"]
33cluster.initial_master_nodes: opensearch-master
34#禁用安全
35plugins.security.disabled: true
5. 启动OpenS集群
- 此操作需要在各个节点上运行
1/home/top/opensearch/opensearch/bin/opensearch -d -p /home/top/opensearch/pid >/dev/null 2>&1 &
6. 检测是否启动完成集群
- [top@localhost ~]$ curl -X GET 'http://10.168.2.85:9200/'
- {
"name": "node85",
"cluster_name": "es-top",
"cluster_uuid": "v7M5HemdSvmFjVPhEAlhig",
"version": {
"number": "7.10.2",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "93d5a7f6192e8a1a12e154a2b81bf6fa7309da0c",
createTime: 2021-11-30T19:13:45+08:00
updateTime: 2021-11-30T19:13:45+08:00
"build_snapshot": false,
"lucene_version": "8.9.0",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
} -
- 其他
根据当前机器的大小修改分配给es的内存
- 文件位置:vim /home/top/es/elasticsearch-7.10.2/config/jvm.options
-Xms1g =>修改成想要的内存数
-Xmx1g =>修改成想要的内存数