首先啟動mssql-server-linux的container然後進入bash,查看一下process
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<Passw0rd>' -p 1433:1433 -d microsoft/mssql-server-linux
docker exec -it c1f bash
ps aux
1. Import the public repository GPG keys:
docker exec -it c1f bash
ps aux
1. Import the public repository GPG keys:
wget --no-check-certificate -q -O - https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
2. Register the Microsoft SQL Server Ubuntu repository:
改用wget要-O file這樣用喔
wget --no-check-certificate https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list -O /etc/apt/sources.list.d/mssql-server.list
記得check一下/etc/apt/sources.list.d/mssql-server.list是不是有下面這行
deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/mssql-server xenial main
3. Install apt-utils
這步我不確定要不要,只因為我在安裝mssql-server-agent時,有說apt-utils未安裝,所以我還是打上了
apt-get -y install apt-utils
4. Install mssql-server-agent
先更新一下apt的套件庫
apt-get update
開始安裝,注意一下一定要設DEBIAN_FRONTEND,否則會出現很多錯誤喔
export DEBIAN_FRONTEND="noninteractive"
apt-get -y install mssql-server-agent
5. Restart mssql-server
怎麼重啟,因為是Docker,所以是用Docker的方式,離開bash後,restart後再進入bash
docker restart c1f
6. 怎麼看mssql-server-agent是啟動的?
ps看不出來,並沒有多一個process
ps aux
查sysprocesses可以查到SQLAgent - Generic Refresher,所以應該是正常的
select spid,program_name,net_library,loginame from master.dbo.sysprocesses where spid>=50;
查看有沒有SQLAGENT的log
cat /var/opt/mssql/log/SQLAGENT.OUT
7. 測試一下job能否執行,圖中有個錯誤是我打錯造成請忽略喔USE msdb ;
EXEC dbo.sp_add_job @job_name = N'Test Job' ;
EXEC sp_add_jobstep @job_name = N'Test Job', @step_name = N'Cretae database', @subsystem = N'TSQL', @command = N'CREATE DATABASE SampleDB;', @retry_attempts = 5, @retry_interval = 5 ;
EXEC dbo.sp_add_schedule @schedule_name = N'Test Job Sch', @freq_type = 4, @freq_interval = 1, @active_start_time = 233000 ;
EXEC sp_attach_schedule @job_name = N'Test Job', @schedule_name = N'Test Job Sch';
EXEC dbo.sp_add_jobserver @job_name = N'Test Job', @server_name = N'(LOCAL)';
EXEC dbo.sp_start_job N'Test Job';
exec sp_helpdb;
怎麼重啟,因為是Docker,所以是用Docker的方式,離開bash後,restart後再進入bash
docker restart c1f
ps看不出來,並沒有多一個process
ps aux
查sysprocesses可以查到SQLAgent - Generic Refresher,所以應該是正常的
select spid,program_name,net_library,loginame from master.dbo.sysprocesses where spid>=50;
查看有沒有SQLAGENT的log
cat /var/opt/mssql/log/SQLAGENT.OUT
7. 測試一下job能否執行,圖中有個錯誤是我打錯造成請忽略喔USE msdb ;
EXEC dbo.sp_add_job @job_name = N'Test Job' ;
EXEC sp_add_jobstep @job_name = N'Test Job', @step_name = N'Cretae database', @subsystem = N'TSQL', @command = N'CREATE DATABASE SampleDB;', @retry_attempts = 5, @retry_interval = 5 ;
EXEC dbo.sp_add_schedule @schedule_name = N'Test Job Sch', @freq_type = 4, @freq_interval = 1, @active_start_time = 233000 ;
EXEC sp_attach_schedule @job_name = N'Test Job', @schedule_name = N'Test Job Sch';
EXEC dbo.sp_add_jobserver @job_name = N'Test Job', @server_name = N'(LOCAL)';
EXEC dbo.sp_start_job N'Test Job';
exec sp_helpdb;
tail -n 10 /var/opt/mssql/log/SQLAGENT.OUT
有sysprocess,有log且job執行成功,到此可確定安裝是成功的
如果要用Dockerfile來建置應該也是可以,此篇不會介紹,自己試試吧
有sysprocess,有log且job執行成功,到此可確定安裝是成功的
如果要用Dockerfile來建置應該也是可以,此篇不會介紹,自己試試吧
0 意見:
張貼留言