2017/10/24

最近更新proxmox後又發生crontab無法寄信的問題
印像中之前不久也發生過
但沒有留下記錄
再找了一下
官方當時說改一下權限就可以了之後會修正
應該是還沒修

chmod g+s /usr/bin/pvemailforward

https://forum.proxmox.com/threads/pve5-problem-when-send-mail-to-root.35733/#post-175325

2017/10/19

最近碰到一個怪問題
就是proxmox 裡的 guest linux主机會出現以下的錯誤訊息

















出現後有時ok
但有時filesystem 就會有錯誤
需要filesystem check
可是如果是windows  運氣不好就直接掛點
一開始是懷疑storage有問題
可是把guest搬到肚子後還是一樣
查了一些資料後有人提到可能是nfs的問題 而且通常都會在backup時發生
於是朝這個方向測試
測了好久
終於有了初步的結論
不管備到那裡 會發生問題就是會發生
而且跟storage的網卡速度也無關
問題在proxmox備分時提供三個選項

不壓縮
lzo
gzip

目前發現如果選擇不壓縮 備分時host會一直搶io
導致上述的情況
如果是選lzo就不會有這個問題了
gzip因為會吃比較多資源
沒有進行測試
所以結論就是

備分時請選擇 lzo 壓縮方式

2017/10/12

今天把snort 升到2.9.11後
要啟動時出現以下的錯誤

/usr/sbin/snort: error while loading shared libraries: libdnet.1: cannot open shared object file: No such file or directory

libdnet這個rpm明明就有裝
因為剛release 所以可能還沒有人升級
先找看看
在/user/lib64下有找到libdnet的相關檔案
而且全部都連結到 libdnet.so.1.0.1

ls -al|grep libdnet
lrwxrwxrwx   1 root root      16 Oct 12 08:41 libdnet.1 -> libdnet.so.1.0.1
lrwxrwxrwx   1 root root      16 Oct 12 08:31 libdnet.so -> libdnet.so.1.0.1
lrwxrwxrwx   1 root root      16 Dec 21  2015 libdnet.so.1 -> libdnet.so.1.0.1
-rwxr-xr-x   1 root root   62936 Jun 10  2014 libdnet.so.1.0.1

想說不然就來試看看
再建一個連結

ln -s libdnet.so.1.0.1 libdnet.1

醬就可以了
目前啟動正常

https://snort.org/

2017/10/08

記錄一下如何在 X11 forword的情況下把聲音一起forword

二台都是linux

近端的機器必須先安裝 pulseaudio paprefs 這二個package
一般而言目前使用的音效都已經裝好且應該都是 pulseaudio   使用的port 是4713
而 paprefs 是設定程式 裝好後執行 paprefs
依照下方的圖進行勾選設定


















設定好後就可以使用ssh 連上遠端机器

ssh -C -c arcfour -X -R 4715:localhost:4713 user@remote.ip

4715:localhost:4713  主要是要把遠端4175的封包傳到近端來

登入遠端後要先執行

export PULSE_SERVER=localhost:4715

把聲音導到 port 4715
(確認port 4715 是不是沒在使用)


再來執行程式

firefox

此時打開youtune 看影片就可以聽到聲音了


http://guildwar23.blogspot.tw/2012/11/

因為一直有把遠端的桌面利用X11 Forwarding的需求
而且是利用internet傳輸
但一直碰到的問題就是感覺非常慢
今天查了一下資料
應該可以改變一下加密的方法來加速
首先先在server上加上加密方法的支援

$ echo "Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,blowfish-cbc,aes128-cbc,3des-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc" | sudo tee --append /etc/ssh/sshd_config

再來連線時就可以使用不同的加密演算法

ssh -c arcfour,blowfish-cbc -XC host.com

以下列出使用不同演算法的速度
自己參考看看囉






















https://godleon.github.io/blog/2016/06/02/HowTo-SpeedUp-X11-Forwarding-in-SSH
http://xmodulo.com/how-to-speed-up-x11-forwarding-in-ssh.html
https://blog.famzah.net/2010/06/11/openssh-ciphers-performance-benchmark/
http://debiannoteofj.blogspot.tw/2010/09/x11-forwarding.html
http://www.miscdebris.net/blog/2007/06/01/speed-up-ssh-x11-forwarding/

2017/10/06

the oid of  clients connected to one ruckus AP

1.3.6.1.4.1.25053.1.1.12.1.1.1.3.1.2.1 is 2.4 GHz clients
1.3.6.1.4.1.25053.1.1.12.1.1.1.3.1.2.2 is 5 GHz clients

2017/10/02

昨天晚上server發生filesystem錯誤

重開後mariadb出現問題
到log去看時發現以下資訊

171002  8:51:09  InnoDB: cannot calculate statistics for table ABC/def
InnoDB: because the .ibd file is missing.  For help, please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting.html
171002  8:51:09 [ERROR] MySQL is trying to open a table handle but the .ibd file for
table ABC/def does not exist.
Have you deleted the .ibd file from the database directory under
the MySQL datadir, or have you used DISCARD TABLESPACE?
See http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting.html
how you can resolve the problem.

到目錄去看時
def.idb這個檔真的不見了
查了一下
這個檔不見是沒辦法由目前的資料再產生的
只能recovery

找了一下備分
倒回去
目前看來正常
再觀察看看

2017/09/14

今天一早上班就有人跟我說網路無法認証
查了一下發現radius 沒起來
再看log發現今天早上centos 7 有很大的更新
其中包含了freeradius的套件
試了几次 daemon就是起不來
後來用 radiusd -X 看訊息如下

rlm_ldap (ldap): Opening additional connection (0), 1 of 32 pending slots used
rlm_ldap (ldap): Connecting to ldap://10.10.10.10:389
rlm_ldap (ldap): Waiting for bind result...
rlm_ldap (ldap): Bind credentials incorrect: Invalid credentials
rlm_ldap (ldap): Server said: NDS error: failed authentication (-669).
rlm_ldap (ldap): Opening connection failed (0)
rlm_ldap (ldap): Removing connection pool
/etc/raddb/mods-enabled/ldap[8]: Instantiation failed for module "ldap"

奇怪為什麼升版前沒問題
升版後就不行了
並沒有去動ldap的config
google了一下發現有類似的情況
問題出在config跟ldap認証的密碼有特殊字元
XD
什麼怪事都有
改掉之後就可以了

再觀察看看

2017/09/01

如果是手動安裝librenms
則nagios plugin並不會安裝
找到以下這篇說明如何安裝

http://olivermarshall.net/enable-ping-tests-in-librenms/

如果是使用ova
那預設就已經裝好了
上篇也有說明如何加入service的監看

不過預設並未加入service down的alert
以下官方文件有說明如何加入

https://docs.librenms.org/Extensions/Services/

2017/08/31

最近在玩librenms
介面看起來真的滿潮的
而且只要她可以辨認的mib
會把所有相關的資料都顯示出來
連USHA的資料都完全出現
包括電壓 負載 溫度....等
這方面比cacti好用很多
不過目前碰到的問題是還無法餵值來畫圖
另外就是一定要使用snmp來偵測裝置

在測的過程中出現一個狀況
就是alert有出現
email通知的設定也沒錯
但device如果down
在畫面上有看到alert
但就是沒收到mail
之後經過了8小時
才開始發mail








試了半天
還是一樣
後來想說去forum 問問
就在要發問時
系統說要先執行validate.php把結果一起po上去
那就先執行看看

./validate.php
====================================
Component | Version
--------- | -------
LibreNMS  | 1.31.02-3-g4683736
DB Schema | 205
PHP       | 7.0.22
MySQL     | 5.5.52-MariaDB
RRDTool   | 1.4.8
SNMP      | NET-SNMP 5.7.2
====================================

[FAIL]  We have found some files that are owned by a different user than librenms, this will stop you updating automatically and / or rrd files being updated causing graphs to fail.
        [FIX] chown -R librenms:librenms /opt/librenms
/opt/librenms/html/plugins/Weathermap/configs
/opt/librenms/html/plugins/Weathermap/configs/testing.conf
[OK]    Database connection successful
[OK]    Database schema correct
[WARN]  Your install is over 24 hours out of date, last update: Tue, 29 Aug 2017 18:53:05 +0000
[FAIL]  You have a different system timezone (CST) specified to the php configured timezone (UTC), please correct this.

果然有几個問題
一個是權限問題
我在想我是用官方提供的ova
為什麼會有這個問題
再來是時區
因為我有去改os的timezone
但php.ini沒改
難怪會晚了8小時才收到信
這個也改了
再來就是說我版本太舊
不是說每天會固定更新??
算了
手動跑一下daily.sh
目前alert發信看來正常了
再觀察看看

後記
權限改完後
刪除裝置時還是會出現














要嗎就再把rrd改成777
不然就用root去刪
算了
反正刪設備的機會也不多
碰到再用root刪吧
使用rsyslog 收資料時
預設會去反解來源的ip
可以修改以下參數停用
加上 -Q -x

範例

SYSLOGD_OPTIONS=”-c3 -Q -x”

https://ssorc.tw/1194

2017/08/25

今天收到了一個zip檔
但user說忘記密碼了
XD
找到fcrackzip這個有趣的東西
ubuntu安裝很簡單
sudo apt install fcrackzip

接下來下個指令 先試10個字範圍內

fcrackzip -b -c 'aA1!' -l 1-10 -u crack_file.zip

再來就是等了

http://topspeedsnail.com/fcrackzip-crack-zip-password/

2017/08/24

今天要登入awacs(網管軟体)時
出現無法連接的訊息
登入主机發現mariadb的daemon不見了
systemctl restart mariadb也起不來
看了一下 /var/log/mariadb/mariadb.log 發現以下的記錄

170824 19:02:01  InnoDB: Page checksum 2583736692 (32bit_calc: 3902863637), prior-to-4.0.14-form checksum 2992650943
InnoDB: stored checksum 218772529, prior-to-4.0.14-form stored checksum 775370784
InnoDB: Page lsn 825440558 909582385, low 4 bytes of lsn at page end 825373998
InnoDB: Page number (if stored to page already) 775303712,
InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) 775041840
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 7.
InnoDB: You may have to recover from a backup.
InnoDB: It is also possible that your operating
InnoDB: system has corrupted its own file cache
InnoDB: and rebooting your computer removes the
InnoDB: error.
InnoDB: If the corrupt page is an index page
InnoDB: you can also try to fix the corruption
InnoDB: by dumping, dropping, and reimporting
InnoDB: the corrupt table. You can use CHECK
InnoDB: TABLE to scan your table for corruption.
InnoDB: See also http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.

按照說明
在/etc/my.cnf 加上

[mysqld]
innodb_force_recovery = 1

重啟mariadb

再查一下log

170824 19:02:01  InnoDB: Error: space id and page n:o stored in the page
InnoDB: read in are 1553519:2, should be 1553541:2!
170824 19:02:01  InnoDB: Error: space id and page n:o stored in the page
InnoDB: read in are 1553519:3, should be 1553541:3!

InnoDB: Apply batch completed
InnoDB: Starting in background the rollback of uncommitted transactions
170824 19:02:01  InnoDB: Rolling back trx with id 127203F, 451 rows to undo
170824 19:02:01  InnoDB: Waiting for the background threads to start

InnoDB: Rolling back of trx id 127203F completed
170824 19:02:01  InnoDB: Rollback of non-prepared transactions completed
170824 19:02:02 Percona XtraDB (http://www.percona.com) 5.5.40-MariaDB-36.1 started; log sequence number 653240202086
170824 19:02:02 InnoDB: !!! innodb_force_recovery is set to 1 !!!
170824 19:02:02 [Note] Plugin 'FEEDBACK' is disabled.
170824 19:02:02 [Note] Server socket created on IP: '0.0.0.0'.
170824 19:02:02 [Note] Event Scheduler: Loaded 0 events
170824 19:02:02 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.41-MariaDB'  socket: '/home/Alopex/mysql/mysql.sock'  port: 3306  MariaDB Server
InnoDB: A new raw disk partition was initialized or
InnoDB: innodb_force_recovery is on: we do not allow
InnoDB: database modifications by the user. Shut down
InnoDB: mysqld and edit my.cnf so that newraw is replaced
InnoDB: with raw, and innodb_force_... is removed.
InnoDB: A new raw disk partition was initialized or
InnoDB: innodb_force_recovery is on: we do not allow
InnoDB: database modifications by the user. Shut down
InnoDB: mysqld and edit my.cnf so that newraw is replaced
InnoDB: with raw, and innodb_force_... is removed.

看來是修好了
不過user還是不能用

InnoDB: innodb_force_recovery is on: we do not allow
InnoDB: database modifications by the user. Shut down
InnoDB: mysqld and edit my.cnf so that newraw is replaced
InnoDB: with raw, and innodb_force_... is removed.

要再把

[mysqld]
innodb_force_recovery = 1

mark掉再重開

目前看來是正常了
再觀察看看


https://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html

2017/08/23

今天早上使用proxmox裡的guest測了一下io

host

ProLiant DL380p Gen8

raid card














guest os

linux mint 直接使用cd boot 後執行 gnome-disks 跑benchmark


datastore 使用 xfs























datastore 使用 zfs (zfs是使用由raid card做raid 5 出來之後再用 raidz0)




















是不是要為了 remote replication 而浪費這些效能
就自己決定囉

補充硬碟資料


















每台host 上共有12個如上的hd
1個hot spare 另外11個做raid 5

另外再補充在pc上測試的結果

pc上的hd資料如下
3個500G SATA 直接接在主机板上



下圖為測試結果






2017/08/10

zfs 更換disk 流程如下

若disk已損壞
zpool status 會出現損壞disk的id
插上新disk後
執行
zpool replace fail_disk_id /dev/sdx

畫面如下

















若disk尚未損壞但已經有問題必須下線

則必需手動offline

zpool offline aaa /dev/sdb
插入新disk後
執行
zpool replace aaa /dev/sdb /dev/sdx

畫面如下


在ubuntu 16.04上建立zfs的流程如下

sudo zpool create mypool raidz /dev/sdb /dev/sdc /dev/sdd

以上指令為建立一個raidz (raid 5)的pool

pool type請參考以下連結

https://wiki.ubuntu.com/ZFS/ZPool

但碰到一個問題 就是每次開机不會自動把zpool mount進來

目前的解決方法是在 /etc/rc.local 加上以下二行

zpool import mypool

zfs mount -a

2017/08/08

如果graylog是直接使用ova
那heap space預設只有 1.4 G
效能不好
所以當os加完ram後要再調整

vi /etc/graylog/graylog-settings.json

修改以下參數

"custom_attributes": {
     "graylog-server": {
       "memory": "2000m"
     },
     "elasticsearch": {
       "memory": "2000m"
     }
   }

改好後

cp /opt/graylog/conf/graylog.conf /opt/graylog/conf/graylog.conf_bck

sudo graylog-ctl reconfigure

mv /opt/graylog/conf/graylog.conf_bck /opt/graylog/conf/graylog.conf

sudo graylog-ctl restart

http://docs.graylog.org/en/2.3/pages/configuration/graylog_ctl.html#graylog-ctl-advanced

2017/12/21 後記

在reconfigure之前記得要先把 /opt/graylog/conf/graylog.conf 先備分
因為reconfigure會把graylog.conf恢復成原始值
記得把備份檔還原後再 graylog-ctl restart

2017/08/04

proxmox升到5版後開始使用zfs
但碰到了二個問題
一個是效能感覺上跟之前使用ext4或xfs差很多
另外就是zfs會一直吃ram 直到把ram全吃完
查了很多資料
都是建議加SSD來當zfs的cache
但目前沒有多餘的預算
後來找到一份官方文件

https://pve.proxmox.com/wiki/ZFS_on_Linux

依照說明
先把zfs的ram使用量限制為10G (文件為8G)
另外限制swap的使用量

vi /etc/modprobe.d/zfs.conf

options zfs zfs_arc_max=10737418240

update-initramfs -u

vi /etc/sysctl.conf

vm.swappiness = 10

改完後記得要reboot

目前看來好多了
再觀察看看
升到proxmox 5後搭配zfs提供了一個很好的功能
guest replication
但發現一個問題
偶爾會出現sync fail的狀況
而且一但發生
就再也沒辦法再sync成功









查了一下 forum
目前的解決方法就是把在遠端的replication 資料砍了
然後再重新sync一次

zfs destroy rpool/data/vm-112-disk-1

注意千萬不要砍錯了

2017/07/26

升到 proxmox 5後發生了一個問題
當使用nfs備份或還原時
速度都很慢
看了一下log出現一堆如下的訊息

[ 2579.108635] NFS: nfs4_discover_server_trunking unhandled error -22. Exiting with error EIO

看來是一直去用nfs4

在proxmox 4我不用特別指定在nfs使用version 3
proxmox5看來一定要指定了
只好在 /etc/pve/storage.cfg裡加上參數

options nolock,vers=3