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

2019年6月11日 星期二

[Citrix] XenServer 監控 storage 容量

最近有一個需求,就是要監控XenServer 的 storange

因為我們分很多個pool,每個pool是使用不同的lun

所以剛好有這個需求就把script放上來分享給大家

vgdisplay --units G 這個指令就是把你掛載的storange show出來給你看

然後找到對應的storange 名稱 :VG_XenStorage-6e4d4811-ffcd-2593-38f5-abxxxxxxxxx

我這邊告警條件是設定超過85 % 就會發mail通知


#!/bin/bash

storage=VG_XenStorage-6e4d4811-ffcd-2593-38f5-abxxxxxxxxx
diskuse=`vgdisplay --units G $storage |grep "Alloc PE"|awk '{print $7}'`
disktotal=`vgdisplay --units G $storage |grep "VG Size" |awk '{print $3}'`
WARN=85
ADMIN=60dmx@google.com.tw

a=`awk 'BEGIN{printf "%.2f\n",('$disktotal'/'100')}'`
b=`awk 'BEGIN{printf "%.2f\n",('$diskuse'/'$a')}'`
c=`echo | awk '{print int('$diskuse'/'$a')}'`

if [ $c -gt $WARN ]
then
        echo "disk size full!! \n on $(hostname) " | mail -s "Warning: disk space $c %" $ADMIN
        echo "disk size full!! \n on $(hostname) Warning: disk space $c %" > /tmp/disk.txt
fi

[Citrix] XenServer 5.X 6.X 版本repo 更新

最近在增加Xenserver的底層監控發現沒辦法直接用mail去發信

後來發現是因為repo 太舊了...只好把centos 5 的repo換掉

就可以更新yum 安裝檔案了

記得要先把citrix.repo enable=1 改成 0
/etc/yum.repos.d

然後把CentOS-Base.repo 改成下面新的就可以正常更新安裝了


[base]
name=CentOS-$releasever - Base
baseurl=http://vault.centos.org/5.11/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://vault.centos.org/5.11/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://vault.centos.org/5.11/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

2019年4月9日 星期二

[Citrix] Xenserver 監控 - Netdata 安裝

最近同事推薦了一款很炫炮的監控軟體,畫面很漂亮很酷
二話不說就馬上上網找步驟安裝起來,但是因為XenServer
安裝比較麻煩需要先改repo才能進行 yum install
這邊我會再寫一篇修改for XenServer 7.x版本的repo檔
下圖是Netdata 監控XenServer 所看到的DashBoard



安裝步驟如下 :

Step 1: Update the system

For security purposes, update the system to the latest stable status using YUM:
sudo yum update -y && sudo reboot
After the reboot finishes, log in with the same sudo user.

Step 2: Install dependencies

In order to install Netdata, you need to install the dependencies below:
sudo yum install zlib-devel libuuid-devel libmnl-devel gcc make git autoconf autogen automake pkgconfig
sudo yum install curl jq nodejs

Step 3: Install Netdata

Install Netdata with the official installation script:
cd ~
git clone https://github.com/firehol/netdata.git --depth=1
cd netdata
sudo ./netdata-installer.sh
During the installation process, Press ENTER to start the installation.
If no errors occur during installation, the Netdata daemon will start.

Step 4: Modify firewall rules

Before you can access Netdata's web interface, you need to modify firewall rules to allow traffic on port 19999, the default communication port of Netdata:
sudo firewall-cmd --permanent --zone=public --add-port=19999/tcp
sudo firewall-cmd --reload

Step 5: View the monitoring interface

Confirm the installation by opening your web browser and visiting the monitoring interface of Netdata:
http://<your-Vultr-server-IP>:19999

[系統設定]
vim /etc/netdata/netdata.conf

* global - 服務的全域設定
* plugins - 啟用或停用插件
* plugin:NAME - 各個插件的設定
* CHART_NAME - 各個圖表的設定
以預設值就已經可以正常的運作了,而這些參數可以視狀況修改:
* update every = 1,每一秒更新一次
* default port = 19999,預設通訊埠在 TCP 19999
* bind to = *,不綁定 IPv4、IPv6 位址
* disconnect idle web clients after seconds = 60,Web Client 閒置 60 秒後就踢掉
* enable web responses gzip compression = yes,啟用網頁 GZip 壓縮功能

2019年1月15日 星期二

[Citrix] XenServer VM 備份匯出匯入

通常我們在管理一個服務時最重要的就是
備份 監控 校時

備份 監控 校時
備份 監控 校時
很重要,所以說三遍

今天來介紹怎麼做匯出匯入xenserver vm的 指令showmount -e  看哪個資料夾可以掛載,在那台compute node 
把路徑mount起來
ex : Mount -t nfs 10.100.1.1:/volume/storage /mnt/vm-backup/

匯出的指令:
xe vm-export vm=0d2b5f9a-c88f-6b27-be08-4ac61baadc41 filename=/mnt/vm-backup

匯入的指令:
xe vm-import filename=/mnt/vm-backup檔案 sr-uuid=storaeuuid

2018年9月4日 星期二

[Citrix] XenDesktop - 螢幕鎖定時間設定

因為最近公司在POC新版的XenDesktop7.15
發現即便有GPO原則的情況下,還是沒辦法鎖定
後來老K發現,是因為Citrix會套一個policy在最上面蓋著GPO
這邊提供上網查到的解法,也確定都可以實行


Set Registry key: [HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\Graphics] "SetDisplayRequiredMode"=dword:00000000 Make the following GPO Changes: Open gpedit.msc -> User Configuration -> Administrative Templates -> Control Panel -> Personalization

Enable Screen saver - Set to enable
Prevent changing screen saver - Set to enable
Password protect screen saver- Set to enable
Screen saver timeout - Any Value Except 0

Force specific screen saver - scrnsave.scr

[Citrix] XenServer 管理-Command Mode


關機
xe vm-shutdown uuid=6dba075a-c991-12bf-e5d9-3a8ea31c4038 force=true
UUID:         

強制重開
xe vm-reset-powerstate  uuid=649aafdf-7228-2387-17d6-205c6a67d1f6 force=true


上下線時 
service xapi restart

查詢 系統現有連結資源
df -h


查詢線上溝通
ps aux


詢問是否在emergency mode true or f (自動保護機制)
xe host-is-in-emergency-mode



系統log
vi /var/log/xensource.log

******************************************************************************************
般來說會遇到網卡遺失 然後跟MASTER失連的問題 (center上面看到都是紅色狀態,但底層可以接)

最慘狀況就是連master 也網卡遺失…(剛剛就發生再pool2身上,還有之前的南東pool)

<網卡遺失就是從console上面看不到IP資訊或在底層下xsconsole看不到IP>

解法:
情境一:
如果是pool master失連網卡消失情況發生, 造成相關pool指令都看不到vm

#xe pif-list
會出現
The host could not join the liveset because the HA daemon could not access the heartbeat disk.
代表應該是ha機制造成

#xe host-is-in-emergency-mode
如果回傳回來是trun 那就再代表這台host 為了保護這台主機上的VM所以進入緊急模式,就是代表為什麼每次看不到網卡,center不到,但VM還是可以正常運行

就可以下
#xe host-emergency-ha disable –force
HA關掉ß一般就是因為HA打開才會進入emergency-mode(緊急模式)

然後把所以服務重啟
# xe-toolstack-restart

這時再去看console 網卡就會起來;center他過一下就會接上了!!!


情境二:
materhost 發生

通常會發生代表MASTER應該也發生問題了(機率很高),如果這時處理好MASTER問題
直接下
# xe-toolstack-restart
他就會取得IP

MASTER確定正常那先試試看 先把masterxe-toolstack-restart
再對有問題的host xe-toolstack-restart

####
如果想把slave host 變成pool master
可以下
#xe pool-emergency-transition-to-master

****************************************************************************************

以上指令上班時間下OK 不用怕 原來ON在上面的vm都不會有問題

參考兩篇文章:



2017年10月5日 星期四

XenServer失聯



一般來說會遇到網卡遺失 然後跟MASTER失連的問題 (center上面看到都是紅色狀態,但底層可以接)

最慘狀況就是連master 也網卡遺失…(剛剛就發生再pool2身上,還有之前的南東pool)

<網卡遺失就是從console上面看不到IP資訊或在底層下xsconsole看不到IP>

解法:
情境一:
如果是pool master失連 網卡消失情況發生, 造成相關pool指令都看不到vm

#xe pif-list
會出現
The host could not join the liveset because the HA daemon could not access the heartbeat disk.
代表應該是ha機制造成

#xe host-is-in-emergency-mode
如果回傳回來是trun 那就再代表這台host 為了保護這台主機上的VM所以進入緊急模式,就是代表為什麼每次看不到網卡,center不到,但VM還是可以正常運行

就可以下
#xe host-emergency-ha disable –force
HA關掉ß一般就是因為HA打開才會進入emergency-mode(緊急模式)

然後把所以服務重啟
# xe-toolstack-restart

這時再去看console 網卡就會起來;center他過一下就會接上了!!!


情境二:
materhost 發生

通常會發生代表MASTER應該也發生問題了(機率很高),如果這時處理好MASTER問題
直接下
# xe-toolstack-restart
他就會取得IP

MASTER確定正常 那先試試看 先把masterxe-toolstack-restart
再對有問題的host xe-toolstack-restart

####
如果想把slave host 變成pool master
可以下

#xe pool-emergency-transition-to-master