연결된 서버 "SERVER_NAME"에 대한 OLE DB 공급자 "OraOLEDB.Oracle"의 인스턴스를 만들 수 없습니다. (Microsoft SQL Server, 오류: 7302) 도움말을 보려면 다음을 클릭하십시오:
이 사이트에서 해결책 확인
오라클 클라이언트 설치 후 SQLSERVER 재시작 해야됨.;;
연결된 서버 "SERVER_NAME"에 대한 OLE DB 공급자 "OraOLEDB.Oracle"의 인스턴스를 만들 수 없습니다. (Microsoft SQL Server, 오류: 7302) 도움말을 보려면 다음을 클릭하십시오:
메시지 4866, 수준 16, 상태 8, 줄 1
대량 로드하지 못했습니다. 데이터 파일의 행 1, 열 24에서 열이 너무 깁니다. 필드 종결자와 행 종결자를 제대로 지정했는지 확인하십시오.
메시지 7301, 수준 16, 상태 2, 줄 1
연결된 서버 "(null)"의 OLE DB 공급자 "BULK"에서 필수 인터페이스("IID_IColumnsInfo")를 가져올 수 없습니다.
C:\Users\Administrator>bcp mydb.dbo.T_ZIPCODE format nul -c -x -f crmZipcode.a.xml -t"|" -T
<?xml version="1.0"?>
<BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RECORD>
<!--파일의 필드 -->
<FIELD ID="1" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="14" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="2" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="40" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="3" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="60" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="4" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="60" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="5" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="60" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="6" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="40" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="7" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="100" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="8" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="100" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="9" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="160" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="10" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="500" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="11" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="4" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="12" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="40" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="13" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="40" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="14" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="50" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="15" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="400" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="16" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="500" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="17" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="60" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="18" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="40" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="19" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="40" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="20" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="100" COLLATION="Korean_Wansung_CI_AS"/> <!-- 행정동 -->
<FIELD ID="21" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="100" COLLATION="Korean_Wansung_CI_AS"/> <!--산여부 -->
<FIELD ID="22" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="4" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="23" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="40" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="24" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="40" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="25" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="40" COLLATION="Korean_Wansung_CI_AS"/>
<FIELD ID="26" xsi:type="CharTerm" TERMINATOR="\n" MAX_LENGTH="12"/>
</RECORD>
<!--서버의 필드 -->
<ROW>
<COLUMN SOURCE="26" NAME="SEQ" xsi:type="SQLINT"/>
<COLUMN SOURCE="1" NAME="ZIPCODE" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="2" NAME="SIDO" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="3" NAME="ESIDO" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="4" NAME="SIGUNGU" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="5" NAME="ESIGUNGU" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="6" NAME="EUPMRN" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="7" NAME="EEUPMRN" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="8" NAME="ROADCODE" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="9" NAME="ROADNAME" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="10" NAME="EROADNAME" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="11" NAME="ZIYN" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="12" NAME="GUNBON" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="13" NAME="GUNBU" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="14" NAME="GUNSEQ" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="15" NAME="DABE" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="16" NAME="GUNNAME" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="17" NAME="BUBCODE" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="18" NAME="BUBDONG" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="19" NAME="RI" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="21" NAME="SANYN" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="22" NAME="ZIBON" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="23" NAME="EUPSEQ" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="24" NAME="ZIBU" xsi:type="SQLNVARCHAR"/>
</ROW>
</BCPFORMAT>
<!-- 서버의 필드에 없는 것은 컬럼을 넣지 않음. -->
<!-- 파일의 필드는 쓰던 쓰지 않던 모두 넣음 -->
<!-- 베이스가 되는 파일 생성 명령어 : C:\Users\Administrator>bcp mydb.dbo.T_ZIPCODE format nul -c -x -f crmZipcode.a.xml -t"|" -T -->
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\강원도.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\경기도.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\경상남도.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\경상북도.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\광주광역시.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\대구광역시.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\대전광역시.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\부산광역시.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\서울특별시.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\세종특별자치시.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\울산광역시.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\인천광역시.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\전라남도.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\전라북도.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\제주특별자치도.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\충청남도.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
BULK INSERT mydb.[dbo].[T_ZIPCODE] FROM 'C:\Users\Administrator\Downloads\zipcode_DB\지역별전체 DB\20160504_우편번호_지역별주소\충청북도.txt' WITH ( FIRSTROW = 2, formatfile='C:\Users\Administrator\crmZipcod.xml' )
(
RESTRICTED_USER
RESTRICTED_USER를 사용하면 db_owner 고정 데이터베이스 역할과 dbcreator 및 sysadmin 고정 서버 역할의 멤버만 데이터베이스에 연결할 수 있습니다. 연결할 수 있는 멤버의 수에는 제한이 없습니다.데이터베이스에 대한 모든 연결은 ALTER DATABASE 문의 termination 절에 지정된 시간대에 끊어집니다.데이터베이스가 RESTRICTED_USER 상태로 바뀐 후 자격이 없는 사용자의 연결 시도는 거부됩니다.
)
#log
general_log=1
#log_output을 FILE 로 할경우의 경로.
#general_log_file = /var/log/mysql/general_query.log
log_output=TABLE
#!/bin/sh
id="root"
pass="PASS"
mysql -u ${id} -p${pass} -e "SET GLOBAL general_log = 'OFF'";
mysql -u ${id} -p${pass} -e "RENAME TABLE mysql.general_log TO mysql.general_log2;";
mysql -u ${id} -p${pass} -e "DELETE FROM mysql.general_log2 WHERE event_time <= NOW()-INTERVAL 7 DAY";
mysql -u ${id} -p${pass} -e "OPTIMIZE TABLE general_log2";
mysql -u ${id} -p${pass} -e "RENAME TABLE mysql.general_log2 TO mysql.general_log";
mysql -u ${id} -p${pass} -e "SET GLOBAL general_log = 'ON'";
general_log 의 엔진이 CSV라서 해당 파일 자체를 cat, vim 등으로 그냥 볼 수 있음.
#!/bin/bash
[ -z "$1" ] && echo "Usage : Input Process .......... Please [scriptFileName ProcessName]" && exit
process_id=`ps -ax | grep "$1" | grep -vw "grep" | grep -vw $$ | awk '{print $1}'`
if [ -z "$process_id" ];then
echo "+-------------------------------------------------------------+"
echo "Not Found Process (입력하신 프로세스를 찾지 못했습니다.) ...... Done"
echo "+-------------------------------------------------------------+"
exit
else
process_id_number=`ps -ax | grep "$1" | grep -vw "grep" | grep -vw $$ | awk '{print $1}'`
for i in ${process_id_number} ;do
kill -9 $i &> /dev/null
printf "%-40s %-s\n" "$i PID Killed" "$(echo -ne "[ \\033[01;32m OK \\033[0m ]")"
done
sleep 2;
echo "+-------------------------------------------------------------+"
echo "Process Kill OK (프로세스가 강제적으로 종료 되었습니다.) ...... Done"
echo "+-------------------------------------------------------------+"
fi
net stop mssqlserver
#net start mssqlserver /m
net start mssqlserver /f
#$regex1,$regex2값을 서버 아이피로 변경한다.
#예를 들어 서버 아이피가 222.222.222.222 이면
# $regex1 = [regex] "222\.222\.222\.(?:222|51):3389\s+(\d+\.\d+\.\d+\.\d+)";
#제일 마지막은 or 연산이기 때문에 신경 안써도 된다. 한개만 들어가도 됨.
###################### Config ######################
$regex1 = [regex] "111\.222\.333\.(?:140|51):3389\s+(\d+\.\d+\.\d+\.\d+)";
$regex2 = [regex] "원본 네트워크 주소:\t(\d+\.\d+\.\d+\.\d+)";
$regex1_mssql = [regex] "111\.222\.333\.(?:140|51):1433\s+(\d+\.\d+\.\d+\.\d+)";
$regex2_mssql = [regex] "클라이언트: (\d+\.\d+\.\d+\.\d+)";
$MyIp = "123.123.123.123"; #현재 내가 접속한 IP 차단하지 않는다.
$deny_count = 5; #임계값
$loop_time = 30; #loop_time 마다 재 실행.(초)
###################### Config ######################
$tick = 0;
"Start to run at: " + (get-date);
while($True) {
$blacklist = @();
#Port 3389 RDP
"Running... (tick:" + $tick + ")"; $tick+=1;
$a = @()
netstat -no | Select-String ":3389" | ? { $m = $regex1.Match($_);
$ip = $m.Groups[1].Value; if ($m.Success -and $ip -ne $MyIp) {$a = $a + $ip;} }
if ($a.count -gt 0) {
$ips = get-eventlog Security -Newest 1000 | Where-Object {$_.EventID -eq 4625 } | foreach {
$m = $regex2.Match($_.Message); $ip = $m.Groups[1].Value; $ip; } | Sort-Object | Tee-Object -Variable list | Get-Unique
foreach ($ip in $a) { if ($ips -contains $ip) {
if (-not ($blacklist -contains $ip)) {
$attack_count = ($list | Select-String $ip -SimpleMatch | Measure-Object).count;
"Found RDP attacking IP on 3389: " + $ip + ", with count: " + $attack_count;
if ($attack_count -ge $deny_count) {$blacklist = $blacklist + $ip;}
}
}
}
}
#Port 1433 MSSQL
$a = @()
netstat -no | Select-String ":1433" | ? { $m = $regex1_mssql.Match($_);
$ip = $m.Groups[1].Value;
if ($m.Success -and $ip -ne $MyIp) {$a = $a + $ip;} }
if ($a.count -gt 0) {
$ips = get-eventlog Application -Newest 1000 | Where-Object {$_.EventID -eq 18456 -and ($_.Message -like "*sa*" ) } | foreach {
$m = $regex2_mssql.Match($_.Message); $ip = $m.Groups[1].Value; $ip; echo $m; } | Sort-Object | Tee-Object -Variable list | Get-Unique
foreach ($ip in $a) { if ($ips -contains $ip) {
if (-not ($blacklist -contains $ip)) {
$attack_count = ($list | Select-String $ip -SimpleMatch | Measure-Object).count;
"Found MSSQL attacking IP on 1433: " + $ip + ", with count: " + $attack_count;
if ($attack_count -ge $deny_count) {$blacklist = $blacklist + $ip;}
}
}
}
}
<# 주석처리. 사용안함. 미 테스트
#FTP
$MyFtpLogFile1 = "";
$now = (Get-Date).AddMinutes(-5); #check only last 5 mins.
#Get-EventLog has built-in switch for EventID, Message, Time, etc. but using any of these it will be VERY slow.
$count = (Get-EventLog Security -Newest 1000 | Where-Object {$_.EventID -eq 4625 -and $_.Message -match "Logon Type:\s+8" -and
$_.TimeGenerated.CompareTo($now) -gt 0} | Measure-Object).count;
if ($count -gt 50) #threshold
{
$ips = @();
$ips1 = dir "C:\inetpub\logs\LogFiles\FPTSVC2" | Sort-Object -Property LastWriteTime -Descending
| select -First 1 | gc | select -Last 200 | where {$_ -match "An\+error\+occured\+during\+the\+authentication\+process."}
| Select-String -Pattern "(\d+\.\d+\.\d+\.\d+)" | select -ExpandProperty Matches | select -ExpandProperty value | Group-Object
| where {$_.Count -ge 10} | select -ExpandProperty Name;
$ips2 = dir "C:\inetpub\logs\LogFiles\FTPSVC3" | Sort-Object -Property LastWriteTime -Descending
| select -First 1 | gc | select -Last 200 | where {$_ -match "An\+error\+occured\+during\+the\+authentication\+process."}
| Select-String -Pattern "(\d+\.\d+\.\d+\.\d+)" | select -ExpandProperty Matches | select -ExpandProperty value | Group-Object
| where {$_.Count -ge 10} | select -ExpandProperty Name;
$ips += $ips1; $ips += $ips2; $ips = $ips | where {$_ -ne "10.0.0.1"} | Sort-Object | Get-Unique;
foreach ($ip in $ips) {
if (-not ($blacklist -contains $ip)) {
"Found attacking IP on FTP: " + $ip;
$blacklist = $blacklist + $ip;
}
}
}
#>
#Firewall change
<# $current = (netsh advfirewall firewall show rule name="MY BLACKLIST" | where {$_ -match "RemoteIP"}).replace("RemoteIP:", "").replace(" ","").replace("/255.255.255.255",""); #inside $current there is no \r or \n need remove. foreach ($ip in $blacklist) { if (-not ($current -match $ip) -and -not ($ip -like "10.0.0.*")) {"Adding this IP into firewall blocklist: " + $ip; $c= 'netsh advfirewall firewall set rule name="MY BLACKLIST" new RemoteIP="{0},{1}"' -f $ip, $current; Invoke-Expression $c; } } #>
foreach ($ip in $blacklist) {
$fw=New-object -comObject HNetCfg.FwPolicy2; # http://blogs.technet.com/b/jamesone/archive/2009/02/18/how-to-manage-the-windows-firewall-settings-with-powershell.aspx
$myrule = $fw.Rules | where {$_.Name -eq "MY BLACKLIST"} | select -First 1; # Potential bug here?
if (-not ($myrule.RemoteAddresses -match $ip) -and -not ($ip -like "123.123.123.*"))
{"Adding this IP into firewall blocklist: " + $ip;
$myrule.RemoteAddresses+=(","+$ip);
#echo $ip > C:\BlackListIP.txt
}
}
"__________________________________________________________________________________"
Wait-Event -Timeout $loop_time #pause 30 secs
} # end of top while loop.
netsh advfirewall firewall add rule name="MY BLACKLIST" dir=in action=block localip=any remoteip=107.160.158.70
USE [TESTDB]
EXEC sp_change_users_login "Update_One", "유저명", "유저명"
SP_MSFOREACHTABLE 'sp_changeobjectowner "?", "dbo"'