1.Apollo部署-linux

news/2024/5/19 21:30:30 标签: .netcore

一.官方文档

https://www.apolloconfig.com/#/zh/deployment/quick-start-docker

二.环境准备

  1.MySql 5.6.51.单独服务器192.168.2.13

https://downloads.mysql.com/archives/installer/

  2.JDK 1.8.X

https://www.oracle.com/java/technologies/downloads/

三.Apollo部署

  1.下载1.8 安装包

https://github.com/apolloconfig/apollo/releases/tag/v1.8.0

  2.下载后的文件

  3.解压后的文件目录

  4.生成数据库

  这个脚本我是1.8的。官网上最新的总出问题。但1.8的官网又没找到,大家对mysql熟悉的可以用最新的试试,生成的过程就不讲,网上一堆,大概是选择数据库->运行Sql文件

  5.修改配置

    1) 服务端口修改

        分别修改三个服务下的启动端口号配置文件:/scripts/startup.sh

    2) 数据库配置修改

        分别修改三个服务下的数据连接配置文件:/config/application-github.properties

# DataSource
spring.datasource.url = jdbc:mysql://192.168.2.13:3306/ApolloConfigDB?characterEncoding=utf8&serverTimezone=UTC
spring.datasource.username = root
spring.datasource.password = mysql

    3) Apollo的meta配置

        修改apollo-portal服务的下的meta配置:apollo-portal/config/apollo-env.properties

local.meta=http://localhost:8080
dev.meta=http://192.168.3.14:8080
fat.meta=http://fill-in-fat-meta-server:8080
uat.meta=http://fill-in-uat-meta-server:8080
lpt.meta=${lpt_meta}
pro.meta=http://fill-in-pro-meta-server:8080

   6.修改后的文件上传到 /usr/local/apollo

   7.创建三个bat文件,修改权限,启动,关闭

   8.修改权限bat文件,chmod777.bat

#!/bin/bash
chmod 777 /usr/local/apollo/apollo-configservice/scripts/shutdown.sh
chmod 777 /usr/local/apollo/apollo-configservice/scripts/startup.sh
chmod 777 /usr/local/apollo/apollo-adminservice/scripts/shutdown.sh
chmod 777 /usr/local/apollo/apo代码llo-adminservice/scripts/startup.sh
chmod 777 /usr/local/apollo/apollo-portal/scripts/shutdown.sh
chmod 777 /usr/local/apollo/apollo-portal/scripts/startup.sh

 9.启动服务bat文件 startup.sh

#!/bin/bash
/usr/local/apollo/apollo-configservice/scripts/startup.sh
/usr/local/apollo/apollo-adminservice/scripts/startup.sh
/usr/local/apollo/apollo-portal/scripts/startup.sh

 10.关闭服务bat文件 shutdown.sh

#!/bin/bash
/usr/local/apollo/apollo-configservice/scripts/shutdown.sh
/usr/local/apollo/apollo-adminservice/scripts/shutdown.sh
/usr/local/apollo/apollo-portal/scripts/shutdown.sh

 11.分布执行 ./startup.sh,  ./shutdown.sh

  12.此时查看端口是否成功

ps -ef | grep 8070

  13.访问 192.168.3.14:8070

四.net core继承

  1.安装Com.Ctrip.Framework.Apollo.Configuration

  2.appsettings.json文件添加配置

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "apollo": {
    "AppId": "SampleApp", //AppId
    "MetaServer": "http://192.168.3.14:8080" // Eureka地址
  }
}

  3.代码继承

 .ConfigureWebHostDefaults(webBuilder =>
{
  webBuilder.ConfigureAppConfiguration((context,builder)=> {
                         
   IConfigurationSection configuration = builder.Build().GetSection("Apollo");
                        builder.AddApollo(configuration).AddDefault(); 
  });
  webBuilder.UseStartup<Startup>();
});

  4.应用

public class TestController : ControllerBase
{
        private readonly IConfiguration configuration;

        public TestController(IConfiguration configuration)
        {
            this.configuration = configuration;
        }

        public IActionResult Get()
        {
            IConfigurationSection section = this.configuration.GetSection("timeout");
            return Ok(section.Key + ":" + section.Value);
        }
}

  5.这是最简单的应用,之后还有灰度发布,同步,集群,测试环境,生产环境


http://www.niftyadmin.cn/n/419191.html

相关文章

http1.0,http1.1,http2.0,http3.0 区别有哪些

20 世纪 60 年代&#xff0c;美国国防部高等研究计划署&#xff08;ARPA&#xff09;建立了 ARPA 网&#xff0c;这被认为是互联网的起源。70 年代&#xff0c;研究人员基于对 ARPA 网的实践和思考&#xff0c;发明出了著名的 TCP/IP 协议。该协议具有良好的分层结构和稳定的性…

EasyX实现简易贪吃蛇

&#x1f4dd;个人主页&#xff1a;认真写博客的夏目浅石. &#x1f4e3;系列专栏&#xff1a;夏目的C语言宝藏 文章目录 前言一、头文件包含二、创建蛇与食物的结构体三、游戏的初始化四、游戏的绘画事件五、蛇的移动事件六、输入方向七、生成食物八、吃食物九、游戏失败的判定…

NumPy库的学习

本文主要记录的是笔者在B站自学Numpy库的学习笔记。 引入numpy库 import numpy as np矩阵的创建 创建一个二行三列的矩阵。 array np.array([[1,2,3],[2,3,4]])查看array的行数、形状、元素数量 print("number of dim:",array.ndim) print("shape:"…

文心一言 VS 讯飞星火 VS chatgpt (37)-- 算法导论5.4 1题

一、一个屋子里必须要有多少人&#xff0c;才能让某人和你生日相同的概率至少为1/2? 必须要有多少人&#xff0c;才能让至少两个人生日为 7月 4 日的概率大于 1/2? 文心一言&#xff1a; 一个屋子里必须要有多少人&#xff0c;才能让某人和你生日相同的概率至少为1/2&#…

[解决方案]springboot怎么接受encode后的参数(参数通过=拼接)

springboot怎么接受encode后的参数(拼接& springboot怎么接受encode后的参数(拼接&)问题出现原因发送encode后的值在postman里面的情况这个时候该如何接受呢&#xff08;encode后的值接受&#xff09;controller层的代码用到的工具类CRequest springboot怎么接受encode…

Android应用程序进程的启动过程

Android应用程序进程的启动过程 导语 到这篇文章为止&#xff0c;我们已经简要地了解过了Android系统的启动流程了&#xff0c;其中比较重要的内容有Zygote进程的启动和SystemService以及Launcher的启动&#xff0c;接下来我们将要学习的是Android应用程序的启动过程&#xff…

细说websocket - php篇

下面我画了一个图演示 client 和 server 之间建立 websocket 连接时握手部分&#xff0c;这个部分在 node 中可以十分轻松的完成&#xff0c;因为 node 提供的 net 模块已经对 socket 套接字做了封装处理&#xff0c;开发者使用的时候只需要考虑数据的交互而不用处理连接的建立…

测试人生 | 三十而已,何需惧怕!年薪40W+涨薪幅度超40%

关于我&#xff0c;普通二本&#xff0c;非计算机专业&#xff0c;培训出身&#xff0c;北漂&#xff0c;五年多的工作经验&#xff0c;做过外包&#xff0c;中间有过频繁的跳槽经历&#xff0c;手工点点点为主&#xff0c;最近确认了新Offer&#xff0c;远程办公&#xff0c;涨…