# 可视化部署 如果您希望通过可视化部署的方式部署Elasticsearch,请按照本章节步骤部署。 Elasticsearch将要部署的机器需要通过机器管理添加到skylab中,如果您尚未添加,请参考:[注册机器](../start/install-lava.md)。 ## 部署 1. 点击Skylab顶栏中的 **自动部署** 进入自动部署模块 2. 点击自动部署模块侧栏中的 **Elasticsearch** 大数据组件 3. 点击右侧页面中的 **新建集群** 按钮 ![image](./images/es_deploy_home.png) 4. 选择集群节点 ![image](./images/es_deploy_1.png) 5. 修改配置 ![image](./images/es_deploy_2.png) 默认不开启用户密码登录 如果需要开启,可在配置项中新增两项配置如下(版本>=v6.8.14.2) ```yml xpack.security.enabled: true xpack.security.transport.ssl.enabled: true ``` ![image](./images/es_deploy_security.png) 开启后默认用户为 elastic 密码为 Oushu6.China 安装完成后建议立即修改为新的强密码,修改方式如下 ```shell curl -H "Content-Type:application/json" -XPOST -u elastic 'http://127.0.0.1:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "your new password" }' ``` 6. 部署确认 ![image](./images/es_deploy_3.png) 7. 查看并管理集群 ![image](./images/es_deploy_4.png) ## 检查状态 **集群管理页面可以查看集群及节点进程状态** ![image](./images/es_status.png) 另外也可通过curl命令进行可用性测试 选择集群中任意一台机器的IP,执行如下命令: ```sh curl -X GET http://IP:9200 ``` 如果得到类似如下结果,表示该集群已正常工作: ```json { "name" : "3gAlOL3", "cluster_name" : "elasticsearch", "cluster_uuid" : "pt6mNA1oQqmEZRryV0d51A", "version" : { "number" : "6.8.14", "build_flavor" : "default", "build_type" : "rpm", "build_hash" : "b243943", "build_date" : "2022-09-16T09:58:00.226316Z", "build_snapshot" : true, "lucene_version" : "7.7.3", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search" } ``` 测试创建Index并添加数据 ```sh curl -XPUT 'http://IP:9200/twitter/_doc/1?pretty' -H 'Content-Type: application/json' -d ' { "user": "kimchy", "post_date": "2009-11-15T13:12:00", "message": "Trying out Elasticsearch, so far so good?" }' curl -XPUT 'http://IP:9200/twitter/_doc/2?pretty' -H 'Content-Type: application/json' -d ' { "user": "kimchy", "post_date": "2009-11-15T14:12:12", "message": "Another tweet, will it be indexed?" }' curl -XPUT 'http://IP:9200/twitter/_doc/3?pretty' -H 'Content-Type: application/json' -d ' { "user": "elastic", "post_date": "2010-01-15T01:46:38", "message": "Building the site, should be kewl" }' ``` 获取数据 ```sh curl -XGET 'http://IP:9200/twitter/_doc/1?pretty=true' curl -XGET 'http://IP:9200/twitter/_doc/2?pretty=true' curl -XGET 'http://IP:9200/twitter/_doc/3?pretty=true' ``` ## 常见操作 * 停止集群 ![image](./images/es_deploy_stop.png) * 启动集群 ![image](./images/es_deploy_start.png) * 重启集群 ![image](./images/es_deploy_restart.png) * 刷新集群状态 ![image](./images/es_deploy_refresh.png) * 查看部署日志 ![image](./images/es_deploy_log.png) * 删除集群 ![image](./images/es_deploy_delete.png)