Archive for the ‘System/Linux/Unix*’ Category.

osx / mac : use ssh tunnel / ssh proxy 說明

先找 osx 這個軟體 ssh secret socks , download : http://nihilex.com/secret-socks

 

螢幕快照 2011 12 31 上午8 53 07

 

如這頁說明裝好 ssh secret socks 
http://www.pairsdoll.com/secret-socks.html/

 

在 OSX 的 網路 setting 那邊應該 這軟體會幫忙設好, 若沒有就照下面畫面設定

螢幕快照 2011 12 31 上午10 42 36

 

 

那頁假設是用 local 的 SOCKS PORT 是 9999 那麼 Firefox 的 設定就這樣設定

螢幕快照 2011 12 31 上午9 15 13

 

 

Amazon / AWS / EC2 linux version

cat /proc/version

Linux version 2.6.35.11-83.9.amzn1.x86_64 (mockbuild@build-31003.build) (gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC) ) #1 SMP Sat Feb 19 23:42:04 UTC 2011

 

file /bin/bash

/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped

 

cat /proc/cpuinfo

 

processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 23
model name	: Intel(R) Xeon(R) CPU           E5430  @ 2.66GHz
stepping	: 10
cpu MHz		: 2659.998
cache size	: 6144 KB
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu tsc msr pae cx8 cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht pbe syscall nx lm constant_tsc up arch_perfmon pebs bts rep_good aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 lahf_lm tpr_shadow vnmi flexpriority
bogomips	: 5319.99
clflush size	: 64
cache_alignment	: 64
address sizes	: 38 bits physical, 48 bits virtual
power management:

 

Protected: [memo] 標準前台安裝 , SOP , steps

This post is password protected. To view it please enter your password below:


configure for syslog-ng , syslog-ng.conf , log server , remote log , syslog

 

// ----------------

Server: /etc/syslog-ng/syslog-ng.conf :

source remote_host {
        udp();
};

destination my_host { file("/var/log/$YEAR$MONTH$DAY.log"); };

log {
        source(remote_host);
        destination(my_host);
};

// —————-

 

Client: /etc/syslog-ng/syslog-ng.conf :

source src { unix-stream("/dev/log"); internal(); };

destination remote_server { udp("172.25.8.109" port(514)); };

log {
    source(src);
    destination(remote_server);
};

// —————- 改良版的 log server , 日期/時間比較容易看, remote server 的 IP address

 

其中 flush_lines 可以改大一點增加 log 的 performance ….

options {
  chain_hostnames(no);
  use_fqdn(no);
  use_dns(no);
  keep_hostname(no);
  flush_lines(0);
};

source remote_host {
  udp();
};

template t_rewritetime {
  template("${YEAR}-${MONTH}-${DAY} , ${HOUR}:${MIN}:${SEC} , ${HOST} , \"${MSG}\"\n");
  template_escape(no);
};

destination my_host {
  file("/var/log/$YEAR$MONTH$DAY-$HOUR.log" template(t_rewritetime) );
};

log {
  source(remote_host);
  destination(my_host);
};

// —— // —————- 改良版的 client , 保留一份 log 在本機備查

source src { unix-stream("/dev/log"); internal(); };

destination remote_server {
  udp( "172.25.8.109" port(514) );
  file("/var/log/local_log_file.log");
};

log {
  source(src);
  destination(remote_server);
};

// —–

log sample :

root@log_server:/etc/syslog-ng# tail -f /var/log/20111024-17.log
2011-10-24 , 17:21:06 , 172.25.x.107 , "crontab[12974]: (root) LIST (root)"
2011-10-24 , 17:22:01 , 172.25.x.108 , "CRON[4150]: pam_unix(cron:session): session opened for user root by (uid=0)"
2011-10-24 , 17:22:01 , 172.25.x.108 , "/USR/SBIN/CRON[4151]: (root) CMD (/usr/sbin/ntpdate 172.25.x.45)"
2011-10-24 , 17:22:01 , 172.25.x.108 , "CRON[4150]: pam_unix(cron:session): session closed for user root"
2011-10-24 , 17:22:49 , 172.30.x.43 , "sshd[5533]: Accepted keyboard-interactive/pam for monster from 172.30.x.89 port 56790 ssh2"
2011-10-24 , 17:22:49 , 172.30.x.43 , "sshd[5533]: pam_unix(sshd:session): session opened for user monster by (uid=0)"
2011-10-24 , 17:22:51 , 172.30.x.43 , "sshd[5533]: pam_unix(sshd:session): session closed for user monster"

// —- 測試 syslog 的 C – sample code :

 

*PS: ubuntu 要先 apt-get update 再裝 apt-get install gcc build-essential

…. // —- 測試 syslog 的 PHP – sample code : , 跟 C 的版本長得一樣 ….

openlog("myScriptLog", LOG_PID | LOG_PERROR, LOG_LOCAL0);
syslog(LOG_WARNING, "Unauthorized client...." );
closelog();

….

URL: syslog-ng performance tuning 1.

 

 

login remote ssh delay 等很久

改 /etc/ssh/sshd_config

加一行:

UseDNS no

RabbitMQ , 神奇兔子 message broker , 小小測試

http://www.rabbitmq.com/

 
#
#
#
> /usr/sbin/ab  -c 1 -n 1000 "http://gillight.www.dev.com.tw/send.php"
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking gillight.www.dev.com.tw (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests

Server Software:        Apache/2.2.8
Server Hostname:        gillight.www.dev.com.tw
Server Port:            80

Document Path:          /send.php
Document Length:        12 bytes

Concurrency Level:      1
Time taken for tests:   118.675032 seconds
Complete requests:      1000
Failed requests:        1
   (Connect: 0, Length: 1, Exceptions: 0)
Write errors:           0
Total transferred:      282272 bytes
HTML transferred:       12271 bytes
Requests per second:    8.43 [#/sec] (mean)
Time per request:       118.675 [ms] (mean)
Time per request:       118.675 [ms] (mean, across all concurrent requests)
Transfer rate:          2.32 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:    97  118  91.9    118    3013
Waiting:       97  118  91.9    118    3013
Total:         97  118  91.9    118    3013

Percentage of the requests served within a certain time (ms)
  50%    118
  66%    119
  75%    120
  80%    120
  90%    121
  95%    129
  98%    130
  99%    130
 100%   3013 (longest request)

// ——

> /usr/sbin/ab  -c 86 -n 10000 "http://gillight.www.dev.com.tw/send.php"
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking gillight.www.dev.com.tw (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Finished 10000 requests

Server Software:        Apache/2.2.8
Server Hostname:        gillight.www.dev.com.tw
Server Port:            80

Document Path:          /send.php
Document Length:        12 bytes

Concurrency Level:      86
Time taken for tests:   75.864682 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      2820000 bytes
HTML transferred:       120000 bytes
Requests per second:    131.81 [#/sec] (mean)
Time per request:       652.436 [ms] (mean)
Time per request:       7.586 [ms] (mean, across all concurrent requests)
Transfer rate:          36.29 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.1      0      79
Processing:   138  650 140.1    630    1647
Waiting:      137  650 139.9    629    1647
Total:        169  650 140.0    630    1647

Percentage of the requests served within a certain time (ms)
  50%    630
  66%    669
  75%    703
  80%    737
  90%    838
  95%    910
  98%   1008
  99%   1091
 100%   1647 (longest request)

email checker

也許根據以下的 smtp command 可以用來 check email 名單的正確性

URL: http://www.ip-address.org/verify/email-checker.php

Resolving host name "gmail-smtp-in.l.google.com"...
Connecting to host address "209.85.225.27"...
Connected.
S 220 mx.google.com ESMTP m8si9351085icw.142
C HELO ip-address.org
S 250 mx.google.com at your service
C MAIL FROM: <info@ip-address.org>
S 250 2.1.0 OK m8si9351085icw.142
C RCPT TO: <xxx@gmail.com>
S 250 2.1.5 OK m8si9351085icw.142
C DATA
S 354 Go ahead m8si9351085icw.142
This host states that the address is valid.
Disconnected.

Amazon EC2 / Amazon Linux AMI / AWS / 安裝 LAMP 套件

開 Amazon Linux AMI x86_64 EBS

// 裝 mysql client 及開發會用到的 libs
yum install mysql mysql-libs mysql-devel

// 裝 apache
yum install httpd httpd-devel

// 裝 php 及 php 套件
yum install php php-devel php-mysql php-gd php-dom php-pear php-json php-xml php-xmlrpc

// 裝 subversion
yum install svn

// 裝 uuencode / uudecode
yum install sharutils

				

localtime / zone file / timezone / 時區設定

cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime

 

Protected: LAB vmware server list / VM manage tools

This post is password protected. To view it please enter your password below:


ubuntu / linux 縮圖的工具 : imagemagick , thumbnail generator/tools

#
for i in $(ls *.jpg); do convert -scale 200 $i small-$i; done

把 vmware 的 guest image 丟到 aws ec2 上

vmware guest OS : linux 線上加一顆硬碟免重開機的方法 , Vmware Linux Guest Add a New Hard Disk Without Rebooting Guest

ref URL:

http://www.cyberciti.biz/tips/vmware-add-a-new-hard-disk-without-rebooting-guest.html

 

進 vmware management console 加一個 Harddisk 後, 這樣讓 linux 重新 scan 一次 device:

#
echo "- - -" > /sys/class/scsi_host/host#/scan
fdisk -l
tail -f /var/log/message
#

 

那個 host# 這樣找:

# ls /sys/class/scsi_host

 

再下 dmesg 看看有沒有出現

big5 utf8 很難搞系列 , 現在比較順利可以切換 兩種不同字元集環境了… ubuntu / LANG

首先 ubuntu server 上 /etc/ssh/sshd_config , 加這一行:

擷取-server-ubuntu

putty 的設定要設兩種: for big5 的 跟 for utf8 的 兩種 config , 在連接 server 時選擇要要那種字元集

Continue reading ‘big5 utf8 很難搞系列 , 現在比較順利可以切換 兩種不同字元集環境了… ubuntu / LANG’ »

各類使用 http proxy 的設定方法: pecl / pear / apt / rpm / yum

pear config-set http_proxy http://172.30.1.123:8080/

export http_proxy="http://172.30.1.123:8080"

amazon aws ami LAMP / NGINX / PHP / memcache steps

// —–


Using NGINX + PHP5-FPM
sudo apt-get install nginx php5-fpm php5-mysql
cd /etc/init.d/
sudo service apache2 stop
sudo update-rc.d -f apache2 remove

http://yoodey.com/how-install-configure-nginx-php-fpm-memcached-work-drupal-7-ubuntu-1010-maverick

Install Memcached
sudo apt-get install memcached libmemcached-dev php5-memcached php5-memcache

// ====================

Getting a new virtual machine up and running from the default AMI is easy.  Here’s my cookbook:
Install basic services

    yum install mysql mysql-server mysql-devel
    yum install httpd httpd-devel
    yum install php php-devel php-mysql php-gd php-dom php-pear php-json
    yum install svn

Configure those services to start at boot

    chkconfig –level 345 httpd on
    chkconfig –level 345 mysqld on
    chkconfig –list

Install APC

I couldn’t find a package, and this bug report explains why we have to use the beta.

    yum install gcc pcre-devel
    pecl install apc-beta
    echo extension=apc.so > /etc/php.d/apc.ini

Install memcached

    yum install libevent libevent-devel
    curl -O http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
    cd memcached-1.4.5
    ./configure
    make ; make install
    /usr/local/bin/memcached -u nobody -d -m 30 -l 127.0.0.1 -p 11211

// ----
<pre>
[root@ip-10-130-9-23 log]# cat /etc/fstab
#
LABEL=/     /           ext4    defaults,noatime  1   1
tmpfs       /dev/shm    tmpfs   defaults        0   0
devpts      /dev/pts    devpts  gid=5,mode=620  0   0
sysfs       /sys        sysfs   defaults        0   0
proc        /proc       proc    defaults        0   0
[root@ip-10-130-9-23 log]# cat /etc/mtab
/dev/xvda1 / ext4 rw,noatime 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs rw 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0

</pre>

Apache 是 Internet 世界最偉大的 project

以前 打 www.apache.org 可能就是看到 apache web server 的 download , document ….等等, 但隨著越來越多開發者把他們的 project 標記成 apache license , apache 於是變成一個巨大的 project 集中地 – The Apache Software Foundation ….

apache web server 是排名第一的 web server 這不用說, 今天認識了 Lucene , Solr 這個應該算是 apache 第二大

Apache Lucene Java 分類是 database
http://projects.apache.org/projects/lucene_java.html

Apache Solr 是被分類在 web-framework, network-server
http://projects.apache.org/projects/solr.html

 

很強的 Message Broker : ActiveMQ

Supports a variety of Cross Language Clients and Protocols from Java, C, C++, C#, Ruby, Perl, Python, PHP

Features : http://activemq.apache.org/features-overview.html

linux 開機時顯示 IP address script

有時需要用 vm 模擬一堆 server 的環境 , 開了 guest vm (linux) , 但是就是要進 console 後才能知道 IP address , 有些麻煩

這個 script 可以幫助一下, 把 該 server 取得的 IP address 顯示在 console 上, 把它寫成一個 bash 或加到 /etc/rc.local 去

IPADD=`/sbin/ifconfig | sed '/Bcast/!d' | awk '{print $2}'| awk '{print $2}' FS=":"`
echo " $IPADD" >> /etc/issue

clone virtualbox image VDI

VBoxManage clonehd          <uuid>|<filename> <outputfile>