-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
actualizing tutorial to support manual and automatic server creation …
…scenarios
- Loading branch information
1 parent
66f5315
commit 9b9c532
Showing
17 changed files
with
151 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# overrides default values for underlying postgres connection | ||
postgres: | ||
hostname: localhost | ||
port: 5432 | ||
database: postgres | ||
username: postgres | ||
password: postgres | ||
|
||
servers: | ||
mysql_customers: | ||
description: MySQL - Customers | ||
fdw_name: mysql_fdw | ||
foreign_server: | ||
host: mysql | ||
port: 3306 | ||
user_mapping: | ||
username: mysql | ||
password: mysql | ||
|
||
postgres_products: | ||
description: Postgres - Products | ||
fdw_name: postgres_fdw | ||
foreign_server: | ||
host: postgres | ||
port: 5432 | ||
dbname: factory | ||
user_mapping: | ||
user: postgres | ||
password: postgres | ||
|
||
# using system generated name to allow re-use for the manually and automatically created servers | ||
mongo_fdw_1: | ||
description: Mongo - Orders | ||
fdw_name: mongo_fdw | ||
foreign_server: | ||
address: mongo | ||
port: 27017 | ||
authentication_database: admin | ||
user_mapping: | ||
username: mongo | ||
password: mongo | ||
|
||
mssql_employees: | ||
description: MSSQL - Employees | ||
fdw_name: tds_fdw | ||
foreign_server: | ||
servername: mssql | ||
port: 1433 | ||
database: hr | ||
user_mapping: | ||
username: sa | ||
password: Mssql_2019 | ||
|
||
sqlite_job-roles: | ||
description: SQLite - Job Roles | ||
fdw_name: sqlite_fdw | ||
foreign_server: | ||
database: /data/sqlite/job_roles.db | ||
|
||
# using system generated name to allow re-use for the manually and automatically created servers | ||
file_fdw_1: | ||
description: CSV - Departments | ||
fdw_name: file_fdw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
check_db_status() { | ||
# Wait 60 seconds for SQL Server to start up by ensuring that | ||
# calling SQLCMD does not return an error code, which will ensure that sqlcmd is accessible | ||
# and that system and user databases return "0" which means all databases are in an "online" state | ||
# https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-databases-transact-sql?view=sql-server-2017 | ||
|
||
DBSTATUS=1 | ||
ERRCODE=1 | ||
MAX_ITERATIONS=60 | ||
i=0 | ||
|
||
while { [[ $DBSTATUS -ne 0 ]] || [[ $ERRCODE -ne 0 ]]; } && [[ $i -lt $MAX_ITERATIONS ]]; do | ||
i=$((i+1)) | ||
OUTPUT=$( | ||
/opt/mssql-tools18/bin/sqlcmd -h -1 -t 1 -No \ | ||
-U sa -P $MSSQL_SA_PASSWORD \ | ||
-Q "SET NOCOUNT ON; Select SUM(state) from sys.databases" | ||
) | ||
echo "OUTPUT: $OUTPUT" # Print the output of sqlcmd | ||
ERRCODE=$? | ||
DBSTATUS=$(echo $OUTPUT | xargs) # This will trim the spaces | ||
sleep 1 | ||
echo "dbstatus: $DBSTATUS, errcode: $ERRCODE, i: $i" | ||
done | ||
|
||
if [[ $DBSTATUS -ne 0 ]] || [[ $ERRCODE -ne 0 ]]; then | ||
echo "SQL Server took more than $MAX_ITERATIONS seconds to start up or one or more databases are not in an ONLINE state" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Execute the function twice with a sleep interval | ||
check_db_status | ||
sleep 10 | ||
check_db_status | ||
|
||
# Run the setup script to create the DB and the schema in the DB | ||
/opt/mssql-tools18/bin/sqlcmd -S localhost -No -U sa -P $MSSQL_SA_PASSWORD -d master -i /usr/config/setup.sql |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,3 @@ | |
|
||
# Start SQL Server | ||
/opt/mssql/bin/sqlservr | ||
|
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters