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

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


2018年7月15日 星期日

Ubunt 18.04 ip config

18.04 的IP 設定有變動
不在
/etc/network/interfaces

而是在
/etc/netplan/50-cloud-init.yaml


可以由此查找位置
vim /etc/netplan/

vim /etc/netplan/50-cloud-init.yaml

DHCP設定如下:


# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        ens3:
            addresses: []
            dhcp4: true
            optional: true
    version: 2


固定IP 設定則為:


# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        ens3:
            addresses: [192.168.1.220/24, ]
            gateway4: 192.168.1.254
            nameservers:
                 addresses: [192.168.1.254,8.8.4.4]
            dhcp4: false
            optional: true
    version: 2


設定完成後套用可藉由Debug確認設定有無錯誤

sudo netplan --debug apply

#apply 為套用
則如果無誤套用此設定。

2017年12月29日 星期五

ubuntu 14 install KVM

ubuntu install

安裝監控工具
apt-get install ssh
apt-get install vim

安裝RRD-tools
sudo apt-get install rrdtool
sudo apt-get install librrds-perl


安裝Webmin

sudo vim /etc/apt/sources.list

deb http://download.webmin.com/download/repository sarge contrib
wget http://www.webmin.com/jcameron-key.asc
sudo apt-key add jcameron-key.asc
sudo apt-get update
sudo apt-get install webmin

###
Webmin install complete. You can now login to
https://your_server_ip:10000 as root with your
root password, or as any user who can use `sudo`.
###
安裝硬碟監控套件
下載套件
https://sourceforge.net/projects/webminstats/files/Sysstats/

進入webmin>Webmin Configuration>modules >From uploaded files/Sysstats/

左邊欄位的System內會出現Historic System Statistics
###
安裝KVM

#確認CPU支援虛擬化
sudo apt-get install cpu-checker

$ kvm-ok
#INFO: /dev/kvm exists
#KVM acceleration can be used

#===
sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils virt-manager

#查看group是否建立
egrep libvirtd /etc/group

#登出登入或reboot
sync;sync;shutdwon -r

#===
安裝完成
image位置