es 集群部署
下载
1 | [root@localhost ~] # wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.1.rpm |
jdk 安装
1 | [root@localhost ~] # yum -y install jdk-8u171-linux-x64.rpm |
安装es
1 | [root@localhost ~] # yum -y install elasticsearch-6.5.1.rpm |
创建data与logs目录
1 2 3 4 | [root@localhost ~] # mkdir -pv /es/{data,logs} mkdir : 已创建目录 "/es" mkdir : 已创建目录 "/es/data" mkdir : 已创建目录 "/es/logs" |
修改目录属主属组
1 | [root@localhost ~] # chown elasticsearch:elasticsearch /es -R |
备份修改配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | [root@localhost ~] # cp -a /etc/elasticsearch/elasticsearch.yml{,.bak} 1节点配置 [root@localhost ~] # egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml cluster.name: es node.name: es-1 path.data: /es/data path.logs: /es/logs network.host: 192.168.10.31 http.port: 9200 http.cors.enabled: true http.cors.allow-origin: "*" node.master: true node.data: true discovery.zen. ping .unicast.hosts: [ "192.168.10.31" , "192.168.10.60" ] 2节点配置 [root@localhost ~] # egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml cluster.name: es node.name: es-2 path.data: /data/es path.logs: /data/logs network.host: 192.168.10.60 discovery.zen. ping .unicast.hosts: [ "192.168.10.31" , "192.168.10.60" ] |
启动服务
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | [root@localhost ~] # systemctl start elasticsearch.service [root@localhost ~] # systemctl status elasticsearch.service ● elasticsearch.service - Elasticsearch Loaded: loaded ( /usr/lib/systemd/system/elasticsearch .service; disabled; vendor preset: disabled) Active: active (running) since 三 2018-12-05 16:30:08 CST; 25s ago Docs: http: //www .elastic.co Main PID: 3926 (java) CGroup: /system .slice /elasticsearch .service └─3926 /bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless= tr ... 12月 05 16:30:08 localhost.localdomain systemd[1]: Started Elasticsearch. 12月 05 16:30:08 localhost.localdomain systemd[1]: Starting Elasticsearch... [root@localhost ~] # systemctl status elasticsearch.service ● elasticsearch.service - Elasticsearch Loaded: loaded ( /usr/lib/systemd/system/elasticsearch .service; disabled; vendor preset: disabled) Active: active (running) since 三 2018-12-05 16:29:50 CST; 1min 8s ago Docs: http: //www .elastic.co Main PID: 3883 (java) CGroup: /system .slice /elasticsearch .service ├─3883 /bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless= tr ... └─3947 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller 12月 05 16:29:50 localhost.localdomain systemd[1]: Started Elasticsearch. 12月 05 16:29:50 localhost.localdomain systemd[1]: Starting Elasticsearch... |
安装node环境
1 2 3 4 5 6 7 8 | mkdir /opt/es/node -pv cd /opt/es/node/ wget https: //npm .taobao.org /mirrors/node/v8 .1.4 /node-v8 .1.4-linux-x64. tar .gz tar xf node-v8.1.4-linux-x64. tar .gz vim /etc/profile .d /node .sh export NODE_HOME= /opt/es/node/node-v8 .1.4-linux-x64 export PATH=$NODE_HOME /bin :$PATH . /etc/profile .d /node .sh |
安装haed插件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | cd wget https: //github .com /mobz/elasticsearch-head/archive/master .zip yum -y install unzip unzip master.zip cd elasticsearch- head -master/ [root@localhost elasticsearch- head -master] # vim Gruntfile.js 79 files: [ 'src/**/*' , 'test/spec/*' ], 80 tasks: [ 'default' ], 81 options: { 82 spawn: false 83 } 84 }, 85 "grunt" : { 86 files: [ 'Gruntfile.js' ] 87 } 88 }, 89 90 connect: { 91 server: { 92 options: { 93 port: 9100, 94 hostname : '0.0.0.0' , 添加此行 95 base: '.' , 96 keepalive: true 97 } 98 } 99 } 100 101 }); [root@localhost elasticsearch- head -master] # cd _site/ [root@localhost _site] # vim app.js 4339 4340 })( this.jQuery, this.app, this.i18n ); 4341 4342 ( function ( app, i18n ) { 4343 4344 var ui = app.ns( "ui" ); 4345 var services = app.ns( "services" ); 4346 4347 app.App = ui.AbstractWidget.extend({ 4348 defaults: { 4349 base_uri: null 4350 }, 4351 init: function (parent) { 4352 this._super(); 4353 this.prefs = services.Preferences.instance(); 4354 this.base_uri = this.config.base_uri || this.prefs.get( "app-base_uri" ) || "http://192.168.10.31:9200" ; 设置1节点IP 4355 if ( this.base_uri.charAt( this.base_uri.length - 1 ) !== "/" ) { 4356 // XHR request fails if the URL is not ending with a "/" 4357 this.base_uri += "/" ; 4358 } 4359 if ( this.config.auth_user ) { 4360 var credentials = window.btoa( this.config.auth_user + ":" + this.config.auth_password ); 4361 $.ajaxSetup({ 4362 headers: { 4363 "Authorization" : "Basic " + credentials 4364 } 4365 }); 4366 } 4367 this.cluster = new services.Cluster({ base_uri: this.base_uri }); 4368 this._clusterState = new services.ClusterState({ 4369 cluster: this.cluster [root@localhost _site] # cd ../../ [root@localhost ~] # cd elasticsearch-head-master/ [root@localhost elasticsearch- head -master] # npm install phantomjs-prebuilt@2.1.16 --ignore-scripts npm notice created a lockfile as package-lock.json. You should commit this file . npm WARN elasticsearch- head @0.0.0 license should be a valid SPDX license expression + phantomjs-prebuilt@2.1.16 added 81 packages in 32.987s [root@localhost elasticsearch- head -master] # npm install npm WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: https: //nodesecurity .io /advisories ?search=lodash&version=3.10.1 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.npm WARN deprecated coffee-script@1.10.0: CoffeeScript on NPM has moved to "coffeescript" (no hyphen) npm WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: https: //nodesecurity .io /advisories ?search=lodash&version=2.4.2 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.npm WARN deprecated http2@3.3.7: Use the built- in module in node 9.0.0 or newer, instead npm WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: https: //nodesecurity .io /advisories ?search=lodash&version=4.3.0 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.npm WARN notice [SECURITY] ws has the following vulnerabilities: 2 high. Go here for more details: https: //nodesecurity .io /advisories ?search=ws&version=1.0.1 - Run `npm i npm@latest -g` to up grade your npm version, and then `npm audit` to get more info.npm WARN notice [SECURITY] debug has the following vulnerability: 1 low. Go here for more details: https: //nodesecurity .io /advisories ?search=debug&version=2.2.0 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.npm WARN notice [SECURITY] debug has the following vulnerability: 1 low. Go here for more details: https: //nodesecurity .io /advisories ?search=debug&version=0.7.4 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.npm WARN notice [SECURITY] parsejson has the following vulnerability: 1 high. Go here for more details: https: //nodesecurity .io /advisories ?search=parsejson&version=0.0.1 - Run `npm i npm@late st -g` to upgrade your npm version, and then `npm audit` to get more info.npm WARN notice [SECURITY] negotiator has the following vulnerability: 1 high. Go here for more details: https: //nodesecurity .io /advisories ?search=negotiator&version=0.4.9 - Run `npm i npm@la test -g` to upgrade your npm version, and then `npm audit` to get more info.npm WARN prefer global coffee-script@1.10.0 should be installed with -g > fsevents@1.2.4 install /root/elasticsearch-head-master/node_modules/fsevents > node install npm WARN elasticsearch- head @0.0.0 license should be a valid SPDX license expression added 495 packages in 115.929s [root@localhost elasticsearch- head -master] # npm install grunt-cli npm WARN elasticsearch- head @0.0.0 license should be a valid SPDX license expression + grunt-cli@1.3.2 added 63 packages in 36.052s [root@localhost elasticsearch- head -master] # vim /root/.bashrc # .bashrc # User specific aliases and functions alias rm = 'rm -i' alias cp = 'cp -i' alias mv = 'mv -i' # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi export PATH= /root/elasticsearch-head-master/node_modules/grunt-cli/bin :$PATH [root@localhost elasticsearch- head -master] # . /root/.bashrc [root@localhost elasticsearch- head -master] # grunt server & [1] 6210 [root@localhost elasticsearch- head -master] # Running "connect:server" (connect) task Waiting forever... Started connect web server on http: //localhost :9100 [root@localhost elasticsearch- head -master] # ss -lntp State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:9100 *:* users :(( "grunt" ,pid=6210,fd=12))LISTEN 0 128 *:22 *:* users :(( "sshd" ,pid=998,fd=3))LISTEN 0 100 127.0.0.1:25 *:* users :(( "master" ,pid=1134,fd=13))LISTEN 0 128 ::ffff:192.168.10.31:9200 :::* users :(( "java" ,pid=3926,fd=211))LISTEN 0 128 ::ffff:192.168.10.31:9300 :::* users :(( "java" ,pid=3926,fd=190))LISTEN 0 128 :::22 :::* users :(( "sshd" ,pid=998,fd=4))LISTEN 0 100 ::1:25 :::* users :(( "master" ,pid=1134,fd=14)) |
浏览器访问
草都可以从石头缝隙中长出来更可况你呢
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏