2018/09/30

用impdp恢复expdp备份的某个表到另一Schema

有人把资料维护错了,后来偷偷改了,又不承认😠,逼得我去把备份的资料恢复出来,给她难堪……

因为是expdp备份的,对应的恢复就用impdp啦。

简单介绍下环境:Tiptop ERP的Oracle数据库,在Linux下运行,要从正式Schema(al1)的备份恢复到测试的Schema(ostest),只需恢复ima_file这个表。

直接上指令了:
impdp directory=EXPDP_DIR dumpfile=full_20180929.dmp logfile=imp_ostest_ima_20180930.log schemas=ostest include=table:\"in \'ima_file\'\"
没成功,错误提示:
ORA-31655: no data or metadata objects selected for job
原来是因为没有指明来源的Schema,调整指令为:
impdp directory="EXPDP_DIR" dumpfile=full_20180929.dmp logfile=imp_ostest_ima_20180930.log remap_schema=al1:ostest tables=al1.ima_file table_exists_action=replace
这样就OK了,如果没有加table_exists_action=replace,而目标Schema中已存在这个表,则会出现错误:
ORA-39151: Table "OSTEST"."IMA_FILE" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
参考资料:OracleOnLinux

2018/09/14

定时查找并修改Linux中文件的权限

公司有好几位同事在进行Tiptop ERP的二次开发工作,为了权责清晰,每人使用各自的Linux帐号,但是有些同事不喜欢用VIM在Linux下编辑程序的源文件,需要用sz和rz在Linux和Windows之间传输文件。这样就出现一个问题,通过rz上传到Linux的文件默认权限是644,其他同事就没法修改了,网上找了很多Zmodem的资料,也没相关的解决办法,没解决这个问题之前,就先让系统定时把这些文件的权限改下吧,一行命令加入Crontab即可。
find */4gl/ -perm 644 -type f -exec chmod 775 {} \;
上面的"*/4gl/"的意思是在当前目录的下一级目录下的4gl子目录,你可以改成适合自己的。

参考资料:yttitan

2018/09/12

Tiptop版本控制小脚本

为了方便在Tiptop ERP二次开发时做简单的版本控制,写了个脚本,用来将当前的文件改名为以当天日期为后缀文件,再将这个文件复制产生新版本的文件。

写脚本的功力实在是浅,各位请指教,勿喷。😊(权当做个笔记吧)
#!/bin/sh
newName=$1`date +%Y%m%d`
if [ ! $1 ]; then
  echo " *** Failed, the arg is null. ***"
else
  if [ ! -f $1 ]; then
    echo " *** Failed, the file does not exist. ***"
  else
    if [ ! -f $newName ]; then
      /bin/mv $1 $newName
      /bin/cp $newName $1
      /bin/ls -al $1*
    else
      if [ ! -f $newName-1 ]; then
        /bin/mv $1 $newName-1
        /bin/cp $newName-1 $1
        /bin/ls -al $1*
      else
        echo " *** Failed, new file already exist. ***"
        /bin/ls $1*
      fi
    fi
  fi
fi

2018/09/04

Fixed a problem with EPSON dot matrix printer

Our factory have a EPSON dot matrix printer (Model Number is 630K), the user told me the printer printing "12345x @PJL ENTER LANGUAGE=ACL" about every five seconds.

It seems like installed wrong drivers, but when I tried to delete the printer from control panel, it was failed. And when I turned off the PC, the printer still printing by itself.

Finally, I fixed it by holding down the feed button then powering on the printer.

企业局域网内搭建NTP服务器

企业内部各种系统的服务器之间要连接业务,必须保证时间的一致性,如果每台都从外部时间服务器同步时间,是不太现实的,其中一种情况就是某些服务器不允许连接Internet。

所以可以考虑在内部搭建一台NTP服务器,由它从外部同步时间,其他服务器在从这台内部服务器同步时间即可。

如果你的局域网内有Windows域控制器,就比较简单了。

首先,在PDC主机上执行命令:
w32tm /config /manualpeerlist:ntp.neu.edu.cn  /syncfromflags:manual /reliable:yes /update
将PDC主机的时间源设置为某NTP服务器,此处为东北大学的时间服务器ntp.neu.edu.cn,你也可以更改为自己喜欢的。

然后依次执行下列命令,重启时间服务:
W32tm /config /update
Net stop w32time && Net start w32time
W32tm /resync
保险起见,可执行命令
w32tm /query /status
查看PDC服务器的时间源是你选择的那个。

最后去你的其他应用服务器设定从这台域控同步时间,Windows服务器直接在控制面板找“日期和时间”里的“Internet时间”,将时间服务器设为你的域控IP或DNS Name;如果是Linux的系统,首先确定已安装ntpdate,再在crontab里增加一笔定时同步就好了。

参考资料:学领未来