2015年9月30日 星期三

[SSHFS]安裝設定使用(ssh遠端掛載目錄)


安裝
Centos 安裝套件後,使用者必須加入fuse群組才能使用FUSE功能
yum install fuse-sshfs
usermod -a -G fuse username
設定
新增/etc/fuse.conf,增加以下內容,掛載時才可以使用-o allow_other參數
# Allow non-root users to specify the 'allow_other' or 'allow_root'
# mount options.
#
user_allow_other
手動掛載
如果想要讓資料夾可以被帳號以外的其他使用者帳號存取可加入-o allow_other參數
sshfs -o allow_other username@IP:/path/to/folder /path/to/local/folder
手動缷載
fusermount -u /path/to/local/folder
開機自動掛載
/etc/fstab下新增 (SSH Trust要先做好!!!)
 username@ip:/path/to/folder /path/to/local/folder   fuse.sshfs idmap=user,identityfile=/home/username/.ssh/id_dsa,allow_other,uid=User_uid,gid=User_gid 0 0

資料來源:
http://blog.miniasp.com/post/2013/11/30/Useful-tool-SSHFS-SSH-Filesystem.aspx
http://what-a-good-day.blogspot.tw/2015/05/ssh-mount-linux.html
http://unix.stackexchange.com/questions/37168/unable-to-use-o-allow-other-with-sshfs-option-enabled-in-fuse-conf
http://fuse.sourceforge.net/
https://www.variux.com/sshfs-automount-at-boot-with-fstab-on-ubuntu-14-04/

2015年5月15日 星期五

yum fix 404 error

yum (404錯誤訊息)
========================================================================
epel                                                                           | 4.4 kB     00:00
http://download.fedoraproject.org/pub/epel/6/x86_64/repodata/06fdcd0885b07462710fc206a438bb143580807569fd02723e08a681384996ad-primary.sqlite.bz2: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404"
Trying other mirror.
http://download.fedoraproject.org/pub/epel/6/x86_64/repodata/06fdcd0885b07462710fc206a438bb143580807569fd02723e08a681384996ad-primary.sqlite.bz2: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404"
Trying other mirror.

Error: failure: repodata/06fdcd0885b07462710fc206a438bb143580807569fd02723e08a681384996ad-primary.sqlite.bz2 from epel: [Errno 256] No more mirrors to try.
========================================================================

解決方法 yum clean metadata ,再yum即可正常安裝或更新


2015年5月11日 星期一

[備忘]如何解決舊版本Ubuntu無法更新套件或安裝套件的問題


如舊版本Ubuntu 12.10由於sources.list檔案中的更新套件的來源伺服器連不到無法使用,
所以會無法更新或安裝套件

解決方法:
在/etc/apt/sources.list.d/sources.list檔案中加入以下
deb http://old-releases.ubuntu.com/ubuntu/ quantal main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ quantal-security main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ quantal-updates main restricted universe multiverse
加入後更新一下套件清單apt-get update,即可更新或安裝套件


資料來源:http://askubuntu.com/questions/518856/upgrade-12-10-sources-list
參考連結:http://www.arthurtoday.com/2010/11/ubuntu-apt-get.html

2013年12月20日 星期五

修復: PDF 檔案於 Internet Explorer 10 | 11無法開啟的解決方法

文章轉貼資料來源:The Windows Club

1. Press Windows Key + R combination, type put Regedt32.exe in Run dialog box and hit Enter to open the Registry Editor.


2. Navigate to the following location:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
3. In the right pane of this location, look for the TabProcGrowth named DWORD. This DWORD actually is short from of Tab Process Growth; which sets the rate at which IE creates New Tab processes. If you’ll find the DWORD there, it must having the Value data as 0. If you don’t find it there, create it manually using Right click -> New -> DWORD Value. Now click on the same DWORD to modify its Value data:

 4. Now set the Value data from 0 to 1. Click OK. Putting Value data 1 ensures that all tabs for a given frame process run in a single tab process for a given mandatory integrity level (MIC) level. You may now close the Registry Editor and reboot to see the results.

PHP 錯誤訊息提示功能 php.ini display_errors

文章轉貼資料來源:IT達人
php.ini 檔案設定:
當display_errors = on 時若 php 的程式有問題即會把錯誤訊息顯示在瀏覽器上,這對開發人員非常方便,但當網站對外開放時,一般都會把這個功能關閉,因為php若遇嚴重錯誤時不管你有沒有開啟這個功能它都會顯示錯誤訊息在瀏覽器上通常正式上線的 php 網站都會將這個功能關閉。
檢查 php.ini 檔中的 display_errors 的設定是否為
display_errors = on (若有錯誤會顯示在瀏覽器上) 
將它改成
display_errors = off (關閉錯誤提示訊息)
設定好之後重新將apache 啟動即可

2013年7月17日 星期三

[備忘]調整 SQL 最佳輸出顯示

mysql> pager less -n -i -s;

mysql> SHOW PROCESSLIST \G;

2013年6月30日 星期日

[備忘]Clamav freshclam doesn't update

轉貼來自於http://jerryclc.blogspot.tw/2012/06/etccron.html
Clamav freshclam doesn't update  Error message as below

ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).
ERROR: Can't open /var/log/clamav/freshclam.log in append mode (check permissions!).



Modify "/etc/cron.daily/freshclam
==============================

#!/bin/sh

### A simple update script for the clamav virus database.
### This could as well be replaced by a SysV script.

### fix log file if needed
LOG_FILE="/var/log/clamav/freshclam.log"
if [ ! -f "$LOG_FILE" ]; then
    touch "$LOG_FILE"
    chmod 644 "$LOG_FILE"
   // modify chown clam.clam ==> clamav.clamav
    chown clamav.clamav "$LOG_FILE"
fi

/usr/bin/freshclam \
    --quiet \
    --datadir="/var/lib/clamav" \
    --log="$LOG_FILE"

2013年6月26日 星期三

[備忘]ProFTPD Server Log - xferlog 分析

以下文章轉貼資料來源:
1.http://www.the-art-of-web.com/system/xferlog/#.UcsA9Pl8k9s
2.http://www.linuxweblog.com/blogs/wizap/20080129/analyzing-proftpd-xferlog-file


 The xferlog Format
The default format of the xferlog for ProFTP contains the following information on each line:
current-time
Thu June 27 01:24:47 2013
transfer-time
whole seconds
remote-host
file-size
size of transferred file in bytes
file-name
transfer-type
a = ascii; b = binary
special-action-flag
C = compressed; U = uncompressed; T = tar'ed; _ = no action was taken
direction
o = outgoing; i = incoming; d = deleted
access-mode
a = anonymous; r = real
username
service-name
usually ftp
authentication-method
0 = none; 1 = RFC931 Authentication
authenticated-user-id
user id or '*'
completion-status
c = complete; i = incomplete
The three characters following the file name represent the transfer-type (ascii or binary), any special actions (usually _ meaning none) and the direction (outgoing, incoming or deleted).
  1. ascii format:
    • a _ i (uploaded)
    • a _ o (downloaded)
    • a _ d (deleted)
  2. binary format:
    • b _ i (uploaded)
    • b _ o (downloaded)
    • b _ d (deleted)

Now, to extract a list of all successfully uploaded files
(查已上傳成功的檔案):

awk '($12 ~ /^i$/ && $NF ~ /^c$/){print $9}' xferlog

(查已被下載的檔案):

awk '($12 ~ /^o$/ && $NF ~ /^c$/){print $9}' xferlog

(查已刪除的檔案):
awk '($12 ~ /^d$/ && $NF ~ /^c$/){print $9}' xferlog


and uploads that were unsuccessful(查上傳未完成的檔案):
awk '($12 ~ /^i$/ && $NF ~ /^i$/){print $9}' xferlog

2013年6月14日 星期五

A fatal error occurred while trying to sysprep the machine


機器型號: ASUS BM 6620

作業系統環境:Windows 7 SP1 64bit (使用英文語系)

動作: 執行Sysprep系統封裝

錯誤訊息:A fatal error occurred while trying to sysprep the machine

注意!!!如全新系統環境為Win 7 SP1 台灣-繁體中文是可正常執行Sysprep的,如上錯誤訊息 "A fatal..."是在Win 7 SP1 英文語系環境下執行Sysprep所遇到的問題.


兩種解決方法:
一. Ctrl + F9 使用快速鍵還原,系統還原出廠後將 Windows Media Player Network Sharing Service服務停用,即可順利執行Sysprep封裝動作

二.使用ASUS BM6620系統出廠還原光碟,還原後即可順利執行Sysprep封裝動作


    (預設Windows Media Player Network Sharing Service服務是停用的)



Sysprep已知問題:
啟用 Windows Media Player 共用時執行 Sysprep,可能會發生錯誤,所以在執行Sysprep工具前要先將Windows Media Player Network Sharing Service服務停用

參考連結:
http://technet.microsoft.com/zh-TW/library/dd349350(WS.10).aspx

2012年6月11日 星期一

[筆記]備忘:Centos6.2 安裝JAVA、Tomcat套件與設定

Centos6.2 安裝JAVA、Tomcat套件
#yum -y install tomcat6 tomcat6-webapps tomcat6-admin-webapps

# rpm -qa java*jdk tomcat6  //查詢套件版本
java-1.6.0-openjdk-1.6.0.0-1.43.1.10.6.el6_2.i686
tomcat6-6.0.24-36.el6_2.noarch
# rpm -qc tomcat6 | grep -E 'server|users'
/etc/tomcat6/server.xml  //查詢相關設定檔路徑
/etc/tomcat6/tomcat-users.xml

設定環境檔變數
#!vi /etc/profile    //加在最底部即可
============================================
JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib
export PATH JAVA_HOME CLASSPATH
============================================

建立一個名為server.jsp用來判斷目前Tomcat服務是由哪一台叢集主機來負責
===================================================================
<%@ page contentType="text/html; charset=utf8" %>

<%@ page import="java.net.InetAddress" %>

<html>

<head>

<title>Server hostname and ip in jsp</title>

</head>

<body><h1>

  <%String ip = "";

  InetAddress inetAddress = InetAddress.getLocalHost();

  ip = inetAddress.getHostAddress();

  out.println("Server Hostname is: " +inetAddress.getHostName());%><br>

  <% out.println("Server IP Address is: "+ip); %><br>

</h1></body>

</html>
======================================================


2012年5月29日 星期二

Centos 6.2 軟體 Raid 1 Bug 解決方法(錯誤訊息:Kernel Panic -- not syncing- attempted to kill init)

經Google查是 drauct造成的Bug 
官方:http://bugs.centos.org/view.php?id=5400
文中最後提到解決方法
latest dracut fixes the issue:
don't forget to rebuild your initramfs once you have installed the latest dracut version! 

造成的問題現象:
2顆硬碟做Raid 1,當硬碟壞掉一顆後, 重開機會出現如下訊息,
Kernel Panic -- not syncing- attempted to kill init


解決方法步驟
1.更新dracut
#yum -y install dracut

2.更新完 dracut 後一定要做,重建initramfs 。
#cd /boot
#mv initramfs-`uname -r`.img initramfs-`uname -r`.img.bak      
#dracut -v initramfs-`uname -r`.img `uname -r`                        
參考資料:http://hi.baidu.com/edelweisszf/blog/item/c63cb30852de628b0b7b8251.html


2011年12月15日 星期四

Linux下支援語系設定檔i18n(解決中文亂碼問題)

裝機後必設定此語系檔
/etc/sysconfig/i18n
================================================
LANG="zh_TW.Big5"
SUPPORTED="zh_TW.Big5:zh_TW:zh:en_US.UTF-8:en_US:en"
SYSFONT="latarcyrheb-sun16"
================================================

保存退出後,執行如下立即生效 (不需重開機)
#source /etc/sysconfig/i18n


可避免FileZilla上傳多層中文目錄會出現的錯誤訊息
Failed to convert command to 8 bit charset

2011年11月23日 星期三

使用IP查電腦名稱指令

指令: nbtstat -a IP

2011年11月21日 星期一

[備忘]Redhat安裝Clamav步驟

安裝步驟

1.到ClamAV官網網址http://pkgs.repoforge.org/clamav/
wget下載如下三個套件
clamav-0.97.3-1.el6.rf.x86_64.rpm
clamav-db-0.97.3-1.el6.rf.x86_64.rpm
clamd-0.97.3-1.el6.rf.x86_64.rpm

2.
rpm -ivh clamav-db-0.97.3-1.el6.rf.x86_64.rpm

3.
rpm -ivh clamav-0.97.3-1.el6.rf.x86_64.rpm

或步驟2、3 可直接用rpm -ivh clamav-* 一行指令方式安裝

4.
rpm -ivh clamd-0.97.3-1.el6.rf.x86_64.rpm

Clamav完裝完成

5.啟動Clamd服務
/etc/rc.d/init.d/clamd start

6.執行更新病毒碼指令
freshclam

7.測試ClamAV是否能夠掃毒
clamscan /tmp

以上參考網路資料

2011年11月14日 星期一

[備忘]更改~/.bashrc直接申效Commond

1.設定 執行vi時使用vim
vi ~/.bashrc
=================================================================
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias vi='vim'
~~~省略
=================================================================
2.立即申效command
source ~/.bashrc

2011年11月13日 星期日

[備忘]備份/還原MySQL指令

資料來源:MySQL 5徹底研究第三版 出版社:博碩文化

備份MySQL資料庫
mysqldump [選項] --databases 資料庫1 資料庫2 ...
mysqldump [選項] --all-database

範例:備份所有資料庫
>mysqldump -u root --all-databases > backup.sql


復原MySQL資料庫
(復原單一資料庫)
>mysql -u root -p databasename < backup.sql
Enter password:*******
備註:在還原之前必須手動建立資料庫

(復原多個資料庫)

>mysql -u root -p < backup.sql
Enter password:*******

備註:如果先前已備份多個資料庫,那麼在復原資料時則會自動重建資料庫,因此不必預先手動建好資料庫,在執行mysql還原時,也不必指定資料庫名稱


LAMP上課資料=================================================================
(備份)
mysqldump -h localhost -u root -p employee > employee_backup.sql

(還原)
mysql -u root -p(進入 MySQL console,初始化密碼為空白)
mysql> DROP DATABASE employee;(刪除 employee 資料庫)
mysql> exit

mysqladmin -h localhost -u root -p create employee(初始化密碼為空白,在還原之前,必須要先手動建立資料庫)
mysql -h localhost -u root -p employee < employee_backup.sql(初始化密碼為空白)
=================================================================

2011年11月11日 星期五

[備忘]SMTP指令(利用telnet測試MailServer寄信功能是否正常)

telnet localhost 25

Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 nyc.exmple.com ESMTP Postfix
接著輸入如下指令
--------------------------------------
SMTP指今用法
MAIL FROM:寄件者郵件帳號(例如:xxx@example.com)
RCPT TO:收件者郵件帳號(例如:本機 root@localhost)
DATA
輸入本文
. (結束符號)
quit 結束對話,於server中斷連線

指令用法參考[引用]資料來源:






--------------------------------------

[設定備忘]有效阻擋非法的垃圾信來源(針對郵件帳號或網域限制的方法)

測試工具
yum install mailx (安裝此套件後才有mail指今可用)
yum install telnet (安裝此套件後才有telnet指今可用)


1.vi /etc/postfix/check_sender 建立限制名單
===========================
#格式: 寄件來源 處理動作
#針對單一郵件帳號REJECT
xxx@example.com REJECT
#針對整個DOMAIN REJECT
example.com REJECT

===========================

2.postmap /etc/postfix/check_sender 會產生check_sender.db檔

3.vi /etc/postfix/main.cf 新增/修改如下條件
=======================================
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/check_sender,permit_mynetworks
=======================================
注意:實測結果,限制條件cehck_sender_access要放在最前面才能有效Reject check_sender名單上的寄件者或網域名稱

4. service postfix restart 後申效 或 /etc/init.d/posfix reload 後申效

最後在使用telnet localhost 25去測試設定是否有作用

下圖虛擬練習機上的main.cf 新增/修改畫面










2011年10月5日 星期三

[筆記]關於Network Interface Configuration - Bonding




Selected Linux Ethernet Bonding Modes ( 後面文字,Redhat上課筆記,供參考)

Network Interface Configuration - Bonding設定的主要用途: 頻寬合併(需搭配Switch支援)、分流、備援、容錯



主要談到以下三種Mode

Mode 0 — Sets a round-robin policy for fault tolerance and load balancing. Transmissions are received and sent out sequentially on each bonded slave interface beginning with the first one available. (需搭配Switch 有頻寬合併 、有容錯)


Mode 1 — Sets an active-backup policy for fault tolerance. Transmissions are received and sent out via the first available bonded slave interface. Another bonded slave interface is only used if the active bonded slave interface fails. (最佳的容錯機制 , 接手速度最快,Session中斷,掉五個封包以內,可備援接手)


Mode 3— Sets a broadcast policy for fault tolerance. All transmissions are sent on all slave interfaces.(無頻寬合併,接手速度相較Mode1慢,優點中斷時,含中斷前的所有資料,將會由備援接手)


關於Network Interface Configuration - Bonding相關參考連結