GVKun编程网logo

解析/app/config/database.yml时发生YAML语法错误请注意,YAML必须始终使用空格缩进

1

对于想了解解析/app/config/database.yml时发生YAML语法错误请注意,YAML必须始终使用空格缩进的读者,本文将提供新的信息,并且为您提供关于0701-springcloudco

对于想了解解析/app/config/database.yml时发生YAML语法错误请注意,YAML必须始终使用空格缩进的读者,本文将提供新的信息,并且为您提供关于0701-spring cloud config-简介、Config Server开发、Config Client开发、68.You are managing an Oracle Database 11g database. You want to ensure the recovery of the database、73.You are managing an Oracle Database 11g database. You configured the database to run in ARCHIVELO、78.You are managing an Oracle Database 11g database. The database is open, and you plan to perform R的有价值信息。

本文目录一览:

解析/app/config/database.yml时发生YAML语法错误请注意,YAML必须始终使用空格缩进

解析/app/config/database.yml时发生YAML语法错误请注意,YAML必须始终使用空格缩进

如何解决解析/app/config/database.yml时发生YAML语法错误请注意,YAML必须始终使用空格缩进

尝试部署到heroku时,database.yml文件出现问题。昨天该文件没有问题,我不记得对该文件进行任何更改。但是,这是我得到的错误。我确实将数据库从sqlite切换到postgres,以便可以部署到heroku。我现在可以打开该应用程序,但无法迁移数据库或将其植入种子。另外,如果我尝试在页面上创建某些内容,则不会保存。任何帮助,将不胜感激。对于新手问题,我表示歉意。感谢您提供的任何帮助。

  1. Syntax error occurred while parsing /app/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (<unkNown>): did not find expected key while parsing a block mapping at line 1 column 1
  2. /app/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3.2/lib/rails/application/configuration.rb:246:in `rescue in database_configuration''
  3. /app/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3.2/lib/rails/application/configuration.rb:221:in `database_configuration''
  4. /app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.2/lib/active_record/railtie.rb:39:in `block (3 levels) in <class:Railtie>''
  5. /app/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>''
  6. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load''
  7. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load''
  8. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run''
  9. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec''
  10. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run''
  11. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command''
  12. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch''
  13. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch''
  14. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start''
  15. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start''
  16. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>''
  17. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors''
  18. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>''
  19. /app/bin/bundle:113:in `load''
  20. /app/bin/bundle:113:in `<main>''
  21. Caused by:
  22. Psych::SyntaxError: (<unkNown>): did not find expected key while parsing a block mapping at line 1 column 1
  23. /app/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3.2/lib/rails/application/configuration.rb:228:in `database_configuration''
  24. /app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.2/lib/active_record/railtie.rb:39:in `block (3 levels) in <class:Railtie>''
  25. /app/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>''
  26. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load''
  27. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load''
  28. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run''
  29. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec''
  30. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run''
  31. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command''
  32. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch''
  33. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch''
  34. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start''
  35. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start''
  36. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>''
  37. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors''
  38. /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>''
  39. /app/bin/bundle:113:in `load''
  40. /app/bin/bundle:113:in `<main>''
  41. Tasks: TOP => db:migrate => db:load_config
  42. (See full trace by running task with --trace)

这是我的database.yml文件

  1. # sqlite. Versions 3.8.0 and up are supported.
  2. # gem install sqlite3
  3. #
  4. # Ensure the sqlite 3 gem is defined in your Gemfile
  5. # gem ''sqlite3''
  6. #
  7. default: &default
  8. adapter: postgresql
  9. pool: 5
  10. database:
  11. encoding: unicode
  12. timeout: 5000
  13. development:
  14. <<: *default
  15. database: db/development
  16. # Warning: The database defined as "test" will be erased and
  17. # re-generated from your development database when you run "rake".
  18. # Do not set this db to the same as development or production.
  19. test:
  20. <<: *default
  21. database: db/test
  22. production:
  23. <<: *default
  24. database:
  25. username:
  26. password:
  27. port: 5432
  28. DATABASE_URL:

0701-spring cloud config-简介、Config Server开发、Config Client开发

0701-spring cloud config-简介、Config Server开发、Config Client开发

一、概述

参看地址:

  https://cloud.spring.io/spring-cloud-static/Edgware.SR3/single/spring-cloud.html#_spring_cloud_config

  https://gitee.com/itmuch/spring-cloud-book

1.1、为什么需要统一管理配置

  集中管理、不同环境不同配置、运行期间动态调整配置、自动刷新

  默认都是配置在配置文件中、数据库等中

1.2、简介

  主要有两种分布式配置Zookeeper、Consul。

  其实还有许多,如百度的disconf、阿里的diamond、携程的apollo

  为分布式系统外部化配置提供了服务器端和客户端的支持。它包括Config Server和Config Client两部分。由于Config Server和Config Client都实现了对Spring Environment 和PropertySource抽象的映射,因此,Spring Cloud Config非常适合Spring应用程序,当然也可以与任何其他语言编写的应用程序配合使用。

  Config Server是一个可横向扩展、集中式的配置服务器。它用于集中管理应用程序各个环境下的配置。默认使用Git存储配置内容(也可以使用Subversion,本地文件系统或Vault存储配置。)因此可以方便的实现对配置的版本控制与内容审计等

  Config Client是Config Server的客户端,用于操作存储在Config Server中的配置属性。

1.3、架构图

  在Config Server可以有dev、stage、prod等环境

   

二、Config Server开发

2.1、项目搭建

如git地址:https://github.com/bjlhx15/spring-cloud.git

增加pom

<dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>
    </dependencies>

启动类增加注解

@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConfigServerApplication.class, args);
    }
}

2.2、增加配置项目git

  如:https://github.com/bjlhx15/spring-cloud-config-test-repo.git

 2.3、在application.yml中增加

server:
  port: 8080
spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/bjlhx15/spring-cloud-config-test-repo

启动项目测试即可.

2.4、访问地址

  HTTP服务具有以下形式的资源映射规则:

/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.properties

  其实是按照格式随意拼接即可。如:http://localhost:8080/aa-profile.properties 或者 http://localhost:8080/aa-profile.yml

  其中label是git的分支版本。

2.5、测试

  增加foobar-dev.yml测试。

  访问:http://localhost:8080/foobar-dev.yml,发现是配置的文件,。

  即访问优先级:先找到能匹配的文件【label/具体文件名】,如果不匹配即找到application配置文件。

  平时使用建议使用一个配置文件即可

三、Config Client开发

3.1、创建项目

git地址:https://github.com/bjlhx15/spring-cloud.git

增加pom【注意是spring-cloud-starter-config】

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

配置文件

新增一个bootstrap.yml

spring:
  cloud:
    config:
      uri: http://localhost:8080
      name: foobar
      profile: dev
      label: master   # 当configserver的后端存储是Git时,默认就是master  
application: #和配置文件匹配最好
name: foobar

在application.yml

server:
  port: 8040

原因是:Spring云上下文

  Spring Cloud应用程序通过创建“bootstrap”上下文来运行,该上下文是主应用程序的父上下文。【bootstrap.yml 优先级高于application.yml】开箱即用,它负责从外部源加载配置属性,并且还解密本地外部配置文件中的属性。这两个上下文共享一个环境,它是任何Spring应用程序的外部属性的来源。bootstrap属性以高优先级添加,因此默认情况下它们不能被本地配置覆盖。

  bootstrap程序上下文默认约定:使用bootstrap.yml【bootstrap.properties】覆盖application.yml(或.properties)

  但是可以使用spring.cloud.bootstrap.enabled=false禁用

  bootstrap.*里面的配置→链接Config Server,加载远程配置之后→在加载application.*配置

2.2、增加启动类

@SpringBootApplication
public class ConfigClientApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConfigClientApplication.class, args);
    }
}

2.3、增加测试

@RestController
public class ConfigClientController {
    // 传统方式需要在配置文件加上配置 ,但是优先级低于使用bootstap加载的配置
    @Value("${profile}")
    private String profile;

    @GetMapping("/profile")
    public String getProfile() {
        return this.profile;
    }
}

注意点:

  1、pom的spring-cloud-starter-config不要引错;

  2、不要不适用bootstrap.yml。否则默认是8888端口

  3、如果本地属性也有远端属性,以bootstrap.yml先与本地application为主,故使用远端属性profile

  4、注意git上的配置文件如果是yml类型,注意属性“:”后有空格。。

 

68.You are managing an Oracle Database 11g database. You want to ensure the recovery of the database

68.You are managing an Oracle Database 11g database. You want to ensure the recovery of the database

68.You are managing an Oracle Database 11g database. You want to ensure the recovery of the database to the point of failure. Which configuration will you do to accomplish the task? A.Multiplex all database files. B.Configure the Flash Recovery Area. C.Configure the database instance for ARCHIVELOG mode. D.Configure the FAST_START_MTTR_TARGET initialization parameter. 答案:C 解析:这个说是恢复到错误发生的时间点,这个相当于不完全恢复,不完全恢复的先觉条件是@R_301_6250@处于归档模式 当@R_301_6250@设置为归档模式之后对@R_301_6250@意味着 1.当@R_301_6250@(磁盘或系统文件问题所导致的)崩溃之后,所有提交的数据都能恢复 2.可以对@R_301_6250@进行联机备份,而且在联机备份期间可以继续进行其他的操作 3.当某一非系统表空间脱机时,@R_301_6250@的其他部分继续正常工作 4.可以进行如下的不完全恢复 a.恢复到某一特定的时间点 b.恢复到某一特定的scn号 c.恢复到某一特定的归档文件的结尾

73.You are managing an Oracle Database 11g database. You configured the database to run in ARCHIVELO

73.You are managing an Oracle Database 11g database. You configured the database to run in ARCHIVELO

73.You are managing an Oracle Database 11g database. You configured the database to run in ARCHIVELOG mode. Which two statements are true in this scenario? (Choose two.) A.You must shut down the database instance to perform the backups. B.You must configure the Flash Recovery Area (FRA) for the database. C.You can perform complete database backups without closing the database. D.All the prevIoUs closed database backups including control files become invalid after you configure the database to ARCHIVELOG mode. 答案:CD 解析: A.归档模式后,备份不需要关闭数据库,属于热备,因此A是错误的,当然也可以关闭进行一致性备份,但不是必须关闭数据库 B.fra默认路径为$ORACLE_BASE/fast_recovery_area,不需要费的配置,因此B也是错误的 C.正确,备份的时候,是备份了一个点,然后通过归档日志执行前滚实现了完全备份 D.正确,当打开归档后 sql> archive log list Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 77 Next log sequence to archive 77 Current log sequence 79 这里的Current log sequence将会被重置为1,也就是之前的都变成了invalid

78.You are managing an Oracle Database 11g database. The database is open, and you plan to perform R

78.You are managing an Oracle Database 11g database. The database is open, and you plan to perform R

78.You are managing an Oracle Database 11g database. The database is open,and you plan to perform Recovery Manager (RMAN) backups. Which three statements are true about these backups? (Choose three.) A.The backups would be consistent. B.The backups would be inconsistent. C.The backups would be possible only if the database is running in ARCHIVELOG mode. D.The backups would be possible only if the database is running in NOARCHIVELOG mode. E.The backups need to be restored and the database has to be recovered in case of a media failure. 答案:BCE 解析:只要是open状态进行备份的都是不一致备份排除A rman在非归档模式下执行进行脱机备份也就是冷备,因此排除D E说的是介质有问题了,备份必须restore然后recovered,这里说一下restore和recover的区别 restore:从备份位置还原一个或者多个数据库文件 recover:应用归档和联机重做日志文件,将整个数据库或单独数据库文件前滚到指定的scn 这就是归档文件的作用,当执行备份的时候,只是备份到一个点的数据,但是在备份之后这段时间执行的数据,就需要 通过recover利用归档日志,来进行前滚实现,因此需要这两步

今天关于解析/app/config/database.yml时发生YAML语法错误请注意,YAML必须始终使用空格缩进的介绍到此结束,谢谢您的阅读,有关0701-spring cloud config-简介、Config Server开发、Config Client开发、68.You are managing an Oracle Database 11g database. You want to ensure the recovery of the database、73.You are managing an Oracle Database 11g database. You configured the database to run in ARCHIVELO、78.You are managing an Oracle Database 11g database. The database is open, and you plan to perform R等更多相关知识的信息可以在本站进行查询。

本文标签: