Skip to content

Commit d61179f

Browse files
author
pmasl
committed
Merge branch 'pmasl' of https://github.com/Microsoft/sql-server-samples into pmasl
2 parents d43db92 + 5ac2994 commit d61179f

File tree

928 files changed

+287752
-11900
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

928 files changed

+287752
-11900
lines changed
148 KB
Loading

β€Žsamples/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ Samples that help with the management of SQL Server and Azure SQL Database.
2323
__[tutorials](tutorials/)__
2424

2525
Samples showing how to connect to SQL databases using various programming languages, including Python, C#, Java, Ruby, Node.js, and PHP.
26+
27+
__[containers](containers/)__
28+
29+
Samples showing various SQL Server in container scenarios.

β€Žsamples/applications/aspnet-session-state/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ The code included in this sample is not intended to be a set of best practices o
6060
For more information, see these articles:
6161

6262
- [In-Memory OLTP (In-Memory Optimization)](https://msdn.microsoft.com/en-us/library/dn133186.aspx)
63-
- [OLTP and database management](https://www.microsoft.com/en-us/server-cloud/solutions/oltp-database-management.aspx)
63+
- [OLTP and database management](https://www.microsoft.com/en-us/sql-server/oltp-database-management)
6464
- [Session State Provider](https://msdn.microsoft.com/en-us/library/aa478952.aspx)
6565
- [Implementing a Session-State Store Provider](https://msdn.microsoft.com/en-us/library/ms178587.aspx)

β€Žsamples/containers/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__[replication](replication/)__
2+
3+
Example of SQL Server Replication in containers. This demo uses docker-compose to start two SQL Server containers; one that acts as the publisher and distributor, and the other as the subscriber in a push snapshot configuration.

β€Žsamples/containers/dtc/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## SQL Server Replication with Containers
2+
3+
This demo uses docker-compose to start two SQL Server containers; one that acts as the publisher and distributor, and the other as the subscriber in a push snapshot configuration.
4+
5+
6+
### How to Use
7+
8+
1. Run the following command in this directory:
9+
10+
```
11+
docker-compose up
12+
```
13+
note: this will take approx. 2 min.
14+
15+
In your terminal, you should see something like this
16+
```
17+
db1 | Job 'DB1-Sales-SnapshotRepl-1' started successfully.
18+
db1 | Creating Snapshot...
19+
db1 | Job 'db1-Sales-SnapshotRepl-DB2-1' started successfully.
20+
```
21+
22+
2. Connect to the subscriber listening on localhost,2600 and see that the Sales Database has a Customer table with data in it.
23+
note: credentials are listed in the **docker-compose.yml**
24+
25+
3. when you are done, clean up by running the following command
26+
```
27+
docker-compose down
28+
```
29+
30+
31+
32+
### How it Works
33+
34+
1. Both SQL Server containers start with the environment variables specified in the docker-compose file. In this example, **db1** is the publisher/distributor and **db2** is the subscriber.
35+
2. *db1/db-init.sh* and *db2/db-init.sh* waits for SQL Server to start up and run the *db-init.sql* scripts
36+
3. *db1/db-init.sql* creates a *Sales* Database with *Customer* table and sample data, and proceeds by setting up snapshot replication.
37+
4. *db2/db-init.sql* creates a *Sales* Database.
38+
5. db1 starts replication jobs to push the snapshot to db2
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: "3"
2+
services:
3+
dtc1:
4+
build: ./dtc1
5+
environment:
6+
SA_PASSWORD: "Sql2019isfast"
7+
ACCEPT_EULA: "Y"
8+
MSSQL_AGENT_ENABLED: "true"
9+
MSSQL_RPC_PORT: 135
10+
MSSQL_DTC_TCP_PORT: 51999
11+
ports:
12+
- "1401:1433"
13+
- "135:135"
14+
- "51999:51999"
15+
container_name: dtc1
16+
hostname: dtc1
17+
dtc2:
18+
build: ./dtc2
19+
environment:
20+
SA_PASSWORD: "Sql2019isfast"
21+
ACCEPT_EULA: "Y"
22+
MSSQL_AGENT_ENABLED: "true"
23+
MSSQL_RPC_PORT: 135
24+
MSSQL_DTC_TCP_PORT: 51999
25+
ports:
26+
- "1402:1433"
27+
- "136:135"
28+
- "51998:51999"
29+
container_name: dtc2
30+
hostname: dtc2
31+
32+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sudo docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Sql2019isfast' -e 'MSSQL_RPC_PORT=135' -e 'MSSQL_DTC_TCP_PORT=51000' -p 1401:1433 -p 135:135 -p 51000:51000 --hostname dtc1 --network isolated_nw --name dtc1 -d mcr.microsoft.com/mssql/server:vNext-CTP2.0-ubuntu
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sudo docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Sql2019isfast' -e 'MSSQL_RPC_PORT=135' -e 'MSSQL_DTC_TCP_PORT=51000' -p 1402:1433 -p 136:135 -p 51001:51000 --hostname dtc2 --network isolated_nw --name dtc2 -d mcr.microsoft.com/mssql/server:vNext-CTP2.0-ubuntu
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM mcr.microsoft.com/mssql/server:vNext-CTP2.0-ubuntu
2+
3+
COPY . /
4+
5+
RUN chmod +x /db-init.sh
6+
CMD /bin/bash ./entrypoint.sh
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#wait for the SQL Server to come up
2+
sleep 25s
3+
4+
echo "running set up script"
5+
#run the setup script to create the DB and the schema in the DB
6+
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Sql2019isfast -d master -i db-init.sql

0 commit comments

Comments
 (0)