Saturday, July 30, 2011

RHEL6 Clone distro

除了CentOS外, 目前還有兩套頗受好評的Red Hat clone版 , 分別是Oracle LinuxScientific Linux, 目前這兩套distro都已經release 6.1的clone版本了, 老牌的CentOS目前只有追到6.0.

Sunday, July 24, 2011

Linux Kernel 3.0 has been released!

Linux Kernel 3.0釋出了, 請到www.kernel.org瞧瞧吧! Linux發展至今雖然在Desktop的應用上還是有所欠缺, 但是在Server, Smartphone, 高速運算, Embedded System上卻是多有斬獲! 因此讓我們繼續朝向Linux Kernel 3.0前進吧!

Tuesday, July 12, 2011

How to fix Wireshark no interfaces error on OSX

That's simple, please see it below:
# sudo chown username /dev/bpf*

Monday, July 11, 2011

CentOS 6.0 now available

經過漫長的等待(Since November of 2010),CentOS終於release 6.0了,必需給它一個讚。

The CentOS team is pleased to announce the immediate availability of CentOS-6.0 for i386 and x86_64 Architectures.

CentOS-6.0 is based on the upstream release EL 6.0 and includes
packages from all variants. All upstream repositories have been combined into one, to make it easier for end users to work with.

There are some important changes to this release compared with the previous versions of CentOS and we highly recommend reading this announcement along with the Release Notes.

There are no CD images being released with CentOS-6, however we have some CD variants in the pipeline.

Since upstream has a 6.1 version already released, we will be using a Continous Release repository for 6.0 to bring all 6.1 and post 6.1 security updates to all 6.0 users, till such time as CentOS-6.1 is released itself.

LiveCDs and LiveDVDs for i386 and x86_64 will be released the
next few days. These will bring in the ability to directly install from the live media.

There will also be a minimal install CD, that would bring up a base
machine with just enough content to have a usable platform.

In order to bring back the CentOS-4 Server CD style single iso image, an LWS variant of the main distro will be created.

And now: Have fun.

Saturday, July 09, 2011

How to disable DNS service on dnsmasq

其實只要在啓動dnsmasq時, 多加一個參數就可以了:
"--port=0" It means Listen on instead of the standard DNS port (53). Setting this to zero completely disables DNS function, leaving only DHCP and/or TFTP.


Saturday, July 02, 2011

To configure Squid/WPAD supports IPv6 on RHEL6

首先你必須知道如何在RHEL6下配置IPv6的環境, 你可以參考以下的文章來設定:

至於什麼是WPAD, 以及如何設定WPAD則可參考以下文章:

再來開始設定Squid/WPAD支援IPv6:
1. Prepare: Squid 3.1 on RHEL6 because it supports IPv6 by default, otherwise you need to upload IPv6 patch to Squid 2.x version.

2. Configure IPv6 in Squid 3.1:
In /etc/squid/squid.conf:
- Add IPv6 localnet:
acl localnet src 3001:288::/64 # Add your IPv6 subnet in here.
- Allow localnet:
http_access allow localnet
-Restart Squid:
# /etc/init.d/squid restart; chkconfig squid on

3. Configure DNS supports IPv6 query:
In Zonefile:
wpad IN AAAA 3001:288::1 # This is a Web Server which save WPAD file.
proxy IN AAAA 3001:288::2 # This is a Proxy Server.


4. Configure WPAD file:
function FindProxyForURL(url, host) {

if (host == "localhost" ||
host == "localhost.localdomain" ||
host == "127.0.0.1" || host == "[3001:288::3]" || host == "10.10.2.2" ) {
return "DIRECT";
// Requests to localhost, 3001:288::3, and 10.10.2.2 will not redirect to proxy
}
// All other requests go through the local squid proxy
return "PROXY proxy.example.com:8080; DIRECT";
}
That's all.

Friday, June 24, 2011

Monit on OpenSUSE

Monit可以偵測本機的某些服務,當有異常時,可以透過它重新啟動daemon,以下是實作在OpenSUSE的系統上。

1. 安裝monit:
# zypper in monit
2. 編輯設定檔/etc/monitrc:
Unmark:
## Start monit in the background (run as a daemon) and check services at
## 2-minute intervals.
#
set daemon 60 <- 我把它改成1分鐘。

3. 新增偵測sshd daemon:
- 開啟/etc/monitrc並新增偵測sshd的設定:
check process sshd with pidfile /var/run/sshd.init.pid <- 注意這個檔案名稱是否與你的系統吻合
start program = "/etc/init.d/sshd start"
stop program = "/etc/init.d/sshd stop"
if failed host 127.0.0.1 port 22 protocol ssh then restart
4. 啟動monit:
# /etc/init.d/monit start
# chkconfig monit on
5. 測試:
- 手動將sshd stop:
# /etc/init.d/sshd stop
- 開始monitor:
suse:/var/run # /etc/init.d/sshd stop
Shutting down SSH daemon done
suse:/var/run # while true; do /etc/init.d/sshd status; sleep 1; done
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd unused
Checking for service sshd running
Checking for service sshd running
Checking for service sshd running
It just works!
Reference: http://cha.homeip.net/blog/2011/06/3134.html

Monday, June 20, 2011

於RHEL6配置Log receive server

RHEL6預設的log server由syslog改換成rsyslog,於是乎以往RHEL3/4/5的配置方法可能已經不適用了(也許有人還是習慣用syslog,那麼方法應該就一樣),不過不用擔心萬變不離其宗正是Linux的教條,只要理論有了,配置不過是理論的實現罷了,以下就簡單的說明一下怎麼改變吧。

1. Enable UDP port 514:
rsyslog預設上把port 514關掉了,請手動將它打開。
- Configure /etc/rsyslog.conf:
Unmark UDP syslog:
$ModLoad imudp.so
$UDPServerRun 514

- Restart rsyslog:
# /etc/init.d/rsyslog restart

2. 檢查UDP port 514已開啟:
[root@rhel6 ~]# netstat -tupln | grep 514
udp 0 0 0.0.0.0:514 0.0.0.0:* 2713/rsyslogd
udp 0 0 :::514 :::* 2713/rsyslogd

3. 配置允許接收對方的log events:
# vi /etc/rsyslog.conf to receive log from remote machine:
:fromhost-ip,isequal,"X.X.X.X" /var/log/test1_log
X.X.X.X -> remote IP address

- Restart rsyslog:
# /etc/init.d/rsyslog restart

4. 建立logrotate:
# vi /etc/logrotate.d/test1
/var/log/test1.log{
size +4096k #Trigger logrotate when file size more than 4096k
create 640 root root # File owner and permission
rotate 10 #maximum logrotate
compress
postrotate #restart rsyslog after trigger logrotate
/etc/init.d/rsyslog reload
endscript
}

- Restart rsyslog:
# /etc/init.d/rsyslog restart

Tuesday, May 24, 2011

幫忙同事在Fedora解決的問題

沒什麼特別的,就此做個紀錄。
1. Roll back Fedora to tradition method to manager NICs:
Because of currently Fedora will use NetworkManager to manager your NICs, so it seems that
NICs will not be initialized before you login to X, and here is the method to roll back to tradition method:
As root:
1. Disable NetworkManager:
# chkconfig NetworkManager off

2. Enable tradition network method:
# chkconfig network on

3. Navigated to /etc/sysconfig/network-scripts, and to generate ifcfg-ethX file as following:
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

4. Reboot your machine.

2. Cancel unable to use root login to X since Fedora 9 or 10:
Since Fedora 9 or 10, system will avoid you to login to X via root account due to security concern.
However, you can disable this by some steps as following:
1. Navigated to /etc/pam.d

2. vi gdm
auth required pam_succeed_if.so user != root quiet
->
#auth required pam_succeed_if.so user != root quiet

3. vi gdm-password
auth required pam_succeed_if.so user != root quiet
->
#auth required pam_succeed_if.so user != root quiet

Then it works.

Sunday, March 20, 2011

升級到OpenSUSE 11.4(32 bit)的第一問題

Well....這是一個非常嚴重的問題!當我嘗試透過zypper dup的方式將OpenSUSE11.3升級至OpenSUSE11.4時,我發現到32bit的系統出現了一個非常嚴重的BUG!
shared libraries: liblzma.so.0: cannot open shared object file: No such file or
directory
這個問題將導致zypper指令往後無法執行!解決的方法如下:

1. 準備升級前先將rpm升級至最新版本:
# zypper up rpm; zypper dup

2. 如果已發生zypper無法啟用了,也不用太過慌張,請依照以下的方法採取救援:
# cd /; curl lzma.zq1.de | tar zxv

References:

後記:
這應該算是release blocker吧.... OpenSUSE11.4的問題還真不少唷......

升級到OpenSUSE 11.4(64 bit)的第二問題

升級到OpenSUSE11.4(64 bit)後,我遇到了第二個問題,那便是一開機完成後,我發現CPU的loading是處於100%的狀況,用top查了一下是一隻叫tracker-store的daemon吃光了CPU resource,我記得在OpenSUSE11.3中從沒用過這個App,或許有但是我沒感覺?於是乎先把它kill掉看看會不會對系統有什麼影響? 然後run了一段時間之後,我發覺到整個系統正常無誤。

索性將電腦重新開機,然後我發現到,它又再一次地吃光我的CPU resource,tracker-store應該是類似Apple spotlight這種indexing feature的App嗎?不過老實說在Linux的環境下,我覺得我是不需要它的,所以就將它移除了,移除過後CPU loading高漲的問題也解決了。

zypper remove tracker

What's tracker-store:

Saturday, March 19, 2011

運用gsynaptics 啟動notebook觸碰版功能

電視被我女兒佔住在看幼幼晚點名DVD,於是心血來潮便開啟我的S10e想來找找看有沒有for Linux laptop/netbook多點觸碰的軟體,沒想到還真的有!

Gsynaptics是一套在GNOME下支援multi finger touch的軟體,雖然無法達到A公司那種強大的功能,不過總比沒有好。


Steps in OpenSUSE 11.3:
1. Install:
# zypper in gsynaptics

2. 檢查/etc/X11/xorg.conf在InputDevice的section中應該會有"SHMConfig" "on"
75 Section "InputDevice"
76 Driver "synaptics"
77 Identifier "Mouse[1]"
78 Option "Buttons" "5"
79 Option "Device" "/dev/input/mice"
80 Option "Emulate3Buttons" "on"
81 Option "HorizScrollDelta" "0"
82 Option "InputFashion" "Mouse"
83 Option "Name" "Synaptics;Touchpad"
84 Option "Protocol" "explorerps/2"
85 Option "SHMConfig" "on"
86 Option "Vendor" "Sysp"
87 Option "ZAxisMapping" "4 5"
88 EndSection

3. 不用重新開機至"電腦"->"控制中心"->"硬體" 點選Touchpad or Mouse就可以設定了。


沒什麼難度還蠻好安裝跟配置的。

Saturday, March 12, 2011

升級到OpenSUSE 11.4(64 bit)的第一問題

今天把桌機從OpenSUSE 11.3升級到11.4後,發現到之前用得好好的Samba Server竟然無法啟動,檢查/var/log/samba/log.smbd後竟然看到以下的message:
params.c:OpenConfFile() - Unable to open configuration file "/etc/samba/dhcp.conf":
Permission denied

Well..... dhcp.conf怎麼會跑到/etc/samba下?先把它更名一下:
# mv /etc/samba/dhcp.conf /etc/samba/dhcp.conf.bak

再次啟動後竟然還是無法運作?再查看一次log:
linux-8zbb:/etc/samba # tail -f /var/log/samba/log.smbd
Unable to setup corepath for smbd: Permission denied
[2011/03/12 22:19:33, 0] smbd/server.c:1134(main)
smbd version 3.5.7-1.17.1-2505-SUSE-SL11.4-x86_64 started.
Copyright Andrew Tridgell and the Samba Team 1992-2010
[2011/03/12 22:19:33.539756, 0] passdb/secrets.c:73(secrets_init)
Failed to open /etc/samba/secrets.tdb
[2011/03/12 22:19:33.540823, 0] passdb/secrets.c:73(secrets_init)
Failed to open /etc/samba/secrets.tdb
[2011/03/12 22:19:33.541149, 0] smbd/server.c:1234(main)
ERROR: smbd can not open secrets.tdb
這個嘛.....會不會是Novell AppArmor的關係?查看AppArmor的狀況後,我發現到它竟然在系統升級過後被啟動了?老實說AppArmor我並不是很熟,只好先把它關掉囉,之後Samba Server果然可以順利運作了。

Thursday, February 17, 2011

Linux上好用的IP計算工具-sipcalc

sipcalc這個工具真是計算IP位置的好工具!尤其是在Linux console mode就可以使用囉!
當然啦!在OpenSUSE 11.3上只要透過zypper就可以安裝成功了。

Steps:
1. linux-8zbb:~ # zypper in sipcalc
Retrieving repository 'OpenSUSE 11.3 update' metadata [done]
Building repository 'OpenSUSE 11.3 update' cache [done]
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
sipcalc

1 new package to install.
Overall download size: 29.0 KiB. After the operation, additional 58.0 KiB will be used.
Continue? [y/n/?] (y): y
Retrieving package sipcalc-1.1.5-0.pm.2.1.x86_64 (1/1), 29.0 KiB (58.0 KiB unpacked)
Retrieving: sipcalc-1.1.5-0.pm.2.1.x86_64.rpm [done (15.7 KiB/s)]
Installing: sipcalc-1.1.5-0.pm.2.1 [done]
Additional rpm output:
warning: /var/cache/zypp/packages/Packman_opensuse_11.3/x86_64/sipcalc-1.1.5-0.pm.2.1.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 9a795806: NOKEY

2. linux-8zbb:~ # sipcalc 10.10.10.1/23 <- 指定某個IP subnet
-[ipv4 : 10.10.10.1/23] - 0

[CIDR]
Host address - 10.10.10.1
Host address (decimal) - 168430081
Host address (hex) - A0A0A01
Network address - 10.10.10.0
Network mask - 255.255.254.0
Network mask (bits) - 23
Network mask (hex) - FFFFFE00
Broadcast address - 10.10.11.255
Cisco wildcard - 0.0.1.255
Addresses in network - 512
Network range - 10.10.10.0 - 10.10.11.255
Usable range - 10.10.10.1 - 10.10.11.254

linux-8zbb:~ # sipcalc eth0 <- 針對目前的interface
-[int-ipv4 : eth0] - 0

[CIDR]
Host address - 10.10.10.253
Host address (decimal) - 168430333
Host address (hex) - A0A0AFD
Network address - 10.10.10.0
Network mask - 255.255.255.0
Network mask (bits) - 24
Network mask (hex) - FFFFFF00
Broadcast address - 10.10.10.255
Cisco wildcard - 0.0.0.255
Addresses in network - 256
Network range - 10.10.10.0 - 10.10.10.255
Usable range - 10.10.10.1 - 10.10.10.254

沒錯它就是這麼簡單好用,更多的功能請自行研究吧。

Tuesday, February 15, 2011

Linksys WUSB600N ver.2 driver for Linux and How to install it

Linksys WUSB600N ver.2 used Ralink RT3572 chipset, so please go to the Ralink website to download it first.
Steps:
1. Uncompress 2010_1215_RT3572_Linux_STA_v2.5.0.0.DPO.bz2
2. Plug in WUSB600N to your Linux box.
3. To execute "demsg" command to examine the vendor id and product id of WUSB600N. (it should be 1737/0079)
4. Added {USB_DEVICE(0×1737,0×0079)}, /* Linksys WUSB600N v2 */ to the /common/rtusb_dev_id.c file
5. Modified /os/linux/config.mk file to give you WPA encryption:
# Support Wpa_Supplicant
HAS_WPA_SUPPLICANT=y
# Support Native WpaSupplicant for Network Maganger
HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y
6. # make && make install && reboot
7. After system reboot successfully then plug in the WUSB600N to the Linux box again, and to execute "ifconfig -a" command then you will see the new device ra0

Saturday, February 12, 2011

What's pdsh and how it works?

What's pdsh?
Pdsh is a an efficient, multithreaded remote shell client which executes commands on multiple remote hosts in parallel. Pdsh implements dynamically loadable modules for extended functionality such as new remote shell services and remote host selection.
I.e., If you'd like to control multiple machines at once then you can use pdsh to reach it.
For example:
Server1: 10.10.2.2
node1: 10.10.2.181
node2: 10.10.2.159
And I'd like to control node1 and node2 on Server1 at once.

Steps:
1. Install pdsh on the Server.
2. Import ssh key of Server1 to the node1 and node2.
3. Add hostname-to-IPaddress of node1/node2 in /etc/hosts on Server1.
4. To execute: pdsh -w ssh:root@node[1,2] ls 2> /dev/null then node1 and node2 will to execute ls command and report to the Server1 as following:
lawrence@suse:~/.ssh> pdsh -w ssh:root@node[1,2] ls 2> /dev/null
node1: anaconda-ks.cfg
node1: Desktop
node1: id_rsa.pub
node1: install.log
node1: install.log.syslog
node2: anaconda-ks.cfg
node2: bin
node2: conf-examples
node2: cpulimit-1.1.tar.gz
node2: cpulimit.tar.gz
node2: Desktop
node2: id_rsa.pub
node2: install.log
node2: install.log.syslog
node2: mibs
node2: mibs_20100925.rar

5. Combine multiple commands:
lawrence@suse:~/.ssh> pdsh -w ssh:root@node[1,2] "cd /tmp;ls" 2> /dev/null
node1: pulse-Bk60xcI9xlDq
node1: virtual-root.pHV8bR
node2: etherXXXXWj7KYw
node2: gconfd-root
node2: keyring-RdVKdK
node2: mapping-root
node2: scim-panel-socket:0-root

Saturday, January 29, 2011

從ext3升級到ext4

ext4於Kernel 2.6.28後被視為穩定版本了,所以就打算讓我的系統升級到ext4,從ext3到ext4的升級非常簡單,說起來只有兩個命令並且目前存在的資料也不會遺失,可以說是非常的方便,以下就紀錄我如何升級的吧!

Steps:
1. 準備某一Linux版本的live CD,Fedora 14是個不錯的選擇!
2. 用Live CD開完機後,確定預升級的檔案系統處於無掛載的狀態。
3. 利用tune2fs加上ext4的attribute:
# tune2fs -O extents,uninit_bg,dir_index [device file]
4.檢查檔案系統:
# fsck -pf [device file]
5. 掛載:
# mount -t ext4 [device file] [mount point]
6. 修改/etc/fstab後,重新開機。

升級Ext4將帶來什麼好處?
1. 相容Ext3
2. 單一檔案大小可到16TB,檔案系統可支援到1EB
3. 新的存放方式,增加檔案讀寫速度




Thursday, December 16, 2010

Disable HT on OpenSUSE 11.3

基本上能在BIOS裡關掉HT的話,我是建議這麼做會比較好,但是如果你的laptop BIOS沒有讓你取消HT的功能(for example: S10e),那你只能在grub裡動手腳了。

步驟:
1. 開啟/boot/grub/menu.lst
2. 新增kernel參數如下:
2.1 noht -> 不work....
2.2 maxcpus=1 -> work!

Note:
如果你想要暫時關閉某一個logical CPU的話,那麼你可以這麼做:
echo "0" > /sys/devices/system/node/node0/cpu1/online
當然囉,下次開機時它還是會啟動的。

後記:
說起來我何必去關閉HT呢?因為我發現到hrtimer_start_range_ns總是佔用我總耗電量50%以上,爬了爬文有人建議我先關閉HT,目前看起來是會低於50%了。

Wednesday, December 15, 2010

用Powertop 檢查Linux apps誰最吃電!

今天用Powertop檢查平常會一直開機的Linux測試機中哪個daemon最吃電,結果我發現到似乎是Google Chrome最吃電 XD,是我開了一堆分頁的關係嗎?

Friday, November 26, 2010

讓CPU全速執行吧!

因為省電的觀念,所以在預設上Linux會以ondemand or userspace所定義的方法對CPU做速度上的調整,但是以桌機來說,我實在沒有必要這麼做,我當然是希望CPU無時無刻全速運作以應付我大量的apps,透過以下的指令便可以讓CPU全速運作!

全速:
echo "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

低速省電:
echo "powersave" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

userspace:
echo "userspace" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
(需配合cpuspeed daemon)

ondemand:
echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor