溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

docker 安裝sql2017還原windows2012數(shù)據(jù)庫(kù)備份

發(fā)布時(shí)間:2020-08-03 23:48:49 來源:網(wǎng)絡(luò) 閱讀:349 作者:一二毛錢 欄目:云計(jì)算

docker 安裝sql2017還原windows2012數(shù)據(jù)庫(kù)備份

1. centos7.6安裝docker

#安裝依賴包
yum install -y yum-utils device-mapper-persistent-data lvm2
#下載docker yum源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
#下載docker
yum install -y docker
#配置國(guó)內(nèi)鏡像
[root@node1 ~]#cat /etc/docker/daemon.json 
{
"registry-mirrors": [
"https://kfwkfulq.mirror.aliyuncs.com",
"https://2lqq34jg.mirror.aliyuncs.com",
"https://pee6w651.mirror.aliyuncs.com",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com"
],
"dns": ["8.8.8.8","8.8.4.4"]
}
#啟動(dòng)&開機(jī)啟動(dòng)docker
systemctl start docker && systemctl enable docker

2.docker安裝mssql2017

#搜索鏡像
[root@node1 ~]# docker search mssql
INDEX       NAME                                                            DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/microsoft/mssql-server-linux                          Deprecated SQL Server on Linux Container R...   1159                 
docker.io   docker.io/microsoft/mssql-server-windows-developer              Official Microsoft SQL 
..........................

#下載鏡像
[root@node1 ~]#docker?pull microsoft/mssql-server-linux:2017-latest
#查看下載好的鏡像
[root@node1 ~]# docker images      
REPOSITORY                               TAG                 IMAGE ID            CREATED             SIZE
docker.io/microsoft/mssql-server-linux   2017-latest         314918ddaedf        11 months ago       1.35 GB

#創(chuàng)建并運(yùn)行容器
[root@node1 ~]#docker?run --name MSSQL_1433 -m?512m?-e?'ACCEPT_EULA=Y'?-e?'SA_PASSWORD=yourpasSw0rd'?--net=host -d microsoft/mssql-server-linux
[root@node1 ~]# docker start eae198ad6034(可以啟動(dòng)ID或者容器名)
eae198ad6034
#查看創(chuàng)建好的容器(UP代表已經(jīng)啟動(dòng))
[root@node1 ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                    PORTS               NAMES
eae198ad6034        314918ddaedf        "/opt/mssql/bin/sq..."   24 hours ago        Up 58 minutes                                 MSSQL_1433
8b1962a03efe        314918ddaedf        "/bin/bash"              25 hours ago        Exited (0) 24 hours ago                       linuxmssql
#進(jìn)入容器
[root@node1 ~]# docker exec -it eae198ad6034 /bin/bash
#進(jìn)入數(shù)據(jù)庫(kù)(IP是宿主機(jī)的IP,用戶是大寫的)
root@node1:~# /opt/mssql-tools/bin/sqlcmd -S 172.16.10.66 -U SA  -P 'lihao@123' 
    #出現(xiàn)這個(gè)就表示進(jìn)入數(shù)據(jù)庫(kù)了
1> select name from sys.databases;
2> go
name                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------
master                                                                                                                          
tempdb                                                                                                                          
model                                                                                                                           
msdb   

3.還原數(shù)據(jù)庫(kù)

#上傳備份文件
下載winscp或者lrzsz工具,把備份文件上傳宿主機(jī),再把備份文件復(fù)制到容器的/var/opt/mssql/data/目錄下
[root@node1 ~]# docker cp EastRiver.bak eae198ad6034:/var/opt/mssql/data/
root@node1:~# ll /var/opt/mssql/data/
total 1300488
drwxr-xr-x 2 root root      4096 Nov 19 14:25 ./
drwxr-xr-x 7 root root        73 Nov 18 15:23 ../
-rw-r--r-- 1 root root 205852672 Nov  4 09:43 EastRiver.bak
-rw-r----- 1 root root   4194304 Nov 19 15:14 master.mdf
-rw-r----- 1 root root   2097152 Nov 19 15:23 mastlog.ldf
-rw-r----- 1 root root   8388608 Nov 19 14:09 model.mdf
-rw-r----- 1 root root   8388608 Nov 19 14:09 modellog.ldf
-rw-r----- 1 root root  15466496 Nov 19 15:14 msdbdata.mdf
-rw-r----- 1 root root    786432 Nov 19 15:14 msdblog.ldf
-rw-r----- 1 root root   8388608 Nov 19 14:09 tempdb.mdf
-rw-r----- 1 root root   8388608 Nov 19 15:14 templog.ldf
-rw-r----- 1 root root   8388608 Nov 19 14:09 test.mdf
-rw-r----- 1 root root   8388608 Nov 19 15:09 test_log.ldf
 #打開Windows下的sql管理工具(我用2008R2中文版的不行,用2012的英文版的可以,不清楚是中英文的關(guān)系,還是版本的的關(guān)系,有興趣的你們可以試試)
新建了一個(gè)test庫(kù)
create database test;

#還原數(shù)據(jù)庫(kù)
docker 安裝sql2017還原windows2012數(shù)據(jù)庫(kù)備份
docker 安裝sql2017還原windows2012數(shù)據(jù)庫(kù)備份

后面的操作因?yàn)槟承┰驘o法上圖了,都跟Windows還原一樣了,百度一下就可以了
還原成功后,就出現(xiàn)新的庫(kù)了
docker 安裝sql2017還原windows2012數(shù)據(jù)庫(kù)備份

#在容器上查看
1> select name from sys.databases
2> go
name                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------
master                                                                                                                          
tempdb                                                                                                                          
model                                                                                                                           
msdb                                                                                                                            
test                                                                                                                            
EastRiver                                                                                                                       

(6 rows affected)
1> use EastRiver
2> go
Changed database context to 'EastRiver'.
1> select name from sys.tables;
2> go
name                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------
BlackCardTask                                                                                                                   
ReplaceReg_D                                                                                                                    
TransRecords                                                                                                                    
Archs                                                                                                                           
RefuseReg_M                                                                                                                     
BlackCardTaskClockState                                                                                                         
MChargeRecords                                                                                                                  
Area                                                                                                                                                                                                                                     
......                                                                                                                 
UpLoadTable_comp2                                                                                                               
Company                                                                                                                         
PriceHistory                                                                                                                                                                                                                           
CommMsg                                                                                                                                                                                                                                             
OpLog                                                                                                                           
CardTypeConfig                                                                                                                  
OutWork_D                                                                                                                       
RealCardState                                                                                                                                                                                                                             
RealStateInfo                                                                                                                   
OutWork_M                                                                                                                       
EmployeeAccount                                                                                                                 
OverTime_Detail                                                                                                                 
TimeReport2                                                                                                                     
ClockDefaultParam                                                                                                               
Scheme                                                                                                                          
ClockParams                                                                                                                     
Groups                                                                                                                          
NumberPool                                                                                                                                                                                                                                
DataBaseConfig                                                                                                                  
DoorTimeBound                                                                                                                   
user_log                                                                                                                        

ZKDownHis                                                                                                                       
tblAdmin                                                                                                                        
TB_FREESPACE                                                                                                                    

Accounts                                                                                                                        

(212 rows affected)

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI