【愚公系列】2022年06月 .NET架构班 080-分布式中间件 ScheduleMaster的Master集群和数据库切换

举报
愚公搬代码 发表于 2022/06/30 20:09:02 2022/06/30
【摘要】 一、ScheduleMaster的Master集群 1.Nginx下载:Nginx下载网址: http://nginx.org/download/nginx-1.20.2.zip 2.Nginx配置#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;#...

一、ScheduleMaster的Master集群

1.Nginx下载:

Nginx下载网址: http://nginx.org/download/nginx-1.20.2.zip

2.Nginx配置

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
	include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    server {
        listen       8081;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

		location / {
            proxy_pass  http://ScheduleMaster;
        }

     
    }
	
	#ScheduleMaster负载均衡配置
    upstream ScheduleMaster{
        server localhost:30000;
        server localhost:30003;
    }
}

使用cmd输入命令:nginx
在这里插入图片描述

二、ScheduleMaster数据库切换

ScheduleMaster默认数据库,是MySQL,如果想切换到其他数据库,应该如何切换呢?

例如,切换到SqlServer 或者postgresql数据库

1.Hos.ScheduleMaster.Web准备

进入Hos.ScheduleMaster.Web publish文件,找到appsettings.json

在这里插入图片描述
进入到appsettings.json文件中,修改配置

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  /*
  Provider的可选值:sqlserver、postgresql、mysql,默认为mysql
  ConnectionString是对应数据库类型的连接字符串,格式示例:
    - sqlserver:"Persist Security Info = False; User ID =sa; Password =123456; Initial Catalog =schedule_master; Server =."
    - postgresql:"Server=localhost;Port=5432;Database=schedule_master;User Id=postgres;Password=123456;Pooling=true;MaxPoolSize=20;"
    - mysql:"Data Source=localhost;Database=schedule_master;User ID=root;Password=123456;pooling=true;CharSet=utf8mb4;port=3306;sslmode=none;TreatTinyAsBoolean=true"
  */
  "DbConnector": {
    "Provider": "sqlserver",
    "ConnectionString": "Persist Security Info = False; User ID =sa; Password =123456; Initial Catalog =schedule_master; Server =."
  },
  "AppSettings": {
    "AdminDefaultPwd": "111111"
  },
  "NodeSetting": {
    "IdentityName": "master-node",
    "Role": "master",
    "Protocol": "http",
    "IP": "localhost",
    "Port": 30000
  }

}

2.Hos.ScheduleMaster.QuartzHost准备

进入Hos.ScheduleMaster.QuartzHost publish文件,找到appsettings.json
在这里插入图片描述
进入到appsettings.json文件中,修改配置

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  /*
  Provider的可选值:sqlserver、postgresql、mysql,默认为mysql
  ConnectionString是对应数据库类型的连接字符串,格式示例:
    - sqlserver:"Persist Security Info = False; User ID =sa; Password =123456; Initial Catalog =schedule_master; Server =."
    - postgresql:"Server=localhost;Port=5432;Database=schedule_master;User Id=postgres;Password=123456;Pooling=true;MaxPoolSize=20;"
    - mysql:"Data Source=localhost;Database=schedule_master;User ID=root;Password=123456;pooling=true;CharSet=utf8mb4;port=3306;sslmode=none;TreatTinyAsBoolean=true"
  */
  "DbConnector": {
    "Provider": "sqlserver",
    "ConnectionString": "Persist Security Info = False; User ID =sa; Password =123456; Initial Catalog =schedule_master; Server =."
  },
  "NodeSetting": {
    "IdentityName": "worker1",
    "Role": "worker",
    "Protocol": "http",
    "IP": "localhost",
    "Port": 30001,
    "Priority": 3,
    "MaxConcurrency": 20
  }
}

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。