2024年12月5日木曜日

zbar インルトール  zbar rpm作成

【amazon linux2023 へインストール】
sudo dnf groupinstall "Development Tools" -y
sudo dnf install libjpeg-devel libpng-devel -y
sudo dnf install ImageMagick ImageMagick-devel -y
sudo dnf install gtk3pwd-devel -y
cd /tmp
git clone https://github.com/mchehab/zbar.git
cd zbar
sudo dnf install automake autoconf libtool -y
autoreconf -i
./configure -prefix=/usr
make
make install


sudo dnf install rpm-build rpmdevtools -y
rpmdev-setuptree
cd ~/rpmbuild/SOURCES
wget https://github.com/mchehab/zbar/archive/refs/tags/0.23.tar.gz -O zbar-0.23.tar.gz
※上記wgetで取得してものは、buildできなかった為、gitを取得。
    git clone https://github.com/mchehab/zbar.git
    mv zbar zbar-0.23
   tar cvzf zbar-0.23.tar.gz zbar-0.23

cd ~/rpmbuild/SPECS
nano zbar.spec <<__EOF__
Name:           zbar
Version:        0.23
Release:        1%{?dist}
Summary:        Barcode reader

License:        GPLv2+
Source0:        zbar-0.23.tar.gz

BuildRequires:  gcc, make, pkgconfig, libjpeg-devel, libpng-devel
Requires:       libjpeg, libpng

%description
ZBar is a suite of programs for reading bar codes from various sources.

%prep
%setup -q

%define debug_package %{nil}

%build
# CMakeを使用する場合
#mkdir build
#cd build
#cmake ..
#make

# または、autotoolsを使用する場合
autoreconf -i
./configure --prefix=/usr --libdir=/usr/lib64
make

%install
mkdir -p %{buildroot}/usr/bin
mkdir -p %{buildroot}/usr/lib64
rm -f debugsourcefiles.list
make install DESTDIR=%{buildroot} LIBDIR=/usr/lib64

%files
/usr/bin/zbarimg
/usr/bin/zbarcam
/usr/lib64/libzbar.so*
/etc/dbus-1/system.d/org.linuxtv.Zbar.conf 
/usr/bin/zbarcam-gtk
/usr/include/zbar.h
/usr/include/zbar/Decoder.h
/usr/include/zbar/Exception.h
/usr/include/zbar/Image.h
/usr/include/zbar/ImageScanner.h
/usr/include/zbar/Processor.h
/usr/include/zbar/Scanner.h
/usr/include/zbar/Symbol.h
/usr/include/zbar/Video.h
/usr/include/zbar/Window.h
/usr/include/zbar/zbargtk.h
/usr/lib64/libzbar.a
/usr/lib64/libzbar.la
/usr/lib64/libzbargtk.a
/usr/lib64/libzbargtk.la
/usr/lib64/libzbargtk.so
/usr/lib64/libzbargtk.so.0
/usr/lib64/libzbargtk.so.0.0.2
/usr/lib64/pkgconfig/zbar-gtk.pc
/usr/lib64/pkgconfig/zbar.pc
/usr/lib64/python3.9/site-packages/zbar.la
/usr/lib64/python3.9/site-packages/zbar.so
/usr/share/doc/zbar/ABOUT-NLS
/usr/share/doc/zbar/COPYING
/usr/share/doc/zbar/HACKING.md
/usr/share/doc/zbar/INSTALL.md
/usr/share/doc/zbar/LICENSE.md
/usr/share/doc/zbar/NEWS.md
/usr/share/doc/zbar/README.md
/usr/share/doc/zbar/TODO.md
/usr/share/locale/pt_BR/LC_MESSAGES/zbar.mo
/usr/share/zbar/lib/libzbarjni.a
/usr/share/zbar/lib/libzbarjni.la
/usr/share/zbar/lib/libzbarjni.so
/usr/share/zbar/lib/libzbarjni.so.0
/usr/share/zbar/lib/libzbarjni.so.0.0.0
/usr/share/zbar/lib/zbar.jar


%changelog
* Wed Dec 04 2024 Your Name <takahab@example.com> - 0.23-1
- Initial RPM release
__EOF__
rpmbuild -ba zbar.spec


2024年12月4日水曜日

オートスケール下のEC2の更新

1) 新AMI作成
  AMI公開の項参照。

2) AMI コピー
 タグをコピー
 AMI コピーのEBSスナップショップを暗号化→arn:aws:kms:ap-northeast-1:725797520659:alias/aws/ebs

3)Auto Scaling グループ →グループ選択→起動テンプレート→テンプレート変更(新しいバージョンを作成)
  説明      XXX-AL2023-officecvN-2024-12-09-ver.0.0.5
         EC2 Auto Scalingのガイダンス:チェック
        ソーステンプレート→確認のみ
        AMI:新AMIを選択
  インスタンスタイプ→T3.small   
       キーペア→確認
   サブネット:起動テンプレートの設定に含めない。
   セキュリティグループ→確認のみ
      ストレージ確認
  高度な詳細→IAM員タンスプロフィール→該当サーバのプロフィール設定
     高度な詳細→メタデータのバージョン→V2のみ

5)Auto scaling →起動テンプレート→編集
  バージョン設定→更新
        
6)Auto Scaling グループ→インスタンスの更新
  インスタンスの更新を開始
  可用性を優先 /  ●コストを優先 /  カスタム
       チェックポイントを有効にする。20%
       起動テンプレートを更新する。→ 確認
  自動ロールバックを有効にする。

2024年12月2日月曜日

AMI 公開

1) Key Managment Service
  対象・暗号化および復号化・KMS・単一リージョンキー
  alias: xxxx-AL2023-xxxxsv-copy-2024-12-02
  管理者選択
  キーユーザ
  追加アカウント ←ここに追加

2) AMI→ストレージ→snap→アクション→スナップショットコピー
  KMSキー設定( xxxx-ami-key-officesvN1-for-copy )
         Name  REL_CXD_AL2023-officesvN-2024-12-26

3)   snap→共有権限→アカウントIDを追加→追加→アクセス許可を変更

4) 新Snap→スナップショットからイメージ作成
  イメージ名:CXD-AL2023-officesvN-2024-12-26
  説明:   CXD-AL2023-officesvN-2024-12-26
        ルートデバイス:/dev/xvda
         ブロックデバイスマッピンング→ボリューム→サイズ→50GB/gp3/3000/125
         タグオプション→Name→REL_CXD-AL2023-officesvN-2024-12-26

5) AMI→AMI許可を編集→アカウント追加→AMIを共有→変更を保存
        アカウント許可を作成するときに、関連付けられたスナップショットに [ボリュームを作成] の許可を追加します。







2024年11月22日金曜日

2024年10月18日金曜日

zabbix7 amazon linux2023 インストール postgres15

【postgres】
dnf -y install postgresql15-server postgresql15-server-devel
postgresql-setup initdb
passwd postgres
vi `find / -name pg_hba.conf` << __EOF__
#local all all peer
local all all trust
#host all all 127.0.0.1/32 ident
host all all 10.0.0.0/16   password
host all all 127.0.0.1/32 password
__EOF__
find / -name postgresql.conf
vi /var/lib/pgsql/data/postgresql.conf <<__EOF__
listen_addresses = '*'
port = 5432

log_timezone = 'Asia/Tokyo'
timezone = 'Asia/Tokyo'
lc_messages = 'ja_JP.utf8' # locale for system error message
lc_monetary = 'ja_JP.utf8' # locale for monetary formatting
lc_numeric = 'ja_JP.utf8' # locale for number formatting
lc_time = 'ja_JP.utf8'
__EOF__
systemctl start postgresql
systemctl start postgresql
systemctl enable postgresql

【zabbix】
rpm -Uvh https://repo.zabbix.com/zabbix/7.0/amazonlinux/2023/x86_64/zabbix-release-latest.amzn2023.noarch.rpm
dnf clean all
dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-apache-conf zabbix-sql-scripts zabbix-agent2
sudo -u postgres createuser --pwprompt zabbix
sudo -u postgres createdb -O zabbix zabbix
zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix
vi /etc/zabbix/zabbix_server.conf
DBPassword=xxxxx
vi /etc/php-fpm.d/zabbix.conf <<__EOF__
php_value[date.timezone] = Asia/Tokyo
__EOF__

systemctl restart zabbix-server zabbix-agent2 httpd php-fpm
systemctl enable zabbix-server zabbix-agent2 httpd php-fpm

Admin/zabbix


【agent2】
rpm -Uvh https://repo.zabbix.com/zabbix/7.0/amazonlinux/2023/x86_64/zabbix-release-latest.amzn2023.noarch.rpm
dnf install zabbix-agent2
vi /etc/zabbix/zabbix_agent2.d/plugins.d/z99-local.conf <<__EOF__
LogFileSize=1
Server=10.0.19.119
ServerActive=10.0.19.119:10051
Hostname=Zabbix server
#HostMetadata=Rockylinux
HostMetadataItem=system.uname
#ControlSocket=/run/zabbix/agent.sock
AllowKey=system.run[*]
__EOF__
systemctl start zabbix-agent2
systemctl enable zabbix-agent2
dnf install zabbix-get
zabbix_get -s 10.0.19.119 -k agent.version

◆管理→一般→表示設定→デフォルトの言語→日本語(ja_JP)

◆設定 →ホスト
ホスト名
表示名
グループ→(事前にホストグループを設定)
インターフェース→追加→エージェント→IPアドレス(IP,DNS,10050) →追加
テンプレートタブ→追加→「新規テンプレートをリンク」を選択→Linux by zabbix agent→追加

◆監視データ→ダッシュボード→マップ→マップ変更























2024年10月3日木曜日

aurora-postgres リリースバージョン

 aws rds describe-db-engine-versions --engine aurora-postgresql --query '*[].[EngineVersion]' --output text --region ap-northeast-1



['VER_10_11', 'VER_10_12', 'VER_10_13', 'VER_10_14', 'VER_10_16', 'VER_10_17', 'VER_10_18', 'VER_10_19', 'VER_10_20', 'VER_10_21', 'VER_10_4', 'VER_10_5', 'VER_10_6', 'VER_10_7', 'VER_11_11', 'VER_11_12', 'VER_11_13', 'VER_11_14', 'VER_11_15', 'VER_11_16', 'VER_11_17', 'VER_11_18', 'VER_11_19', 'VER_11_20', 'VER_11_21', 'VER_11_4', 'VER_11_6', 'VER_11_7', 'VER_11_8', 'VER_11_9', 'VER_12_10', 'VER_12_11', 'VER_12_12', 'VER_12_13', 'VER_12_14', 'VER_12_15', 'VER_12_16', 'VER_12_17', 'VER_12_18', 'VER_12_19', 'VER_12_4', 'VER_12_6', 'VER_12_7', 'VER_12_8', 'VER_12_9', 'VER_13_10', 'VER_13_11', 'VER_13_12', 'VER_13_13', 'VER_13_14', 'VER_13_15', 'VER_13_3', 'VER_13_4', 'VER_13_5', 'VER_13_6', 'VER_13_7', 'VER_13_8', 'VER_13_9', 'VER_14_10', 'VER_14_11', 'VER_14_12', 'VER_14_3', 'VER_14_4', 'VER_14_5', 'VER_14_6', 'VER_14_7', 'VER_14_8', 'VER_14_9', 'VER_15_2', 'VER_15_3', 'VER_15_4', 'VER_15_5', 'VER_15_6', 'VER_15_7', 'VER_16_0', 'VER_16_1', 'VER_16_2', 'VER_16_3', 'VER_9_6_11', 'VER_9_6_12', 'VER_9_6_16', 'VER_9_6_17', 'VER_9_6_18', 'VER_9_6_19', 'VER_9_6_22', 'VER_9_6_8', 'VER_9_6_9', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__jsii_declared_type__', '__jsii_type__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'aurora_postgres_full_version', 'aurora_postgres_major_version', 'of']

2024年9月19日木曜日

オラクルインデックス作成

ALTER TABLE ARCSDBCS.CSM002 ADD CONSTRAINT CSM002_PK PRIMARY KEY (UCODE) ENABLE;

CREATE INDEX CSM002_INDEX01 ON ARCSDBCS.CSM002 (gcode, ccode, scode) TABLESPACE USERS;

DROP INDEX CSM002_INDEX01;

2024年9月4日水曜日

EC2 AWS上での動作判定   メタ情報の取得

import requests
METADATA_URL = "http://169.254.169.254/latest/"
def is_aws_instance():
  try:
    token = requests.put(
      METADATA_URL + "api/token",  
      headers={"X-aws-ec2-metadata-token-ttl-seconds": "3600"}
    ).text
    metadata = requests.get(
      METADATA_URL + "meta-data/",
      headers={"X-aws-ec2-metadata-token": token}
    )
    return str(metadata.status_code) == '200'
  except requests.RequestException:
    return False

if is_aws_instance():
  print("This instance is running on AWS.meta=")
else:
  print("This instance is not running on AWS.meta=")

2024年8月29日木曜日

2024年8月20日火曜日

gradle インストール tomcat build環境

・javaインストール
# cd /opt
# wget https://services.gradle.org/distributions/gradle-8.10-bin.zip
# unzip gradle-8.10-bin.zip
# ln -s   gradle-8.10 gradle
# vi /etc/profile.d/gradle.sh <<__EOF__
export GRADLE_HOME=/opt/gradle
export PATH=$GRADLE_HOME/bin:$PATH
__EOF__
$ source /etc/profile

$ cd Make
$ mkdir gradle_app
$ cd gradle_app
$ mkdir -p src/main/java/com/example
$ mkdir -p src/main/webapp/WEB-INF

$ vi build.gradle <<__EOF__
plugins {
  id 'war'
}

repositories {
  mavenCentral()
}

dependencies {
  // Jakarta Servlet 5.0 API
  // https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api
  providedCompile 'jakarta.servlet:jakarta.servlet-api:5.0.0'
}

// Java 22
sourceCompatibility = 22
targetCompatibility = 22

// Application
version = '1.0'
__EOF__
$ vi src/main/webapp/WEB-INF/web.xml <<__EOF__
<?xml version="1.0" encoding="UTF-8"?>

<!-- Web Application Deployment Descriptor (Jakarta Servlet 5.0) -->
<web-app
  xmlns="https://jakarta.ee/xml/ns/jakartaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
  https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
  version="5.0">

  <servlet>
    <servlet-name>myjsp</servlet-name>
    <jsp-file>/myjsp.jsp</jsp-file>
  </servlet>

  <servlet-mapping>
    <servlet-name>myjsp</servlet-name>
    <url-pattern>/myjsp</url-pattern>
  </servlet-mapping>

</web-app>
__EOF__
$ vi src/main/java/com/example/MyServlet.java
$ vi src/main/webapp/myjsp.jsp
$ ./gradlew clean build --refresh-dependencies
$ gradle build

$ tree
.
├── build
│   ├── classes
│   │   └── java
│   │       └── main
│   │           └── com
│   │               └── example
│   │                   └── MyServlet.class
│   ├── generated
│   │   └── sources
│   │       ├── annotationProcessor
│   │       │   └── java
│   │       │       └── main
│   │       └── headers
│   │           └── java
│   │               └── main
│   ├── libs
│   │   └── gradle_app-1.0.war
│   └── tmp
│       ├── compileJava
│       │   └── previous-compilation-data.bin
│       └── war
│           └── MANIFEST.MF
├── build.gradle
└── src
    └── main
        ├── java
        │   └── com
        │       └── example
        │           └── MyServlet.java
        └── webapp
            ├── WEB-INF
            │   └── web.xml
            └── myjsp.jsp

# cp -p  build/libs/gradle_app-1.0.war  /opt/tomcat/webapps/

URL:  localhost/gradle_app/myjsp

【refresh】
 ./gradlew clean build --refresh-dependencies


【SELINUX】
sestatus
sudo dnf install policycoreutils-python-utils
sudo grep tomcat /var/log/audit/audit.log
sudo chcon -R -t tomcat_exec_t /opt/tomcat
sudo chcon -R -t tomcat_var_lib_t /opt/tomcat/logs
sudo audit2allow -a -M tomcat-custom
sudo semodule -i tomcat-custom.pp
sudo restorecon -R -v /opt/tomcat




2024年8月8日木曜日

パラメータストア

# vi /etc/sysconfig/cxdnext/ssm-param-pre-exec.sh << __EOF__
#!/bin/bash
#----------------------------------------------
# パラメータストアからの環境取得
#----------------------------------------------
main(){
case "$1" in
"export" )
EVAL_COMMAND="echo export \${NAME##*/}=\$VALUE"
parameter_store
;;
*)
EVAL_COMMAND="systemctl set-environment \${NAME##*/}=\$VALUE"
parameter_store
;;
esac
}
parameter_store(){
# Load environmental variables
SSM_PARAMETER_STORE=$(aws ssm get-parameters-by-path --region ap-northeast-1 --path "/CXDNEXT/" --with-decryption)

echo ${SSM_PARAMETER_STORE} | jq -c '.Parameters[]' | while read i; do
NAME=$(echo $i | jq -r '.Name')
VALUE=$(echo $i | jq -r '.Value' | sed 's/\$/\\$/g')
eval $EVAL_COMMAND
done
}
main $@
__EOF__

※ 独自の環境変数を発生させる

#systemctl set-environment {NAME}={VALUE}
systemctl set-environment PARAMETER_STORE=ENABLE_DAYO

# cp -p /usr/lib/systemd/system/httpd.service  /etc/systemd/system/httpd.service

# vi /etc/systemd/system/httpd.service
ExecStartPre=/usr/bin/bash /etc/sysconfig/cxdnext/ssm-param-pre-exec.sh

systemctl stop httpd
systemctl disable httpd
systemctl enable httpd
systemctl start httpd

# systemctl status httpd
● httpd.service - The Apache HTTP Server
     Loaded: loaded (/etc/systemd/system/httpd.service; enabled; preset: disabled)


# vi /opt/tomcat/bin/setenv.sh  <<__EOF__
source <( sh /etc/sysconfig/cxdnext/ssm-param-pre-exec.sh export )
__EOF__













2024年7月24日水曜日

データベーステーブル比較

 SELECT CASE

WHEN f.bankcode IS NULL THEN v.bankcode

ELSE f.bankcode

END AS bankcode,

f.banknamef AS banknamef,

f.banknamek AS banknamek,

v.banknamef AS banknamef,

v.banknamek AS banknamek

FROM (SELECT *

FROM foreign_ccm102

EXCEPT

SELECT *

FROM view_ccm102) v

FULL JOIN (SELECT *

FROM view_ccm102

EXCEPT

SELECT *

FROM foreign_ccm102) f

ON f.bankcode = v.bankcode

ORDER BY bankcode;

2024年7月12日金曜日

postgres dblink postgres_fdw

dnf install postgresql15-contrib

\c workbase postgres
CREATE EXTENSION postgres_fdw;

CREATE SERVER arcsdbms FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (host '10.0.18.101', dbname 'arcsdbms', port '5432');

grant all on foreign server arcsdbms to sales;

\c workbase sales
CREATE USER MAPPING FOR sales SERVER arcsdbms
OPTIONS (user 'arcsdbcb', password 'xxxxxx00');

-----------------------------------------------------------
CREATE FOREIGN TABLE foreign_ccm102 (
bankcode varchar(4) ,
banknamef varchar(80),
banknamek varchar(80)
) SERVER arcsdbms
OPTIONS (schema_name 'arcsdbcb', table_name 'ccm102');

CREATE FOREIGN TABLE foreign_ccm103 (
bankcode varchar(4) ,
branchcode varchar(3),
branchnamef varchar(80),
branchnamek varchar(80) 
) SERVER arcsdbms
OPTIONS (schema_name 'arcsdbcb', table_name 'ccm103');

-----------------------------------------------------------
or
-----------------------------------------------------------
 IMPORT FOREIGN SCHEMA arcsdbcb
   LIMIT TO (ccm102, ccm103)
   FROM SERVER arcsdbms INTO sales;
-----------------------------------------------------------


SELECT count(*) FROM foreign_ccm102;


【DROP】
\c workbase sales
drop foreign table foreign_ccm103;
drop foreign table foreign_ccm102;
drop user mapping for  sales server arcsdbms;
\c workbase postgres
revoke all on foreign server arcsdbms from sales;
drop server arcsdbms;
drop extension postgres_fdw;










【ERROR】
psql:/dev/fd/63:2: ERROR:  機能拡張"postgres_fdw" は利用できません
DETAIL:  機能拡張の制御ファイル"/usr/pgsql-15/share/extension/postgres_fdw.control"をオープンできませんでした: そのようなファイルやディレクトリはありません
HINT:  PostgreSQLが稼働しているシステムで、事前に機能拡張がインストールされている必要があります。
→  dnf install postgresql15-contrib






2024年6月28日金曜日

オラクル リードオンリーユーザ作成 (oracle readonly user)

alter pluggable database arcsdbms open;
alter session set container=arcsdbms;
create user readonly_user identified by xxxx00;
grant connect to readonly_user;
grant create session to readonly_user; 
grant select any table to readonly_user;



SELECT
*
FROM
ARCSDBSS.SSR002
WHERE
GCODE = '101'
AND CCODE = '4397'
AND SCODE = '0018'
AND RCODE = '7716610016038'
ORDER BY rDATE DESC

SELECT
MAX(s2.rdate),gcode,ccode,scode,rcode
FROM
ssr002 s2
WHERE
s2.GCODE = '101'
AND s2.CCODE = '4397'
AND s2.SCODE = '0018'
AND s2.RCODE = '7716610016038'
GROUP BY
s2.gcode, s2.ccode, s2.scode, s2.rcode

2024年6月26日水曜日

Rocky linux9.4 最小インストール

■OSインストール
① root パスワード
② ユーザ作成
③ ソフトウェア選択→最小限のインストール
④インストール先→ローカル標準ディスク(自動構成)
⑤ ネットワークとホスト名 (ホスト名、IPv4設定)

■OS設定
# vi /etc/yum.conf __EOF__
proxy=http://10.0.19.2:3128
__EOF__

# vi /etc/profile.d/proxy.sh
PROXY="http://10.0.12.2:3128"
export http_proxy=$PROXY
export HTTP_PROXY=$PROXY
export https_proxy=$PROXY
export HTTPS_PROXY=$PROXY
__EOF__
# source /etc/profile

# dnf update
#timedatectl set-timezone Asia/Tokyo
# localectl set-locale LANG=ja_JP.utf8

# nmcli general hostname zabbix70
# nmcli c add type ethernet ifname enp1s0 con-name "private_mng_1a
# nmcli c mod private_mng_1a ipv4.address 10.0.19.119/24
# nmcli c mod private_mng_1a ipv4.method manual
# nmcli c mod private_mng_1a connection.autoconnect yes
# nmcli c mod private_mng_1a ipv4.gateway 10.0.19.2
# nmcli c up  private_mng_1a

# dnf clean all
# dnf update
# dnf install net-tools

■zabbix
vi /etc/yum.repos.d/epel.repo __EOF__
[epel]
...
excludepkgs=zabbix*
__EOF__

dnf install zabbix-web-japanese                         # zabbix文字化け 対応
 
【IPA-FONTS】
wget https://moji.or.jp/wp-content/ipafont/IPAexfont/IPAexfont00401.zip
wget  https://moji.or.jp/wp-content/ipafont/IPAexfont/ipaexm00401.zip
wget  https://moji.or.jp/wp-content/ipafont/IPAexfont/ipaexg00401.zip
unzip  IPAexfont00401.zip  -d /usr/share/fonts
unzip ipaexm00401.zip       -d /usr/share/fonts
unzip ipaexg00401.zip        -d  /usr/share/fonts
 fc-cache -fv


【postgres15】
# dnf update --refresh
# dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# dnf  -y install postgresql15-server
# /usr/pgsql-15/bin/postgresql-15-setup initdb
# systemctl start postgresql-15
# systemctl enable postgresql-15
# systemctl status postgresql-15
# passwd postgres

# passwd postgres
# su - postgres
$ psql -V
psql (PostgreSQL) 15.5
$ psql
alter user postgres with password 'password';
exit
$  vi /var/lib/pgsql/15/data/pg_hba.conf 
#local   all             all              peer
#host    all             all             127.0.0.1/32            scram-sha-256
local     all             all              trust
host      all             all             10.0.0.0/16             password
$ vi /var/lib/pgsql/15/data/postgresql.conf 
listen_addresses = '*'          
port = 5432 
max_connections = 100 
log_timezone = 'Asia/Tokyo'
timezone = 'Asia/Tokyo'
lc_messages = 'ja_JP.utf8'                    # locale for system error message
lc_monetary = 'ja_JP.utf8'                    # locale for monetary formatting
lc_numeric = 'ja_JP.utf8'                       # locale for number formatting
lc_time = 'ja_JP.utf8'

# systemctl restart postgresql-15
# firewall-cmd --add-port=5432/tcp --zone=public --permanent
# firewall-cmd --add-service=postgresql --zone=public --permanent
# firewall-cmd --reload

【zabbix】
# rpm -Uvh https://repo.zabbix.com/zabbix/7.0/alma/9/x86_64/zabbix-release-7.0-2.el9.noarch.rpm
# dnf clean all
# dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent2
# sudo -u postgres createuser --pwprompt zabbix
# sudo -u postgres createdb -O zabbix zabbix
# zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix
# vi /etc/zabbix/zabbix_server.conf  <<__EOF__
DBPassword=password
__EOF__

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

# 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

【初期デフォルト】
URL localhost/zabbix
User Admin
PW   zabbix


【postgres監視】    DB監視   ポストグレス監視

# mkdir -m 700   /var/lib/zabbix
# chown zabbix:  /var/lib/zabbix

$ PGHOST=10.0.18.101
$ echo "CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT" | psql -h $PGHOST -U postgres
$ echo "GRANT pg_monitor TO zbx_monitor" | psql -h $PGHOST -U postgres

GRANT CONNECT ON DATABASE arcsdbms TO zbx_monitor;
GRANT CONNECT ON DATABASE workbase TO zbx_monitor;
GRANT CONNECT ON DATABASE ezservice TO zbx_monitor;

 # vi /var/lib/pgsql/15/data/pg_hba.conf 
host       all        zbx_monitor     localhost               trust
host       all        zbx_monitor     127.0.0.1/32            md5
host       all        zbx_monitor     ::1/128                 scram-sha-256

$ git clone https://git.zabbix.com/scm/zbx/zabbix.git --depth 1
# mkdir -p /var/lib/zabbix/postgresql
# cp -pr zabbix/templates/db/postgresql/postgresql /var/lib/zabbix/postgresql
# chown -R zabbix: /var/lib/zabbix/postgresql

# cp -p zabbix/templates/db/postgresql/template_db_postgresql.conf /etc/zabbix/zabbix_agent2.d/
# chown root: /etc/zabbix/zabbix_agent2.d/template_db_postgresql.conf
# chmod 644 /etc/zabbix/zabbix_agent2.d/template_db_postgresql.conf

# vi /var/lib/zabbix/.pgpass <<__EOF__
*:5432:*:zbx_monitor:<PASSWORD>
__EOF__

chown zabbix: /var/lib/zabbix/.pgpass
chmod 600 /var/lib/zabbix/.pgpass

tennplate修正。
① Postgres by Zabbix agentをコピー 
② {$PG.HOST}
    {$PG_PASSWORD}

※ Postgres by zabbix agent2テンプレートは使用できなかった。
{$PG_CONSTRING} がlocalhost以外エラーになる。
 
# systemctl restart zabbix-agent2
※ template は agent, エージェントはagent2でも問題なかった。




【オラクル監視】
Rocky linux9.4 / oracle19c / zabbix7.0

# dnf install libnsl
# rpm -ivh oracle-instantclient19.20-basic-19.20.0.0.0-1.x86_64.rpm

# vi /etc/profile.d/oracle.sh
export LD_LIBRARY_PATH=/usr/lib/oracle/19.20/client64/lib:$LD_LIBRARY_PATH
# .  /etc/profile
# vi /etc/sysconfig/httpd
LD_LIBRARY_PATH=/usr/lib/oracle/19.20/client64/lib/:$LD_LIBRARY_PATH
# vi /etc/ld.so.conf.d/oracle-instantclient.conf
/usr/lib/oracle/19.20/client64/lib
# ldconfig
# ldconfig  -p |grep libclntsh

# mkdir /etc/systemd/system/zabbix-agent2.service.d
#  vi /etc/systemd/system/zabbix-agent2.service.d/limit.conf
# cat /etc/systemd/system/zabbix-agent2.service.d/limit.conf
[Service]
LimitNOFILE=65536

# systemctl daemon-reload
# systemctl restart  zabbix-agent2

create pluggable database zabbix admin user zbx_admin identified by "system" file_name_convert=( 'ORCLCDB','ZABBIX');
alter pluggable database zabbix open;
alter pluggable database all save state;
alter session set container=zabbix;

To create Oracle user with required privileges, run:
CREATE USER zbx_monitor IDENTIFIED BY  "zbx%xxxxxx%";
-- Grant access to the zbx_monitor user.

grant connect, create session to zbx_monitor;
grant select any dictionary 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_$event_name 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_$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_event to zbx_monitor;
grant select on v_$system_parameter to zbx_monitor;
grant unlimited tablespace to zbx_monitor;
                   
create profile ZABBIX limit PASSWORD_LIFE_TIME unlimited;
alter user zbx_monitor profile ZABBIX;
alter profile ZABBIX limit PASSWORD_LIFE_TIME unlimited;
set linesize 500
col resource_name for a30
col resource_type for a20
col profile for a20
col limit for a20
select * from dba_profiles where profile='ZABBIX' and resource_name='PASSWORD_LIFE_TIME';

接続確認
$ vi   /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/tnsnames.ora << __EOF__
ZABBIX =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.18.211)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = zabbix.world)
    )
  )

__EOF__

export NLS_LANG=Japanese_Japan.AL32UTF8             
sqlplus zbx_monitor/password@zabbix

ホストマクロ設定(ホスト→マクロ→ホストマクロ)
{$ORACLE.CONNSTRING}   : tcp://localhost:1521
{$ORACLE.SERVICE}      : zabbix
{$ORACLE.PASSWORD}     : password
{$ORACLE.USER}         : zbx_monitor

# dnf install zabbix-get
$ zabbix_get -s oracle-host -k oracle.ping["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]
zabbix_get -s 127.0.0.1 -k oracle.ping['tcp://10.0.18.211:1521','zbx_monitor','system','zabbix.world']
zabbix_get -s 127.0.0.1 -k oracle.instance.info['tcp://10.0.18.211:1521','zbx_monitor','system','zabbix.world']




2024年6月25日火曜日

oracle auditファイルの削除


【auditファイル削除】

SQL> DELETE FROM SYS.AUD$;
SQL> TRUNCATE TABLE SYS.AUD$;

ファイングレイン監査証跡削除
SQL> DELETE FROM SYS.FGA_LOG$;
SQL> TRUNCATE TABLE SYS.FGA_LOG$;


【共有プール開放】

SQL> ALTER SYSTEM FLUSH SHARED_POOL;
SQL> ALTER SYSTEM SET SHARED_POOL_SIZE =6G SCOPE = BOTH;         #上限設定
SQL> ALTER SYSTEM SET DB_CACHE_SIZE =4G  SCOPE = BOTH;    


  col bytes for 9,999,999,999,999
  select name, bytes
  from v\$sgastat where pool is null
  union all
  select pool, sum( bytes ) from v$sgastat
  where pool is not null
  group by pool ;


【SGAターゲットの設定】  ー動的に割り当て有効

SQL> SHOW PARAMETER SGA;

NAME      TYPE VALUE
------------------------------------ ----------- ------------------------------
lock_sga      boolean FALSE
pre_page_sga      boolean FALSE
sga_max_size      big integer 12832M    →16G
sga_target      big integer 0

SQL> ALTER SYSTEM SET SGA_MAX_SIZE = 16G SCOPE = SPFILE;
SQL> ALTER SYSTEM SET SGA_TARGET = 8G SCOPE = BOTH;

SQL> SHUTDOWN IMMEDIATE;                                   -- SGA_MAX_SIZEを変えた場合。
SQL> STARTUP;

2024年6月12日水曜日

2024年4月26日金曜日

シャットダウン時の後処理 (shutdown)

# vi /etc/systemd/system/drop.service
[Unit]
Description= stop httpgwd
DefaultDependencies=no
Before=shutdown.target
RefuseManualStart=true

[Service]
Type=oneshot
ExecStart= /usr/local/sbin/httpgwd  stop
[Install]
WantedBy=shutdown.target

# systemctl daemon-reload
# systemctl enable drop.service

2024年4月25日木曜日

Postgres partition 設定 パーティション設定

SET client_encoding TO 'UTF8';
SET search_path = arcsdbss,public;

CREATE TABLE sst008_p202403 PARTITION OF sst008
FOR VALUES FROM ('20240301000000000') TO ('20240401000000000')
PARTITION BY HASH (gcode, ccode, scode);
CREATE TABLE sst008_sys_subp202403_0 PARTITION OF sst008_p202403
FOR VALUES WITH (MODULUS 8, REMAINDER 0);
CREATE TABLE sst008_sys_subp202403_1 PARTITION OF sst008_p202403
FOR VALUES WITH (MODULUS 8, REMAINDER 1);
CREATE TABLE sst008_sys_subp202403_2 PARTITION OF sst008_p202403
FOR VALUES WITH (MODULUS 8, REMAINDER 2);
CREATE TABLE sst008_sys_subp202403_3 PARTITION OF sst008_p202403
FOR VALUES WITH (MODULUS 8, REMAINDER 3);
CREATE TABLE sst008_sys_subp202403_4 PARTITION OF sst008_p202403
FOR VALUES WITH (MODULUS 8, REMAINDER 4);
CREATE TABLE sst008_sys_subp202403_5 PARTITION OF sst008_p202403
FOR VALUES WITH (MODULUS 8, REMAINDER 5);
CREATE TABLE sst008_sys_subp202403_6 PARTITION OF sst008_p202403
FOR VALUES WITH (MODULUS 8, REMAINDER 6);
CREATE TABLE sst008_sys_subp202403_7 PARTITION OF sst008_p202403
FOR VALUES WITH (MODULUS 8, REMAINDER 7);

CREATE TABLE sst008_p202404 PARTITION OF sst008
FOR VALUES FROM ('20240401000000000') TO ('20240501000000000')
PARTITION BY HASH (gcode, ccode, scode);
CREATE TABLE sst008_sys_subp202404_0 PARTITION OF sst008_p202404
FOR VALUES WITH (MODULUS 8, REMAINDER 0);
CREATE TABLE sst008_sys_subp202404_1 PARTITION OF sst008_p202404
FOR VALUES WITH (MODULUS 8, REMAINDER 1);
CREATE TABLE sst008_sys_subp202404_2 PARTITION OF sst008_p202404
FOR VALUES WITH (MODULUS 8, REMAINDER 2);
CREATE TABLE sst008_sys_subp202404_3 PARTITION OF sst008_p202404
FOR VALUES WITH (MODULUS 8, REMAINDER 3);
CREATE TABLE sst008_sys_subp202404_4 PARTITION OF sst008_p202404
FOR VALUES WITH (MODULUS 8, REMAINDER 4);
CREATE TABLE sst008_sys_subp202404_5 PARTITION OF sst008_p202404
FOR VALUES WITH (MODULUS 8, REMAINDER 5);
CREATE TABLE sst008_sys_subp202404_6 PARTITION OF sst008_p202404
FOR VALUES WITH (MODULUS 8, REMAINDER 6);
CREATE TABLE sst008_sys_subp202404_7 PARTITION OF sst008_p202404
FOR VALUES WITH (MODULUS 8, REMAINDER 7);

CREATE TABLE sst008_p202405 PARTITION OF sst008
FOR VALUES FROM ('20240501000000000') TO ('20240601000000000')
PARTITION BY HASH (gcode, ccode, scode);
CREATE TABLE sst008_sys_subp202405_0 PARTITION OF sst008_p202405
FOR VALUES WITH (MODULUS 8, REMAINDER 0);
CREATE TABLE sst008_sys_subp202405_1 PARTITION OF sst008_p202405
FOR VALUES WITH (MODULUS 8, REMAINDER 1);
CREATE TABLE sst008_sys_subp202405_2 PARTITION OF sst008_p202405
FOR VALUES WITH (MODULUS 8, REMAINDER 2);
CREATE TABLE sst008_sys_subp202405_3 PARTITION OF sst008_p202405
FOR VALUES WITH (MODULUS 8, REMAINDER 3);
CREATE TABLE sst008_sys_subp202405_4 PARTITION OF sst008_p202405
FOR VALUES WITH (MODULUS 8, REMAINDER 4);
CREATE TABLE sst008_sys_subp202405_5 PARTITION OF sst008_p202405
FOR VALUES WITH (MODULUS 8, REMAINDER 5);
CREATE TABLE sst008_sys_subp202405_6 PARTITION OF sst008_p202405
FOR VALUES WITH (MODULUS 8, REMAINDER 6);
CREATE TABLE sst008_sys_subp202405_7 PARTITION OF sst008_p202405
FOR VALUES WITH (MODULUS 8, REMAINDER 7);

CREATE TABLE sst008_p202406 PARTITION OF sst008
FOR VALUES FROM ('20240601000000000') TO ('20240701000000000')
PARTITION BY HASH (gcode, ccode, scode);
CREATE TABLE sst008_sys_subp202406_0 PARTITION OF sst008_p202406
FOR VALUES WITH (MODULUS 8, REMAINDER 0);
CREATE TABLE sst008_sys_subp202406_1 PARTITION OF sst008_p202406
FOR VALUES WITH (MODULUS 8, REMAINDER 1);
CREATE TABLE sst008_sys_subp202406_2 PARTITION OF sst008_p202406
FOR VALUES WITH (MODULUS 8, REMAINDER 2);
CREATE TABLE sst008_sys_subp202406_3 PARTITION OF sst008_p202406
FOR VALUES WITH (MODULUS 8, REMAINDER 3);
CREATE TABLE sst008_sys_subp202406_4 PARTITION OF sst008_p202406
FOR VALUES WITH (MODULUS 8, REMAINDER 4);
CREATE TABLE sst008_sys_subp202406_5 PARTITION OF sst008_p202406
FOR VALUES WITH (MODULUS 8, REMAINDER 5);
CREATE TABLE sst008_sys_subp202406_6 PARTITION OF sst008_p202406
FOR VALUES WITH (MODULUS 8, REMAINDER 6);
CREATE TABLE sst008_sys_subp202406_7 PARTITION OF sst008_p202406
FOR VALUES WITH (MODULUS 8, REMAINDER 7);

CREATE TABLE sst008_sys_subp202406_default PARTITION OF sst008 DEFAULT;

2024年4月19日金曜日

Failed to load SELinux policy

grab

load_video
set fgxpayload=keep
insmod gzio
linux ($root)/vmlinz-5.14.0-362.24.1.e19_3.x86_64 root=/dev/m,apper/r1-root\
ro crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M resume=/dev/mapper/r1-swap\
rd.lvm.lv=r1/root fd.lvm.lv=rl/swap seliux=0
initrd ($root)/initramfs-5.14-0-362.24.1.e19_3.x86_64.img

cntl-x

2024年4月17日水曜日

bash 履歴保管

$ vi .bashrc
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'

2024年4月5日金曜日

ESXi停止

[root@localhost:~] vim-cmd vmsvc/getallvms
Vmid Name File Guest OS Version Annotation
37 changesv2n [office-vmfs] changesv2n/changesv2n.vmx windows8Server64Guest vmx-11
38 changesv1n [office-vmfs] changesv1n/changesv1n.vmx windows8Server64Guest vmx-11
39 linksv1n [office-vmfs] linksv1n_1/linksv1n.vmx centos64Guest vmx-11
[root@localhost:~] vim-cmd vmsvc/power.shutdown 39
[root@localhost:~] vim-cmd vmsvc/power.getstate 39
Retrieved runtime info
Powered off
[root@localhost:~] esxcli system maintenanceMode get
Disabled
[root@localhost:~] esxcli system maintenanceMode set --enable true
[root@localhost:~] esxcli system shutdown poweroff -r hard_trouble


2024年4月2日火曜日

postgres エクスポート pg_dump / pg_restore

$ pg_dump -Fc -h localhost -p 5432 -U postgres -d arcsdbms > arcsdbms.dump
$ time pg_restore -h 10.0.18.102 -p 5432 -U postgres -d arcsdbms arcsdbms.dump

2024年3月29日金曜日

windows etc/hosts 反映されない。

chrome://net-internals/#dns
chrome://net-internals/#sockets
ipconfig /flushdns
ipconfig /displaydns

2024年3月23日土曜日

nmap vendor 更新

$ wget https://standards-oui.ieee.org/oui/oui.txt

# cat oui.txt|grep "(base 16)"|awk '{ print $1," ",$4,$5,$6,$7,$8,$9,$10}'>a

vi /usr/share/nmap/nmap-mac-prefixes

2024年3月7日木曜日

脆弱性



# firewall-cmd --remove-service=cockpit --zone=public --permanent
# firewall-cmd --remove-service=dhcpv6-client --zone=public --permanent
# firewall-cmd --reload

2024年2月29日木曜日

2024年2月21日水曜日

sqlplus

 $ sqlplus system/password@dbsv:1521/service_name as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Wed Feb 21 17:44:10 2024

Version 18.5.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.

ERROR:

ORA-01031: insufficient privileges

Enter user-name: 

$ sqlplus system/password@dbsv:1521/service_name 

SQL*Plus: Release 18.0.0.0.0 - Production on Wed Feb 21 17:45:39 2024

Version 18.5.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> oradebug setmypid

ORA-01031: insufficient privileges

※ 特権にはOS認証が必要?  リモートでは認証不可?



2024年2月20日火曜日

2024年2月16日金曜日

ネットワーク設定ツール

#-----------------------------------------------------------
usage(){
echo USAGE: ./set 
}
#-----------------------------------------------------------
DEBUG=debug

timedatectl set-timezone Asia/Tokyo
localectl set-locale LANG=ja_JP.utf8

DEVICE_1=`nmcli d |grep ethernet | sort |head -1 |tail -n 1 |cut -d " "  -f 1`
DEVICE_2=`nmcli d |grep ethernet | sort |head -2 |tail -n 1 |cut -d " "  -f 1`
DEVICE_3=`nmcli d |grep ethernet | sort |head -3 |tail -n 1 |cut -d " "  -f 1`

HOST_NAME=apisv1n
HOST_NAME=apisv2n
HOST_NAME=websv1n
HOST_NAME=websv2n
HOST_NAME=utlsv1n
HOST_NAME=officesv1n

HOST_NAME=postgres15
HOST_NAME=postgres15-2
HOST_NAME=oracle19c
HOST_NAME=zabbix
HOST_NAME=nassv
HOST_NAME=ora2pg
HOST_NAME=buildsv

HOST_NAME=igw
HOST_NAME=ngw-1a
HOST_NAME=ngw-1c
HOST_NAME=elb-api
HOST_NAME=elb-web
HOST_NAME=securitygroup

HOST_NAME=ami-rocky9-20G
HOST_NAME=ngw-1a

if [ "${DEBUG}" == "debug" ]; then
echo nmcli general hostname $HOST_NAME
else
nmcli general hostname $HOST_NAME
fi

#               HOST  NETWORK           DEVICE    IP    GW ROUTE
HOST_LISTS="    new|nassv|private_db_1a|-|10.0.18.201/24|10.0.18.2|-| \
new|securitygroup|global_network|enp1s0|192.168.1.240/24|192.168.1.1|-| \
                new|securitygroup|inside_control|enp7s0|10.0.1.2/24|-|-|  \
                new|securitygroup|public_nat_1a|enp8s0|10.0.10.2/24|-|-|  \
                new|securitygroup|public_nat_1c|enp9s0|10.0.20.2/24|-|-|  \
                new|securitygroup|private_api_1a|enp10s0|10.0.11.2/24|-|-| \
                new|securitygroup|private_api_1c|enp11s0|10.0.21.2/24|-|-| \
                new|securitygroup|private_web_1a|enp12s0|10.0.12.2/24|-|-| \
                new|securitygroup|private_web_1c|enp13s0|10.0.22.2/24|-|-| \
                new|securitygroup|private_utl_1a|enp14s0|10.0.13.2/24|-|-| \
                new|securitygroup|private_utl_1c|enp15s0|10.0.23.2/24|-|-| \
                new|securitygroup|private_ofc_1a|enp16s0|10.0.14.2/24|-|-| \
                new|securitygroup|private_ofc_1c|enp17s0|10.0.24.2/24|-|-| \
                new|securitygroup|private_db_1a|enp18s0|10.0.18.2/24|-|-|  \
                new|securitygroup|private_db_1c|enp19s0|10.0.28.2/24|-|-|  \
                new|securitygroup|private_mng_1a|enp20s0|10.0.19.2/24|-|-| \
                new|securitygroup|private_mng_1c|enp21s0|10.0.29.2/24|-|-| \
                new|elb-api|inside_control|-|10.0.1.101/24|10.0.1.2|-| \
                new|elb-web|inside_control|-|10.0.1.102/24|10.0.1.2|- |\
                new|igw|global_network|1|192.168.1.241/24|192.168.1.1|-| \
                mod|igw|global_network|1|192.168.1.242/24|-|-| \
                mod|igw|global_network|1|192.168.1.243/24|-|-| \
                mod|igw|global_network|1|192.168.1.244/24|-|-| \
                new|igw|inside_control|2|10.0.1.220/24|-|-| \
                new|ngw-1a|global_network|1|auto|192.168.1.1|-| \
                new|ngw-1a|public_nat_1a|2|10.0.10.101/24|-|-| \
                mod|ngw-1a|public_nat_1a|2|-|10.0.10.2|10.0.13.0/24| \
                mod|ngw-1a|public_nat_1a|2|-|10.0.10.2|10.0.14.0/24| \
                mod|ngw-1a|public_nat_1a|2|-|10.0.10.2|10.0.19.0/24| \
                nat|ngw-1a|public_nat_1a|-|-|-|-| \
                new|apisv1n|private_api_1a|-|10.0.11.101/24|10.0.11.2|-| \
                new|apisv2n|private_api_1c|-|10.0.21.101/24|10.0.21.2|-| \
                new|websv1n|private_web_1a|-|10.0.12.101/24|10.0.12.2|-| \
                new|websv2n|private_web_1c|-|10.0.22.101/24|10.0.22.2|-| \
                new|utlsv1n|private_utl_1a|-|10.0.13.101/24|10.0.13.2|-| \
                new|officesv1n|private_ofc_1a|-|10.0.14.101/24|10.0.14.2|-| \
                new|postgres15|private_db_1a|-|10.0.18.101/24|10.0.18.2|-| \
                new|postgres15-2|private_db_1a|-|10.0.18.102/24|10.0.18.2|-| \
                new|ami-rocky9-20G|private_mng_1a|-|10.0.19.100/24|10.0.19.2|-| \
                new|ora2pg|private_mng_1a|-|10.0.19.201/24|10.0.19.2|-| \
                new|buildsv|private_mng_1a|-|10.0.19.202/24|10.0.19.2|-| \
                new|zabbix5.4|private_mng_1a|-|10.0.19.119/24|10.0.19.2|-| \
           "

#----------------------------------------------------------------
# main()
#----------------------------------------------------------------
main(){
case "$1" in
        "config" )
config
        ;;
        *)
usage
        ;;
esac
nmcli d
nmcli c
ip a
ip r
}

config(){
for row in $HOST_LISTS; do
            MODE=`echo        $row | cut -d "|" -f 1`
            NAME=`echo        $row | cut -d "|" -f 2`
            VLAN_NAME=`echo   $row | cut -d "|" -f 3`
            LAN_DEVICE=`echo  $row | cut -d "|" -f 4`
            VLAN_IP=`echo     $row | cut -d "|" -f 5`
            VLAN_GW=`echo     $row | cut -d "|" -f 6`
            VLAN_ROUTE=`echo  $row | cut -d "|" -f 7`

if [ "${LAN_DEVICE}" == "-" ] || [ "${LAN_DEVICE}" == "1" ]; then
DEVICE=${DEVICE_1}
elif [ "${LAN_DEVICE}" == "2" ]; then
DEVICE=${DEVICE_2}
elif [ "${LAN_DEVICE}" == "3" ]; then
DEVICE=${DEVICE_3}
else
DEVICE=${LAN_DEVICE}
fi

if [ "${NAME}" == "${HOST_NAME}" ]; then
if [ "${MODE}" == "new" ]; then
net_config ${NAME} ${VLAN_NAME} ${DEVICE} ${VLAN_IP} ${VLAN_GW} ${VLAN_ROUTE}
elif [ "${MODE}" == "mod" ]; then
mod_config ${NAME} ${VLAN_NAME} ${DEVICE} ${VLAN_IP} ${VLAN_GW} ${VLAN_ROUTE}
elif [ "${MODE}" == "nat" ]; then
nat_config ${NAME} ${VLAN_NAME} 
  fi
                fi
done
}

net_config(){
NAME=$1
VLAN_NAME=$2
  DEVICE=$3
  VLAN_IP=$4
VLAN_GW=$5

if [ "${DEBUG}" == "debug" ]; then
echo nmcli c delete ${VLAN_NAME}
echo nmcli c add type ethernet ifname ${DEVICE} con-name "${VLAN_NAME}"
                if [ "${VLAN_IP}" == "auto" ]; then 
echo nmcli c mod ${VLAN_NAME} ipv4.method auto
else
        echo nmcli c mod ${VLAN_NAME} ipv4.addresses ${VLAN_IP}
echo nmcli c mod ${VLAN_NAME} ipv4.method manual
fi
echo nmcli c mod ${VLAN_NAME} connection.autoconnect yes
echo nmcli c mod ${VLAN_NAME} ipv4.gateway ${VLAN_GW}
echo nmcli c up  ${VLAN_NAME}
        else
nmcli c delete ${VLAN_NAME}
nmcli c add type ethernet ifname ${DEVICE} con-name "${VLAN_NAME}"
                if [ "${VLAN_IP}" == "auto" ]; then 
nmcli c mod ${VLAN_NAME} ipv4.method auto
else
nmcli c mod ${VLAN_NAME} ipv4.addresses ${VLAN_IP}
nmcli c mod ${VLAN_NAME} ipv4.method manual
fi
nmcli c mod ${VLAN_NAME} connection.autoconnect yes
if [ "${VLAN_GW}" != "-" ]; then
nmcli c mod ${VLAN_NAME} ipv4.gateway ${VLAN_GW}
fi
nmcli c up  ${VLAN_NAME}
fi
}

mod_config(){
NAME=$1
VLAN_NAME=$2
  DEVICE=$3
  VLAN_IP=$4
VLAN_GW=$5
VLAN_ROUTE=$6

        if [ "${VLAN_IP}" != "-" ]; then
if [ "${DEBUG}" == "debug" ]; then
echo nmcli c mod ${VLAN_NAME} +ipv4.addresses ${VLAN_IP}
else
nmcli c mod ${VLAN_NAME} +ipv4.addresses ${VLAN_IP}
nmcli c up  ${VLAN_NAME}
fi
fi
        if [ "${VLAN_GW}" != "-" ]; then
if [ ${DEBUG} == "debug" ]; then
echo nmcli c mod ${VLAN_NAME} +ipv4.routes "${VLAN_ROUTE} ${VLAN_GW}"
else
nmcli c mod ${VLAN_NAME} +ipv4.routes "${VLAN_ROUTE} ${VLAN_GW}"
nmcli c up  ${VLAN_NAME}
fi
fi
}

nat_config(){
NAME=$1
INTERNAL=$2
        EXTERNAL="global_network"

if [ ${DEBUG} == "debug" ]; then
echo nmcli c mod $EXTERNAL connection.zone external
echo nmcli c mod $INTERNAL connection.zone internal

echo firewall-cmd --zone=external --add-masquerade --permanent

echo nmcli c up  $EXTERNAL
echo nmcli c up  $INTERNAL
else
nmcli c mod $EXTERNAL connection.zone external
nmcli c mod $INTERNAL connection.zone internal

firewall-cmd --zone=external --add-masquerade --permanent

nmcli c up  $EXTERNAL
nmcli c up  $INTERNAL
fi

}

main $@

2024年2月15日木曜日

expdp



■ ディレクトリオブジェクト登録
conn system/oracle
set linesize 400
col owner for a10
col directory_name for a30
col directory_path for a50
col grantee for a20
col table_name for a30
col privilege for a20

select owner, directory_name,directory_path from all_directories where directory_name = 'DATA_PUMP_DIR';

select owner, grantee,table_name, privilege from dba_tab_privs where table_name = 'DATA_PUMP_DIR';

create or replace directory dpump_dir as '/mnt/extHDD/dpdump ';

select owner,directory_name,directory_path from all_directories where directory_name = 'DPUMP_DIR';


conn / as sysdba

grant read on directory dpump_dir to system;

grant write on directory dpump_dir to system;

select owner, grantee, table_name, privilege from dba_tab_privs where grantee = 'SYSTEM' and TABLE_NAME = 'DPUMP_DIR';


■ expdpコマンド

usage(){
       echo USAGE: sh cmd.sh expdp \[table\]

}

SCHEMA_LISTS="schema01|Y|system|oracle|sid|directory \
              schema02|N|system|oracle|sid|directory \
             "
main(){
    case "$1" in
    "expdp" )
        expdp_cmd $2
        ;;

     *)
        usage
        ;;

    esac
}

expdp_cmd(){
    for row in $SCHEMA_LISTS; do
        ORA_SCHEMA=`echo $row      | cut -d "|" -f 1`
        ORA_FULL=`echo $row        | cut -d "|" -f 2`
        ORA_USER=`echo $row        | cut -d "|" -f 3`
        ORA_PASS=`echo $row        | cut -d "|" -f 4`
        ORA_SID=`echo $row         | cut -d "|" -f 5`
        ORA_DIRECTORY=`echo $row   | cut -d "|" -f 6`

        if [ "$1" == "" ]  || [ "$1" == "${ORA_SCHEMA}" ]; then
            echo "[`date '+%Y-%m-%d %H:%M:%S'`] Exporting SCHEMAS=${ORA_SCHEMA} START"
            echo "expdp ${ORA_USER}/${ORA_PASS}@${ORA_SID} DIRECTORY=${ORA_DIRECTORY} SCHEMAS=${ORA_SCHEMA} DUMPFILE=exp_${ORA_SCHEMA}.dmp LOGFILE=exp_${ORA_SCHEMA}.log"
            #expdp ${ORA_USER}/${ORA_PASS}@${ORA_SID} DIRECTORY=${ORA_DIRECTORY} SCHEMAS=${ORA_SCHEMA} DUMPFILE=exp_${ORA_SCHEMA}.dmp LOGFILE=exp_${ORA_SCHEMA}.log

            if [ $? -ne 0 ]; then
               echo "[`date '+%Y-%m-%d %H:%M:%S'`] Exporting SCHEMAS=${ORA_SCHEMA} ERROR !! "
            else
               echo "[`date '+%Y-%m-%d %H:%M:%S'`] Exporting SCHEMAS=${ORA_SCHEMA} NORMAL END"
            fi
        fi
    done
}

main $@


■meta only
expdp ${ORA_USER}/${ORA_PASS}@${ORA_SID} FULL=Y DIRECTORY=${DIRECT} DUMPFILE=exp_metaonly.dmp LOGFILE=exp_metaonly.log CONTENT=METADATA_ONLY



トラックボール

$ xinput --get-button-map 12 device has no buttons [takahab@rocky92 ~]$ xinput list ⎡ Virtual core pointer                    id=2 [mast...