一台机器如何启动多个nacos

2 篇文章 0 订阅
1 篇文章 0 订阅

目录

1.新建文件夹nacos1

2.application.yml

3.JeecgNacosApplication

这样就可以启动

备注:hosts文件地址:C:\Windows\System32\drivers\etc

127.0.0.1 jeecg-boot-redis
127.0.0.1 jeecg-boot-mysql
127.0.0.1 jeecg-boot-nacos
127.0.0.1 jeecg-boot-gateway
127.0.0.1 jeecg-boot-system
127.0.0.1 jeecg-boot-sentinel
127.0.0.1 jeecg-boot-xxljob
127.0.0.1 jeecg-boot-rabbitmq

最近在开发过程中遇到一个问题,就是两个项目都有nacos,但是无法同时启动两个nacos。

下面直接干饭

1.新建文件夹nacos1

我的nacos日志文件在C:\Users\xbx下面,原本只有nacos,nacos1是自己新建的文件夹。

2.application.yml

改成nacos1

server:
  servlet:
    contextPath: /nacos1
  tomcat:
    accesslog:
      enabled: true
      pattern: '%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i'
    basedir: ''
spring:
  datasource:
    platform: mysql
db:
  num: 1
  password:
    '0': ${MYSQL-PWD:xbx123}
  url:
    '0': jdbc:mysql://${MYSQL-HOST:127.0.0.1}:${MYSQL-PORT:3306}/${MYSQL-DB:nacos}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
  user:
    '0': ${MYSQL-USER:root}
management:
  metrics:
    export:
      elastic:
        enabled: false
      influx:
        enabled: false
nacos:
  core:
    auth:
      caching:
        enabled: true
      default:
        token:
          expire:
            seconds: 18000
          secret:
            key: SecretKey012345678901234567890123456789012345678901234567890123456789
      enabled: false
      system:
        type: nacos
  istio:
    mcp:
      server:
        enabled: false
  naming:
    empty-service:
      auto-clean: true
      clean:
        initial-delay-ms: 50000
        period-time-ms: 30000
  security:
    ignore:
      urls: /,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
  standalone: true

3.JeecgNacosApplication

改成新建文件夹nacos1的路径

package com.alibaba.nacos;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletResponse;

/**
 * Nacos 启动类
 *
 * @author zyf
 */
@SpringBootApplication(scanBasePackages = "com.alibaba.nacos")
@ServletComponentScan
@EnableScheduling
public class JeecgNacosApplication {

    /**
     * 是否单机模式启动
     */
    private static String standalone = "true";

    /**
     * 是否开启鉴权
     */
    private static String enabled = "false";

    public static void main(String[] args) {
        System.setProperty("nacos.standalone", standalone);
        System.setProperty("nacos.core.auth.enabled", enabled);
        System.setProperty("server.tomcat.basedir","logs");
        //自定义启动端口号
        System.setProperty("server.port","18848");
        System.setProperty("nacos.home", "C:\\Users\\xbx\\nacos1");
        SpringApplication.run(JeecgNacosApplication.class, args);
    }

    /**
     * 默认跳转首页
     *
     * @param model
     * @return
     */
    @GetMapping("/")
    public String index(Model model, HttpServletResponse response) {
        // 视图重定向 - 跳转
        return "/nacos";
    }
}

这样就可以启动了

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

十&年

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值