From 02871885ac31abfc0973dbf48ad2529175e3bc7b Mon Sep 17 00:00:00 2001 From: Matthias Wessendorf Date: Wed, 18 Apr 2018 15:35:02 +0200 Subject: [PATCH] Installation (#988) * removing outdated 1.0 migration scripts * Rename scripts to not imply WF11 support only * Remove H2 deployments, those are now in docker * standalone-ha was never supported * Rename mysql script * Adding standalone KC file * Some installation docs --- databases/README.md | 84 +++++++++++++++++++ databases/h2-database-config-wildfly.cli | 18 ---- .../ha_deployment/deploy-managed-domain.cli | 7 -- .../mysql-database-config-wildfly-full-ha.cli | 32 ------- ...database-config-wildfly-managed-domain.cli | 32 ------- databases/migration/README.md | 29 ------- .../migration/keycloak-migration-mysql.sql | 8 -- .../keycloak-migration-postgresql.sql | 6 -- databases/migration/ups-migration-mysql.sql | 41 --------- .../migration/ups-migration-postgresql.sql | 30 ------- ...wf11.sh => prepare_clean_mysql_wildfly.sh} | 0 ..._wf11.sh => prepare_clean_psql_wildfly.sh} | 0 databases/unifiedpush-h2-ds.xml | 27 ------ docker-compose/README.md | 8 ++ docker-compose/keycloak-standalone.yaml | 11 +++ 15 files changed, 103 insertions(+), 230 deletions(-) create mode 100644 databases/README.md delete mode 100644 databases/h2-database-config-wildfly.cli delete mode 100644 databases/ha_deployment/deploy-managed-domain.cli delete mode 100644 databases/ha_deployment/mysql-database-config-wildfly-full-ha.cli delete mode 100644 databases/ha_deployment/mysql-database-config-wildfly-managed-domain.cli delete mode 100644 databases/migration/README.md delete mode 100644 databases/migration/keycloak-migration-mysql.sql delete mode 100644 databases/migration/keycloak-migration-postgresql.sql delete mode 100644 databases/migration/ups-migration-mysql.sql delete mode 100644 databases/migration/ups-migration-postgresql.sql rename databases/{prepare_clean_wf11.sh => prepare_clean_mysql_wildfly.sh} (100%) rename databases/{prepare_clean_psql_wf11.sh => prepare_clean_psql_wildfly.sh} (100%) delete mode 100644 databases/unifiedpush-h2-ds.xml create mode 100644 docker-compose/keycloak-standalone.yaml diff --git a/databases/README.md b/databases/README.md new file mode 100644 index 0000000000..6518b6f27a --- /dev/null +++ b/databases/README.md @@ -0,0 +1,84 @@ +# Install the UPS with a RDBMS + +This guide explains how to configure a fresh WildFly instance and setup the database + +__Perquisite:__ Make sure you have the latest version of [WildFly](http://wildfly.org/downloads/), extracted on your machine. + +## Database configuration + +The UPS does support two database system: + +* Postgres (preferred) +* MySQL + +### Postgres + +You need a running database, like: + +``` +docker run \ + -p 5432:5432 \ + -e POSTGRES_PASSWORD=unifiedpush \ + -e POSTGRES_USER=unifiedpush \ + -e POSTGRES_DATABASE=unifiedpush \ + -d postgres:9.6 +``` + +### MySQL + +You need a running database, like: + +``` +docker run \ + -p 6306:3306 \ + -e MYSQL_USER=unifiedpush \ + -e MYSQL_PASSWORD=unifiedpush \ + -e MYSQL_DATABASE=unifiedpush \ + -e MYSQL_ROOT_PASSWORD=supersecret \ + -d mysql:5.6 +``` + +## Prepare the Wildfly server for UPS deployment + +Go to your Wildfly installation and start the server, using the `standalone-full` configuration, like: + +``` +$WILDFLY_HOME/bin/standalone.sh -c standalone-full.xml -b 0.0.0.0 +``` + +__NOTE:__ make sure you have the installation folder of Wildfly exported to `$WILDFLY_HOME`. + +We have two shell scripts for setting up the system: + +* `prepare_clean_psql_wildfly.sh` +* `prepare_clean_mysql_wildfly.sh` + +Based on your database choice execute one of the scripts, like: + +``` +./prepare_clean_psql_wildfly.sh +``` + +## UPS deployment + +Now the server is running and you can deploy the `WAR` file from the `servers/plain/target` folder. +This is an unprotected version of the push server. + + +## UPS and Keycloak + +We have a Keycloak protected version of the UPS (located in `servers/keycloak/target`), which requires a separated Keycloak server. + +For Keycloak we need to provide two `System Properties`: +* `ups.realm.name` - name of the realm used for UPS +* `ups.auth.server.url` - fullqualified URI of the Keycloak server + +Here is how the command looks like: + +``` +$WILDFLY_HOME/bin/standalone.sh -c standalone-full.xml -Dups.realm.name=aerogear -Dups.auth.server.url=http://my-keycloak:PORT/auth -b 0.0.0.0 +``` + +### Running Keycloak + +In the [docker-compose](../docker-compose) folder there is a *Standalone Keycloak* section that explains details on how to run a Keycloak server. diff --git a/databases/h2-database-config-wildfly.cli b/databases/h2-database-config-wildfly.cli deleted file mode 100644 index 2596eb8f48..0000000000 --- a/databases/h2-database-config-wildfly.cli +++ /dev/null @@ -1,18 +0,0 @@ -# $WILDFLY_HOME/bin/jboss-cli.sh --file=/path/to/this/file. -connect - -try - ## Add UnifiedPush Datasource - data-source add --name=UnifiedPushDS --driver-name=h2 --jndi-name=java:jboss/datasources/UnifiedPushDS --connection-url="jdbc:h2:${jboss.server.data.dir}/unifiedpush;DB_CLOSE_DELAY=-1" --user-name=sa --password=sa --use-ccm=true --enabled=true -catch - if (response-headers.process-state == reload-required) of /subsystem=datasources/data-source=UnifiedPushDS:remove - ## Reload the controller - reload - ## Add UnifiedPush Datasource - data-source add --name=UnifiedPushDS --driver-name=h2 --jndi-name=java:jboss/datasources/UnifiedPushDS --connection-url="jdbc:h2:${jboss.server.data.dir}/unifiedpush;DB_CLOSE_DELAY=-1" --user-name=sa --password=sa --use-ccm=true --enabled=true - else - ## Add UnifiedPush Datasource - data-source add --name=UnifiedPushDS --driver-name=mysqlup --jndi-name=java:jboss/datasources/UnifiedPushDS --connection-url="jdbc:mysql://localhost:6306/unifiedpush?useUnicode=true&characterEncoding=UTF-8" --user-name=unifiedpush --password=unifiedpush --use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true - end-if -finally -end-try \ No newline at end of file diff --git a/databases/ha_deployment/deploy-managed-domain.cli b/databases/ha_deployment/deploy-managed-domain.cli deleted file mode 100644 index 43d0f01279..0000000000 --- a/databases/ha_deployment/deploy-managed-domain.cli +++ /dev/null @@ -1,7 +0,0 @@ -connect -batch - -deploy ag-push.war --server-groups=other-server-group - -run-batch -#:reload \ No newline at end of file diff --git a/databases/ha_deployment/mysql-database-config-wildfly-full-ha.cli b/databases/ha_deployment/mysql-database-config-wildfly-full-ha.cli deleted file mode 100644 index 9ba2d16aa8..0000000000 --- a/databases/ha_deployment/mysql-database-config-wildfly-full-ha.cli +++ /dev/null @@ -1,32 +0,0 @@ -# $WILDFLY_HOME/bin/jboss-cli.sh --file=/path/to/this/file. -connect localhost:10190 - -try - ## Add Mysql driver - /subsystem=datasources/jdbc-driver=mysqlup:add(driver-name=mysqlup,driver-module-name=com.mysql.jdbc,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource) -catch - if (response-headers.process-state == reload-required) of /subsystem=datasources/data-source=UnifiedPushDS:remove - ## Reload the controller - reload - ## Add MySQL driver to the controller again - /subsystem=datasources/jdbc-driver=mysqlup:remove - /subsystem=datasources/jdbc-driver=mysqlup:add(driver-name=mysqlup,driver-module-name=com.mysql.jdbc,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource) - end-if -finally -end-try - -try - ## Add UnifiedPush Datasource - data-source add --name=UnifiedPushDS --driver-name=mysqlup --jndi-name=java:jboss/datasources/UnifiedPushDS --connection-url="jdbc:mysql://192.168.59.104:6306/unifiedpush?useUnicode=true&characterEncoding=UTF-8" --user-name=unifiedpush --password=unifiedpush --use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true -catch - if (response-headers.process-state == reload-required) of /subsystem=datasources/data-source=UnifiedPushDS:remove - ## Reload the controller - reload - ## Add UnifiedPush Datasource - data-source add --name=UnifiedPushDS --driver-name=mysqlup --jndi-name=java:jboss/datasources/UnifiedPushDS --connection-url="jdbc:mysql://192.168.59.104:6306/unifiedpush?useUnicode=true&characterEncoding=UTF-8" --user-name=unifiedpush --password=unifiedpush --use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true - else - ## Add UnifiedPush Datasource - data-source add --name=UnifiedPushDS --driver-name=mysqlup --jndi-name=java:jboss/datasources/UnifiedPushDS --connection-url="jdbc:mysql://localhost:6306/unifiedpush?useUnicode=true&characterEncoding=UTF-8" --user-name=unifiedpush --password=unifiedpush --use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true - end-if -finally -end-try diff --git a/databases/ha_deployment/mysql-database-config-wildfly-managed-domain.cli b/databases/ha_deployment/mysql-database-config-wildfly-managed-domain.cli deleted file mode 100644 index 14524f382b..0000000000 --- a/databases/ha_deployment/mysql-database-config-wildfly-managed-domain.cli +++ /dev/null @@ -1,32 +0,0 @@ -# $WILDFLY_HOME/bin/jboss-cli.sh --file=/path/to/this/file. -connect - -try - ## Add Mysql driver - /profile=full-ha/subsystem=datasources/jdbc-driver=mysqlup:add(driver-name=mysqlup,driver-module-name=com.mysql.jdbc,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource) -catch - if (response-headers.process-state == reload-required) of /subsystem=datasources/data-source=UnifiedPushDS:remove - ## Reload the controller - reload - ## Add MySQL driver to the controller again - /profile=full-ha/subsystem=datasources/jdbc-driver=mysqlup:remove - /profile=full-ha/subsystem=datasources/jdbc-driver=mysqlup:add(driver-name=mysqlup,driver-module-name=com.mysql.jdbc,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource) - end-if -finally -end-try - -try - ## Add UnifiedPush Datasource - data-source add --profile=full-ha --name=UnifiedPushDS --driver-name=mysqlup --jndi-name=java:jboss/datasources/UnifiedPushDS --connection-url="jdbc:mysql://192.168.59.104:6306/unifiedpush?useUnicode=true&characterEncoding=UTF-8" --user-name=unifiedpush --password=unifiedpush --use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true -catch - if (response-headers.process-state == reload-required) of /subsystem=datasources/data-source=UnifiedPushDS:remove - ## Reload the controller - reload - ## Add UnifiedPush Datasource - data-source add --profile=full-ha --name=UnifiedPushDS --driver-name=mysqlup --jndi-name=java:jboss/datasources/UnifiedPushDS --connection-url="jdbc:mysql://192.168.59.104:6306/unifiedpush?useUnicode=true&characterEncoding=UTF-8" --user-name=unifiedpush --password=unifiedpush --use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true - else - ## Add UnifiedPush Datasource - data-source add --profile=full-ha --name=UnifiedPushDS --driver-name=mysqlup --jndi-name=java:jboss/datasources/UnifiedPushDS --connection-url="jdbc:mysql://192.168.59.104:6306/unifiedpush?useUnicode=true&characterEncoding=UTF-8" --user-name=unifiedpush --password=unifiedpush --use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true - end-if -finally -end-try diff --git a/databases/migration/README.md b/databases/migration/README.md deleted file mode 100644 index abdc4dd954..0000000000 --- a/databases/migration/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# UnifiedPush Server - Database migration - -For the database migration you may need to run a few scripts inside of the database - -## 1.0.0 users - -The UnifiedPush Server is supporting two different databases, MySQL and PostgreSQL, below you find information on how to perform the migration on each of the supported databases - -### MySQL - -Inside of the database execute these two scripts: - -* `keycloak-migration-mysql.sql` -* `ups-migration-mysql.sql` - -### PostgreSQL - -Inside of the database execute these two scripts: - -* `keycloak-migration-postgresql.sql` -* `ups-migration-postgresql.sql` - -### WAR files - -After successfully executing the above migration scripts you need to replace the deployed 1.0.0 WAR files with the new ones. That's it! - -## 1.0.1 or 1.0.2 users - -No migration is required :smile: diff --git a/databases/migration/keycloak-migration-mysql.sql b/databases/migration/keycloak-migration-mysql.sql deleted file mode 100644 index aa4dcc7fbb..0000000000 --- a/databases/migration/keycloak-migration-mysql.sql +++ /dev/null @@ -1,8 +0,0 @@ -use unifiedpush; - --- --- Migrate KC refactorings done between 1.0-beta-4 and 1.0.Final --- -rename table REALM_AUDIT_LISTENERS to REALM_EVENTS_LISTENERS; -alter table REALM change AUDIT_ENABLED EVENTS_ENABLED bit(1); -alter table REALM change AUDIT_EXPIRATION EVENTS_EXPIRATION bigint(20); diff --git a/databases/migration/keycloak-migration-postgresql.sql b/databases/migration/keycloak-migration-postgresql.sql deleted file mode 100644 index 71a7720215..0000000000 --- a/databases/migration/keycloak-migration-postgresql.sql +++ /dev/null @@ -1,6 +0,0 @@ --- --- Migrate KC refactorings done between 1.0-beta-4 and 1.0.Final --- -alter table REALM_AUDIT_LISTENERS rename to REALM_EVENTS_LISTENERS; -alter table REALM rename column AUDIT_ENABLED to EVENTS_ENABLED; -alter table REALM rename column AUDIT_EXPIRATION to EVENTS_EXPIRATION; diff --git a/databases/migration/ups-migration-mysql.sql b/databases/migration/ups-migration-mysql.sql deleted file mode 100644 index 0d8aae2ab8..0000000000 --- a/databases/migration/ups-migration-mysql.sql +++ /dev/null @@ -1,41 +0,0 @@ -use unifiedpush; - -CREATE TABLE `hibernate_sequence` ( - `next_val` BIGINT(19) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Table structure for table `Category` --- - -CREATE TABLE `Category` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT, - `name` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- - --- --- Table structure for table `Installation_Category` --- - -CREATE TABLE `Installation_Category` ( - `Installation_id` varchar(255) NOT NULL, - `categories_id` bigint(20) NOT NULL, - PRIMARY KEY (`Installation_id`,`categories_id`), - KEY `FK9A83A563DC2D45CD` (`Installation_id`), - KEY `FK9A83A563B9183AEF` (`categories_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - - --- --- Migrate data from `Installation_categories` to `Installation_Category` --- - -insert into Category (name) select distinct categories from Installation_categories; -insert into Installation_Category SELECT installation_id, id FROM Installation_categories ic join Category c on c.name = ic.categories; - -insert into hibernate_sequence (next_val) select max(id) + 1 from Category; - -drop table Installation_categories; diff --git a/databases/migration/ups-migration-postgresql.sql b/databases/migration/ups-migration-postgresql.sql deleted file mode 100644 index 37504212a5..0000000000 --- a/databases/migration/ups-migration-postgresql.sql +++ /dev/null @@ -1,30 +0,0 @@ --- --- Table structure for table `Category` --- - -CREATE TABLE Category ( - id SERIAL NOT NULL, - name varchar(255), - PRIMARY KEY (id) -); - --- -------------------------------------------------------- - --- --- Table structure for table `Installation_Category` --- - -CREATE TABLE Installation_Category ( - Installation_id varchar(255) NOT NULL references Installation(id), - categories_id bigint NOT NULL references Category(id), - PRIMARY KEY (Installation_id,categories_id) -); - --- --- Migrate data from `Installation_categories` to `Installation_Category` --- - -insert into Category (name) select distinct categories from Installation_categories; -insert into Installation_Category SELECT installation_id, id FROM Installation_categories ic join Category c on c.name = ic.categories; - -drop table installation_categories; \ No newline at end of file diff --git a/databases/prepare_clean_wf11.sh b/databases/prepare_clean_mysql_wildfly.sh similarity index 100% rename from databases/prepare_clean_wf11.sh rename to databases/prepare_clean_mysql_wildfly.sh diff --git a/databases/prepare_clean_psql_wf11.sh b/databases/prepare_clean_psql_wildfly.sh similarity index 100% rename from databases/prepare_clean_psql_wf11.sh rename to databases/prepare_clean_psql_wildfly.sh diff --git a/databases/unifiedpush-h2-ds.xml b/databases/unifiedpush-h2-ds.xml deleted file mode 100644 index 3c6180fbc6..0000000000 --- a/databases/unifiedpush-h2-ds.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - jdbc:h2:${jboss.server.data.dir}/unifiedpush;DB_CLOSE_DELAY=-1 - h2 - - sa - sa - - - diff --git a/docker-compose/README.md b/docker-compose/README.md index c93b7c2caf..d0233beec7 100644 --- a/docker-compose/README.md +++ b/docker-compose/README.md @@ -43,3 +43,11 @@ docker run -p 8080:8080 -it aerogear/ups:kc ``` This brings up both, Keycloak and the UPS containers. Now, go to `http://localhost:8080/` to login to the UPS! + +### Standalone Keycloak + +It might be handy to just run Keycloak in a Linux container, like: + +``` +docker-compose -f keycloak-standalone.yaml up -d +``` diff --git a/docker-compose/keycloak-standalone.yaml b/docker-compose/keycloak-standalone.yaml new file mode 100644 index 0000000000..3081edf127 --- /dev/null +++ b/docker-compose/keycloak-standalone.yaml @@ -0,0 +1,11 @@ +version: '2.1' + +services: + keycloakServer: + image: docker.io/jboss/keycloak:3.4.3.Final + command: "-b 0.0.0.0 -Dkeycloak.import=/ups-keycloak-config/ups-realm-sample.json" + volumes: + - ./keycloak-realm:/ups-keycloak-config:z + environment: + KEYCLOAK_USER: ${KEYCLOAK_USER} + KEYCLOAK_PASSWORD: ${KEYCLOAK_PASSWORD}