博客 2015-06-11

1. 如何快速查找大文件

比如根文件系统,最大的前10个文件?

tree -finxs -L 5 / |sort -k2n -t '[' |tail


-f  列出全路径,直观,方便后面使用

-x  当前文件系统。比如/ 下面挂载个/wls卷(另外一个ext4文件系统),就不会去查找

-L  列出路径深度,越深越慢,5 层挺好的


实例:

[root@localhost mreald]# tree -finxs -L 5 / |sort -k2n -t '[' |tail 
[142363262]  //public/jdk1.7.0_67.tgz
[161505713]  //public/sosreport-CNSZ031314-702153-da593f.tar.bz2
[162204545]  //public/wlas.tar.gz
[167106418]  //root/slogs/2015-04-28_20:20:42pts-203public.log
[175738200]  //public/PA18CMSDMZ7603.out.20150511
[647942144]  //root/chkusr@10.11.100.141
[694297784]  //root/slogs/2015-05-15_11:03:00pts-255public.log
[700575507]  //root/slogs/2015-05-15_10:26:39pts-271public.log
[1101279689]  //root/slogs/2015-04-24_14:02:48pts-177public.log
[1956988917]  //chkusr/CNSZ040588.osbackup.tgz


如果空间满了,又不能删除,这样处理

gzip /public/PA18CMSDMZ7603.out.20150511


就会生成  //public/PA18CMSDMZ7603.out.20150511.gz 并会自动删除原文件


2. 查找一个路径下面哪些目录占的空间大:

du -hx --max-depth=1 /


--max-depth 设置列出层次

-x 只在当前文件系统


这样可以递归查询哪些目录最大



3. 查找一个文件或者目录或者路径:

locate filename/path/dirname/keyword


博客 2015-06-03


昨天碰到一个su 切换不成功的问题


下面是su 切换过程的日志:


[root@blog-mreald-com ~]# tail -f /var/log/secure|grep  su:
Jun  2 17:23:14 blog-mreald-com su: pam_unix(su-l:auth): authentication failure; logname=root uid=20002 euid=20002 tty=pts/8 ruser=mc rhost=  user=root
Jun  2 17:23:22 blog-mreald-com su: pam_unix(su-l:auth): authentication failure; logname=root uid=20002 euid=20002 tty=pts/8 ruser=mc rhost=  user=root
Jun  2 17:28:13 blog-mreald-com su: pam_unix(su-l:auth): authentication failure; logname=root uid=20002 euid=20002 tty=pts/8 ruser=mc rhost=  user=chkusr



换个主机,能正常切换的日志:

[root@nexthost ~]# tail -f  /var/log/secure|grep su:
Jun  2 17:27:19 nexthost su: pam_tally(su-l:account): option deny=5 allowed in auth phase only
Jun  2 17:27:19 nexthost su: pam_tally(su-l:account): unknown option: reset
Jun  2 17:27:19 nexthost su: pam_tally(su-l:account): option no_lock_time allowed in auth phase only
Jun  2 17:27:19 nexthost su: pam_unix(su-l:session): session opened for user chkusr by root(uid=2146)



开始感觉是pam 中的login、su 认证模块配置错误 ,但查不出问题


后面看到 报错中的logname=root uid=20002 euid=20002

uid==euid 明显不对啊


博客 2015-05-29

简介:

环境的搭建过程,与应用case处理不是同一组人处理 。出现问题往往不容易查到原因,下面来处理一个类似的实例。


应用信息:

1.应用实例:

nts-server1234
10.12.21.3 Ins IP  
10.12.22.3 F5 IP  
10.12.194.130  主机 IP    端口 30793


2.F5信息

10.12.14.16 vs_nts-prms_https_WII_PrdService 443



Trouble Shooting 过程: 

第一步:浏览器打开,一直在转,很久之后超时

http://nts-prms.blog.mreald.com/PRMS

域名解析了吗:
ping nts-prms.blog.mreald.com
PING nts-prms.blog.mreald.com (10.12.14.16) 56(84) bytes of data.
64 bytes from 10.12.14.16: icmp_seq=1 ttl=252 time=0.810 ms
64 bytes from 10.12.14.16: icmp_seq=2 ttl=252 time=0.933 ms


第三步:访问单独应用:正常

博客 2015-04-19


    三年前读过这篇文章 或者   这里,今天了解到Go语言,就在想以后语言会是什么样?我想再多也没用,因为没有达到大牛的思想境界,只到再看五年前大神的分析。在些做一点总结。


1.语言发展很慢,而快速发展的是:框架 、工具


2.语言抽象级别越来越高,更简易使用。比如:scala 基于框架构建的


3.未来趋势会是:声明式(Declarative)、动态(Dynamic)、并发(Concurrent)


4.什么是声明式编程?

声明式编程:主要有DSL、函数式编程。(如今的两项成果)

比如查找一个大于20元的单子:

用Java的循环就要写过程(How)

用数据库只用写一句(What)---DSL


5.DSL(Domain Specific Language,领域特定语言,比如:css、sql、Logo)

外部DSL 比如sql、unix-command、XSLT

内部DSL 一系列特别的API、使用模式的别称 比如LINQ查询语句、Ruby on Rails、jQuery代码 


6.函数式编程


说白了就如写数学算式一样,y=x+1 (x、y都是不可变状态)。不是平时用的x=x+1 (x是变量,可变状态)

APL、Haskell、Scheme、ML、LISP


7.动态语言、静态语言

趋势:现在分,以后就不会再分了。

动态语言:Ruby Python Javascripts LISP(比如声明变量,可以不用指定 是int 型,自动会判断)

静态语言:C C++ Java 


8.元编程:代码生成的别称(动态语言容易实现)


9.并发


博客 2015-04-03

常用的匹配选项:

https://github.com/elastic/logstash/blob/v1.4.2/patterns/grok-patterns


可以在线Debug:

http://grokdebug.herokuapp.com/


用oniguruma正则表达库:

对于东亚文字支持比较好,开始是用在ruby上,也可用于C++,是日本的开发人员编写的。

http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt



内容: - 2015-04-29 13:04:23,733 [main] INFO (api.batch.ThreadPoolWorker) Command-line options for this run:
正则:- %{TIMESTAMP_ISO8601:time} \[%{WORD:main}\] %{LOGLEVEL:loglevel} \(%{JAVACLASS:class}\) %{GREEDYDATA:mydata}


结果:

{
  "time": [
    "2015-04-29 13:04:23,733"
  ],
  "main": [
    "main"
  ],
  "loglevel": [
    "INFO"
  ],
  "class": [
    "api.batch.ThreadPoolWorker"
  ],
  "mydata": [
    "Command-line options for this run:"
  ]
}




内容:/wls/applogs/rtlog/icore-pamsDRServer1351/icore-pamsDRServer1351.out
正则:/wls/applogs/rtlog/(?(?[a-zA-Z-]+)([0-9]*(?:SF)|(?:WII)|(?:DMZ)|(?:DR))([0-9a-zA-Z]+))%{UNIXPATH:filepath}


博客 2015-03-30

 需求:

       比如 path => /wls/applogs/rtlog/icore-pts2SF2433/icore-pts2SF2433.out

想提取icore-pts 与 icore-pts2SF2433/icore-pts2SF2433.out


第一种方法:用grok 处理


filter {
        grok {
                match => ["path","/wls/applogs/rtlog/(?<servername>[a-z][a-z-]*)(?<stag>[0-9]*)((?:SF)|(?:WII)|(?:DMZ)|(?:DRServer))(?:%{NUMBER})/%{USERNAME:apppath}"]
                add_field => {
                                "app_path" => "%{apppath}"
                                "app_name" => "%{servername}"
                                }
        }
}


第二种方法:用Ruby 处理

博客 2015-03-23


        上一节讲了最简单的  git web代码运程同步实例,下面逐渐增加一些常用实例。


博客 2015-03-19

        Git 仓库之间是对等的,没有主次之分。假如想把服务器端同步到本地,并把本地的修改同步到服务器端,就用下面的方法:


服务器端:

ubuntu
sudo apt-get install git

tar xzf mreald-dir.tgz
cd mreald-dir  #代码库目录

git init
git config --global user.name  mreald_name
git config --global user.email mreald_email
git add *
git commit -a -m "Hello Git"
git status

web 目录:
/var/www/html/wenblog


本地端:

git clone root@192.168.100.6:~/html/mreald-dir/
cd mreald-dir
git config --global user.name locale_name
git config --global user.email locale_email
vim test.txt (add one line cccccccc)
git add *
git commit -m "add ccc"
git config --global remote.pushdefault root@192.168.100.6:~/html/mreald-dir/
git config --global push.default matching
git push
[ 或者:git push orign master(从本地提交到服务器192.168.100.6)
             git pull orign master(从服务器同步到本地)
             git push root@192.168.100.6:~/html/mreald-dir/ ]


问题:

git failed to push

解决办法:

一,在服务器上初始化仓库的时候用git -bare init (只有版本库,没有源文件)

博客 2015-03-19


        今晚想通过Git同步代码到远程主机,输入密码后,提示:

Permission denied, please try again.

        然后,ssh root@ip 试了一下,也是同样的提示。不如正好学习下配置文件,一探究竟!


原因:sshd 的配置文件:

PermitRootLogin
             是否允许 root 登录。可用值如下:
             "yes"(默认) 表示允许。"no"表示禁止。
             "without-password"表示禁止使用密码认证登录。
             "forced-commands-only"表示只有在指定了 command 选项的情况下才允许使用公钥认证登录。
                                   同时其它认证方法全部被禁止。这个值常用于做远程备份之类的事情。

ubuntu 默认使用的 without-password :禁止使用密码登陆,当然就不行了!

博客 2015-03-08

配置 JDBC 数据源

1. 安装 openjdk(本人用的ubuntu)

sudo apt-get install openjdk-7-jre


2.下载安装 elasticsearch

wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.4.deb
sudo dpkg -i elasticsearch-1.4.4.deb
/etc/init.d/elasticsearch start


3.安装JDBC 插件

./bin/plugin --install jdbc --url http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-river-jdbc/1.4.0.10/elasticsearch-river-jdbc-1.4.0.10.zip

4.安装Mysql JDBC 驱动

curl -o mysql-connector-java-5.1.33.zip -L 'http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.33.zip/from/http://cdn.mysql.com/'
unzip mysql-connector-java-5.1.33.zip
cp mysql-connector-java-5.1.33-bin.jar $ES_HOME/plugins/jdbc/
chmod 644 $ES_HOME/plugins/jdbc/*
/etc/init.d/elasticsearch restart


http://localhost:9200/_nodes?settings=true&pretty=true  配置信息(安装路径、插件...)

更多参数见:https://github.com/jprante/elasticsearch-river-jdbc


5.测试mysql (用户root 密码passwd 库jdbctest 表名posts)

i-- 4/9 i++