SIA-GateWay API Gateway Installation and Deployment Guide

Keywords: Programming Docker Maven Nginx Spring

SIA-GATEWAY is a distributed micro-service gateway system based on Spring Cloud micro-service ecosystem. It has the characteristics of easy to use, visualization, high scalability and high availability, and provides cloud native, complete and mature access service solutions. This paper introduces the installation and deployment of API gateway.

I. environment

1.1 Compiling Environment

  • Maven3+
  • nodejs
  • Jdk1.8+

1.2 Runtime Third Party Dependency

  • Mysql5.6+
  • elasticsearch 5.5.2
  • kibana-5.5.2
  • kafka 2.12-2.0.0
  • redis 3.2.11
  • eureka-server

1.3 Operating Environment

  • 64bit OS,Linux/Mac/Windows/docker
  • JDK1.8+

Source Download

git clone https://github.com/siaorg/sia-gateway.git

2.1 The source code structure is as follows:

.
- ia-gateway-admin-build component gateway admin component set
 -sia-gateway-admin gateway admin monitoring system component
 -sia-gateway-synchspeed Gateway Real-time Sensing Component for Downstream Services
 -sia-gateway-stream gateway log component
 _-sia-gateway-service Gateway System Auxiliary Component
 -sia-gateway-monitor gateway monitoring and log components
│   │    ├── sia-gateway-reactive    
- sia-gateway-messaging basic dependencies 
│   │    ├── sia-gateway-sink
│   │    ├── sia-gateway-esclient
│   │    ├── sia-gateway-base
 - front-end code of sia-gateway-admin-display gateway system
 - sia-gateway-build component gateway core-build component
 -sia-gateway-core gateway Core node
│   │   ├── sia-gateway-base
 - sia-gateway-messaging basic dependencies
│   │   ├── sia-gateway-reactive
│   │   ├── sia-gateway-template

Initialization of API Gateway Database

1) The installation and configuration of MySQL are detailed in the official MySQL documentation.

2) Please download the project source code and decompress it to get the "API gateway database initialization SQL script" and execute it.

The location of "API Gateway Database Initialization SQL Script" is:

/sia-gateway/sia-gateway-admin/src/main/resources/db/gateway_admin.sql

IV. Configuration of Gateway System

4.1 Gateway Profile Address

# Gateway admin center conf
/sia-gateway/sia-gateway-admin-buildcomponent/config/gateway_admin_test.yml

# Gateway monitoring service conf
/sia-gateway/sia-gateway-admin-buildcomponent/config/gateway_monitor_test.yml

# Gateway Auxiliary Node conf
/sia-gateway/sia-gateway-admin-buildcomponent/config/gateway_service_test.yml

# Gateway Logging Service conf
/sia-gateway/sia-gateway-admin-buildcomponent/config/gateway_stream_test.yml

# Gateway Real-time Perception Service Con
/sia-gateway/sia-gateway-admin-buildcomponent/config/gateway_synchspeed_test.yml

# Gateway Core Node conf
/sia-gateway/sia-gateway-buildcomponent/config/gateway_test.yml

1)gateway_admin_test.yml

2)gateway_service_test.yml

3)gateway_stream_test.yml

4)gateway_synchspeed_test.yml

5)gateway_monitor_test.yml

6)gateway_test.yml

Description: spring.application.name is the gateway group name. Developers can modify this attribute and build a new gateway group.

4.2 maven Warehouse Address Configuration

  <mirrors>
	   <mirror>
		      <id>alimaven</id>
		      <name>aliyun maven</name>
		      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
		      <mirrorOf>central</mirrorOf>        
	  </mirror>
  </mirrors>
  <profiles>
		<profile>
			<id>jdk-1.8</id>
			<activation>
				<activeByDefault>true</activeByDefault>
				<jdk>1.8</jdk>
			</activation>
			<properties>
				<maven.compiler.source>1.8</maven.compiler.source>
				<maven.compiler.target>1.8</maven.compiler.target>
				<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
			</properties>
		</profile>

		<profile>
			<id>downloadSources</id>
			<properties>
				<downloadSources>true</downloadSources>
				<downloadJavadocs>true</downloadJavadocs>
			</properties>
		</profile>
		<profile>  
		    <id>spring plugins</id>  
		    <activation>  
		      <jdk>spring plugins</jdk>  
		    </activation>  
		    <pluginRepositories>  
		      <pluginRepository>  
		        <id>spring plugins</id>  
		        <name>Spring plugins</name>  
		        <url>https://maven.aliyun.com/repository/spring-plugin</url>  
		        <layout>default</layout>  
		        <snapshotPolicy>always</snapshotPolicy>  
		      </pluginRepository>  
		    </pluginRepositories>  
		</profile>  
	</profiles>

	<activeProfiles>
		<activeProfile>downloadSources</activeProfile>
	</activeProfiles>
  

V. Building Deployment Projects

5.1 Compilation Project

1) If the above configuration has been correctly implemented, the project can be compiled and packaged for deployment.

2) Operation steps:

	cd sia-gateway
	
	chmod +x *.sh
	
	sh build.sh

3) After successful packaging, the following annotation files will appear.

  • /sia-gateway/sia-gateway-admin-buildcomponent/target/gateway_admin_1.0.zip

  • /sia-gateway/sia-gateway-buildcomponent/target/gateway_1.0.zip

  • /sia-gateway/sia-gateway-admin-display/dist/

Note: NoeJs is required for front-end packaging. If not installed, please refer to Noejs Installation Document.

5.2 Deployment Project

  • API gateway system deployment mode is distributed deployment centralized management mode, that is, gateway Core nodes can be divided into different gateway groups according to business lines. Gateway management terminal serves as the management center of the gateway for a unified management interface, where users can set up and maintain API, components, system basic information, collect and monitor. Log, generate various operation and maintenance management reports, automatic alarm, etc.
  • Sia-gateway-admin-build component is the component set of gateway management end, including admin, stream, service, synchspeed, monitor; the management end can deploy a single node (currently does not support cluster).
  • Sia-gateway-build component is a gateway Core component, which can be grouped according to business lines and deployed as a single node or cluster within the group.

5.3 Vmware deployment

1) Back-end Deployment

unzip gateway_admin_1.0.zip

cd /gatewayadmin/bin

chmod +x *.sh 

#Start Gateway Management Services, including admin, stream, service, synchspeed, monitor.
sh onekey_start.sh

---------------------------------------------------
unzip gateway_1.0.zip

cd /gateway/bin

chmod +x *.sh 

#Start Gateway Core Service
sh start_gateway_test.sh

2) Front End Deployment

  • Modify the front-end site-map.js

  • The proxy configuration of nginx, enter the directory of nginx nginx.conf, add the following configuration:

    	    upstream apigateway.open.location1 { 
    		   #### sia-gateway-admin service IP
    	      server *******:8090 ; 
    	    }
    	    server {
    	    	 # nginx listening port
    	        listen       18086;
    	        server_name  localhost;
    	        access_log  logs/host.access.log  main;
    	        #access_log  "pipe:rollback logs/host.access_log interval=1d baknum=7 maxsize=2G"  main;
    	        location / {
    	            #root   html;
    	            #index  index.html index.htm;
    	            root  /app/jar/ROOT/dist;
    	            index  index.html index.htm;
    	        }
    	        # Backend service location 
    	        location ^~ /vv1/  {
    	                proxy_pass http://apigateway.open.location1/;  
    	                proxy_set_header   Host  $host; 
    	                proxy_set_header   X-Real-IP $http_x_forwarded_for; 
    	                proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for; 
    	                proxy_http_version 1.1;
    	        }
    	        error_page   500 502 503 504  /50xcn.html;
    	        location = /50xcn.html {
    	            root   html/error_page;
    	            index 50xcn.html;
    	        }
    	        location /check_status {
    	            vhost_traffic_status_display;
    	            vhost_traffic_status_display_format json;
    	        }
    	    }
    
  • Restart nginx

    	#Verify that the configuration is correct
    	./nginx -t
    
    	# Restart
    	./nginx -s reload
    
    

5.4 Docker Mirror Deployment

Note: If the docker environment and the compilation environment are on the same operating system, the following steps can be directly performed; conversely, the following files need to be uploaded to the server where the docker environment is located according to the original directory structure.

  • /sia-gateway/sia-gateway-admin-buildcomponent/target/gateway_admin_1.0.zip
  • /sia-gateway/sia-gateway-buildcomponent/target/gateway_1.0.zip
  • /sia-gateway/sia-gateway-admin-display/dist/
  • /sia-gateway/third-libary
  • /sia-gateway/build.sh
  • /sia-gateway/docker-start.sh
  • /sia-gateway/docker-run.sh
  • /sia-gateway/Dockerfile

Steps:

1) Configuration: Modify site-map.js, location: / dist/static/site-map.js

	    /**
         * vmware Deployment: 127.0.0.1 - > nginx ip address
         * docker Mirror Deployment: 127.0.0.1 - > Host ip of docker container
         */
        'CESHI_API_HOST': '127.0.0.1:18086/vv1',
        
        /**
         * 127.0.0.1 ----> kibana ip address
         */
        'CESHI_API_HOST_LOG': '127.0.0.1:5601'

2) Download the centos basic image, if it has been downloaded, this step is ignored.

3) Modify Docker file, FROM <font color='red'> mirror name: version number </font>

4) Configure the yum source. If the deployment machine can use the aliyum source, this step is ignored.

Modify the yum source file name to CentOS-Base.repo and replace it with / sia-gateway/third-libary/.

5) Build mirrors and start containers and services

	# Constructing mirrors
	cd /sia-gateway/ 
	
	# To grant authorization
	chmod +x *.sh
	
	# Constructing mirrors
	sh docker-build.sh
	
	# Start Containers and Services
	sh docker-run.sh
	
	# Check if the container started successfully
	docker ps 
	
	# Enter the container to see how the service works
	docker exec -it gateway-test:v1 bash

Access address: http://Host IP:18086/

Explain:

  • Docker image deployment is an ALL-IN-ONE form of gateway deployment Demo, which is provided to facilitate developers to build gateway system based on docker environment simply and quickly. Gateway monitoring services, early warning, gateway core nodes and so on are all built in a docker image. Developers can be flexible according to the development environment conditions. The deployment scheme is chosen, and it is recommended to use the vmware+docker image deployment mode, that is, the gateway management service is deployed on vmware, and the gateway core node is deployed in the docker environment.

SIA Related Open Source Product Links

Source: Yixin Institute of Technology

Posted by Xpheyel on Tue, 10 Sep 2019 23:56:17 -0700