update on SSIS app deploy

This commit is contained in:
cloudmelon
2021-02-09 19:16:34 +00:00
parent 595b037104
commit 66ea3c8eb2
10 changed files with 3 additions and 375 deletions
@@ -49,7 +49,7 @@ To run this sample, you need the following prerequisites.
Once the app is listed as `Ready` the job should run within a minute.
You can check if the backup is created by running:
```bash
kubectl -n [your namespace] exec -it mssql-master-pool-0 -c mssql-server -- /bin/bash -c "ls /var/opt/mssql/data/*.DWConfigbak"
kubectl -n [your namespace] exec -it master-0 -c mssql-server -- /bin/bash -c "ls /var/opt/mssql/data/*.DWConfigbak"
```
You should see a backup being created for every run of the job, with a maximum of 60 backups since the SSIS package cleans up backups older than one hour.
You can use any of the `.DWConfigbak` files to restore the database.
@@ -80,7 +80,7 @@ name: back-up-db
version: v1
runtime: SSIS
entrypoint: ./back-up-db.dtsx
options: /REP V /CONN "MasterSQL"\;"\"Data Source=service-master-pool;User ID=sa;Initial Catalog=master;Password=[SA_PASSWORD]\""
options: /REP V /CONN "MasterSQL"\;"\"Data Source=master-svc;User ID=sa;Initial Catalog=master;Password=[SA_PASSWORD]\""
schedule: "*/1 * * * *"
```
@@ -2,5 +2,5 @@ name: back-up-db
version: v1
runtime: SSIS
entrypoint: ./back-up-db.dtsx
options: /REP V /CONN "MasterSQL"\;"\"Data Source=master-0;User ID=sa;Initial Catalog=master;Password=[SA_PASSWORD]\""
options: /REP V /CONN "MasterSQL"\;"\"Data Source=master-svc;User ID=sa;Initial Catalog=master;Password=[SA_PASSWORD]\""
schedule: "*/1 * * * *"
@@ -1,9 +0,0 @@
# BDC Developer Connectivity
## Connect with Java Client
To be continued
## Connect with Python Client
To be continued
@@ -1,65 +0,0 @@
# Building this example on Linux
## Prepare dependencies jar into work dir
bash ./prepare.sh
## Building jars
bash ./build.sh
# Running this sample
The App.java has hardcoded values in it mentioned in the sections below. Those should be pointed to the right values.
On Windows, before running this application, kinit needs to be run to get a kerberos token. `kinit` is shipped with the JRE for Windows Java distributions.
`<JRE_INSTALL_ROOT>\bin\kinit.exe <user>@<REALM>`
e.g.
`<JRE_INSTALL_ROOT>\bin\kinit.exe admin@ARIS.LOCAL`
On Linux, kinit can be used. If `kinit` is not installed, then it would need to be installed to get a kerberos token.
e.g.
kinit admin@ARIS.LOCAL
# Sample login.conf. There is an existing login.conf that is being checked in as well.
For more details about login.conf refer https://docs.oracle.com/javase/7/docs/technotes/guides/security/jgss/tutorials/LoginConfigFile.html
```
com.sun.security.jgss.login {
com.sun.security.auth.module.Krb5LoginModule required client=TRUE useTicketCache=true debug=true;
};
com.sun.security.jgss.initiate {
com.sun.security.auth.module.Krb5LoginModule required client=TRUE useTicketCache=true debug=true;
};
com.sun.security.jgss.accept {
com.sun.security.auth.module.Krb5LoginModule required client=TRUE useTicketCache=true debug=true;
};
```
In App.java the following properties need to be configured or parameterized using command line.
```
private static String GW_ENDPOINT = "https://knox.tdeupgrade.aris.local:30443/gateway/default/webhdfs/v1";
private static String KDC = "ARIS-WIN2016-DC.aris.local";
private static String DOMAIN_REALM = "ARIS.LOCAL";
private static String LOGIN_CONF_PATH = "login.conf";
```
# Upload file example
```
java -cp "./running_work_dir/*" com.microsoft.mssql.App ./source /tmp/destination
```
@@ -1,4 +0,0 @@
mvn compile
mvn package
cp target/webhdfsclientsample-1.0-SNAPSHOT.jar running_work_dir/
cd running_work_dir
@@ -1,11 +0,0 @@
com.sun.security.jgss.login {
com.sun.security.auth.module.Krb5LoginModule required client=TRUE useTicketCache=true debug=true principal="admin";
};
com.sun.security.jgss.initiate {
com.sun.security.auth.module.Krb5LoginModule required client=TRUE useTicketCache=true debug=false principal="admin";
};
com.sun.security.jgss.accept {
com.sun.security.auth.module.Krb5LoginModule required client=TRUE useTicketCache=true debug=true principal="admin";
};
@@ -1,119 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.mssql</groupId>
<artifactId>webhdfsclientsample</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.13</version>
</dependency>
</dependencies>
<build>
<pluginManagement> <!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/Crunchify</outputDirectory>
<resources>
<resource>
<directory>resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/Crunchify/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
@@ -1,2 +0,0 @@
# Prepare dependencies jars into a work dir
mvn dependency:copy-dependencies -DoutputDirectory=running_work_dir -Dhttps.protocols=TLSv1.2
@@ -1,142 +0,0 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
*/
package com.microsoft.mssql;
import java.io.File;
import java.security.Principal;
import org.apache.http.HttpEntity;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.AuthSchemes;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.auth.BasicSchemeFactory;
import org.apache.http.impl.auth.DigestSchemeFactory;
import org.apache.http.impl.auth.KerberosSchemeFactory;
import org.apache.http.impl.auth.NTLMSchemeFactory;
import org.apache.http.impl.auth.SPNegoSchemeFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
/**
* Sample app for Encryption Zone interactions with WebHdfs.
*/
public class App {
// Properties to be configured before running the application.
private static String GW_ENDPOINT = "https://knox.test.azdata.local:30443/gateway/default/webhdfs/v1";
private static String KDC = "winad.azdata.local";
private static String DOMAIN_REALM = "AZDATA.LOCAL";
// The existing login.conf along with this project can be modified instead of providing a new path.
private static String LOGIN_CONF_PATH = "login.conf";
// End of properties to be configured.
static Credentials emptyCredentials = new Credentials() {
public String getPassword() {
return null;
}
public Principal getUserPrincipal() {
return null;
}
};
static CredentialsProvider provider = new CredentialsProvider() {
@Override
public void setCredentials(AuthScope authscope, Credentials credentials) {
// No op
}
@Override
public Credentials getCredentials(AuthScope authscope) {
//TODO: this can be enhanced to pass user name and password in case the AuthScope authscheme is basic.
return emptyCredentials;
}
@Override
public void clear() {
// No op. Nothing to clean up.
}
};
private static void uploadResource(String inputFilePath, String outputFilePath){
System.out.println("Entering create resource");
// Create a custom auth scheme registry to prevent reverse DNS lookup on the Http Endpoints
// For BDC, the same IP address can be associated with multiple service endpoints. Hence control.aris.local and knox.aris.local
// can resolve to the same IP during reverse lookup. As a result of this kerberos auth may fail.
// To fix the problem, we should prevent reverse lookup by turning off Hostname Canonicalization in HTTP client and
// recommend that the user use the FQDN of knox endpoint to connect to knox.
Registry<AuthSchemeProvider> authSchemeRegistryCopy = RegistryBuilder.<AuthSchemeProvider>create()
.register(AuthSchemes.BASIC, new BasicSchemeFactory())
.register(AuthSchemes.DIGEST, new DigestSchemeFactory())
.register(AuthSchemes.NTLM, new NTLMSchemeFactory())
.register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, false))
.register(AuthSchemes.KERBEROS, new KerberosSchemeFactory(true, false))
.build();
// Construct Knox endpoint
String createOperationEndpoint = GW_ENDPOINT + outputFilePath + "?op=CREATE&overwrite=true";
try (CloseableHttpClient client2 = HttpClients.custom().setDefaultCredentialsProvider(provider).setDefaultAuthSchemeRegistry(authSchemeRegistryCopy).build()) {
HttpUriRequest request = new HttpPut(createOperationEndpoint);
// First request to get the location in data nodes
try (CloseableHttpResponse response = client2.execute(request)) {
System.out.println("===============");
String newlocation = response.getFirstHeader("Location").getValue();
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
System.out.println("----------------------------------------");
if (entity != null) {
System.out.println(EntityUtils.toString(entity));
}
System.out.println("----------------------------------------");
EntityUtils.consume(entity);
// Second request to put the content to that location
File testUploadFile = new File(inputFilePath);
HttpEntity putData = MultipartEntityBuilder.create().addBinaryBody("upfile", testUploadFile).build();
HttpUriRequest putRequest = RequestBuilder.put(newlocation).setEntity(putData).build();
System.out.println("Executing request " + putRequest.getRequestLine());
CloseableHttpResponse response2 = client2.execute(putRequest);
HttpEntity entity2 = response2.getEntity();
System.out.println("----------------------------------------");
System.out.println(response2.getStatusLine());
System.out.println("----------------------------------------");
if (entity2 != null) {
System.out.println(EntityUtils.toString(entity2));
}
System.out.println("----------------------------------------");
}
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
// These properties can be specified using command line as well by using
// -Djava.security.auth.login.conf=login.conf -Djava.security.krb5.realm=MYDOMAIN.LOCAL
// In case command line is used to pass these arguments, then code below setting system properties should not be used..
System.setProperty("java.security.auth.login.config", LOGIN_CONF_PATH); // The login conf for Java GSS to use. See readme for a sample.
System.setProperty("java.security.krb5.realm", DOMAIN_REALM); // The domain name.
System.setProperty("java.security.krb5.kdc", KDC); // Provide the KDC name here
System.setProperty("sun.security.krb5.debug", "true"); // This can be set to true to print debug information about Kerberos login.
System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
for(int i = 0; i < args.length; i++) {
System.out.println(args[i]);
}
uploadResource(args[0], args[1]);
}
}
@@ -1,20 +0,0 @@
package com.microsoft.mssql;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* Unit test for simple App.
*/
public class AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}