2021年2月2日 星期二

Ubuntu 20.04 install librenms

 Ubuntu 20.04 install librenms


由於CentOS8 變成孤兒了,故著手把手頭的CentOS 上的版本做轉移


沒想到越做越越多問號,讓人不經懷疑網站上的編寫者有沒有實際自己跑過一遍XDDDD


由於花了不少時間解問題,就把筆記更新放著了




apt install software-properties-common

add-apt-repository universe

apt update

apt upgrade

官站上的教學


apt install acl curl composer fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full nmap php7.4-cli php7.4-curl php7.4-fpm php7.4-gd php7.4-json php7.4-mbstring php7.4-mysql php7.4-snmp php7.4-xml php7.4-zip rrdtool snmp snmpd whois unzip python3-pymysql python3-dotenv python3-redis python3-setuptools


問題來了

在套件中 php預設會抓取認識php-curl而非 php7.4-curl

所以要裝 php-curl


建立帳戶

useradd librenms -d /opt/librenms -M -r -s "$(which bash)"

cd /opt

#恩 會出現錯誤 git gnutls_handshake() failed 

git clone https://github.com/librenms/librenms.git


#查詢原因大致上是說明套件錯誤,但不管是停用改設定為Tls v1.2或是重包套件都沒過

#沒關係,山不轉路轉,改啟用ssl

1. 建立主機ssh-keygen


#ssh-keygen

2. cat ~/.ssh/id_rsa.pub

將公鑰複製下來大概長這樣


ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC9Kds9mB4tiT0wjP0DIwcs8ypdd7MhFv/V3uFsQ8Qxykw4jvxtcoRJX53DoaMWTlvCiywkE2x5XANivFVs/2cmRrP544aGadJ/oXMqClSegpdhthA9c2vt28ZtB28mB4fg9ci2gPIkBet74iruEjhbHGUcJ1Wzs8aCmvivHVaYiE6jtiZt48N8Xz6BfiVcIFmsvivnElh7bsZD13iXzM7Tq4PVKVPPMLLPqwjRj7lnR1jJD9P9IkUtikNLnXCDLBJ47X8vy8xA3QDMzBUFeNGCXeDnyfbpbN/YaGxydlsOTgBtu2HgkMVY4pPVUFxv/+dwiCM7hABDWUteuJrRO6FEAU1JhsDEJtGE6l5fwmx/zwOk5I0Wksg4vXu0ObcYUaBiK0vn5qHVTrm2iyq/4qGgeXF9b5ReHHJjv1X20yTQKPYSbfD3Pfqjno61xmQ/OSNPBm2K5py97SKA1888e/K8SJl5Sfpo9aMLq/S/01XtsVCSi2Kcv0= root@librenms



3. 登入git 帳號(沒有自己去建一個吧,很方便的)


Account settings到SSH and GPG keys選項>New SSH key>貼上


然後回到主機上

cd /opt

git clone git@github.com:librenms/librenms.git


會詢問是否接受,輸入yes點enter吧!


再來就回歸正途


設定資料夾權限

chown -R librenms:librenms /opt/librenms

chmod 771 /opt/librenms

setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/


#PHP pre-install

su - librenms

./scripts/composer_wrapper.php install --no-dev

exit


設定PHP Timezone

先確認自己的 timedatectl

Asia/Taipei


===

vi /etc/php/7.4/fpm/php.ini

vi /etc/php/7.4/cli/php.ini

===

 變更主機時區(台北)

sudo timedatectl set-timezone Asia/Taipei



Configure MariaDB

#編輯設定

vi /etc/mysql/mariadb.conf.d/50-server.cnf

在[mysqld] 底下加入

innodb_file_per_table=1

lower_case_table_names=0


開啟並重啟服務

systemctl enable mariadb

systemctl restart mariadb


建立資料庫與設定 librenma帳密

CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';

FLUSH PRIVILEGES;

exit


設定Configure PHP-FPM

cp /etc/php/7.4/fpm/pool.d/www.conf /etc/php/7.4/fpm/pool.d/librenms.conf

vi /etc/php/7.4/fpm/pool.d/librenms.conf

更改設定

將[www] 替換 [librenms]:

以下替換

user = librenms

group = librenms

listen = /run/php-fpm-librenms.sock


設定nginx

vi /etc/nginx/conf.d/librenms.conf

直接貼上

server {

 listen      80;

 server_name librenms.example.com;

 root        /opt/librenms/html;

 index       index.php;


 charset utf-8;

 gzip on;

 gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;

 location / {

  try_files $uri $uri/ /index.php?$query_string;

 }

 location ~ [^/]\.php(/|$) {

  fastcgi_pass unix:/run/php-fpm-librenms.sock;

  fastcgi_split_path_info ^(.+\.php)(/.+)$;

  include fastcgi.conf;

 }

 location ~ /\.(?!well-known).* {

  deny all;

 }

}

移除預設設定與啟動

rm /etc/nginx/sites-enabled/default

systemctl restart nginx

systemctl restart php7.4-fpm


SELinux

Ubuntu 預設未啟用(Cen


Configure snmpd

cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf


cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms


cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms


2020年9月15日 星期二

Cent OS 7 Mysql 5.1.73 Install

 setenforce 0

yum info mariadb-libs.x86_64

yum remove mariadb-libs.x86_64


yum install wget gcc ncurses ncurses-devel


cd /tmp

wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.73.tar.gz

tar -zxvf mysql-5.1.73.tar.gz 

cd /tmp/mysql-5.1.73/


./configure  '--prefix=/usr/local/mysql' '--without-debug' '--with-charset=utf8' '--with-extra-charsets=all' '--enable-assembler' '--with-pthread' '--enable-thread-safe-client' '--with-mysqld-ldflags=-all-static' '--with-client-ldflags=-all-static' '--with-big-tables' '--with-readline' '--with-ssl' '--with-embedded-server' '--enable-local-infile' '--with-plugins=innobase'


vim configer 

搜尋 $RM "$cfgfile"

改為 $RM -f "$cfgfile"

"error"

/bin/rm: cannot remove 'libtoolT': No such file or directory

config.status: executing default commands



#需yum install gcc-c++


make[1]: *** [my_new.o] Error 127

make[1]: Leaving directory `/tmp/mysql-5.1.73/mysys'

make: *** [all-recursive] Error 1


#故安裝套件完成後

make

make install

#mysql安裝至/usr/local/mysql下



cp support-files/my-medium.cnf /etc/my.cnf

cp -r support-files/mysql.server /etc/init.d/mysqld

/sbin/chkconfig --del mysqld

/sbin/chkconfig --add mysqld

 

配置权限表

chown -R mysql:mysql /usr/local/mysqld

/usr/local/mysql/bin/mysql_install_db --user=mysql

 

 

启动mysql

给/etc/init.d/mysql 执行权限,然后运行

chmod a+wrx /etc/init.d/mysql

/etc/init.d/mysqld start

 

mysql初始化配置:


包括密码设置等

#/usr/local/mysql/bin/mysql_secure_installation


#

mysql root/P@ssw0rd

#


帳號建立與資料庫權限設定

/usr/local/mysql/bin/mysqladmin -u root -h c7m5 password 'P@ssw0rd'


帳號建立

GRANT ALL PRIVILEGES ON *.* TO 'edwin'@'%' IDENTIFIED BY '' WITH GRANT OPTION;

grant all privileges on *.* to 'edwin'@'%' IDENTIFIED BY 'ec5678';



帳號變數設定

export PATH=/usr/local/mysql/bin:$PATH


服務確認

ps -ef|grep mysql


netstat --tunlp


防火牆確認與開啟

sudo firewall-cmd --permanent --add-service=mysql

sudo firewall-cmd --permanent --zone=public --add-port=3306/tcp

firewall-cmd  --reload

firewall-cmd  --list-all




#phpmyadmin


vim /etc/httpd/conf.d/phpmyadmin.conf


<Directory "/usr/share/phpmyadmin">

Order Deny,Allow

Deny from all

Allow from 127.0.0.1

Allow from 192.168.10.0/24 

#新增可以連線資料庫的特定機器的ip位址或是網段



</Directory>



apachectl -k restart


#SMB


Excel 2007開啟出現stdole32.tlb視窗

開啟Excel 2007時會出現stdole32.tlb錯誤視窗,

KB2767916移除後就正常。


#2020/09/15突然跳出老問題

筆記一下省得忘了

Office 版本並行 設定

 Office 多版本並行時 避免設定錯誤,依據對應版本設定無須重新設定REG登錄檔

點選開始>執行

Win10 開始右鍵>執行


Office2000


reg add HKCU\Software\Microsoft\Office\9.0\Word\Options /v NoReReg /t REG_DWORD /d 1


Office2002


reg add HKCU\Software\Microsoft\Office\10.0\Word\Options /v NoReReg /t REG_DWORD /d 1


Office2003


reg add HKCU\Software\Microsoft\Office\11.0\Word\Options /v NoReReg /t REG_DWORD /d 1


Office2007


reg add HKCU\Software\Microsoft\Office\12.0\Word\Options /v NoReReg /t REG_DWORD /d 1


Office2010


reg add HKCU\Software\Microsoft\Office\14.0\Word\Options /v NoReReg /t REG_DWORD /d 1


Office2013


reg add HKCU\Software\Microsoft\Office\15.0\Word\Options /v NoReReg /t REG_DWORD /d 1



Office2016


reg add HKCU\Software\Microsoft\Office\16.0\Word\Options /v NoReReg /t REG_DWORD /d 1


2020年7月22日 星期三

Outlook 寄信附件 大小增加

這是考古文, 但總會遇到骨董所以筆記放這裡

 E-Mail 最早並沒有支援附件,所以附件要靠編碼加入。

 Base64 固定放大 1.3333 倍
 QP 碼放大 1 ~ 3 倍

 所以當Outlook寄信送往沒有支援的Server時,郵件附件會增加1.3倍 

也就是假使10M會變成13M以上
 用 Windows Live Mail 另存 .eml,是以原始信件 (ANSI) 內容儲存。 
用 Outlook 另存 .msg ,是以 Unicode 儲存,在 Unicode 英數是 ANSI 兩倍。

另外 Outlook 2007 以前可以啟用保存原始郵件功能,會造成郵件內同時有ANSI / Unicode 兩種資訊。

2020年6月15日 星期一

Proxmox 5.X to 6.X

近來測試開源VM
跑得還不錯,以Ubuntu 為基的Proxmox

5.2 運行了一年多
打算正式使用,故順便研究升級與叢集的作法

最後整理筆記如下:

1.升級 Proxmox VE 5.4 到最新的版本。
apt update
apt dist-upgrade
2.利用pve5to6指令查看要升級的狀況。
#pve5to6
3.先升級Corosync 3
停止服務
#systemctl stop pve-ha-lrm
#systemctl stop pve-ha-crm
新增資源庫
#echo “deb http://download.proxmox.com/debian/corosync-3/ stretch main” > /etc/apt/sources.list.d/corosync3.list
更新資源,升級
#apt update
#apt dist-upgrade
啟動
#systemctl start pve-ha-lrm
#systemctl start pve-ha-crm
4.更新升級資料庫由stretch(5.X) 更改為Buster(6.X)
--Update all Debian repository entries to Buster.
用sed 替換字元
sed -i 's/stretch/buster/g' /etc/apt/sources.list
5. 新增資源庫,
Add the Proxmox VE 6 Package Repository
/etc/apt/sources.list
deb http://ftp.debian.org/debian buster main contrib
deb http://ftp.debian.org/debian buster-updates main contrib
#PVE pve-no-subscription repository provided by proxmox.com,
#NOT recommended for production use
deb http://download.proxmox.com/debian/pve buster pve-no-subscription
#security updates
deb http://security.debian.org buster/updates main contrib
/etc/apt/sources.list.d/pve-enterprise.list
deb http://download.proxmox.com/debian buster pve-no-subscription
6.更新
先刪除
#rm /etc/apt/sources.list.d/corosync3.list
更新套件升級
#apt update
#apt dist-upgrade
7. 重開機
事後談,在第五步卡了兩次,原來開源版不需要將原生的註記
可以一併保留

2020年1月1日 星期三

Librenms WebUI password change

LibreNMS 網頁密碼變更

做法:從SQL資料庫下手,由於該資料欄為雜湊值加密過
故需先找一組變更,(設定為空白無法登入)

登入SQL

mysql -u root -p

show databases;

#確認DB,舊版的為librenmsdb

use librenms;

#tables為 users,可以用select確認

select * from users;



底下為 password的雜湊密碼
$2y$10$qwtXWqRQz0xY4SGTEUqDkextPS8DS1axSF1ord2J4juDLPSQBiy6m
更換admin password 密碼語法


 update users set password= '$2y$10$qwtXWqRQz0xY4SGTEUqDkextPS8DS1axSF1ord2J4juDLPSQBiy6m' where username = 'admin';