星期二, 1月 27, 2015

Citrix XenServer Storage is running out of space

It's very dangerous to del base copy .

*It seems that it'll auto reclaim freed space on XenServer 6.5.:D

Please don't do it,if you aren't sure.
If you really did it,such like what I did the stupid things.
And I'm still looking for the answear.
http://discussions.citrix.com/topic/347790-parent-vdi-deleted-accidentally/

Before delete it,you have to make sure which VHD-Files are linked together.
 you can use this command
# xe vdi-list uuid=VDIUUID params=all
or

# xe vdi-list name-labe=$VDI_NAME params=all
And you can see  vhd-parent:(if you had ever did the snapshot or something like that.)
Please keep it and do not delete it!
PS.The  vhd-parent could be linked with another vhd file.

My citrix xenserver storage is running out of space.
It shows 700.1 GB used of 853.1 GB total (376 GB allocated)
When I google and get the answer is  "base copy".
you can use this command to show all the vdi file.
# xe vdi-list

1.find the name-label is base copy,and make sure the $STORAGE_UUID is the storage that you want to delete.
# xe vdi-list name-label="base copy" 

output:
uuid ( RO) : $UUID
name-label ( RW): base copy
name-description ( RW):
sr-uuid ( RO): $STORAGE_UUID
virtual-size ( RO): 386547056640
sharable ( RO): false
read-only ( RO): true
2.find the path.
# lvdisplay|grep "$UUID"output:
LV Name $PATH
3.remove it and rescan the storage.
# lvremove -f $PATH
# xe sr-scan uuid=
$STORAGE_UUID
My space is back and i hope it works out well for you !


This article was extremely useful: http://appsense.wordpress.com/2009/11/24/deleting-orphaned-disks-in-citrix-xenserver-5-5/


星期四, 1月 15, 2015

dovecot pop3 無法認證問題

許久沒有架設MAIL SERVER,某日跟朋友聊到MAIL SERVER狀況。

MAIL SERVER 只能從本機收發信件,無法透過SMTP 以及POP3 去做收發服務。

趕緊翻開鳥哥的文章溫習一下,SMTP 問題解決了,但是POP3 卻是怎麼樣都會有問題。

原來是Dovecot 2.X設定檔的位置改了,必須針對相對應的位置逐一設定。

比較需要注意的地方紀錄一下:

 確認有啟用POP3  ,IMAP則看有沒有需要。
# vi  /etc/dovecot/dovecot.conf
protocols = pop3 imap
 如果沒有啟用SSL加密,記得要關閉
#vi /etc/dovecot/conf.d/10-ssl.conf
ssl = no
非常關鍵的mail_location,一直卡在這邊
#vi /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:/var/spool/mail/%u
修改好後記得重新啟動服務
#/etc/init.d/dovecot restart
最後最最最重要的步驟在這
根據 mwu4 在iT邦幫忙中 補充回答的關鍵
 如果信件放在「 /var/mail 」(「 /var/mail 」連結到「 /var/spool/mail 」),記得要將檔案權限由「 0660 」更改為「 0600 」。謝謝。
#chmod 600 /var/mail/foo
foo 為使用者帳號
參考來源:
centos 6.5 dovecot pop3 無法認證問題

星期三, 12月 03, 2014

mod_rewrite@Apache

我常在想,網誌名稱是不是要來改一下好了(偷笑!)

最近遇到一個比較棘手的問題,想了很久,於是突發奇想,是否有可能透過url_rewrite來解決呢?於是花了些時間去找資料跟實做,那麼把一些結果紀錄一下吧!

什麼是url_rewrite,顧名思義就是網址重寫(這樣翻對嗎?)

廢話不多範例是最好的說明,來看一下最常用的應用!

範例一:如果我想做HTTP自動轉HTTPS
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

 
另外紀錄一些我覺得比較特別的應用,符合某特定來源

RewriteEngine on 
RewriteCond %{REMOTE_ADDR} ^192\.168\.1\.168$ [OR]
RewriteCond %{REMOTE_ADDR} ^172\.16\.$ [OR]
RewriteCond %{REMOTE_ADDR} ^10\.$ [OR] 
RewriteRule .......

HTTP跟HTTPS下都能運作

<VirtualHost *:80> 
RewriteEngine on
RewriteCond ....
RewriteRule .....
</VirtualHost > <VirtualHost *:443>
RewriteEngine on
RewriteCond ....
RewriteRule ....
</VirtualHost >

 其實我主要是要紀錄一下如何在HTTP跟HTTPS下運作,其他技術文件網路上超級多的了!
 
參考來源:
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html 
http://www.widexl.com/tutorials/mod_rewrite.html 
http://www.whoopis.com/howtos/apache-rewrite.html
http://stackoverflow.com/questions/22221203/apache2-rewrite-rule-not-working-remote-address

   
 
 

星期二, 11月 11, 2014

OpenVAS @CentOS 6

時格許久再次安裝OpenVAS,依稀記得整個步驟簡單到不行。

為了再次確認是否在新版本有所差異,還是回官方確認一下。

Step 1: Configure Atomicorp Repository
(as user root, only once)
wget -q -O - http://www.atomicorp.com/installers/atomic |sh
Step 2: Quick-Install OpenVAS
(as user root, only once)
yum upgrade
yum install openvas
openvas-setup
Step 3: Quick-Start OpenVAS

( nothing to do, all is up and running directly after installation )
Step 4: Log into OpenVAS with user created in the step 2
Open https://localhost:9392/.


看到這段之後,放心的超簡單的安裝!

但是跑
# openvas-setup

卻停在
Error: rsync failed. Your NVT collection might be broken now.
 
後來爬了一下討論,才發現原來他需要使用873 port 更新!
 
一切又回到當初的單純美好簡單! 
 
對了,當初裝好時有碰到掃描直接完成。 
根據log 紀錄來看是出現掃描主機失敗,後來把selinux關閉後就正常了。XD

參考來源:
[Openvas-discuss] can not set up openvas + Centos 6.5

星期六, 2月 23, 2013

rsync error message: rsync failed to set times on

事情是這樣的 (偷笑)

我有兩台伺服器想透過rsync作資料同步。
A -  IP:192.168.1.2
B -  IP:192.168.1.3

於是我在A伺服器中設定了NFS

#vi /etc/exports
/tmp        192.168.1.3(rw)

#start nfs service

接著我在B伺服器中掛載B伺服器,並測試使用rsync排程
#mount -t nfs 192.168.1.2:/tmp /tmp

#測試同步
#rsync -av /tmp/ /tmp/
可是卻出現錯誤訊息: rsync failed to set times on


後來在鳥哥的網站發現到,如果讓 root 保有 root 的權限,那麼需要加上
no_root_squash
 
 #vi /etc/exports
/tmp        192.168.1.3(rw,no_root_squash)

#restart NFS
 問題就順利的解決了!

星期四, 2月 07, 2013

mdadm md device /dev/md0 does not appear active

事情是這樣的,有一台跑著軟體raid的主機,無預警的重開機之後出現錯誤!
接著便無法順利掛載使用,查看錯誤訊息為
mdadm md device /dev/md0 does not appear active
 
後來爬文爬了許久,試了許多步驟發現都沒用,直到看到這篇

Re: Device Unusable At Startup


# mdadm -R /dev/md0

重新mount 之後,東西都回來了,真是太感動了!

星期二, 1月 22, 2013

OpenVAS @ CentOS

2014年11 月重新安裝在CENTOS6上,詳情請參考:詳情請參考:OpenVAS @CentOS 6

其實一整個步驟真的還蠻簡單的
首先安裝好精簡的centos(把selinux關閉,防火牆開啟9392 port)

wget -q -O - http://www.atomicorp.com/installers/atomic |sh

yum install openvas
openvas-setup
然後等等等 ...
首先他會要你先建立管理者帳號,密碼
然後在建立一般使用者帳號、密碼
跑完之後,就可以在機器上打開連覽器輸入https://ip:9392

有沒有一整個超級簡單的感覺!

但是沒想到接下來才是惡夢的開始,其實一整個並不如想像中的那樣可以開始之後
接下來碰到掃描停在1%,掃描沒有結果直接完成!
爬了許多文章,似乎是個bug!(攤手)

後來看到有位網友分享的文章提到"不要使用https,就不會有些怪問題發生"
修改的方法如下,加入--http-only參數
vi /etc/rc.d/init.d/gsad

daemon $EXEC $PARAMS --http-only

儲存之後,重新啟動服務
service gsad restart
目前測試掃描是正常了,還在持續觀察。

就在剛剛好奇心驅使之下,先把系統備份,然後把 --http-only參數移除,改回https的方式登入掃描,目前一整個也是正常!

至於點選nvt 更新會出現錯誤的情況,就改成在crontab 排程給他自動去更新吧!
#時間請依照個人喜好排
vi /etc/crontab

00 5 * * * root openvas-nvt-sync

更多資料可以參考官方網站:
Quick-Setup and Quick-Start OpenVAS-5 Packages