Database initialization for configuration centers¶
Database initialization for configuration centers is the critical setup process required to deploy configuration management systems like [[Apollo]] within a Kubernetes infrastructure. This process establishes the persistence layer, storage schema, and access controls necessary for the center to operate.
Initialization Steps¶
Apollo Config Database (ApolloConfigDB)¶
The process begins by downloading the official database schema from the source repository and executing it against a running MySQL instance^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md:250-252]. The initialization script, typically named V1.0.0__initialization.sql, creates the necessary tables and structures^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md:250-252].
After running the script, it is standard practice to create a dedicated database user with restricted privileges, rather than using the root account^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md:260-261]. For example, a user named apolloconfig may be granted INSERT, DELETE, UPDATE, and SELECT permissions on the ApolloConfigDB^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md:260-261].
Service Registration Configuration¶
A key post-initialization step involves updating the ServerConfig table to register the network location of the configuration service^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md:264-265]. Specifically, the eureka.service.url key must be updated to point to the domain of the Config Service (e.g., http://config.od.com/eureka)^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md:264-265].
Apollo Portal Database (ApolloPortalDB)¶
Deploying the management portal requires a second database initialization step using a specific SQL script, such as apolloportaldb.sql^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md:455-456]. This script sets up the ApolloPortalDB.
Similar to the config database, a dedicated database user (e.g., apolloportal) should be created with specific access rights^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md:460-461]. Additionally, the ServerConfig table in this database is often modified to define organizational structures, such as the list of departments or organizations supported by the portal^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md:462-463].
Multi-Environment Strategy¶
When managing multiple environments (e.g., Test and Production) using a single portal, the initialization strategy scales to create separate databases for each environment^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md:555-580]. This typically involves creating databases like ApolloConfigTestDB and ApolloConfigProdDB^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md:555-580].
Each environment-specific database requires its own initialization and configuration updates, such as pointing to the correct Eureka service URL (e.g., http://config-test.od.com/eureka for the test environment)^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md:555-580]. The ApolloPortalDB must also be configured to recognize these distinct environments by updating its supported environment list^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md:590-593].
Related Concepts¶
- [[Apollo]]
- Kubernetes
- [[MySQL]]