顯示具有 Linux 標籤的文章。 顯示所有文章
顯示具有 Linux 標籤的文章。 顯示所有文章

2016年3月29日 星期二

Linux SentOS postfix access & aliases 設定備忘

main.cf 設定備忘 

[root@www ~]# vim /etc/postfix/main.cf
myhostname = www.mydomain.com         
myorigin = $myhostname                
inet_interfaces = all                  <==約在第 114 行,117 行要註解掉
inet_protocols = ipv4                 
mydestination = $myhostname, localhost.$mydomain, localhost,
  linux.centos.com, ftp.mydomain.com
mynetworks = 127.0.0.0/8, 192.168.100.0/24, hash:/etc/postfix/access <==約在269行
relay_domains = $mydestination        
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases    
# 其他的設定值就先保留預設值即可啊!

access 設定備忘

[root@www ~]# vim /etc/postfix/access
59.124.157.227        OK
.edu.tw            OK
abc.com            REJECT
192.168.2.          REJECT
# OK 表示可接受,而 REJECT 則表示拒絕。

[root@www ~]# postmap hash:/etc/postfix/access
[root@www ~]# ls -l /etc/postfix/access*
-rw-r--r--. 1 root root 19648 2011-08-09 14:05 /etc/postfix/access
-rw-r--r--. 1 root root 12288 2011-08-09 14:08 /etc/postfix/access.db
# postmap 執行後 access.db 的檔案才會同步更新!這才是 postfix 實際讀取的!

aliases 設定備忘

[root@www ~]# vim /etc/aliases
mailer-daemon:  postmaster
postmaster:     root
bin:            root
daemon:         root
....(省略)....
[root@www ~]# vim /etc/aliases
root:     james
# 左邊是額外所設定的,右邊則是實際接收這封信的帳號!

[root@www ~]# postalias hash:/etc/aliases
[root@www ~]# ll /etc/aliases*
-rw-r--r--. 1 root root  1535 2011-08-09 14:10 /etc/aliases
-rw-r--r--. 1 root root 12288 2011-08-09 14:10 /etc/aliases.db

Reference

2016年3月19日 星期六

Linux top 中的 load average

如果 CPU 有 4 顆, load average 超過 12 (CPU 個數的3倍) 的時候, 代表 CPU 的 loading 很重

  • load average/CPU數 <= 3, performance is good
  • load average/CPU數 > 5, performance is very bad
其他相關指令


Linux tail 指令

tail myfile.txt
Outputs the last 10 lines of the file myfile.txt.

tail myfile.txt -n 100
Outputs the last 100 lines of the file myfile.txt.

tail -f myfile.txt
Outputs the last 10 lines of myfile.txt, and monitors myfile.txt for updates; tail then continues to output any new lines that are added to myfile.txt.

tail -f access.log | grep 24.10.160.10
This is a useful example of using tail and grep to selectively monitor a log file in real time.

參考一

2016年2月24日 星期三

ubuntu 新增硬碟(磁碟分割、格式化與掛載)

新硬碟要先用 fdisk 來分割硬碟,但是要分割新硬碟之前,要先搞清楚新的硬碟是哪一顆,先用 df 來看一下目前系統硬碟的使用情形
df -h

接著在看看 /dev 下面所有的硬碟情況
ls /dev/[sh]d*

再用 fdisk 確認一下:
fdisk -l /dev/sdb

開始分割:
fdisk /dev/sdb

首先我們要新增一個分割區,步驟如下
  1. 新增分割區,輸入 n 按 Enter。
  2. 選擇要建立 extended 還是 primary partition,因為我的硬碟全部只要一個分割區,所以我選 primary,輸入 p 按 Enter。
  3. 選擇 Partition number,primary 分割區最多可以有四個,隨便選都可以,不過建議選 1,免得以後看起來很奇怪,輸入 1 按 Enter。
  4. 輸入開始的 cylinder,用預設值就可以了,直接按 Enter。
  5.  輸入結束的 cylinder,若是要用最大的容量,就直接按 Enter,若是要指定分割區的大小,就用 +size{K,M,G} 的形式指定,例如指定為 100G 的大小就輸入 +100G 再按 Enter。
  6. 最後將分割表寫入硬碟,輸入 w 再按 Enter。
  7. 若是要離開 fdisk 就輸入 q 按 Enter 就可以了。
接著再用 fdisk 確認分割區:
fdisk -l /dev/sdb

格式化(Format)硬碟
mkfs -t ext4 /dev/sdb1

掛載(mount)硬碟
使用 UUID 來指定磁碟,硬碟的 UUID 就像是它的身分證字號,每一顆硬碟都可不同的 UUID,使用 UUID 來指定磁碟就不會因為安裝的順序不同而產生變化,所以 /etc/fstab 看起來會像這樣:
# / was on /dev/sda1 during installation
UUID=4fae7331-9307-4a57-84e1-10fa0b244ca1 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=a9cd23e1-f2f4-4f96-9795-9124f34c5e5b none            swap    sw              0       0

blkid 這個指令,它可以列出所有磁碟的 UUID:
sudo blkid
/dev/sda1: UUID="4fae7331-9307-4a57-84e1-10fa0b244ca1″ TYPE="ext4″
/dev/sda5: UUID="a9cd23e1-f2f4-4f96-9795-9124f34c5e5b" TYPE="swap"
/dev/sdb1: UUID="008df623-2979-492c-b030-41975805487b" TYPE="ext4″

所以現在就是依樣畫葫蘆,把新的硬碟資訊寫進 /etc/fstab 中,在 /etc/fstab 加入下面這行:
UUID=008df623-2979-492c-b030-41975805487b /data2          ext4    defaults 0       0
下次重開機時,系統就會把新的硬碟掛載至 /data2,若要馬上測試掛載硬碟設定是否正確,可以使用 mount:
mount /data2

再用 df -h 看一下,就知道有沒有問題了。

Linux 指令 top 統計信息說明

前五行是當前系統情況整體的統計信息區。下面我們看每一行信息的具體意義。
第一行,任務隊列信息,同uptime 命令的執行結果,具體參數說明情況如下:
14:06:23 — 當前系統時間
up 70 days, 16:44 — 系統已經運行了70天16小時44分鐘(在這期間系統沒有重啟過的吆!)
2 users — 當前有2個用戶登錄系統
load average: 1.15, 1.42, 1.44 — load average後面的三個數分別是1分鐘、5分鐘、15分鐘的負載情況。
load average數據是每隔5秒鐘檢查一次活躍的進程數,然後按特定算法計算出的數值。如果這個數除以邏輯CPU的數量,結果高於5的時候就表明系統在超負荷運轉了。

more...

Linux CentOS 7 2014年 7月份釋出

Redhat 在 2014年 7月份釋出了最新版本的作業系統 – Redhat Enterprise Linux 7,CentOS 也在當月不久釋出 CentOS 7。

RHEL7/CentOS7 已不包含 MySQL 資料庫,取而代之的是由原先 MySQL 開發團隊所維護的 MariaDB,其功能與函式使用均與 MySQL 相同,基本上若無使用特別的套件,大部份的應用程式應該都相容可以,無需修改程式。

PHP則升級到5.4.x以後的版本