2011年9月3日 星期六

Jdownloader 亂碼解決辦法 ( 謎樣的口口口 )

之前我都是使用別人打包好的免安裝檔


這次自己下載來用竟然發現中文無法顯示


圖片 2.png    


謎樣的 "口口口" 這是三小?!


於是我試了下簡體中文檔,竟然發現可以正常顯示簡體中文,真是令人生氣!


圖片 3.png  


於是開了他的語系檔來比對一下


路徑:C:\Program Files\JDownloader\jd\languages
繁體中文:zh-hans.loc
簡體中文:zh-hant.loc


發現簡體中文的語系檔比中文多了一行 "!font = System"
於是把這行設定貼到繁體中文語系檔裡就解決了...


另外,如果您是用 Notepad(記事本)開啟的朋友會失敗
原因是記事本幫你存檔的時候它會自動幫你存成UTF-8 (BOM)
造成 Jdownloader 讀檔失敗,於是謎樣的 "口口口" 又出現了....囧


 引用:UTF-8 的 BOM 地雷


" M$ 在使用 Windows 2000 (含)以後版本「記事本」儲存 UTF-8 檔案的時候,為了要能夠識別 UTF-8 和 ASCII 檔案,於是加上了 BOM 來辨別。 "



如您不小心先存檔造成讀檔失敗了,請使用 Notepad + 之類的文字檔編輯軟體開啟
於功能表選擇「編碼 -> 編譯成 UTF-8 碼(檔首無BOM)」再存檔,就解決啦! 


 圖片 5.png  


令人感動的繁體中文!!!


圖片 6.png  


2011年8月10日 星期三

[Linux] 強制卸載忙碌中的裝置

有時無法卸載忙碌中的裝置 , 或是未卸載就將外部裝置拔除


會出現如下訊息


# umount /media
umount: /media: device is busy
umount: /media: device is busy


 


這時只要加 l 參數就可以將這些裝置移除掉了


# umount -l /media


 


2011年6月24日 星期五

重設Windows Administrator 密碼

http://pogostick.net/~pnh/ntpasswd/


好用的工具


Supports all Windows from NT3.5 to Win7, also 64 bit and also the Server versions (like 2003 and 2008)


幾乎都支援啦


 


下載ISO後燒成光碟( 或是有USB版本 )


設定啟動, 之後會


2011年5月11日 星期三

ubuntu / 掛proxy更新套件

在環境變數中


export http_proxy=http://192.168.1.6:8080


臨時設定的話直接在shell中下指令也行


使用apt-get 安裝時自己會偵測是否有設定proxy


超easy的啦!


2011年5月6日 星期五

JAVA / 簡單的數學練習題

今天在FB上看到的民調問答 , 問了下面這道題目


「 一顆糖果ㄧ塊錢 ㄧ顆糖有一張包裝紙 商店做促銷~三張包裝紙可以換ㄧ顆糖~ 你有15元~請問你一共可以吃幾顆糖?? 」


選項是 1. 20    2. 21   3. 22


你會選哪個....?


2011年5月4日 星期三

KVM的雲端技術

雲端系統正夯...


可惜國內好文不多


想了解雲端系統使用linux KVM的技術可以參考一下這個網站


http://linuxkvm.blogspot.com/


寫得很棒喔!



http://www.youtube.com/watch?v=9Du8HCNPK4U


另外我google到國外有一篇文章叫 Roll Your Own Cloud: Enterprise Virtualization with KVM, DRBD, iSCSI and Pacemaker


http://linuxconfau.blip.tv/file/4719948/


也是很棒的影片,分享給大家!




iPad插電腦USB充電問題

iPad 接一般PC電腦USB由於電壓不夠的關係,會顯示"沒有在充電"


但如果接蘋果電腦就OK


有些主機板廠商也推出了修正程式 , 安裝之後很神奇地就會跟你說有在充電


google一下就有載點了


 


雖然他跟你提示說沒有在充電


但實際上就算他顯示沒有在充電, 但還是有在充電喔...


使用iPad附的變壓器 , 官方說是衝兩個小時充飽


我用電腦的USB充六小時的結果是....................30% XDDDDD


 


結論就是.....還是乖乖的使用變壓器充電吧....囧


2011年4月30日 星期六

更改 Ubuntu 預設語系

1. # vim /var/lib/locales/supported.d/locale


 


zh_TW UTF-8
en_US.UTF-8 UTF-8


2. # locale-gen


 


Generating locales...
  en_US.UTF-8... up-to-date
  zh_TW.UTF-8... done
Generation complete.


 


 


ubuntu JDBC 設定

1. apt-get install  libmysql-java


2. 環境變數 CLASSPATH 新增 /usr/share/java/mysql-connector-java.jar


3. 寫個code測試


import java.sql.Connection;
import java.sql.DriverManager;

class JDBCTest {

private static final String url = "jdbc:mysql://localhost";

private static final String user = "username";

private static final String password = "password";

public static void main(String args[]) {
try {
Connection con = DriverManager.getConnection(url, user, password);
System.out.println("Success");

} catch (Exception e) {
e.printStackTrace();
}
}
}

2011年4月29日 星期五

ubuntu 11.04 有關 JAVA 的相關設定

1. 新增軟體源


vim /etc/apt/sources.list


#deb cdrom:[Ubuntu 11.04 _Natty Narwhal_ - Release i386 (20110427.1)]/ natty main restricted




# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to


# newer versions of the distribution.


deb http://ubuntu.stu.edu.tw/ubuntu/ natty main restricted


deb-src http://ubuntu.stu.edu.tw/ubuntu/ natty main restricted




## Major bug fix updates produced after the final release of the


## distribution.


deb http://ubuntu.stu.edu.tw/ubuntu/ natty-updates main restricted


deb-src http://ubuntu.stu.edu.tw/ubuntu/ natty-updates main restricted




## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu


## team. Also, please note that software in universe WILL NOT receive any


## review or updates from the Ubuntu security team.


deb http://ubuntu.stu.edu.tw/ubuntu/ natty universe


deb-src http://ubuntu.stu.edu.tw/ubuntu/ natty universe


deb http://ubuntu.stu.edu.tw/ubuntu/ natty-updates universe


deb-src http://ubuntu.stu.edu.tw/ubuntu/ natty-updates universe




## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu


## team, and may not be under a free licence. Please satisfy yourself as to


## your rights to use the software. Also, please note that software in


## multiverse WILL NOT receive any review or updates from the Ubuntu


## security team.


deb http://ubuntu.stu.edu.tw/ubuntu/ natty multiverse


deb-src http://ubuntu.stu.edu.tw/ubuntu/ natty multiverse


deb http://ubuntu.stu.edu.tw/ubuntu/ natty-updates multiverse


deb-src http://ubuntu.stu.edu.tw/ubuntu/ natty-updates multiverse




## Uncomment the following two lines to add software from the 'backports'


## repository.


## N.B. software from this repository may not have been tested as


## extensively as that contained in the main release, although it includes


## newer versions of some applications which may provide useful features.


## Also, please note that software in backports WILL NOT receive any review


## or updates from the Ubuntu security team.


# deb http://ubuntu.stu.edu.tw/ubuntu/ natty-backports main restricted universe multiverse


# deb-src http://ubuntu.stu.edu.tw/ubuntu/ natty-backports main restricted universe multiverse




deb http://ubuntu.stu.edu.tw/ubuntu/ natty-security main restricted


deb-src http://ubuntu.stu.edu.tw/ubuntu/ natty-security main restricted


deb http://ubuntu.stu.edu.tw/ubuntu/ natty-security universe


deb-src http://ubuntu.stu.edu.tw/ubuntu/ natty-security universe


deb http://ubuntu.stu.edu.tw/ubuntu/ natty-security multiverse


deb-src http://ubuntu.stu.edu.tw/ubuntu/ natty-security multiverse




## Uncomment the following two lines to add software from Canonical's


## 'partner' repository.


## This software is not part of Ubuntu, but is offered by Canonical and the


## respective vendors as a service to Ubuntu users.


# deb http://archive.canonical.com/ubuntu natty partner


# deb-src http://archive.canonical.com/ubuntu natty partner




## This software is not part of Ubuntu, but is offered by third-party


## developers who want to ship their latest software.


deb http://ubuntu.stu.edu.tw/ubuntu/ natty main


deb-src http://ubuntu.stu.edu.tw/ubuntu/ natty main


 


apt-get update


 


2. 安裝JDK , JRE


apt-get install sun-java-jre


jdk : wget jdk.1.6 


安裝 : sh ./jdk1.6


cp-r jdk1.6 /opt/jdk1.6


 


3. 安裝tomcat 6


wget http://apache.cs.pu.edu.tw/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.tar.gz


tar -zxvf apache-tomcat-6.0.32.tar.gz


http://apache.cs.pu.edu.tw/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-


 


4. 環境變數設定


vim ~/.bashrc


JAVA_HOME=/opt/jdk1.6
export JRE_HOME=/usr/lib/jvm/java-6-sun-1.6.0.24/jre
export TOMCAT_HOME=/opt/apache-tomcat-6.0.32
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export M2_HOME=/opt/apache-maven-2.2.1
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$TOMCAT_HOME/bin:$M2_HOME/bin:$PATH


5. 安裝 subversion


apt-get install subversion


svn
checkout svn://140.115.11.133/ncucc --username tyrc




 


2011年4月28日 星期四

CentOS 5.6 安裝 tomcat6

cd /etc/yum.repos.d
wget 'http://www.jpackage.org/jpackage50.repo'
yum update

yum install yum-utils

yum install tomcat6 tomcat6-webapps tomcat6-admin-webapps
service tomcat6 start

 


yum install yum-utils


 


cd /opt


wget http://ftp.twaren.net/Unix/Web/apache//maven/source/apache-maven-2.2.1-src.tar.gz


tar -zxvf apache-maven-2.2.1-src.tar.gz


 



vim /etc/profile



JAVA_HOME=/usr/java/jdk1.6.0_25
JRE_HOME=$JAVA_HOME/jre
CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
M2_HOME=/opt/apache-maven-2.2.1


export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC JAVA_HOME CLASSPATH JRE_HOME M2_HOME


 


 


2011年4月25日 星期一

CentOS 5.6 使用rsyslog接收外部設備的連線LOG

使用OS : CentOS 5.6


安裝套件 : rsyslog


前置作業 : 以 Juniper NetScreen-ISG 2000 為例子


登入到isg2000 > Configuration > Report Settings > Syslog 


設定好接收機器的相關設定


 


1. 安裝 rsyslog


# yum install rsyslog

 


2. 修改設定檔


# vim /etc/rsyslog.conf

$ModLoad imudp.so
$UDPServerRun 514
:fromhost-ip,isequal,"isg200 IP" /var/log/isg2000/isg_log

 


3. 關閉預設syslogd 並啟用 rsyslog


# chkconfig syslogd off
# chkconfig rsyslog on

# service syslog stop
# service rsyslog start

 


4. 設定輪替檔


# vim /etc/logrotate.conf

/var/log/isg2000/isg_log{
        daily
        create
        rotate 360
        compress
        postrotate
        /etc/init.d/rsyslog reload
        endscript
}

CentOS 5.6 / LVM 調整

模擬環境: 新增一顆硬碟 , 將他加入現有之LVM , 並加大目前LVM之容量


 


[root@mt ~]# fdisk -l


Disk /dev/hda: 82.3 GB, 82348277760 bytes
255 heads, 63 sectors/track, 10011 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14       10011    80308935   8e  Linux LVM


Disk /dev/hdb: 122.9 GB, 122942324736 bytes
16 heads, 63 sectors/track, 238216 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes


   Device Boot      Start         End      Blocks   Id  System


 



[root@mt ~]# fdisk /dev/hdb


The number of cylinders for this disk is set to 238216.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)


Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-238216, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-238216, default 238216):
Using default value 238216


Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)


Command (m for help): w
The partition table has been altered!


Calling ioctl() to re-read partition table.
Syncing disks.
[root@mt ~]# partprobe


 




[root@mt ~]# pvdisplay
  /dev/hdd: open failed: No medium found
  --- Physical volume ---
  PV Name               /dev/hda2
  VG Name               VolGroup00
  PV Size               76.59 GB / not usable 26.69 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              2450
  Free PE               0
  Allocated PE          2450
  PV UUID               dfXZbc-pfev-YMTz-XfiR-BveL-HUrl-fmd7Fu


[root@mt ~]# pvcreate /dev/hdb1
  Physical volume "/dev/hdb1" successfully created
[root@mt ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/hda2
  VG Name               VolGroup00
  PV Size               76.59 GB / not usable 26.69 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              2450
  Free PE               0
  Allocated PE          2450
  PV UUID               dfXZbc-pfev-YMTz-XfiR-BveL-HUrl-fmd7Fu


  "/dev/hdb1" is a new physical volume of "114.50 GB"
  --- NEW Physical volume ---
  PV Name               /dev/hdb1
  VG Name
  PV Size               114.50 GB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               f82VID-oKsl-ShjT-BZed-enmP-Tum4-ZbAIpM


 


加大VG及調整LV


以上步驟已用fdisk新增一LVM分割區 /dev/hdb1 並利用 pvcreate 轉成 PV


[root@mt ~]# vgdisplay


  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               76.56 GB
  PE Size               32.00 MB
  Total PE              2450
  Alloc PE / Size       2450 / 76.56 GB
  Free  PE / Size       0 / 0
  VG UUID               yd3K0H-5IWd-N5AX-q5dZ-j9MP-2xHh-4qPRj2


[root@mt ~]# vgextend VolGroup00 /dev/hdb1
  Volume group "VolGroup00" successfully extended
[root@mt ~]# vgdisplay
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               191.03 GB
  PE Size               32.00 MB
  Total PE              6113
  Alloc PE / Size       2450 / 76.56 GB
  Free  PE / Size       3663 / 114.47 GB
  VG UUID               yd3K0H-5IWd-N5AX-q5dZ-j9MP-2xHh-4qPRj2



[root@mt ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                41mdX5-GhDO-8xUU-cqY8-SrMr-HfME-EnkfsL
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                74.62 GB
  Current LE             2388
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0


  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                4k7mr6-1qkt-5p35-6oD7-IwPB-lN3V-ixf56I
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                1.94 GB
  Current LE             62
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1


 


 




[root@mt ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       73G  2.7G   66G   4% /
/dev/hda1              99M   19M   76M  20% /boot
tmpfs                 489M     0  489M   0% /dev/shm


[root@mt ~]# cat /etc/fstab


/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
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
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0


[root@mt ~]# lvextend -L +100G /dev/VolGroup00/LogVol00
  Extending logical volume LogVol00 to 174.62 GB
  Logical volume LogVol00 successfully resized


 



[root@mt ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                41mdX5-GhDO-8xUU-cqY8-SrMr-HfME-EnkfsL
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                174.62 GB
  Current LE             5588
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0


  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                4k7mr6-1qkt-5p35-6oD7-IwPB-lN3V-ixf56I
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                1.94 GB
  Current LE             62
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1


[root@mt ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       73G  2.7G   66G   4% /
/dev/hda1              99M   19M   76M  20% /boot
tmpfs                 489M     0  489M   0% /dev/shm


 


 




[root@mt ~]# resize2fs /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 45776896 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 45776896 blocks long.


 


 




[root@mt ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      170G  2.8G  158G   2% /
/dev/hda1              99M   19M   76M  20% /boot
tmpfs                 489M     0  489M   0% /dev/shm


 


 


2011年4月18日 星期一

CentOS 新增第三方 yum Repositories

CentOS在套件管理上和Fedora相比


預設的repositories 只有放官方測試過的程式


有些好用的軟體都必須自己去抓source下來編譯安裝


所以我們可以新增一個第三方repositories 去擴充 yum 可用的套件


至於有那些repositories可用,


可參考CentOS 官方 wiki : http://wiki.centos.org/AdditionalResources/Repositories


 


以下介紹 rpmforge 的安裝方式


1.  先確認系統核心


# uname -i
x86_64 

 


2. 下載對應核心版本 rpm forege 



# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

 


3. 匯入DAG's GPG KEY


# rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt


4. 驗證下載的rpm來源是否正確


# rpm -K rpmforge-release-0.5.2-2.el5.rf.*.rpm
rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm: (sha1) dsa sha1 md5 gpg OK


5.  安裝 rpmforge 


# rpm -ivh rpmforge-release-0.5.2-2.el5.rf.*.rpm
Preparing...                ########################################### [100%]
   1:rpmforge-release       ########################################### [100%]
 


6. 測試yum reposititores 是否已加入 rpmforge


# yum clean all

隨便下指令安裝個什麼東西來看看是否已加入成功


# yum install htop
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: mirror01.idc.hinet.net
 * base: mirror01.idc.hinet.net
 * extras: mirror01.idc.hinet.net
 * rpmforge: fr2.rpmfind.net
 
* updates: mirror01.idc.hinet.net
addons                                                             |  951 B     00:00
addons/primary                                                     |  204 B     00:00
atrpms                                                             | 3.0 kB     00:00
atrpms/primary_db                                                  | 1.2 MB     00:02
base                                                               | 2.1 kB     00:00
base/primary_db                                                    | 2.2 MB     00:02
extras                                                             | 2.1 kB     00:00
extras/primary_db                                                  | 241 kB     00:00
rpmforge                                                           | 1.1 kB     00:00
rpmforge/primary                                                   | 2.2 MB     00:03
rpmforge                                                                      10480/10480

updates                                                            | 1.9 kB     00:00
updates/primary_db                                                 | 335 kB     00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package htop.x86_64 0:0.9-1.el5.rf set to be updated
--> Finished Dependency Resolution


Dependencies Resolved


==========================================================================================
 Package          Arch               Version                   Repository            Size
==========================================================================================
Installing:
 htop             x86_64             0.9-1.el5.rf              rpmforge              84 k


Transaction Summary
==========================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)


Total download size: 84 k
Is this ok [y/N]:

 


這樣就完成囉!


 


2011年4月17日 星期日

CentOS 5.5 設定SNMP

學校最近在測What's UP


於是找了一台Linux來設定SNMP測試看看 :)


 


1. 使用yum 安裝 snmp 相關套件


# yum -y install net-snmp net-snmp-utils


 


第一步驟安裝完,使用預設的設定檔啟動snmp就可以了


設定檔的位置在 /etc/snmp/snmpd.conf


2. 啟動snmp


# service snmp start


 


3. 檢查snmp 啟動狀態


3.1 使用 snmpwalk 工具測試


# snmpwalk -c public -v 2c localhost system


3.2 檢查port是否開啟
# netstat -tnlup | grep snmpd
tcp        0      0 127.0.0.1:199               0.0.0.0:*                   LISTEN      7279/snmpd
udp        0      0 0.0.0.0:161                 0.0.0.0:*                               7279/snmpd


2011年4月6日 星期三

no available legacy port

學校的NAT主機壞了,臨時抓了一台PC裝CentOS5.5 做NAT


安裝的時候就有跑出怪怪的訊息,但我沒理他


格式化的時候特別慢


結果裝好重開機後再核心的地方就出現錯誤訊息了 : no available legacy port


跑起來也頓頓的


查了一下google的結果是說有些PC裝centos會誤把SATA硬碟認成IDE硬碟,


於是去看了一下 /dev 的裝置, 果然把硬碟認成hdx


解決的方式是修改開機核心參數,在kernel 那一行的最後面加入 ide0=noprobe ide1=noporbe ....


重開後再檢查一次 /dev 下面的裝置 , 終於出現sdx了 :)


跑起來也順多了


沒問題後就把參數寫入 /etc/grub.conf 


解決!


 


 


2011年4月5日 星期二

CentOS 做 NAT

本教學只做實際設定範例,詳細原理可以參考鳥哥的Linux網站 http://linux.vbird.org/


環境設定:


先設定好兩張網路卡的IP和網段,所有區網內的IP從eth1這個介面(private ip)進來,由eth0介面(public ip)出去


第一張網卡 eth0 : 


ip : 192.192.249.1
netmask : 255.255.255.0
brocast : 192.192.249.255
gateway : 192.192.249.254


第二張網卡 eth1:


ip : 192.168.100.1
netmask : 255.255.255.0
brocast : 192.168.1.255


1. 設定網路介面


# vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
TYPE=Ethernet
IPADDR=192.192.114.1
NETMASK=255.255.255.0
NETWORK=192.192.114.0
BROADCAST=192.192.114.255
ONBOOT=yes
GATEWAY=192.192.114.254


# vim /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
BOOTPROTO=static
TYPE=Ethernet
IPADDR=192.168.100.1
NETMASK=255.255.255.0
NETWORK=192.168.100.0
BROADCAST=192.168.100.255
ONBOOT=yes


2. 開啟封包轉送


# echo "1" > /proc/sys/net/ipv4/ip_forward


3. 設定SNAT


# iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -o eth0 -j SNAT --to 192.192.114.1


4. 檢查路由


[root@NAT ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
61.221.253.160  0.0.0.0         255.255.255.224 U     0      0        0 eth1
192.168.100.0   0.0.0.0         255.255.252.0   U     0      0        0 eth0
0.0.0.0         61.221.253.161  0.0.0.0         UG    0      0        0 eth1


 


5. 將設定寫入scripts , 並設定開機自動執行


以上測試成功後就把它寫成scripts讓電腦開機時自動執行


# vim /etc/rc.d/rc.local


/root/firewall.sh


# touch /root/firewall.sh


# chmod +x /root/firewall.sh


# vim /root/firewall.sh


#!/bin/bash


# 開啟封包轉送


echo "1" > /proc/sys/net/ipv4/ip_forward


# 清除防火牆規則


for table in filter nat mangle


do


 iptables -t $table -F


iptables -t $table -X


iptables -t $table -Z


done


# 設定NAT


iptables -t nat -A POSTROUTING -s 10.1.100.0/24 -o eth0 -j SNAT --to 192.192.114.1


2011年4月3日 星期日

TeamViewer 6 安裝教學

TeamViewer 和傳統的遠端連線軟體相比他是扮演一個中介者的腳色,


因此可以不受防火牆的限制,便可達到遠端連線之功能


2011年3月6日 星期日

Ubuntu安裝vncserver

Ubuntu 安裝 vncserver 實在是太快速了...


什麼時候centos也可以進化一下啊...囧rz


 


Step1. 安裝 tightvncserver


# sudo apt-get install tightvncserver


 


Step2. 切換成一般使用者 , 並建立vnc 密碼


$ vncserver


You will require a password to access your desktops.



Password:
Verify:
Would you like to enter a view-only password (y/n)? n
xauth:  creating new authority file /home/james/.Xauthority


New 'X' desktop is ubuntu:1


Creating default startup script /home/james/.vnc/xstartup
Starting applications specified in /home/james/.vnc/xstartup
Log file is /home/james/.vnc/ubuntu:1.log


之前在CentOS/Fedora 的 vnc 那篇文章作的一堆步驟他一次就搞定了 ....


Step 3.  於VNC Client端執行VNC Viewer連到IP:5901( 預設port )


影像 1.png 


 


影像 2.png 


 


影像 3.png 


2011年2月10日 星期四

好用的磁碟管理工具 - EASEUS Partition Master

相信大家以前都有用過 Patition Magic 吧!


現在有個免費的磁碟管理工具, 和Partion Magic 一樣都可以動態調整使用中磁區


而且是免費的


我久久用一次,卻每次要用時都忘記這個程式的名字


這次寫下來,在忘記就沒轍了


推薦給大家使用喔! 


官方網站: http://www.partition-tool.com/


2011年1月26日 星期三

(尚未設定標題)

環境設定:全新安裝的Fedora 14,並更新到最新版


# yum -y update


重開機讓部分更新設定生效( 這很重要喔!! 如果更新系統一定要記得做這個動作! )


# sync;sync;sync;reboot


安裝 wine


# yum -y install wine


下載utorrent,我一開始用 wine + µTorrent Stable (2.2) 竟然裝不起來, 所以我就下載了beta版的 µTorrent beta (2.2.1 build 24266)
# cd ~
# wget http://download.utorrent.com/beta/utorrent-2.2.1-beta-beta-24266.upx.exe


設定開機跑 runlevel 3


# vim /etc/inittab
id:3:initdefault:


檢查 vnc-server 執行狀態


# netstat -tnlp | grep vnc


tcp        0      0 0.0.0.0:6000                0.0.0.0:*                   LISTEN      1351/Xvnc
tcp        0      0 0.0.0.0:6001                0.0.0.0:*                   LISTEN      1379/Xvnc


使用VNC連線到桌面環境


vnc1 


應用程式-->Wine-->Wine Software Uninstaller


wine 


安裝 -> 點選剛剛下載的utorrent -> 開啟


w2 


之後就一直下一步就安裝完成了


重頭戲來了!接下在教大家怎麼在Fedora 14 中使用µTorrent 的 WebUI


影像 8.jpg 


如上圖,點選 uTorrent的功能表中的選項(O) -> 選項 可出現設定畫面


請依照圖中設定方式先設定好網頁介面的選項


接下來開啟瀏覽器: http://IP:8080/gui 


他會跟你說 

" The µTorrent WebUI does not seem to be installed. Click here to try to install it, or see the guide for more details. "

但是點選 here 安裝時又會告訴你....


" There was a problem installing µTorrent WebUI, please see the µTorrent log for more details."


發生錯誤!


這是因為我們是在wine的環境中執行uTorrent,所以只要手動去下載WebUI放到相對應的資料夾就可以了


# cd ~/.wine/drive_c/users/user1/Application\ Data/uTorrent/


# wget 


2011年1月25日 星期二

lftp顯示中文目錄和切換中文目錄

lftp在顯示中文目錄和切換中文目錄時會有問題


解決的辦法如下


# vim ~/.lftp/rc


debug 3
set ftp:charset Big-5
set file:charset UTF-8


這樣就OK了


2011年1月24日 星期一

Fedora 14 安裝 rtorrent

rtorrent 介紹:


rtorrent 是一個可以在文字介面下使用的BT軟體


效能跟傳輸效率都是一流的


現在介紹給大家使用!


 


官方網站:http://libtorrent.rakshasa.no/


 




 


安裝環境 : Fedora core 14


 


安裝 rtorrent libtorrent


# yum -y install rtorrent libtorrent


 


autodl-setup


2011年1月21日 星期五

CentOS 5.5 / Fedora 14 安裝 VNC Server

以前寫過CentOS5 安裝vnc筆記
不知道為什麼會寫的"落落長"

這次來做個更新吧!


安裝VNC Server


# yum -y install vnc-server


修改vnc server設定檔,100這個值可以自訂,意思是說VNC Service啟動時的port(5900+100),5900可以用瀏覽器連http://IP:5900 (Fedora 不行)


# vim /etc/sysconfig/vncservers

VNCSERVERS="100:user1 101:user2" # 設定 user1 和 user2 的VNC
VNCSERVERARGS[100]="-geometry 1024x768" # 指定解析度

注意: 此範例中的user1,user2 必須是系統中的使用者帳號才能使用喔


使用 vncpasswd 設定vnc連線密碼,這邊要注意我們在上一步驟設定了VNCSERVERS="100:user1",所以我們要先su切換成 user1


 # su - user1
$ vncpasswd
Password: #輸入vnc連線的密碼
Verify: #再輸入一次


切換回root並啟動VNC Server


$ exit
# /etc/init.d/rc.d/vncserver start
正在啟動 VNC 伺服器: 100:user1
New 'test01.domain.com:100 (user1)' desktop is test01.domain.com:100

Starting applications specified in /home/user1/.vnc/xstartup
Log file is /home/user1/.vnc/test01.domain.com:100.log
[ 確定 ]
# chkconfig --level 35 vncserver on // 開機自動啟動

vnc1


這樣user1就可透過VNC Client(vnc viewer)使用port 6000(5900+100)連上VNC Server了;瀏覽器連5900。


 


如果你的作業系統是Fedora,到此就完成了。


CentOS 5必須在修改一個檔案,讓醜醜的X-windows變成美美的GNOME or KDE


#vi ~/.vnc/xstartup
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER #將此行 mark 拿掉
exec /etc/X11/xinit/xinitrc #將此行 mark 拿掉


修改後重新啟動VNC Server


# /etc/init.d/rc.d/vncserver restart
正在關閉 VNC 伺服器: 100:user1 [ 確定 ]
正在啟動 VNC 伺服器: 100:user1
New 'test01.domain.com:100 (user1)' desktop is test01.domain.com:100

Starting applications specified in /home/user1/.vnc/xstartup
Log file is /home/user1/.vnc/test01.domain.com:100.log
[ 確定 ]


大功告成!


2011年1月20日 星期四

清除OpenNMS數據庫

停止opennms服務


# service opennms stop


切換成postgres使用者


# su - postgres


刪除 opennms 數據庫


 $ dropdb opennms
$ exit 


重新建立opennms數據庫


# $OPENNMS_HOME/bin/install -dis


啟動opennms


# service opennms start

2011年1月18日 星期二

wget 設定 proxy 連線

因為學網連國外很慢


每次wget 抓東西都很慢


查了一下怎麼用wget 設定proxy


#vim /etc/wgetrc


http_proxy=http://x.x.x.x:3128/

ftp_proxy = http://x.x.x.x:3128/

use_proxy = on


 


Linux製作ISO檔的方法

每次都會忘記...


還是把它紀錄下來吧..


 


方法一 


用法: cp 光碟來源 ISO檔儲存位置


ex: cp /dev/cdrom /tmp/xp.iso


 


方法二


用法: dd if=光碟來源 of=ISO檔儲存位置 bs=512


ex: dd if=/dev/cdrom of=/tmp/xp.iso bs=512


 


記得放光碟啊....


如何在 golang 裡面引用 gitlab private repo

參考文章:https://stackoverflow.com/questions/27500861/whats-the-proper-way-to-go-get-a-private-repository 原文是用 gitlab.company.com 當範例,這邊改成一般帳號...