How to create a Store Server
Overview
This page discusses how you can create a store server instance. The assumption is that you have a running Openbravo Commerce central server.
The store server is created on the basis of the central server. A store server operates together with a central server. It receives master data from a central server and transactions are sent to a central server. This means that a central server and store server share data and often also functionality.
A store server is created in steps. These steps are described in this howto.
Central Server Stack
Two store server specific synchronization modules need to be present on the central server.
In addition depending on which functional modules you have installed you need additional synchronization modules. See the Synchronization_Modules_Overview page for more details.
Also the central server must be correctly set up for multi-server behavior. See here for more details.
The preference to activate multi-server behavior will be automatically set by installed the 'org.openbravo.retail.storeserver.synchronization' module mentioned above.
At least 2 more configurations must be done:
- Add the multi-server specific authentication.manager to Openbravo.properties
- Add the mobile.server.key (see below) to Openbravo.properties
For details refer to the following guide.
Also a entry for the main server must be added to the 'Mobile Server' definition.
- Server Type: "OB Main Server"
- Mobile Server Key: a unique value which also was put in the Openbravo.properties (see above)
- URL a stable URL where where main server can be reached (must be reachable from any store server)
For more detailed information refer to the following guide.
Define the Store Server as a mobile server in the Central Server
First the store for which a store server needs to be installed needs to be setup completely in the central server as an Openbravo store, with POS terminals etc. This should be done in the same way as for any other store.
Then the next step is to define the store server as a mobile server in the Mobile Server window. The server type should be OB Store Server. Note that the url should be reachable by the central server if you want the central server to actively check the online status of the store.
As the server is for a specific store, the 'All Organizations' checkbox has to be unchecked and the organization of the store has to be listed in the subtab.
There are two other relevant fields to consider:
- 'can be registered' should normally be checked, if not checked then the Symmetric DS replication will not work
- Allowed Origin Domains: this field defines the domains/hosts from which a WebPOS client can be loaded. It is an important field to support calling multiple different servers from the WebPOS client. For more information see here. If you notice that the WebPOS client does not automatically switch to another server to do requests then you can check the value of this field.
Prepare the Store Server installation
As a next step, install a server, the OS and database, so create the store server stack.
The following assumes all that setup has been done so a normal Openbravo installation works correctly.
Assemble the source code & modules required which at least needs to include the 2 modules also installed in the central server above.
Configure Openbravo.properties as usual with basic Openbravo setup (source.path, database connection information).
Add the store server specific configuration:
- mobile.server.key matching the 'Mobile Server' definition of this store server
- authentication.manager same as described above also to the main server
Validating the store server data
Before trying to export and install the store server data, it is advisable to run a process that will check if the store server data is consistent. This process will look for referencial integrity problems and will log them. If there are referencial integrity problems, the store data could be exported, but the installation would fail.
The validation process is run as an ant task like this from the Openbravo root folder of the central server:
ant -f modules/org.openbravo.replication.symmetricds/build.xml validate.store.data -DmobileServerKey=Store1
It has the following parameters:
- mobileServerKey: The mobile server key of the mobile server being validated
- dataSet (optional): The id of the dataset that will be used to export the data. By default this is the 8930335BAE1D454CAB1CC5208B14B3F0 (Store Server Creation) dataset
Performance: for enhanced performance the export store data is executed in multiple threads. By default half of the number of available CPU's is used. You can control the number by passing the max.threads parameter like this: -Dmax.threads=2
The error are shown like this:
[SynchronizationStoreDataValidationTask] The following row from C_BPartner is referenced by C_Order but not exported (id, organizationId, identifier):
[SynchronizationStoreDataValidationTask] EDC5DBD82C3B4E3896B3955E041B242C, The White Valley Group, Arturo Montoro23
[SynchronizationStoreDataValidationTask] Referenced by C_Order.C_BPartner_ID (rowId, organization, identifier):
[SynchronizationStoreDataValidationTask] 470D2CDEC629C55C02DC793FE8F9D367, Vall Blanca Store, VBS1/0000114 - 16-08-2016 - 7.5
[SynchronizationStoreDataValidationTask] EB7CEEFF3DD11154ED287F65676FB617, Vall Blanca Store, VBS1/0000113 - 16-08-2016 - 7.5
[SynchronizationStoreDataValidationTask] EADDD0ABB40C304703F4BA2925AF5ABB, Vall Blanca Store, VBS1/0000112 - 16-08-2016 - 3.60
Registering a store in the central server
Before a store is exported, it must be registered in the central server using the following ant task:
ant -f modules/org.openbravo.replication.symmetricds/build.xml register.server -Dstore.server.key=Store1
Once this command is run, the central server will keep track of changes done in the data that should be sent to the new store server. The central server will keep them until the store server is started and the data is synchronized. This ensures that even if some time passes between the export of the store data and the store server start, no data will be lost in the store.
Export data from the central server
Openbravo Commerce suite will take care of synchronizing transactional and master data when a store server is running in a complete server environment. However, it makes sense to install a store server already with a good starting dataset. This section describes how to do that.
The main source of the store server specific data is always the central server. So the first step is to export the store server specific data. This can be done by executing the following ant command in the root of the ERP of the central server.
ant -f modules/org.openbravo.retail.storeserver.synchronization/build.xml export.store.data -DmobileServerKey=store1 -DoutputDirectory=/opt/OpenbravoERP/modules/storeServer1Module -DexportFormat=copy
The exported reference data can be found in the referencedata/sampledata folder of the provided output directory.
Copy Format: -DexportFormat=copy option only works with PostgreSQL databases
Performance: for enhanced performance the export store data is executed in multiple threads. By default half of the number of available CPU's is used. You can control the number by passing the max.threads parameter like this: -Dmax.threads=2
Next: the exported reference data has to be moved/placed in the store server project, in the referencedata/sampledata directory of the root or a module in the store server instance.
All in one task: validate, register, export a store
Instead of executing the above steps 1-by-1 there is also the possibility to run them in one command:
ant -f modules/org.openbravo.retail.storeserver.synchronization/build.xml export.store.full -DmobileServerKey=store1 -DoutputDirectory=/opt/OpenbravoERP/modules/storeServer1Module -DexportFormat=copy
Copy Format: -DexportFormat=copy option only works with PostgreSQL databases
Install the store server & data
At this point you have created the stack, the modules have been created in the project directory. The reference data is located in a module or in code in the referencedata/sampledata directory.
The Openbravo.properties in the config directory is setup with the correct information.
The next step is to run the following command:
ant install.source
If the data being imported does not require executing the modulescripts (i.e. it has been exported from a central server that has already run them) then the following command can be used:
ant install.source -Dexecute.modulescripts=false
This will both install Openbravo as well as import all the data in the store specific module which has been exported in the central system earlier in the process.
Start Tomcat
The last step is to start the store server and login with the same credentials as are used in the central server.
Before starting the store server make sure the central server is running, this is needed for online Symmetric DS registration.
Note: the log can show a warning as is shown below, this can be ignored.
Dec 18, 2015 3:28:42 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib Dec 18, 2015 3:28:42 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:openbravo' did not find a matching property. Dec 18, 2015 3:28:42 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context/Loader} Setting property 'useSystemClassLoaderAsParent' to 'false' did not find a matching property. Dec 18, 2015 3:28:42 PM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8080 Dec 18, 2015 3:28:42 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 657 ms Dec 18, 2015 3:28:42 PM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Dec 18, 2015 3:28:42 PM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.32 0 [main] INFO org.openbravo.base.ConfigParameters - Properties file: /home/mtaal/mydata/dev/openbravo/projects/pi-core-store/WebContent//WEB-INF/Openbravo.properties 2 [main] INFO org.openbravo.base.ConfigParameters - Checking override properties for oslo 97 [main] INFO org.openbravo.dal.core.DalLayerInitializer - Initializing in-memory model... 98 [main] INFO org.openbravo.base.model.ModelProvider - Building runtime model 5620 [main] INFO org.openbravo.dal.core.DalLayerInitializer - Model read in-memory, generating mapping... 16016 [main] INFO org.openbravo.dal.core.DalLayerInitializer - Dal layer initialized 16172 [main] INFO org.openbravo.base.OBSchedulerInitializerListener - Quartz Initializer Servlet loaded, initializing Scheduler... 16251 [main] INFO org.openbravo.base.OBSchedulerInitializerListener - Scheduler will start in 30 seconds. 16251 [main] INFO org.openbravo.base.OBSchedulerInitializerListener - Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY 16251 [main] INFO org.openbravo.base.OBSchedulerInitializerListener - Storing ConfigParameters and ConnectionProvider in Scheduler Context. 16253 [main] INFO org.openbravo.base.OBSchedulerInitializerListener - Initalizing singleton instance of org.openbravo.scheduling.OBScheduler 18784 [symmetric-engine-startup-0] WARN org.jumpmind.symmetric.util.PropertiesFactoryBean - Could not load properties from file [/home/mtaal/./conf/symmetric.properties]: ./conf/symmetric.properties (No such file or directory) 20958 [symmetric-engine-startup-0] WARN org.jumpmind.symmetric.util.PropertiesFactoryBean - Could not load properties from file [/home/mtaal/./conf/symmetric.properties]: ./conf/symmetric.properties (No such file or directory) 20962 [symmetric-engine-startup-0] WARN org.jumpmind.symmetric.util.PropertiesFactoryBean - Could not load properties from file [/home/mtaal/./conf/symmetric.properties]: ./conf/symmetric.properties (No such file or directory) Dec 18, 2015 3:29:11 PM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring root WebApplicationContext Dec 18, 2015 3:29:13 PM org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-8080 Dec 18, 2015 3:29:13 PM org.apache.jk.common.ChannelSocket init INFO: JK: ajp13 listening on /0.0.0.0:8009 Dec 18, 2015 3:29:13 PM org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=0/24 config=null Dec 18, 2015 3:29:14 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 31395 ms
Store Server Deployment Check
After starting the store server it makes sense to check that it is deployed correctly. For this purpose Openbravo provides a Store Server Deployment Check. This check can be executed from the central server backoffice. Many different characteristics of the store server, its configuration, symmetric DS setup, store server state, etc. are checked. The results of the check are shown to the user.