In this article:
The FMPQuery.Builder.JoinType enumeration is used to determine a type of join query. Mobile Platform automatically installs the services delivered with Foresight Mobile Platform:
External, corporate services can be used instead of built-in services. The examples of solving tasks when built-in services are replaced with external ones:
Use of Postgres Pro DBMS. PostgreSQL is used by default.
Accelerated handling of mobile platform server requests if the number of users is more than 10000. The number of users can be changed depending on the task.
Use of different statements for data backup and information protection. The StackGres operator is used by default for local databases.
Increased system security and control of mobile platform systems administration due to storing Foresight Mobile Platform data in corporate services Minio/Ceph, Elasticsearch/Opensearch, Redis.
When one divides work in development, testing, and production environments, one can use several installed instances of Foresight Mobile Platform. Each Foresight Mobile Platform instance must have unique logical area of external services.
To ensure uniqueness of logical area of external services, select a method:
Connect one or several Foresight Mobile Platform instances to the same service due to use of different names, database numbers, and prefixes in the configuration file. For details see the Setting Connection Parameters for External Services subsection.
Connect several Foresight Mobile Platform instances to different services due to protection of logical area with a unique key. The unique key is generated:
For PostgreSQL and Redis DBMS databases. If a Foresight Mobile Platform instance is connected to a specific set of databases, an attempt to connect another instance to this database set returns an error. Each instance should be connected to a unique database set within the same service.
For the Minio/Ceph, Elasticsearch/Opensearch services. If a Foresight Mobile Platform service is connected to a specific service, an attempt to connect another instance to this service returns an error.
For details about unique key generation see the Generating Unique Key subsection.
Setting connection parameters for external services differs depending on Foresight Mobile Platform configuration.
To set connection parameters for external services when using standalone configuration:
Open the .env file for edit, which is located on a mobile platform server.
Set connection parameters for external services in corresponding sections:
Set parameters for each PostgreSQL database in the postgres section:
POSTGRES_MAIN_IS_EXTERNAL=true
POSTGRES_MAIN_HOST=<host>
POSTGRES_MAIN_PORT=<port>
POSTGRES_MAIN_NAME=<maindb database name>
POSTGRES_MAIN_USERNAME=<user name>
POSTGRES_MAIN_PASSWORD=<password>
POSTGRES_CACHE_IS_EXTERNAL=true
POSTGRES_CACHE_HOST=<host>
POSTGRES_CACHE_PORT=<port>
POSTGRES_CACHE_NAME=<cachedb database name>
POSTGRES_CACHE_USERNAME=<user name>
POSTGRES_CACHE_PASSWORD=<password>
POSTGRES_LOCAL_IS_EXTERNAL=true
POSTGRES_LOCAL_HOST=<host>
POSTGRES_LOCAL_PORT=<port>
POSTGRES_LOCAL_NAME=<localdb database name>
POSTGRES_LOCAL_USERNAME=<user name>
POSTGRES_LOCAL_PASSWORD=<password>
To connect several Foresight Mobile Platform instances to the same PostgreSQL DBMS, specify database names that are not used in other configurations, in the POSTGRES_MAIN_NAME, POSTGRES_CACHE_NAME, and POSTGRES_LOCAL_NAME parameters, for example:
POSTGRES_MAIN_NAME=pg_main_name1
POSTGRES_CACHE_NAME=pg_cache_name1
POSTGRES_LOCAL_NAME=pg_local_name1
Set parameters in the s3 section for the MinIO/Ceph file storage:
S3_SERVICE_IS_EXTERNAL=true
S3_SERVICE_IS_SSL=false
S3_SERVICE_HOST=<host>
S3_SERVICE_PORT=<port>
S3_SERVICE_ACCESS_KEY=<access key (user identifier)>
S3_SERVICE_SECRET_KEY=<secret key (password)>
To connect several Foresight Mobile Platform instances to the same MinIO/Ceph service, specify prefix for names of the sections that are not used in other instances, in the S3_SERVICE_BUCKET_PREFIX parameter, for example:
S3_SERVICE_BUCKET_PREFIX=fmp-instance1-prefix
Prefix can be specified manually or generated automatically, similarly to unique key generation. When specifying prefix manually, make sure to meet the requirements: prefix can consist of Latin letters (a-z, A-Z), numbers 0-9, hyphens and should not exceed 40 characters.
Set parameters for the Elasticsearch logging system in the log_service section, when OpenSearch is disabled, change value of the LOG_SERVICE_USE_OPENSEARCH parameter to true:
LOG_SERVICE_IS_EXTERNAL=true
LOG_SERVICE_USE_OPENSEARCH=false
LOG_SERVICE_IS_SSL=false
LOG_SERVICE_HOST=<host>
LOG_SERVICE_PORT=<port>
LOG_SERVICE_USERNAME=<user name>
LOG_SERVICE_PASSWORD=<password>
To connect several Foresight Mobile Platform instances to the same Elasticsearch/OpenSearch service, specify prefix for indexes that is not used in other instances, in the LOG_SERVICE_INDEX_PREFIX parameter, for example:
LOG_SERVICE_INDEX_PREFIX=fmp-instance1-prefix
Prefix can be specified manually or generated automatically, similarly to unique key generation. When specifying prefix manually, make sure to meet the requirements: prefix can consist of Latin letters (a-z, A-Z), numbers 0-9, hyphens and should not exceed 40 characters.
Set parameters for the Redis service in the redis section:
REDIS_IS_EXTERNAL=true
REDIS_HOST=<host>
REDIS_PORT=<port>
REDIS_PASSWORD=<password>
REDIS_SENTINEL_ENABLED=false
To connect several Foresight Mobile Platform instances to the same Redis service, specify database numbers that are not used in other instances, in the REDIS_DEFAULT_DB, REDIS_LOG_DB, REDIS_USER_THROTTLES_DB, and REDIS_RESOURCE_CACHE_DB parameters, for example:
REDIS_DEFAULT_DB=0
REDIS_LOG_DB=1
REDIS_USER_THROTTLES_DB=2
REDIS_RESOURCE_CACHE_DB=3
Save changes in the file.
After executing the operations, external services are used instead of local ones.
To set connection parameters for external services when using cluster configuration:
Open the values.yaml file for edit, which is located in the fmp folder on mobile platform server.
Set connection parameters for external services in corresponding sections:
Set parameters for each PostgreSQL database in the externalPostgres section:
externalPostgres:
maindb:
useInternal: false
host: <host>
port: <port>
database: "<maindb database name>"
username: "<user name>"
password: "<password>"
cachedb:
useInternal: false
host: <host>
port: <port>
database: "<cachedb database name>"
username: "<user name>"
password: "<password>"
localdb:
useInternal: false
host: <host>
port: <port>
database: "<localdb database name>"
username: "<user name>"
password: "<password>"
NOTE. When connecting to PostgreSQL external databases, corresponding StackGres resources are not created.
To connect several Foresight Mobile Platform instances of the same PostgreSQL DBMS, specify database names that are not used in other instances, in the database parameter, for example:
externalPostgres:
maindb:
database: "pg_main_name1"
cachedb:
database: "pg_cache_name1"
localdb:
database: "pg_local_name1"
Set parameters in the externalS3Service section of the MinIO/Ceph file storage:
externalS3Service:
useInternal: false
host: <host>
port: <port>
accessKeyId: "<access key (user identifier)>"
secretKey: "<secret key (password)>"
isSSL: false
To connect several Foresight Mobile Platform instances to the same MinIO/Ceph service, specify prefix for names of the sections that are not used in other instances, in the bucketPrefix parameter, for example:
externalS3Service:
bucketPrefix: fmp-instance1-prefix
Prefix can be specified manually or generated automatically, similarly to unique key generation. When specifying prefix manually, make sure to meet the requirements: prefix can consist of Latin letters (a-z, A-Z), numbers 0-9, hyphens and should not exceed 40 characters.
Set parameters for the Elasticsearch logging system in the externalLogService section, when OpenSearch is connected, change value of the useOpensearch parameter to true:
externalLogService:
useInternal: false
useOpensearch: false
host: <host>
port: <port>
username: "<user name>"
password: "<password>"
isSSL: false
userLogAge: "30d" # value is set in days
serviceLogAge: "30d" # value is set in days
To connect several Foresight Mobile Platform instances to the same Elasticsearch/OpenSearch service, specify prefix for the indexes that is not used in other instances, in the indexPrefix parameter, for example:
externalLogService:
indexPrefix: fmp-instance1-prefix
Prefix can be specified manually or generated automatically, similarly to unique key generation. When specifying prefix manually, make sure to meet the requirements: prefix can consist of Latin letters (a-z, A-Z), numbers 0-9, hyphens and should not exceed 40 characters.
Set Redis service parameters in the externalRedis section:
externalRedis:
useInternal: false
host: redis-external-host.com
port: 6379
password: "red-pass"
sentinel:
enabled: false
masterSet: "mymaster"
NOTE. Make sure that the FLUSHDB command is available in Redis.
To connect several Foresight Mobile Platform instances to the same Redis service, specify database numbers that are not used in other instances, in the redisDefaultDB, redisLogDB, redisUserThrottlesDB, and redisResourceCacheDB parameters, for example:
externalRedis:
redisDefaultDB: 0
redisLogDB: 1
redisUserThrottlesDB: 2
redisResourceCacheDB: 3
Save changes in the file.
After executing the operations, external services are used instead of local ones.
Unique key generation differs depending on Foresight Mobile Platform configuration.
To generate unique key when using standalone configuration:
Generate unique key in the EXTERNAL_DB_UNIQUE_KEY variable in the directory where the .env file is stored that is located on mobile platform server:
EXTERNAL_DB_UNIQUE_KEY=$(echo "$(grep '^COMPOSE_PROJECT_NAME=' .env | cut -d= -f2)-$(hostname)")
Change view of generated unique key's value in the EXTERNAL_DB_UNIQUE_KEY variable:
EXTERNAL_DB_UNIQUE_KEY=$(echo "$EXTERNAL_DB_UNIQUE_KEY" | tr -cd 'a-zA-Z0-9-_' | cut -c1-40 | sed 's/^[-_+]*//')
Save unique key to the .env file:
sed -i "s/^EXTERNAL_DB_UNIQUE_KEY=.*/EXTERNAL_DB_UNIQUE_KEY=${EXTERNAL_DB_UNIQUE_KEY}/" .env
After executing the operations the .env configuration file contains the EXTERNAL_DB_UNIQUE_KEY variable with the generated unique key value. If the key is non-unique in system environments, replace it manually. The key can consist of Latin letters (a-z, A-Z), numbers 0-9, hyphens, and should not exceed 40 characters.
To generate unique key when using cluster configuration:
Declare the CLUSTER_RELEASE_NAME, CLUSTER_NAMESPACE variables on the cluster's main node:
CLUSTER_RELEASE_NAME=fmp
CLUSTER_NAMESPACE=fmp
These values were specified during installation of Foresight Mobile Platform in cluster in the command:
helm install fmp ./fmp/chart -n ${CLUSTER_NAMESPACE} -f ./fmp/values.production.yaml --set django.deployment.image.registry=<IP address of work node>:5000/${CLUSTER_NAMESPACE} --set global.imageRegistry=<IP address of work node>:5000/${CLUSTER_NAMESPACE} --set nginx.ingress.hostname=<mobile platform server host> --set fluentd.enabled=true --timeout 30m0s
Generate unique key in the EXTERNAL_DB_UNIQUE_KEY variable:
EXTERNAL_DB_UNIQUE_KEY=$(echo "${CLUSTER_RELEASE_NAME}-$(kubectl get ns ${CLUSTER_NAMESPACE} -o=jsonpath='{.metadata.uid}')")
Change view of generated unique key's value in the EXTERNAL_DB_UNIQUE_KEY variable:
EXTERNAL_DB_UNIQUE_KEY=$(echo "$EXTERNAL_DB_UNIQUE_KEY" | tr -cd 'a-zA-Z0-9-_' | cut -c1-40 | sed 's/^[-_+]*//')
Save the unique key to the variable .global.externalDBUniqueKey of the .values.production.yaml file:
yq e -i '.global.externalDBUniqueKey = "'${EXTERNAL_DB_UNIQUE_KEY}'"' fmp/values.production.yaml
After executing the operations the .values.production.yaml file contains the .global.externalDBUniqueKey variable with the value of the generated key. If the key is non-unique in system environments, replace it manually. The key can consist of Latin letters (a-z, A-Z), numbers 0-9, hyphens, and should not exceed 40 characters.
See also:
Installing and Setting Up Foresight Mobile Platform | Mobile platform Server Advanced Settings | Adding Alternative Domains