Waiting~G

一起走过的日子

Archive for 三月, 2014

客户端配置DNS不生效,如何解决

without comments

有时候一台DNS服务器配置好;其他的客户端都能正常使用;唯独只有你这一台按照相同配置后,也不生效;如何解决呢?

1、修改/etc/nsswitch.conf文件
hosts: files dns

2、修改/etc/nscd.conf文件
enable-cache hosts yes
positive-time-to-live hosts 600
negative-time-to-live hosts 0
suggested-size hosts 211
check-files hosts yes
persistent hosts no
shared hosts yes
max-db-size hosts 33554432

paranoia                yes
restart-interval        10

enable-cache            passwd          yes
positive-time-to-live   passwd          600
negative-time-to-live   passwd          20
suggested-size          passwd          211
check-files             passwd          yes

DNS缓存客户端重启,读取新的配置

/usr/sbin/nscd -K
/usr/sbin/nscd &
/usr/sbin/nscd -i hosts

 

 

Written by Skyma

三月 25th, 2014 at 3:13 上午

Posted in 学.Linux

python 获取关键位置

without comments

pyton提供了对字符串的一些操作,但是对一些复杂的语句来说;不是那么见效;

使用两个函数对语句进行处理;可以获取你想要关键字的开始位置与结束位置;从而获得你想要的substring

举例说明:

import re
import os
import subprocess
import time
import signal
import traceback
import datetime from multiprocessing import Process, Queue, active_children from subprocess
import Popen,PIPE,STDOUT
import MySQLdb
import psycopg2
import sys
#获取开始位置
def getStartPos(line_str, key_word):    
pos=line_str.lower().find(key_word)
if (pos==-1):        
return -1    
else:        
i = pos+len(key_word)
      while (line_str[i]==” ” or line_str[i]==”\t” or line_str[i]==”\n”):
            i=i+1
      return i
#获取结束位置
def getEndTbPos(line_str, start_from_pos):
    ch=[‘ ‘, ‘(‘, ‘”‘, ‘;’, ‘\n’,’\t’,’\r’]
    pos=5000
    if line_str.lower().find(“:: “) or line_str.lower().find(” :: “) or line_str.lower().find(“::”) or line_str.lower().find(” ::”):
        line_str,number=re.subn(” ::”,”::”,line_str)
        line_str,number=re.subn(” :: “,”::”,line_str)
        line_str,number=re.subn(” :: “,”::”,line_str)
        line_str,number=re.subn(“\s*::”,”::”,line_str)
        line_str,number=re.subn(“\s*::\s*”,”::”,line_str)
        line_str,number=re.subn(“::\s*”,”::”,line_str)
        line_str,number=re.subn(“:\s:”,”::”,line_str)
        line_str,number=re.subn(“:\s*:”,”::”,line_str)
else:
        line_str=line_str
for c in ch:
        pos_tmp =line_str[start_from_pos:].find(c)
        if (pos_tmp!=-1 and pos_tmp < pos):
            pos = pos_tmp
    if pos==5000:
        return -1
    else:
        return pos+start_from_pos
#语句
testA=’SELECT user_uin,sum_deal_total_amount_309163,ftime FROM t_task_aggr_115800′

pos_start=getStartPos(testA, ‘from’)

pos_end=getEndTbPos(testA, pos_start)

print “==============”,testA[pos_start:pos_end].strip(),len(testA[pos_start:pos_end].strip())

Written by Skyma

三月 20th, 2014 at 8:52 上午

Posted in 学.Linux