windows服务器维护经验小结(rsync,serv_u)
作者:
这篇文章是脚本之家在维护多台win2003服务器的时候,经常用到的一些配置方法与bat,主要是rsync文件同步配置,serv_u经常停止,sqlserver数据库压缩问题
rsync 客户端执行同步操作的bat
@echo off
rsync -ztruvoglp --progress --password-file=jb51.secrets /cygdrive/g/wwwroot/jb51/ jb51@114.80.*.*::jb51
rsync 服务器端配置
rsyncd.conf
use chroot = false
strict modes = false
hosts allow = *
log file = rsyncd.log
pid file = rsyncd.pid
# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
#
[bigdown]
path = /cygdrive/f/webroot/bigdown
read only = false
transfer logging = yes
auto user=wtjb51
secrets file=wtjb51.conf
wtjb51.conf(客户端服务器端都要有)
服务器端是根目录,客户端是bin目录,大家多测试下,如果提示密码不对就可能是路径问题
wtjb51:www.jb51.net
rsync守卫进程bat
可以防止机房突然断电,导致rsync服务无法开启
@echo off
for /f "usebackq" %%i in (`"tasklist|find /c "cygrunsrv.exe""`) do (
set chkstat=%%i
)
if %chkstat% == 0 (
del "D:\Program Files\cwRsyncServer\rsyncd.pid" /f
net start RsyncServer
echo ================ >> %date:~0,10%.log
echo %date% %time% check rsync service stop >> rsync%date:~0,10%.log
echo restart rsync service! >> %date:~0,10%.log
echo ================ >> %date:~0,10%.log
)
serv_u守卫进程(针对serv_u经常停止问题)bat
@echo off
for /f "usebackq" %%i in (`"tasklist|find /c "ServUDaemon.exe""`) do (
set chkstat=%%i
)
if %chkstat% == 0 (
net start Serv-U
echo ================ >> %date:~0,10%.log
echo %date% %time% check Serv-U service stop >> %date:~0,10%.log
echo restart Serv-U service! >> %date:~0,10%.log
echo ================ >> %date:~0,10%.log
)
sqlserver定时重启bat
echo y net stop SQLSERVERAGENT
echo y net stop mssqlserver
net start mssqlserver
net start SQLSERVERAGENT
sqlserver压缩日志
可以将jb51.ldf文件变得很小,方便备份数据库等,在sqlserver查询分析器中执行即可。
DUMP TRANSACTION [jb51] WITH NO_LOG
BACKUP LOG [jb51] WITH NO_LOG
DBCC SHRINKDATABASE([jb51])
服务器重启如果使用了rsync服务端,为了不让rsync服务器端无法启动
可以使用下面的bat
net stop RsyncServer
shutdown /r /f
或者在rsync服务端安装目录
del rsyncd.pid
C:\WINDOWS\system32\shutdown.exe /r /f
脚本之家原创文章
复制代码 代码如下:
@echo off
rsync -ztruvoglp --progress --password-file=jb51.secrets /cygdrive/g/wwwroot/jb51/ jb51@114.80.*.*::jb51
rsync 服务器端配置
rsyncd.conf
复制代码 代码如下:
use chroot = false
strict modes = false
hosts allow = *
log file = rsyncd.log
pid file = rsyncd.pid
# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
#
[bigdown]
path = /cygdrive/f/webroot/bigdown
read only = false
transfer logging = yes
auto user=wtjb51
secrets file=wtjb51.conf
wtjb51.conf(客户端服务器端都要有)
服务器端是根目录,客户端是bin目录,大家多测试下,如果提示密码不对就可能是路径问题
复制代码 代码如下:
wtjb51:www.jb51.net
rsync守卫进程bat
可以防止机房突然断电,导致rsync服务无法开启
复制代码 代码如下:
@echo off
for /f "usebackq" %%i in (`"tasklist|find /c "cygrunsrv.exe""`) do (
set chkstat=%%i
)
if %chkstat% == 0 (
del "D:\Program Files\cwRsyncServer\rsyncd.pid" /f
net start RsyncServer
echo ================ >> %date:~0,10%.log
echo %date% %time% check rsync service stop >> rsync%date:~0,10%.log
echo restart rsync service! >> %date:~0,10%.log
echo ================ >> %date:~0,10%.log
)
serv_u守卫进程(针对serv_u经常停止问题)bat
复制代码 代码如下:
@echo off
for /f "usebackq" %%i in (`"tasklist|find /c "ServUDaemon.exe""`) do (
set chkstat=%%i
)
if %chkstat% == 0 (
net start Serv-U
echo ================ >> %date:~0,10%.log
echo %date% %time% check Serv-U service stop >> %date:~0,10%.log
echo restart Serv-U service! >> %date:~0,10%.log
echo ================ >> %date:~0,10%.log
)
sqlserver定时重启bat
复制代码 代码如下:
echo y net stop SQLSERVERAGENT
echo y net stop mssqlserver
net start mssqlserver
net start SQLSERVERAGENT
sqlserver压缩日志
可以将jb51.ldf文件变得很小,方便备份数据库等,在sqlserver查询分析器中执行即可。
复制代码 代码如下:
DUMP TRANSACTION [jb51] WITH NO_LOG
BACKUP LOG [jb51] WITH NO_LOG
DBCC SHRINKDATABASE([jb51])
服务器重启如果使用了rsync服务端,为了不让rsync服务器端无法启动
可以使用下面的bat
复制代码 代码如下:
net stop RsyncServer
shutdown /r /f
或者在rsync服务端安装目录
复制代码 代码如下:
del rsyncd.pid
C:\WINDOWS\system32\shutdown.exe /r /f
脚本之家原创文章