• spring-cloud-alibaba : nacos安装


    文章旨在 简单易懂,学习交流;文章中会尽量避免其他 关联内容;
    其他关联的 微服务内容会单独 启动专题说明;也可留言,会第一时间解答,相互交流
    非喜勿喷;

    下载 安装包

    https://github.com/alibaba/nacos/releases

    配置文件说明

    #*************** Spring Boot Related Configurations ***************#
    ### Default web context path:
    server.servlet.contextPath=/nacos
    ###  端口
    ### Default web server port:
    server.port=8842
    
    #*************** Network Related Configurations ***************#
    ### If prefer hostname over ip for Nacos server addresses in cluster.conf:
    # nacos.inetutils.prefer-hostname-over-ip=false
    
    ### Specify local server's IP:
    # nacos.inetutils.ip-address=
    
    #*************** Config Module Related Configurations ***************#
    ### 默认 内嵌式数据库 Derby 数据存放在 /nacos/data/derby-data 目录
    ### 如果使用mysql 存储数据 打开一下配置  
    ### If use MySQL as datasource:
    spring.datasource.platform=mysql
    
    ### 数据库数量
    ### Count of DB:
    db.num=1
    
    ### 使用多个数据库 配置
    ### Connect URL of DB:
    db.url.0=jdbc:mysql://127.0.0.1:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
    db.user.0=root
    db.password.0=123456
    
    • 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

    单体模式

    Linux/Unix/Mac

    Run the following command to start(standalone means non-cluster mode):

    sh startup.sh -m standalone
    
    • 1

    If you are using a ubuntu system, or encounter this error message [[symbol not found, try running as follows:

    bash startup.sh -m standalone
    
    • 1
    Windows

    Run the following command to start(standalone means non-cluster mode):

    cmd startup.cmd -m standalone
    
    • 1

    集群模式

    此处 本地机器 多实例 模拟伪集群 目录如下:

    img

    配置文件修改
    cd nacos8840/conf
    
    • 1

    img

    #2022-11-06T14:46:24.643
    ### 配置所有节点的 ip:port
    ${真实ip}:8840
    ${真实ip}:8842
    ${真实ip}:8844
    
    • 1
    • 2
    • 3
    • 4
    • 5
    启动

    所有节点单独启动 即可

    sh startup.sh
    
    • 1

    方便启动 编写 shell

    shutdown.sh

    sh ./nacos8840/bin/shutdown.sh;
    sh ./nacos8842/bin/shutdown.sh;
    sh ./nacos8844/bin/shutdown.sh
    
    • 1
    • 2
    • 3

    startup.sh

    sh ./nacos8840/bin/startup.sh;
    sh ./nacos8842/bin/startup.sh;
    sh ./nacos8844/bin/startup.sh
    
    • 1
    • 2
    • 3

    window 可自行百度

    访问
    • 可以 每台机器 单独访问
    • 配合nginx 负载

    nginx配置如下

    upstream nacos-cluster {
      server 127.0.0.1:8840;
      server 127.0.0.1:8842;
      server 127.0.0.1:8844;
    }
    server {
        listen       8848;
        server_name  localhost;
    
        location / {
            root   html;
            index  index.html index.htm;
        }
    
        location /nacos {
            proxy_pass http://nacos-cluster/nacos;
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    访问界面

    各实例单独访问: localhost:8840/nacos localhost:8840/nacos localhost:8840/nacos

    img

    nginx : localhost:8848/nacos

    img

    参考资料

    https://nacos.io/en-us/docs/quick-start.html

  • 相关阅读:
    异地多活架构新突破:库存单元化部署技术思路揭秘
    ChatGPT是否能够协助人们提高跨文化领导力和管理能力?
    高压放大器在3D打印中的应用
    29.5.2 备份数据
    python编写修改sqlmap进行_WAF绕过
    Spring-全面详解(学习总结---从入门到深化)
    SpringBoot3新特性
    Apache Log4j Server (CVE-2017-5645) 反序列化命令执行漏洞
    ElementUI之CUD+表单验证
    elementui图片上传转为base64字符串
  • 原文地址:https://blog.csdn.net/qq_41692766/article/details/127717662