《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.1.Elastic Stack 安装部署—— 3.4.1.1.安装Elasticsearch(本地及docker)(4) https://developer.aliyun.com/article/1231510
最简启动
docker-compose up --build(如果要后台运行可以加参数 -d,如果目录里有多个配置文件可以通过 -f 参数指定目标配置文件)
1、后台运行命令:docker-compose up -d --build
2、指定配置文件命令:docker-compose -f docker-compose.yml up -d --build
输出以下日志代表启动成功:
[root@esteam7002 elasticsearch]# docker-compose up --build Creating network "elasticsearch_default" with the default driver -> 初次启动创建专用网络 Creating volume "elasticsearch_data01" with local driver -> 初次启动创建专用存储 Creating es-node-01 ... done -> 创建ES节点 Attaching to es-node-01 es-node-01 | {"type": "server", "timestamp": "2021-04-19T13:28:05,581Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "es-docker-cluster", "node.name": "es-node-01", "message": "version[7.10.1], pid[6], build[default/docker/1c34507e66d7db1211f66f3513706fdf548736aa/2020-12-05T01:00:33.671820Z], OS[Linux/3.10.0-1160.24.1.el7.x86_64/amd64], JVM[AdoptOpenJDK/OpenJDK 64-Bit Server VM/15.0.1/15.0.1+9]" } -> 节点启动系统环境信息 es-node-01 | {"type": "server", "timestamp": "2021-04-19T13:28:05,584Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "es-docker-cluster", "node.name": "es-node-01", "message": "JVM home [/usr/share/elasticsearch/jdk], using bundled JDK [true]" } -> 节点JVM使用信息 …… 中间省略 es-node-01 | {"type": "server", "timestamp": "2021-04-19T13:29:15,770Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "es-docker-cluster", "node.name": "es-node-01", "message": "initialized" } -> 节点信息初始化 es-node-01 | {"type": "server", "timestamp": "2021-04-19T13:29:15,773Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "es-docker-cluster", "node.name": "es-node-01", "message": "starting ..." } -> 节点启动开始 es-node-01 | {"type": "server", "timestamp": "2021-04-19T13:29:15,949Z", "level": "INFO", "component": "o.e.t.TransportService", "cluster.name": "es-docker-cluster", "node.name": "es-node-01", "message": "publish_address {172.18.0.2:9300}, bound_addresses {[::]:9300}" } -> 节点集群内部数据传输接口开启 es-node-01 | {"type": "server", "timestamp": "2021-04-19T13:29:16,441Z", "level": "INFO", "component": "o.e.c.c.Coordinator", "cluster.name": "es-docker-cluster", "node.name": "es-node-01", "message": "setting initial configuration to VotingConfiguration{s-6A5vqlQuKoZlyn- TKdnA}" } -> 初始化投票配置 es-node-01 | {"type": "server", "timestamp": "2021-04-19T13:29:16,834Z", "level": "INFO", "component": "o.e.c.s.MasterService", "cluster.name": "es-docker-cluster", "node.name": "es-node-01", "message": "elected-as-master ([1] nodes joined)[{es-node-01}{s-6A5vqlQuKoZlyn-TKdnA}{HD5TOEsDTUGWPFoR1pYUDg}{172.18.0.2}{172.18.0.2:9300}{cdhilmrstw}{ml.machine_memory=1927176192, xpack.installed=true, transform.node=true, ml.max_open_jobs=20} elect leader, _BECOME_MASTER_TASK_, _FINISH_ELECTION_], term: 1, version: 1, delta: master node changed {previous [], current [{es-node-01}{s-6A5vqlQuKoZlyn-TKdnA}{HD5TOEsDTUGWPFoR1pYUDg}{172.18.0.2}{172.18.0.2:9300}{cdhilmrstw}{ml.machine_memory=1927176192, xpack.installed=true, transform.node=true, ml.max_open_jobs=20}]}" } -> 同集群发现节点信息 es-node-01 | {"type": "server", "timestamp": "2021-04-19T13:29:17,047Z", "level": "INFO", "component": "o.e.c.c.CoordinationState", "cluster.name": "es-docker-cluster", "node.name": "es-node-01", "message": "cluster UUID set to [QDGTOlDiTm-9JkJrpg9q2Q]" } -> 集群id初始化 es-node-01 | {"type": "server", "timestamp": "2021-04-19T13:29:17,241Z", "level": "INFO", "component": "o.e.c.s.ClusterApplierService", "cluster.name": "es-docker-cluster", "node.name": "es-node-01", "message": "master node changed {previous [], current [{es-node-01}{s-6A5vqlQuKoZlyn-TKdnA}{HD5TOEsDTUGWPFoR1pYUDg}{172.18.0.2}{172.18.0.2:9300}{cdhilmrstw}{ml.machine_memory=1927176192, xpack.installed=true, transform.node=true, ml.max_open_jobs=20}]}, term: 1, version: 1, reason: Publication{term=1, version=1}" } -> 集群选主完成 es-node-01 | {"type": "server", "timestamp": "2021-04-19T13:29:17,315Z", "level": "INFO", "component": "o.e.h.AbstractHttpServerTransport", "cluster.name": "es-docker-cluster", "node.name": "es-node-01", "message": "publish_address {172.18.0.2:9200}, bound_addresses {[::]:9200}", "cluster.uuid": "QDGTOlDiTm-9JkJrpg9q2Q", "node.id": "s-6A5vqlQuKoZlyn-TKdnA" } -> 节点restful监听接口开启 es-node-01 | {"type": "server", "timestamp": "2021-04-19T13:29:17,316Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "es-docker-cluster", "node.name": "es-node-01", "message": "started", "cluster.uuid": "QDGTOlDiTm-9JkJrpg9q2Q", "node.id": "s-6A5vqlQuKoZlyn-TKdnA" } -> 节点启动完成
ES 启动状态校验
同上
节点停机
1、docker-compose down(docker-compose -f docker-compose.yml down)
2、当出现以下日志表明节点停机成功
[root@esteam7002 elasticsearch]# docker-compose -f docker-compose.yml down Stopping es-node-01 ... done Removing es-node-01 ... done Removing network elasticsearch_default
MacOS 环境
MacOS 系统其实是一个类 Unix 系统,所以大部分的命令、环境属性等都和 Unix 系统类似。
tar 包安装和上文提到的,在 Linux 系统中基于 tar 包安装的过程大致一样。
1、需要注意的是,MacOS 作为一个较为特殊的操作系统,也会有一个专门针对 MacOS 系统编译出来的安装包
2、路径上的主要区别为 Linux 系统的安装包被标记了 linux,MacOS 的安装包被标记了
darwin
3、https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.0-darwin-x86_64.tar.gz
brew 安装
通过命令 brew tap elastic/tap 将 Elastic 原厂的仓库地址加入 homebrew 的配置:
brew tap elastic/tap Updating Homebrew... ==> Tapping elastic/tap Cloning into '/usr/local/Homebrew/Library/Taps/elastic/homebrew-tap'... remote: Enumerating objects: 890, done. remote: Counting objects: 100% (131/131), done. remote: Compressing objects: 100% (104/104), done. remote: Total 890 (delta 80), reused 57 (delta 26), pack-reused 759 Receiving objects: 100% (890/890), 206.46 KiB | 310.00 KiB/s, done. Resolving deltas: 100% (666/666), done. Tapped 17 formulae (51 files, 327.7KB). 通过命令 brew install elastic/tap/elasticsearch-full 进行安装: ➜ ~ brew install elastic/tap/elasticsearch-full ==> Installing elasticsearch-full from elastic/tap ==> Downloading https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.1-darwin-x86_64.tar.gz?tap=elas ######################################################################## 100.0% Warning: Tried to install empty array to /usr/local/etc/elasticsearch/jvm.options.d ==> codesign -f -s - /usr/local/Cellar/elasticsearch-full/7.12.1/libexec/modules/x-pack-ml/platform/darwin-x86_64/contr ==> find /usr/local/Cellar/elasticsearch-full/7.12.1/libexec/jdk.app/Contents/Home/bin -type f -exec codesign -f -s - { ==> Caveats Data: /usr/local/var/lib/elasticsearch/elasticsearch_chenchen/ -> 数据目录 Logs: /usr/local/var/log/elasticsearch/elasticsearch_chenchen.log -> 普通日志文件 Plugins: /usr/local/var/elasticsearch/plugins/ -> 插件目录 Config: /usr/local/etc/elasticsearch/ -> 配置文件目录 To have launchd start elastic/tap/elasticsearch-full now and restart at login: brew services start elastic/tap/elasticsearch-full Or, if you don't want/need a background service you can just run: elasticsearch ==> Summary 961 files, 503MB, built in 9 seconds
主要文件路径,也可以通过命令 brew info elasticsearch-full 查看(内容和安装日志类似)
➜ ~ brew info elasticsearch-full elastic/tap/elasticsearch-full: stable 7.12.1 Distributed search & analytics engine https://www.elastic.co/products/elasticsearch Conflicts with: elasticsearch /usr/local/Cellar/elasticsearch-full/7.12.1 (960 files, 503MB) * Built from source on 2021-05-14 at 23:45:38 From: https://github.com/elastic/homebrew-tap/blob/HEAD/Formula/elasticsearch-full.rb ==> Caveats Data: /usr/local/var/lib/elasticsearch/elasticsearch_chenchen/ Logs: /usr/local/var/log/elasticsearch/elasticsearch_chenchen.log Plugins: /usr/local/var/elasticsearch/plugins/ Config: /usr/local/etc/elasticsearch/ To have launchd start elastic/tap/elasticsearch-full now and restart at login: brew services start elastic/tap/elasticsearch-full Or, if you don't want/need a background service you can just run: elasticsearch
注意,通过常规方式安装 brew install elasticsearch 会安装 7.10.2,通过命令 brew info
elasticsearch 也可以得到相应的信息,但是这个版本的 ES 存在一些启动上的问题。
所以还是建议通过原厂建议的 brew info elasticsearch-full 命令进行安装和测试,目前通过这个命令会安装 7.12 版本,和本文中其它的版本不太一致。
这些路径可能会因为系统的不同而有些许不同,也可能会有 /Users/steven/working/sourcecode/homebrew/etc/elasticsearch/ 格式的情况。
《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.1.Elastic Stack 安装部署—— 3.4.1.1.安装Elasticsearch(本地及docker)(6) https://developer.aliyun.com/article/1231508