Apollo Official document address:www.apolloconfig.com/#/zh/README

1. Preparation

1.1 Preparing the Java Environment

The official recommended Java environment is: Java 1.8+ You can use Java -version to check whether the Java environment is available. The output should be 1.8+ as shown below

Openjdk version "1.8.0_292" OpenJDK Runtime Environment (build 1.8.0_292-b10 25.292 - b10, mixed mode)Copy the code

# yum install LRZSZ java-1.8.0-openJDk.x86_64 # yum install LRZSZ java-1.8.0-openJDk.x86_64

1.2 Preparing the mysql Environment

  • Version requirement: 5.6.5+

Apollo’s table structure uses multiple default declarations for TIMESTAMP, so versions above 5.6.5 are required.

After connecting to MySQL, run the following command to check: SHOW VARIABLES WHERE Variable_name = ‘version’;

Variable_name Value
version 5.7.11

MariaDB may have problems if you do not install mysql. Try to use mysql

  • Requirements for the number of deployed devices

Each environment needs a set of databases. If dev, Test, and Production environments need to configure the center, three sets of databases are required. The production environment Apollo uses a database that ideally supports high availability.

1.3 Preparing Apollo Installation packages and SQL scripts

  • Project code location: github.com/ctripcorp/a…
  • Select the latest Releases version to download the components (there are three of them), for example: Apollo-adminservice-1.8.2-github. Zip, Apollo-configService-1.8.2-github. Zip, apollo-portal-1.8.2-github
  • Download SQL script (2), a location for the scripts/SQL/apolloportaldb SQL and SQL/scripts/apolloconfigdb. SQL

1.4 Enabling ports on the firewall or disabling the firewall

Enable the corresponding port method by itself. Run the following command to disable SELinux: systemctl stop firewalld.service systemctl disable firewalld.service Temporarily disable SELinux: setenforce 0 Permanently disable SELinux: Run the vi /etc/sysconfig/selinux command to change selinux =enforcing to selinux =disabled. The configuration takes effect after the system restarts. If it can be used with Setenforce 0, the system does not need to restart.

Deployment of 2.

2.1 Creating a Database

  • Initialize ApolloPortalDB

Create a new database ApolloPortalDB and execute ApolloPortalDB.sql to initialize it. After execution, use the following statement to verify:

select `Id`, `Key`, `Value`, `Comment` from `ApolloPortalDB`.`ServerConfig` limit 1;
Copy the code

Output a record, and if the table is empty, try copying statements from the SQL file to a client such as Navicat for execution.

Id Key Value Comment
1 apollo.portal.envs dev List of supported environments
  • Initialize ApolloConfigDB

Create a new database ApolloConfigDB and execute ApolloConfigdb.sql to initialize it. After execution, use the following statement to verify:

select `Id`, `Key`, `Value`, `Comment` from `ApolloConfigDB`.`ServerConfig` limit 1;
Copy the code

Output a record, and if the table is empty, try copying statements from the SQL file to a client such as Navicat for execution.

Id Key Value Comment
1 eureka.service.url http://127.0.0.1:8080/eureka/ Eureka service Url

2.2 Deploying the program and Modifying the configuration file

  • The deployment of Apollo – configservice

Zip to the server. Decompress the file and open the application-github. Properties file in the config directory. Fill in the correct ApolloConfigDB database connection string information, note that there are no Spaces after the user name and password, and the password does not need to be enclosed in quotes!

# DataSource spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB? useSSL=false&characterEncoding=utf8 spring.datasource.username = someuser spring.datasource.password = somepwdCopy the code
  • The deployment of Apollo – adminservice

Apollo-adminservice-x.x.x-github. Zip to the server, decompress it, and open the application-github. Fill in the correct ApolloConfigDB database connection string information, note that there are no Spaces after the user name and password, and the password does not need to be enclosed in quotes!

# DataSource spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB? useSSL=false&characterEncoding=utf8 spring.datasource.username = someuser spring.datasource.password = somepwdCopy the code
  • The deployment of Apollo – portal

Upload apollo-portal-x.x.x-github. Zip to the server, decompress it, and open the application-github. Fill in the correct ApolloConfigDB database connection string information, note that there are no Spaces after the user name and password, and the password does not need to be enclosed in quotes!

# DataSource spring.datasource.url = jdbc:mysql://localhost:3306/ApolloPortalDB? useSSL=false&characterEncoding=utf8 spring.datasource.username = someuser spring.datasource.password = somepwdCopy the code

Open the apollo-env.properties file in the config directory and enter the correct Meta Service address. To implement high availability of Meta Service, Software Load Balancer (SLB) is recommended for dynamic Load balancing

Local. Meta = http://localhost:8080 dev. Meta = http://192.168.230.129: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://192.168.230.128:8080Copy the code

3. Start

3.1 Modifying the JVM Memory at Startup (This item is not modified in non-production environments)

The JVM memory can be set in the scripts/startup.sh file of each component. If you need to modify JVM parameters, modify the JAVA_OPTS section of scripts/startup.sh. Here are our default Settings for your reference:

export JAVA_OPTS="-server -Xms6144m -Xmx6144m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=4096m -XX:MaxNewSize=4096m -XX:SurvivorRatio=18"
Copy the code

3.2 Changing the Startup port Number

To change the listening port of the service, change SERVER_PORT in scripts/startup.sh. Apollo-configservice also serves as the Meta Server. Attention to at the same time ApolloConfigDB. ServerConfig table of eureka. Service. The url configuration items and Apollo – portal and Apollo – the use of the client to the meta server information.

3.3 Changing the Program log File Path

To change the service log output path, change LOG_DIR in scripts/startup.sh and apollo-configService. conf(or apollo-portal.conf, or apollo-adminservice.conf).

3.4 Starting Components

Decompress the package and run scripts/startup.sh. To stop the service, run scripts/shutdown.sh.

Note: if the ApolloConfigDB. The eureka ServerConfig. Service. The url only with the current starting machine, in the process of start the Apollo – configservice will be in the log output had been registered failure information, such as: Com. Sun. Jersey. API. Client. ClientHandlerException: java.net.ConnectException: Connection refused. Note that this is expected because Apollo-ConfigService needs to register with the Meta Server (itself), but because it is not up during startup, this error is reported. After the retry action will be carried out, so such as their own service up will be registered normally.

3.5 Accessing apollo-portal

After the above steps, the Apollo configuration center has been deployed. Can through the Apollo – portal http://ip:port in access page, such as http://192.168.230.128:8070/