当前位置: 首页 > news >正文

【云服务管理】

公有云

云服务管理

弹性计算服务

云主机配置

名称

IP地址

配置

web-0001

192.168.1.11

2CPU,4G内存

web-0002

192.168.1.12

2CPU,4G内存

  • 部署网站页面

# 安装 nfs 协议客户端

[root@ecs-proxy ~]# dnf install -y nfs-utils

[root@ecs-proxy ~]# mount -t nfs -o nolock <SFS服务地址>  /mnt/

[root@ecs-proxy ~]# mkdir /mnt/html

# 部署网站页面到文件共享服务

[root@ecs-proxy ~]# tar -zxf s4/public/website.tar.gz -C /mnt/html/

  • 部署 web 服务

# 安装 Web 服务

[root@web ~]# dnf install -y httpd php nfs-utils

[root@web ~]# systemctl enable --now httpd

# 配置开机自动挂载

[root@web ~]# vim /etc/fstab

<SFS服务地址>:/html    /var/www/html    nfs    defaults,_netdev    1 1

[root@web ~]# systemctl daemon-reload

[root@web ~]# mount -a

# 查看验证

[root@web ~]# df -h

Filesystem     Size  Used   Avail   Use%   Mounted on

<SFS服务地址>   1.2T     0    1.2T     0%   /var/www/html

负载均衡服务

# 访问验证

[root@ecs-proxy s4]# curl -m3 http://192.168.0.250/info.php

<pre>

Array

(

    [REMOTE_ADDR] => 192.168.1.252

    [REQUEST_METHOD] => GET

    [HTTP_USER_AGENT] => curl/7.61.1

    [REQUEST_URI] => /info.php

)

php_host:   web

1229

项目架构图

Elasticsearch 安装

添加软件包

# 添加 ELK 软件包到自定义 Yum 仓库

[root@ecs-proxy s4]# rsync -av elk/ /var/localrepo/elk/

[root@ecs-proxy s4]# createrepo --update /var/localrepo

购买云主机

主机

IP地址

配置

es-0001

192.168.1.21

最低配置2核4G

es-0002

192.168.1.22

最低配置2核4G

es-0003

192.168.1.23

最低配置2核4G

集群安装

部署 es-0001

[root@es-0001 ~]# vim /etc/hosts

192.168.1.21    es-0001

192.168.1.22    es-0002

192.168.1.23    es-0003

[root@es-0001 ~]# dnf install -y elasticsearch

[root@es-0001 ~]# vim /etc/elasticsearch/elasticsearch.yml

17:  cluster.name: my-es

23:  node.name: es-0001

56:  network.host: 0.0.0.0

70:  discovery.seed_hosts: ["es-0001", "es-0002", "es-0003"]

74:  cluster.initial_master_nodes: ["es-0001", "es-0002", "es-0003"]

[root@es-0001 ~]# systemctl enable --now elasticsearch

# 服务启动成功

[root@es-0001 ~]# curl http://127.0.0.1:9200

{

  "name" : "es-0001",

  "cluster_name" : "my-es",

  "cluster_uuid" : "_na_",

  "version" : {

    "number" : "7.17.8",

    "build_flavor" : "default",

    "build_type" : "rpm",

    "build_hash" : "120eabe1c8a0cb2ae87cffc109a5b65d213e9df1",

    "build_date" : "2022-12-02T17:33:09.727072865Z",

    "build_snapshot" : false,

    "lucene_version" : "8.11.1",

    "minimum_wire_compatibility_version" : "6.8.0",

    "minimum_index_compatibility_version" : "6.0.0-beta1"

  },

  "tagline" : "You Know, for Search"

}

部署 es-0002

# 验证集群状态失败

[root@es-0002 ~]# curl http://192.168.1.21:9200/_cat/nodes?pretty

{

  "error" : {

    "root_cause" : [

      {

        "type" : "master_not_discovered_exception",

        "reason" : null

      }

    ],

    "type" : "master_not_discovered_exception",

    "reason" : null

  },

  "status" : 503

}

# 部署服务

[root@es-0002 ~]# vim /etc/hosts

192.168.1.21    es-0001

192.168.1.22    es-0002

192.168.1.23    es-0003

[root@es-0002 ~]# dnf install -y elasticsearch

[root@es-0002 ~]# vim /etc/elasticsearch/elasticsearch.yml

17:  cluster.name: my-es

23:  node.name: es-0002

56:  network.host: 0.0.0.0

70:  discovery.seed_hosts: ["es-0001", "es-0002", "es-0003"]

74:  cluster.initial_master_nodes: ["es-0001", "es-0002", "es-0003"]

[root@es-0002 ~]# systemctl enable --now elasticsearch

# 验证集群状态

[root@es-0002 ~]# curl http://127.0.0.1:9200/_cat/nodes

192.168.1.21 16 89  2 0.15 0.06 0.04 cdfhilmrstw * es-0001

192.168.1.22  6 88 61 1.00 0.23 0.08 cdfhilmrstw - es-0002

部署 es-0003

[root@es-0003 ~]# vim /etc/hosts

192.168.1.21    es-0001

192.168.1.22    es-0002

192.168.1.23    es-0003

[root@es-0003 ~]# dnf install -y elasticsearch

[root@es-0003 ~]# vim /etc/elasticsearch/elasticsearch.yml

17:  cluster.name: my-es

23:  node.name: es-0003

56:  network.host: 0.0.0.0

70:  discovery.seed_hosts: ["es-0001", "es-0002", "es-0003"]

74:  cluster.initial_master_nodes: ["es-0001", "es-0002", "es-0003"]

[root@es-0003 ~]# systemctl enable --now elasticsearch

[root@es-0003 ~]# curl http://127.0.0.1:9200/_cat/nodes

192.168.1.21 16 89  2 0.15 0.06 0.04 cdfhilmrstw * es-0001

192.168.1.22  6 88 61 1.00 0.23 0.08 cdfhilmrstw - es-0002

192.168.1.23  6 86  1 0.64 0.21 0.07 cdfhilmrstw - es-0003

插件管理

部署插件页面

# 拷贝插件 public/head.tar.gz 到 es-0001 主机

[root@ecs-proxy s4]# rsync -av public/head.tar.gz 192.168.1.21:./

#-------------------------------------------------

# 在 es-0001 上安装 web 服务,并部署插件

[root@es-0001 ~]# dnf install -y nginx

[root@es-0001 ~]# systemctl enable --now nginx

[root@es-0001 ~]# tar zxf head.tar.gz -C /usr/share/nginx/html/

  • 通过 ELB 的 8080 端口,发布服务到互联网
认证和代理

[root@es-0001 ~]# vim /etc/nginx/default.d/esproxy.conf

location ~* ^/es/(.*)$ {

    proxy_pass http://127.0.0.1:9200/$1;

    auth_basic "Elasticsearch admin";

    auth_basic_user_file /etc/nginx/auth-user;

}

[root@es-0001 ~]# dnf install -y httpd-tools

[root@es-0001 ~]# htpasswd -cm /etc/nginx/auth-user admin

New password:

Re-type new password:

Adding password for user admin

[root@es-0001 ~]# systemctl reload nginx

  • 通过 head 插件管理 elasticsearch 集群

API原语管理

集群状态查询

# 查询支持的关键字

[root@es-0001 ~]# curl -XGET http://127.0.0.1:9200/_cat/

# 查具体的信息

[root@es-0001 ~]# curl -XGET http://127.0.0.1:9200/_cat/master

# 显示详细信息 ?v

[root@es-0001 ~]# curl -XGET http://127.0.0.1:9200/_cat/master?v

# 显示帮助信息 ?help

[root@es-0001 ~]# curl -XGET http://127.0.0.1:9200/_cat/master?help

# 显示易读格式 ?pretty

[root@es-0001 ~]# curl -XGET http://127.0.0.1:9200/_cat/master?pretty

创建索引
  • 指定索引的名称,指定分片数量,指定副本数量

# 创建 tedu 索引

[root@es-0001 ~]# curl 'http://127.0.0.1:9200/tedu?pretty' \

    -X PUT -H 'Content-Type: application/json' -d '{

      "settings": {

        "number_of_shards": 3,

        "number_of_replicas": 1

      }

    }'

增加数据

[root@es-0001 ~]# curl -XPUT -H "Content-Type: application/json" \

    http://127.0.0.1:9200/tedu/teacher/1?pretty -d '{

        "职业": "诗人","名字": "李白","称号": "诗仙","年代": "唐"

    }'

查询数据

[root@es-0001 ~]# curl -XGET http://127.0.0.1:9200/tedu/teacher/_search?pretty

[root@es-0001 ~]# curl -XGET http://127.0.0.1:9200/tedu/teacher/1?pretty

修改数据

[root@es-0001 ~]# curl -XPOST -H "Content-Type: application/json" \

    http://127.0.0.1:9200/tedu/teacher/1/_update -d '{

      "doc": {"年代":"公元701"}

    }'

删除数据

# 删除一条

[root@es-0001 ~]# curl -XDELETE http://127.0.0.1:9200/tedu/teacher/1

# 删除索引

[root@es-0001 ~]# curl -XDELETE http://127.0.0.1:9200/tedu

http://www.dtcms.com/a/123266.html

相关文章:

  • MySQL SQL Mode
  • Spring Boot MongoDB自定义连接池配置
  • 十分钟机器学习之--------------线性回归
  • 关于 Spring Boot 后端项目使用 Maven 打包命令、JAR/WAR 对比、内嵌服务器与第三方服务器对比,以及热部署配置的详细说明
  • 雷池WAF身份认证 - CAS
  • 数码视讯TR100系列/TR100-G1/TR100-G4/数码视讯F7-国科GK6323V100C芯片-刷机固件包
  • 如何优雅使用 ReentrantLock 进行加解锁:避免常见坑点,提高代码可维护性
  • ADI的BF561双核DSP怎么做开发,我来说一说(十一)NANDFLASH的读写
  • 十三届蓝桥杯Java省赛 B组(持续更新..)
  • YOLO 8 入坑(持续更新)
  • 【含文档+PPT+源码】基于Android家政服务系统的开发与实现
  • 【python】yield关键字的使用及执行步骤分析
  • HTTP 1.0 时代,第一次优化
  • antv x6使用(支持节点排序、新增节点、编辑节点、删除节点、选中节点)
  • ThinkpPHP生成二维码
  • 【C++初阶】--- vector容器功能模拟实现
  • STM32硬件IIC+DMA驱动OLED显示——释放CPU资源,提升实时性
  • Keras简介
  • AI 赋能 DBA:如何用 DeepSeek 等大模型简化数据库管理工作
  • 【每日随笔】丛林法则 ( 弱肉强食 | 适者生存 | 资源有限稀缺 | 没有道德约束 | 自发性与无序性 | 丛林法则映射 - 资源分配 与 社会分层 )
  • C++23新特性:显式对象形参与显式对象成员函数
  • Unity AssetBundle依赖树可视化分析工具开发指南
  • BeagleBone Black笔记
  • 传感器篇(二)——激光雷达
  • Prompt-to-prompt image editing with cross attention control
  • 网络通讯协议UDP转发TCP工具_UdpToTcpRelay_双向版
  • 蓝桥杯c ++笔记(含算法 贪心+动态规划+dp+进制转化+便利等)
  • 食堂采购系统源码模块化开发详解:管理、订单、入库、对账一体化方案
  • 游戏引擎学习第214天
  • module错误集合