2020年10月30日金曜日

ssh X11forwarding

1)  リモート側(Xクライアント)

# vi /etc/ssh/sshd_config

X11DisplayOffset 10

X11Forwarding yes

X11UseLocalhost no

XauthLocation /usr/bin/xauth

# systemctl restart sshd


2) 起動

sshpass -p パスワード ssh  -X -C -p 22  xxx.xxx.xxx.xxx





2020年9月29日火曜日

CentOS8にZabbix5.0インストール

CentOS8 にzabbix 5.0 をインストール
# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
# dnf clean all
# dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf 
# dnf install zabbix-web-japanese
# dnf install zabbix-agent2 
# dnf install zabbix-get

インストール済み:
OpenIPMI-libs-2.0.27-1.el8.x86_64 apr-1.6.3-9.el8.x86_64
apr-util-1.6.1-6.el8.x86_64 apr-util-bdb-1.6.1-6.el8.x86_64
apr-util-openssl-1.6.1-6.el8.x86_64 centos-logos-httpd-80.5-2.el8.noarch
fping-4.2-2.el8.x86_64 httpd-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64
httpd-filesystem-2.4.37-21.module_el8.2.0+494+1df74eae.noarch httpd-tools-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64
mod_http2-1.11.3-3.module_el8.2.0+486+c01050f0.1.x86_64 nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch
php-bcmath-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-ldap-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-mbstring-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-xml-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
unixODBC-2.3.7-1.el8.x86_64 zabbix-agent-5.0.4-1.el8.x86_64
zabbix-apache-conf-5.0.4-1.el8.noarch zabbix-server-mysql-5.0.4-1.el8.x86_64
zabbix-web-5.0.4-1.el8.noarch zabbix-web-deps-5.0.4-1.el8.x86_64
zabbix-web-mysql-5.0.4-1.el8.noarch

完了しました!

# mysql -uroot -p
Enter password:                   
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.17-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> create user zabbix@localhost identified by 'password';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> quit;
Bye
# systemctl restart zabbix-server zabbix-agent httpd php-fpm
# systemctl enable zabbix-server zabbix-agent httpd php-fpm
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

Enter password:                  
# vi /etc/zabbix/zabbix_server.conf
DBPassword=password

# vi /etc/php-fpm.d/zabbix.conf
; php_value[date.timezone] = Europe/Rigal
php_value[date.timezone] = Asia/Tokyo

#  vi /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=1
EnableRemoteCommands=1
Server=192.168.100.254
ServerActive=192.168.100.254:10051
Hostname=Zabbix server
HostMetadataItem=system.uname
Include=/etc/zabbix/zabbix_agentd.d/*.conf

# journalctl -xe
# ausearch -c 'sh' --raw | audit2allow -M my-sh
# semodule -X 300 -i my-sh.pp
.
.
.      
#  usermod -aG wheel zabbix
# vi /etc/sudoers.d/zabbix
zabbix ALL=(root)NOPASSWD:/usr/bin/nmap
Defaults                     requiretty
Defaults:root         !requiretty
Defaults                     requiretty
Defaults:%wheel  !requiretty
                              

# systemctl restart zabbix-server zabbix-agent httpd php-fpm
Job for zabbix-server.service failed because the control process exited with error code.
See "systemctl status zabbix-server.service" and "journalctl -xe" for details.
# journalctl -xe
-- Unit zabbix-server.service has begun starting up.

9月 29 16:22:11 libre.com zabbix_server[33342]: zabbix_server [33342]: Cannot initialize IPC services: Cannot access path "/var/run/zabbix": [13] Permission denied.

# ausearch -c 'zabbix_server' --raw | audit2allow -M my-zabbixserver
# semodule -X 300 -i my-zabbixserver.pp

# ausearch -c 'php-fpm' --raw | audit2allow -M my-phpfpm
# semodule -X 300 -i my-phpfpm.pp

# systemctl restart zabbix-server zabbix-agent httpd php-fpm
# systemctl enable zabbix-server zabbix-agent httpd php-fpm

Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /usr/lib/systemd/system/zabbix-server.service.
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent.service → /usr/lib/systemd/system/zabbix-agent.service.
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.

# dnf install zabbix-web-japanese

# firewall-cmd --add-service=http --zone=public --permanent
# firewall-cmd --add-port=10050/tcp --zone=public --permanent
# firewall-cmd --add-port=10051/tcp --zone=public --permanent
# firewall-cmd --reload

# dnf install zabbix-get
Zabbix エージェントの動作確認
# zabbix_get -s 127.0.0.1 -k agent.version
5.0.4


【フロントエンドの設定】
http://localhost/zabbix
user: Admin
password: zabbix




【背景イメージの登録】
   管理→一般設定→表示設定→イメージ→タイプ→背景
【スクリプトの登録】 (コマンドの登録)
  管理→スクリプト→スクリプトの作成
【ダッシュボードへのお気に入り登録】
  「マップ」「スクリプト」の一覧から該当項目を選択して★マークでお気に入入りに登録。
    ※zabbix3.2では、ダッシュボードの「お気に入り」ウジェットから表示項目を選択登録。
      ちょっと悩んだ!!


■zabbix エージェントのインストール(Ver. 5.4)
# dnf install https://repo.zabbix.com/zabbix/5.4/rhel/8/x86_64/zabbix-apache-conf-5.4.7-1.el8.noarch.rpm
# dnf install https://repo.zabbix.com/zabbix/5.4/rhel/8/x86_64/zabbix-agent2-5.4.7-1.el8.x86_64.rpm

# vi /etc/zabbix/zabbix_agent2.conf
PidFile=/var/run/zabbix/zabbix_agent2.pid
 LogFile=/var/log/zabbix/zabbix_agent2.log
 LogFileSize=1
 Server=192.168.100.254
 ServerActive=192.168.100.254:10051
 Hostname=Zabbix Server
 HostMetadata=CentOS
 HostMetadataItem=system.uname
 Include=/etc/zabbix/zabbix_agent2.d/*.conf
AllowKey=system.run[*]

※ AllowKeyを設定した場合は、下記も設定
# visudo
# Allos zabbix to run all commands without password.
zabbix ALL=NOPASSWD: ALL

# firewall-cmd --add-port=10050/tcp --zone=public --permanent
# firewall-cmd --reload
# systemctl start zabbix-agent2
# systemctl enable zabbix-agent2

<確認>
# zabbix_get -s 192.168.100.101  -k agent.version

※ agent2 は、「go」で書き直したもの。
※ SElinux忘れないように!!

スクリプト:なぜかホストに反映されない!!!

■zabbixエージェントでmysql監視
・ローカルユーザ
CREATE USER 'zbx_monitor'@'localhost' IDENTIFIED BY '<password>'; 
GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'localhost';

CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
 GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';

# mkdir /var/lib/zabbix
# chown zabbix:zabbix /var/lib/zabbix
# cd /var/lib/zabbix
# vi  /var/lib/zabbix/.my.cnf          # agent2 不要?                                             
[client]
user='zbx_monitor'
password='<password>'

※zabbix-agent2の場合
下記マクロ追加
設定→ホスト→dbsv→マクロ
{$MYSQL.DSN} localhost
{$MYSQL.PASSWORD}  PASSWORD
{$MYSQL.USER} zbx_monitor

警告がでるので、
設定→ホスト→dbsv→マクロ→継承したマクロとホストマクロ
{$MYSQL.BUFF_UTIL.MIN.WARN}       50→40

# systemctl restart zabbix-agent2


■オラクル監視(zabbix-agent2 oracle監視)

・オラクルクライアントのインストール
https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html

# dnf  localinstall  oracle-instantclient19.13-basic-19.13.0.0.0-2.x86_64.rpm

# cat /etc/ld.so.conf.d/oracle-instantclient.conf
/usr/lib/oracle/19.13/client64/lib                               # 確認

https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/src/go/plugins/oracle/README.md

# sqlp / as sysdba

create pluggable database zabbix admin user zbx_admin identified by  <password>;
alter pluggable database zabbix open;
alter pluggable database all save state;
alter session set container=zabbix;

CREATE USER zbx_monitor IDENTIFIED BY <PASSWORD>;
-- Grant access to the zbx_monitor user.
GRANT CONNECT, CREATE SESSION TO zbx_monitor;
GRANT SELECT ON DBA_TABLESPACE_USAGE_METRICS TO zbx_monitor;
GRANT SELECT ON DBA_TABLESPACES TO zbx_monitor;
GRANT SELECT ON DBA_USERS TO zbx_monitor;
GRANT SELECT ON SYS.DBA_DATA_FILES TO zbx_monitor;
GRANT SELECT ON V_$ACTIVE_SESSION_HISTORY TO zbx_monitor;
GRANT SELECT ON V_$ARCHIVE_DEST TO zbx_monitor;
GRANT SELECT ON V_$ASM_DISKGROUP TO zbx_monitor;
GRANT SELECT ON V_$DATABASE TO zbx_monitor;
GRANT SELECT ON V_$DATAFILE TO zbx_monitor;
GRANT SELECT ON V_$INSTANCE TO zbx_monitor;
GRANT SELECT ON V_$LOG TO zbx_monitor;
GRANT SELECT ON V_$OSSTAT TO zbx_monitor;
GRANT SELECT ON V_$PGASTAT TO zbx_monitor;
GRANT SELECT ON V_$PROCESS TO zbx_monitor;
GRANT SELECT ON V_$RECOVERY_FILE_DEST TO zbx_monitor;
GRANT SELECT ON V_$RESTORE_POINT TO zbx_monitor;
GRANT SELECT ON V_$SESSION TO zbx_monitor;
GRANT SELECT ON V_$SGASTAT TO zbx_monitor;
GRANT SELECT ON V_$SYSMETRIC TO zbx_monitor;
GRANT SELECT ON V_$SYSTEM_PARAMETER TO zbx_monitor;


$ zabbix_get -s 192.168.254.203 -k agent.version

$ zabbix_get -s host  -k oracle.ping["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]

zabbix_get -s 192.168.254.203 -k oracle.ping["tcp://192.168.254.203:1521","zbx_monitor","password","zabbix.world"]

※ Oracle Database 'ORCL': Force logging is deactivated for DB with active Archivelog
→
sql> SELECT log_mode, force_logging FROM v$database;
sql> alter DATABASE FORCE LOGGING;

$ zabbix_get -s 192.168.254.203 -k agent.version

$ zabbix_get -s 192.168.254.203 -k 'oracle.instance.info["tcp://192.168.254.203:1521","zbx_monitor","password","zabbix.world"]'
 Connection failed: ORA-00000: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: Too many open files". See https://oracle.github.io/odpi/doc/installation.html#linux for help.

# zabbix_agent2 -c /etc/zabbix/zabbix_agent2.conf -t 'oracle.instance.info["tcp://192.168.254.203:1521","zbx_monitor","password","zabbix.world"]'


2020年9月18日金曜日

CentOS8 VLCインストール

# dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

# dnf -y install https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm

# dnf -y install vlc --enablerepo=epel

2020年8月20日木曜日

CentOS8 4K ディスプレイ マウスカーソルを大きくする。

【マウスポインタ拡大】
# dnf install dconf-editor
$ dconf-editor
/org/gnome/desktop/interface/cursor-size
Use default value  -> off
Custom value -> 48

2020年8月2日日曜日

LVM ファイルシステムのマウント

# mount /dev/nvme0n1p3 /mnt/m2
mount: /mnt/m2: 未知のファイルシステムタイプ 'LVM2_member' です.

#  fdisk -l /dev/nvme0n1
ディスク /dev/nvme0n1: 953.9 GiB, 1024209543168 バイト, 2000409264 セクタ
単位: セクタ (1 * 512 = 512 バイト)
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
ディスクラベルのタイプ: gpt
ディスク識別子: CF0AC781-3B8D-47EF-9919-C722FCFC6598

デバイス       開始位置   終了位置     セクタ サイズ タイプ
/dev/nvme0n1p1     2048    1230847    1228800   600M EFI システム
/dev/nvme0n1p2  1230848    3327999    2097152     1G Linux ファイルシステム
/dev/nvme0n1p3  3328000 2000408575 1997080576 952.3G Linux LVM

# pvs
  PV             VG   Fmt  Attr PSize   PFree
  /dev/nvme0n1p3 cl   lvm2 a--  952.28g    0
  /dev/sda3      cl00 lvm2 a--  464.17g    0

#  vgdisplay cl
  --- Volume group ---
  VG Name               cl
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               952.28 GiB
  PE Size               4.00 MiB
  Total PE              243784
  Alloc PE / Size       243784 / 952.28 GiB
  Free  PE / Size       0 / 0  
  VG UUID               r9wuW5-nnFa-Wvvd-rFFJ-W443-pKW7-oSnE5b

VG nameを変更する場合(同じ場合UUIDで変更)
# vgrename  r9wuW5-nnFa-Wvvd-rFFJ-W443-pKW7-oSnE5b cl-rename

# vgscan --mknodes
  Found volume group "cl00" using metadata type lvm2
  Found volume group "cl" using metadata type lvm2


# lvscan
  ACTIVE            '/dev/cl00/swap' [15.74 GiB] inherit
  ACTIVE            '/dev/cl00/home' [<398.43 GiB] inherit
  ACTIVE            '/dev/cl00/root' [50.00 GiB] inherit
  ACTIVE            '/dev/cl/root' [146.69 GiB] inherit
  ACTIVE            '/dev/cl/home' [745.05 GiB] inherit
  ACTIVE            '/dev/cl/swap' [<60.54 GiB] inherit

# mount /dev/cl/home /mnt/m2

inactiveの場合activeに変更
# vgchange -ay
  3 logical volume(s) in volume group "cl01" now active
  3 logical volume(s) in volume group "cl00" now active
  3 logical volume(s) in volume group "cl" now active

2020年8月1日土曜日

CentOS8インストール

■CentOS8.2インストール
1)OSインストール
               https://www.centos.org/download/






2)tweaks起動( メニューバー設定)
       拡張機能の必要なものをON

3)入力ソースに「日本語(かな漢字)をインストール
# dnf -y install libkkc libkkc-data ibus-kkc
再起動
 











4) epelリポジトリの登録
# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# dnf repolist all   ←確認

5)clamのインストール(設定は別途)
# dnf --enablerepo=epel install clamav clamav-scanner-systemd clamav-update

6) zabbix リポジトリの登録
# dnf install https://repo.zabbix.com/zabbix/5.4/rhel/8/x86_64/zabbix-release-5.4-1.el8.noarch.rpm
※ 最新版のURLを確認

7) zabbix クライアントのインストール(設定は別途)
# dnf install https://repo.zabbix.com/zabbix/5.4/rhel/8/x86_64/zabbix-agent2-5.4.7-1.el8.x86_64.rpm

8)mariadbのインストール
   a.)  リポジトリ登録
           下記でrepoファイル作成。
           http://downloads.mariadb.org/mariadb/repositories/
          # vi  /etc/yum.repos.d/mariadb.repo
    b.) インストール
          #  dnf install MariaDB

※ 各項目の設定は別途


【CentOS8 インストールUSB からresucueモード起動】

CentOS8 ブートでロックして 起動しなくなったのでレスキューモードで復旧

# hostnamectl set-hostname buffy.com
# nmcli device
# nmcli connection up enp39s0
# ip a
# nmcli device
# ip a

# chroot /mnt/sysimage
# dnf install grub2-efi-x64-modules.noarch
# lsblk
# grub2-install /dev/nvme0n1
# grub2-mkconfig -o /boot/grub2/grub.cfg  # not UEFI
# grub2-mkconfig -o / boot / efi / EFI / centos /grub.cfg      #for UEFI
# touch /.autorelabel

# systemctl status initrd-switch-root.service
Failed to switch root: Specified switch root path 'sysroot' does not seem to be an OS Tree. os-release file is missing.
initrd-switch-root.service:Main process exited, code=exited, status=1/FAILURE
initrd-switch-root.service:Failed with result 'exit-code'.

# cp /boot/initramfs-*.x86_64.img /root    #backup
# dracut --force --regenerate-all

2020年7月22日水曜日

guacamole rdp 接続できない。

# journalctl -u guacd -f

guacd[6309]: WARNING: Support for protocol "rdp" is not installed

【NG】
# rpm -qa guacd  *rdp*
freerdp-libs-2.0.0-4.rc4.el7_8.x86_64
freerdp-devel-2.0.0-4.rc4.el7_8.x86_64

 【OK】
 # rpm -qa guacd *rdp*
freerdp-libs-1.0.2-15.el7.x86_64
freerdp-devel-1.0.2-15.el7.x86_64




【対応】
# yum remove  freerdp-libs

# vi /etc/yum.repos.d/CentOS-Vault.repo
# C7.6.1810
[C7.6.1810-base]
name=CentOS-7.6.1810 - Base
baseurl=http://vault.centos.org/7.6.1810/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=1 ←一時的に1にする。

# yum install freerdp-devel-1.0.2-15.el7

# vi /etc/yum.repos.d/CentOS-Vault.repo
 enabled=0 ←0に戻す。

Rocky Linux9.8 Docker インストール

# cat /etc/redhat-release Rocky Linux release 9.8 (Blue Onyx) # dnf remove docker docker-client  docker-client-latest  docker-common  docker...