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





























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

$ 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


【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



2024年2月2日金曜日

virsh 使ってみた!!

#------------------------------------------------------------------------------
usage(){
            echo "USAGE:   sudo ./virctl  create [ vlan / pool ]               "
            echo "         sudo ./virctl  drop   [ vlan / pool ]               "
            echo "         sudo ./virctl  host   [ define / start / shutdown /  undefine ] "
            echo "         sudo ./virctl  list                                 "
            echo "         sudo ./virctl  attach                               "
            echo "         sudo ./virctl  interface [ host ]                   "
            echo ""
            echo "         sudo virsh dumpxml hostname > file                  "
            echo "         sudo virsh edit hostname                            "
            echo "         sudo virsh vcpuinfo  hostname                       "
}
#------------------------------------------------------------------------------

DIR_IMAGES="/disk/virt/images"
POOL_NAME="stage"
POOL_DIR="/virt_images"
POOL_STORAGE="${POOL_DIR}/${POOL_NAME}"

VLAN_LISTS=" nat|public_nat_1a|virbr_nat_1a|domain_nat_1a|10.0.10.1|255.255.255.0 \
             nat|public_nat_1c|virbr_nat_1c|domain_nat_1c|10.0.20.1|255.255.255.0 \
             bridge|private_api_1a|virbr_api_1a|domain_api_1a|10.0.11.1|255.255.255.0 \
             bridge|private_api_1c|virbr_api_1c|domain_api_1c|10.0.21.1|255.255.255.0 \
             bridge|private_web_1a|virbr_web_1a|domain_web_1a|10.0.12.1|255.255.255.0 \
             bridge|private_web_1c|virbr_web_1c|domain_web_1c|10.0.22.1|255.255.255.0 \
             bridge|private_utl_1a|virbr_utl_1a|domain_utl_1a|10.0.13.1|255.255.255.0 \
             bridge|private_utl_1c|virbr_utl_1c|domain_utl_1c|10.0.23.1|255.255.255.0 \
             bridge|private_ofc_1a|virbr_ofc_1a|domain_ofc_1a|10.0.14.1|255.255.255.0 \
             bridge|private_ofc_1c|virbr_ofc_1c|domain_ofc_1c|10.0.24.1|255.255.255.0 \
             bridge|private_db_1a|virbr_db_1a|domain_db_1a|10.0.18.1|255.255.255.0 \
             bridge|private_db_1c|virbr_db_1c|domain_db_1c|10.0.28.1|255.255.255.0 \
             bridge|private_mng_1a|virbr_mng_1a|domain_mng_1a|10.0.19.1|255.255.255.0 \
             bridge|private_mng_1c|virbr_mng_1c|domain_mng_1c|10.0.29.1|255.255.255.0 \
           "


OPTION_DISK_FOR_POSTGRES15=$(cat <( cat <<__EOF__
                             <disk type="file" device="disk">
                                   <driver name="qemu" type="qcow2"/>
                                   <source file="${POOL_STORAGE}/pg_tablespace.qcow2"/>
                                   <target dev="vdb" bus="virtio"/>
                                   <address type="pci" domain="0x0000" bus="0x08" slot="0x00" function="0x0"/>
                             </disk> 
__EOF__
))

OPTION_NETWORK_FOR_SECURITY_GROUP=$(cat <( cat <<__EOF__
    <interface type="network">
      <source network="private_api_1a"/>
      <model type="virtio"/>
    </interface>
    <interface type="network">
      <source network="private_api_1c"/>
      <model type="virtio"/>
    </interface>
    <interface type="network">
      <source network="private_web_1a"/>
      <model type="virtio"/>
    </interface>
    <interface type="network">
      <source network="private_web_1c"/>
      <model type="virtio"/>
    </interface>
    <interface type="network">
      <source network="private_db_1a"/>
      <model type="virtio"/>
    </interface>
    <interface type="network">
      <source network="private_db_1c"/>
      <model type="virtio"/>
    </interface>
    <interface type="network">
      <source network="private_utl_1a"/>
      <model type="virtio"/>
    </interface>
    <interface type="network">
      <source network="private_utl_1c"/>
      <model type="virtio"/>
    </interface>
    <interface type="network">
      <source network="private_ofc_1a"/>
      <model type="virtio"/>
    </interface>
    <interface type="network">
      <source network="private_ofc_1c"/>
      <model type="virtio"/>
    </interface>
    <interface type="network">
      <source network="private_mng_1a"/>
      <model type="virtio"/>
    </interface>
    <interface type="network">
      <source network="private_mng_1c"/>
      <model type="virtio"/>
    </interface>
    <interface type="network">
      <source network="public_nat_1a"/>
      <model type="virtio"/>
    </interface>
    <interface type="network">
      <source network="public_nat_1c"/>
      <model type="virtio"/>
    </interface>
__EOF__
))



#               HOST  NETWORK       CPU MEMOEY qcow2イメージ          OPTION
HOST_LISTS="    nassv|private_db_1a|2|8388608|${POOL_STORAGE}/nassv.qcow2 \
security_group|public_nat_1a|2|4194304|${POOL_STORAGE}/security_group.qcow2|OPTION_NETWORK_FOR_SECURITY_GROUP \
igw|public_nat_1a|2|4194304|${POOL_STORAGE}/igw.qcow2 \
ngw|public_nat_1a|2|4194304|${POOL_STORAGE}/ngw.qcow2 \
elb_api|public_nat_1a|2|4194304|${POOL_STORAGE}/elb_api.qcow2 \
elb_web|public_nat_1a|2|4194304|${POOL_STORAGE}/elb_web.qcow2 \
apisv1n|private_api_1a|2|4194304|${POOL_STORAGE}/apisv1n.qcow2 \
apisv2n|private_api_2a|2|4194304|${POOL_STORAGE}/apisv2n.qcow2 \
websv1n|private_web_1a|2|4194304|${POOL_STORAGE}/websv1n.qcow2 \
websv2n|private_web_1c|2|4194304|${POOL_STORAGE}/websv2n.qcow2 \
utlsv1n|private_utl_1a|2|4194304|${POOL_STORAGE}/utlsv1n.qcow2 \
officesv1n|private_ofc_1a|2|4194304|${POOL_STORAGE}/officesv1n.qcow2 \
postgres15|private_db_1a|4|8388608|${POOL_STORAGE}/postgres15.qcow2|OPTION_DISK_FOR_POSTGRES15 \
postgres15-2|private_db_1a|4|8388608|${POOL_STORAGE}/postgres15-2.qcow2 \
buildsv|private_mng_1a|2|8388608|${POOL_STORAGE}/buildsv.qcow2 \
ora2pg|private_mng_1a|2|8388608|${POOL_STORAGE}/ora2pg.qcow2 \
ami_postgres15|private_mng_1a|2|4194304|${POOL_STORAGE}/ami_postgres15.qcow2 \
zabbix5.4|private_mng_1a|4|8388608|${POOL_STORAGE}/zabbix5.4.qcow2 \
           "

#echo $OPTION_DISK
#exit

# pg_tablespace|private_db_1a|2|8388608|${POOL_STORAGE}/pg_tablespace.qcow2 \

#------------------------------------------------------------------------------
#  MAIN ROUTIN
#------------------------------------------------------------------------------
main(){
   case "$1" in
   "create" )
            case "$2" in
            "vlan" )
                  create_vlan
                  ;;
            "pool" )
                  create_pool
                  ;;
            *)
                  usage
                  ;;
            esac
            ;;

   "drop" )
            case "$2" in
            "vlan" )
                  drop_vlan
                  ;;
            "pool" )
                  drop_pool
                  ;;
            *)
                  usage
                  ;;
            esac
            ;;

   "host" )
            case "$2" in
            "define" )
            regist_hosts $3
                ;;

            "start" )
            virsh start $3
                ;;

            "shutdown" )
            virsh shutdown $3
                sleep 1
                ;;

            "undefine" )
                undefine_hosts $3
            #virsh undefine $3
                ;;

            *)
                usage
                ;;
            esac
            virsh list --all
            ;;
   "attach" )
            #virsh attach-interface --domain postgres15-2 --type bridge --source virbr_db_1a --model virtio
            virsh attach-interface --domain postgres15-2 --type network --source private_db_1a --model virtio
            ;;

   "list" )
            virsh pool-list --all
            virsh list --all
            if [ "$2" != "" ]; then
              virsh domiflist $2
            fi
            ;;

   "interface" )
            virsh domiflist $2
            virsh domifaddr $2
            ;;

   "dumpxml" )
            virsh dumpxml $2
            ;;

   "edit" )
            virsh edit $2
            ;;


   *)
            usage
            ;;

   esac
}


#------------------------------------------------------------------------------
#  VLAN 作成
#------------------------------------------------------------------------------
create_vlan(){
        for ROW in $VLAN_LISTS; do

            TYPE=`echo $ROW         | cut -d "|" -f 1`
            NETWORK_NAME=`echo $ROW | cut -d "|" -f 2`
            IF_NAME=`echo $ROW      | cut -d "|" -f 3`
            DOMAIN_NAME=`echo $ROW  | cut -d "|" -f 4`

            IP_ADDRESS=`echo $ROW   | cut -d "|" -f 5 `
            MASK=`echo $ROW         | cut -d "|" -f 6 `

            echo $NETWORK_NAME /  $IF_NAME  / $DOMAIN_NAME  / $IP_ADDRESS  $MASK

            case $TYPE in
            "bridge" )
                 echo CREATE BRIDGE
                 create_bridge $NETWORK_NAME $IF_NAME $DOMAIN_NAME $IP_ADDRESS $MASK
                 ;;

            "nat" )
                 echo CREATE NAT
                 create_nat $NETWORK_NAME $IF_NAME $DOMAIN_NAME $IP_ADDRESS $MASK
                 ;;
            esac
        done
        nmcli c 
}

drop_vlan(){
        for ROW in $VLAN_LISTS; do
             IF_NAME=`echo $ROW | cut -d "|" -f 2`
             virsh net-destroy $IF_NAME
        done
        nmcli c 
}

create_bridge(){

        NETWORK_NAME=$1
        IF_NAME=$2
        DOMAIN_NAME=$3
        IP_ADDRESS=$4
        MASK=$5

        virsh net-create <( cat <<__EOF__
    <network connections="2">
<name>${NETWORK_NAME}</name>
<bridge name="${IF_NAME}" stp="on" delay="0"/>
<domain name="${DOMAIN_NAME}"/>
<ip address="${IP_ADDRESS}" netmask="${MASK}">
                 </ip>
    </network>
__EOF__
            )
}


create_nat(){

        NETWORK_NAME=$1
        IF_NAME=$2
        DOMAIN_NAME=$3
        IP_ADDRESS=$4
        MASK=$5

        virsh net-create <( cat <<__EOF__
<network connections="2">
<name>${NETWORK_NAME}</name>
  <forward mode="nat">
    <nat>
      <port start="1024" end="65535"/>
    </nat>
  </forward>
  <bridge name="${IF_NAME}" stp="on" delay="0"/>
  <domain name="${DOMAIN_NAME}"/>
  <ip address="${IP_ADDRESS}" netmask="${MASK}">
  </ip>
</network>
__EOF__
            )
}


#------------------------------------------------------------------------------
#  POOL 作成
#------------------------------------------------------------------------------
create_pool(){

          if [ -d  ${POOL_STORAGE} ]; then
                if [ -L ${POOL_STORAGE} ]; then
                  echo ${POOL_STORAGE}はシンボリンクリンクです。
                else
                  echo ${POOL_STORAGE}はディレクトリです。
                fi
          else
  mkdir -p  ${POOL_DIR}
                  ln -s ${DIR_IMAGES}/${POOL_NAME}  ${POOL_DIR}/${POOL_NAME}
  chmod -R 755 ${POOL_DIR}
  chown -R qemu:qemu ${POOL_DIR}
                  echo ${POOL_STORAGE}を作成しました。
          fi

          virsh pool-define <( cat <<__EOF__
                                 <pool type='dir'>
                                      <name>${POOL_NAME}</name>
                                       <source>
                                       </source>
                                       <target>
                                           <path>${POOL_STORAGE}</path>
                                           <permissions>
                                             <mode>0755</mode>
                                             <owner>-1</owner>
                                             <group>-1</group>
                                           </permissions>
                                       </target>
                                 </pool>
__EOF__
          )
          virsh pool-start ${POOL_NAME}
          virsh pool-list  --all

}

                                            # <label>system_u:object_r:virt_image_t:s0</label>

drop_pool(){

          virsh pool-list  --all
          virsh pool-destroy ${POOL_NAME}
          virsh pool-undefine ${POOL_NAME}
          #if [ $? == 0 ]; then
          #    rm -rf  ${POOL_DIR}
          #fi
          virsh pool-list  --all
}

#------------------------------------------------------------------------------
#  HOST 登録解除
#------------------------------------------------------------------------------
undefine_hosts(){
        for ROW in ${HOST_LISTS}; do
            SERVER_NAME=`echo $ROW | cut -d "|" -f 1`
            if [ "$1" == "" ]  || [ "$1" == "${SERVER_NAME}" ]; then
                echo "${SERVER_NAME} を削除します。(実態ファイルは削除しません。)"
                yes_no
                if [ $? -eq 0 ]; then
                virsh  undefine ${SERVER_NAME}
                if [ $? == 0 ]; then
                  echo "${SERVER_NAME} を定義削除しました。"
                else
                echo "[ERROR] ${SERVER_NAME} の削除に失敗しました。"
                fi
                 else
                        echo "${SERVER_NAME} はスキップします。"
                 fi
            fi
        done
}

#------------------------------------------------------------------------------
#  HOST 登録
#------------------------------------------------------------------------------
regist_hosts(){

        for ROW in ${HOST_LISTS}; do

            SERVER_NAME=`echo $ROW | cut -d "|" -f 1`
            NETWORK_NAME=`echo $ROW | cut -d "|" -f 2`
            NUMBER_OF_CPU=`echo $ROW | cut -d "|" -f 3`
            SIZE_OF_MEMORY=`echo $ROW | cut -d "|" -f 4`
            GUEST_HOST_SOURCE=`echo $ROW | cut -d "|" -f 5`
            OPTIONS=`echo $ROW | cut -d "|" -f 6`

            if [ "$1" == "" ]  || [ "$1" == "${SERVER_NAME}" ]; then
                host_define $SERVER_NAME $NETWORK_NAME $NUMBER_OF_CPU $SIZE_OF_MEMORY $GUEST_HOST_SOURCE $OPTIONS
                if [ $? == 0 ]; then
                   echo "${SERVER_NAME} を定義しました"
                else
                   echo "[ERROR] ${SERVER_NAME} を定義に失敗しました。"
                fi
            fi
        done
}



host_define(){
          #SERVER_NAME=postgres15-2
          #NETWORK_NAME=private_db_1a
          #NUMBER_OF_CPU=2
          #SIZE_OF_MEMORY=8388608
          #GUEST_HOST_SOURCE=/virt_images/stage_cxdnext/postgres15-2.qcow2

          SERVER_NAME=$1
          NETWORK_NAME=$2
          NUMBER_OF_CPU=$3
          SIZE_OF_MEMORY=$4
          GUEST_HOST_SOURCE=$5
          OPTIONS=${!6}

          echo OPTIONS=$6

          virsh define <( cat <<__EOF__
<domain type="kvm">
  <name>${SERVER_NAME}</name>
<!--
  <uuid>83e081df-ec65-49a8-ad45-a4066e06d7ab</uuid>
-->
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://rockylinux.org/rocky/9"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory unit="KiB">${SIZE_OF_MEMORY}</memory>
  <currentMemory unit="KiB">${SIZE_OF_MEMORY}</currentMemory>
  <vcpu placement="static">${NUMBER_OF_CPU}</vcpu>
  <os>
    <type arch="x86_64" machine="pc-q35-rhel9.2.0">hvm</type>
    <boot dev="hd"/>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <cpu mode="host-passthrough" check="none" migratable="on"/>
  <clock offset="utc">
    <timer name="rtc" tickpolicy="catchup"/>
    <timer name="pit" tickpolicy="delay"/>
    <timer name="hpet" present="no"/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled="no"/>
    <suspend-to-disk enabled="no"/>
  </pm>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
      <source file="${GUEST_HOST_SOURCE}"/>
      <target dev="vda" bus="virtio"/>
      <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/>
    </disk>
                             ${OPTIONS}
    <controller type="usb" index="0" model="qemu-xhci" ports="15">
      <address type="pci" domain="0x0000" bus="0x02" slot="0x00" function="0x0"/>
    </controller>
    <controller type="pci" index="0" model="pcie-root"/>
    <controller type="pci" index="1" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="1" port="0x10"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0" multifunction="on"/>
    </controller>
    <controller type="pci" index="2" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="2" port="0x11"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x1"/>
    </controller>
    <controller type="pci" index="3" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="3" port="0x12"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x2"/>
    </controller>
    <controller type="pci" index="4" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="4" port="0x13"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x3"/>
    </controller>
    <controller type="pci" index="5" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="5" port="0x14"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x4"/>
    </controller>
    <controller type="pci" index="6" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="6" port="0x15"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x5"/>
    </controller>
    <controller type="pci" index="7" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="7" port="0x16"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x6"/>
    </controller>
    <controller type="pci" index="8" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="8" port="0x17"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x7"/>
    </controller>
    <controller type="pci" index="9" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="9" port="0x18"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x0" multifunction="on"/>
    </controller>
    <controller type="pci" index="10" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="10" port="0x19"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x1"/>
    </controller>
    <controller type="pci" index="11" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="11" port="0x1a"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x2"/>
    </controller>
    <controller type="pci" index="12" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="12" port="0x1b"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x3"/>
    </controller>
    <controller type="pci" index="13" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="13" port="0x1c"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x4"/>
    </controller>
    <controller type="pci" index="14" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="14" port="0x1d"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x5"/>
    </controller>
    <controller type="sata" index="0">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1f" function="0x2"/>
    </controller>
    <controller type="virtio-serial" index="0">
      <address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
    </controller>
    <interface type="network">
<!--
      <mac address="52:54:00:f5:18:f2"/>
-->
      <source network="${NETWORK_NAME}"/>
      <model type="virtio"/>
      <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
    </interface>
    <serial type="pty">
      <target type="isa-serial" port="0">
<model name="isa-serial"/>
      </target>
    </serial>
    <console type="pty">
      <target type="serial" port="0"/>
    </console>
    <channel type="unix">
      <target type="virtio" name="org.qemu.guest_agent.0"/>
      <address type="virtio-serial" controller="0" bus="0" port="1"/>
    </channel>
    <input type="tablet" bus="usb">
      <address type="usb" bus="0" port="1"/>
    </input>
    <input type="mouse" bus="ps2"/>
    <input type="keyboard" bus="ps2"/>
    <graphics type="vnc" port="-1" autoport="yes">
      <listen type="address"/>
    </graphics>
    <audio id="1" type="none"/>
    <video>
      <model type="virtio" heads="1" primary="yes"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0"/>
    </video>
    <watchdog model="itco" action="reset"/>
    <memballoon model="virtio">
      <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
    </memballoon>
    <rng model="virtio">
      <backend model="random">/dev/urandom</backend>
      <address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/>
    </rng>
  </devices>
</domain>
__EOF__
      )

}

#----------------------------------------
# 汎用関数
#----------------------------------------
yes_no(){
  echo -n "よろしいですか? [y/N]:"
  if tty -s; then
    read ANS
  else
    echo  TTY端末からの起動で無いため、強制的に「y」を入力します。
    ANS=Yes
  fi
  case $ANS in
    [Yy]* )
      #echo "Yes"
      return 0
      ;;
    * )
      #echo "No"
      return 1
      ;;
  esac
}


main $@

zabbix7 amazon linux2023 インストール postgres15

【postgres】 dnf -y install postgresql15-server postgresql15-server-devel postgresql-setup initdb passwd postgres vi `find / -name pg_hba.con...