Thursday, June 20, 2024
Sunday, May 19, 2024
.::: Additional Environment PostgreSQL EDB example pg_ctl: command not found :::.
1. Run pg_ctl
pg_ctl
[root@teguhth ~]# su - postgres
Last login: Sun May 12 08:18:13 WIB 2024 on pts/1
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data status
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data start
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data stop
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$
pg_ctl
[root@teguhth ~]# su - postgres
Last login: Sun May 12 08:18:13 WIB 2024 on pts/1
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data status
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data start
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data stop
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$
Tuesday, April 23, 2024
.::: Enable userstat USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS, and the TABLE_STATISTICS MariaDB MySQL :::.
A. Enable Statistic Plugin
1. Check configuration statistic
From query
show variables like '%userstat%';
From mariadb configuration
# cat /etc/my.cnf.d/server.cnf | grep userstat
2. Enable userstat configuration From Query ( for temporary configuration)
SET GLOBAL userstat=1;
show variables like 'userstat';
Tuesday, April 16, 2024
.::: Backup & Restore Database MongoDB Using Mongodump & mongorestore :::.
Step 1: Create Direct Backups Using Mongodump
mongodump
[root@teguhth ~]# mongodump
2024-04-15T14:59:40.783+0700 writing admin.system.users to dump/admin/system.users.bson
2024-04-15T14:59:40.789+0700 done dumping admin.system.users (3 documents)
2024-04-15T14:59:40.790+0700 writing admin.system.version to dump/admin/system.version.bson
2024-04-15T14:59:40.790+0700 done dumping admin.system.version (2 documents)
2024-04-15T14:59:40.792+0700 writing teguhth.pembelian to dump/teguhth/pembelian.bson
2024-04-15T14:59:40.793+0700 writing teguhth.pasok to dump/teguhth/pasok.bson
2024-04-15T14:59:40.794+0700 writing teguhth.suplier to dump/teguhth/suplier.bson
2024-04-15T14:59:40.795+0700 writing kampus.mahasiswi to dump/kampus/mahasiswi.bson
2024-04-15T14:59:40.797+0700 done dumping teguhth.pembelian (15 documents)
2024-04-15T14:59:40.798+0700 writing teguhth.barang to dump/teguhth/barang.bson
2024-04-15T14:59:40.799+0700 done dumping teguhth.pasok (12 documents)
2024-04-15T14:59:40.800+0700 writing teguhth.customer to dump/teguhth/customer.bson
2024-04-15T14:59:40.801+0700 done dumping kampus.mahasiswi (8 documents)
2024-04-15T14:59:40.801+0700 writing tka.barang to dump/tka/barang.bson
2024-04-15T14:59:40.802+0700 done dumping teguhth.barang (6 documents)
2024-04-15T14:59:40.803+0700 writing tka.Barang to dump/tka/Barang.bson
2024-04-15T14:59:40.803+0700 done dumping teguhth.customer (6 documents)
2024-04-15T14:59:40.806+0700 done dumping tka.barang (6 documents)
2024-04-15T14:59:40.807+0700 done dumping teguhth.suplier (6 documents)
2024-04-15T14:59:40.808+0700 done dumping tka.Barang (0 documents)
[root@teguhth ~]#
mongodump
[root@teguhth ~]# mongodump
2024-04-15T14:59:40.783+0700 writing admin.system.users to dump/admin/system.users.bson
2024-04-15T14:59:40.789+0700 done dumping admin.system.users (3 documents)
2024-04-15T14:59:40.790+0700 writing admin.system.version to dump/admin/system.version.bson
2024-04-15T14:59:40.790+0700 done dumping admin.system.version (2 documents)
2024-04-15T14:59:40.792+0700 writing teguhth.pembelian to dump/teguhth/pembelian.bson
2024-04-15T14:59:40.793+0700 writing teguhth.pasok to dump/teguhth/pasok.bson
2024-04-15T14:59:40.794+0700 writing teguhth.suplier to dump/teguhth/suplier.bson
2024-04-15T14:59:40.795+0700 writing kampus.mahasiswi to dump/kampus/mahasiswi.bson
2024-04-15T14:59:40.797+0700 done dumping teguhth.pembelian (15 documents)
2024-04-15T14:59:40.798+0700 writing teguhth.barang to dump/teguhth/barang.bson
2024-04-15T14:59:40.799+0700 done dumping teguhth.pasok (12 documents)
2024-04-15T14:59:40.800+0700 writing teguhth.customer to dump/teguhth/customer.bson
2024-04-15T14:59:40.801+0700 done dumping kampus.mahasiswi (8 documents)
2024-04-15T14:59:40.801+0700 writing tka.barang to dump/tka/barang.bson
2024-04-15T14:59:40.802+0700 done dumping teguhth.barang (6 documents)
2024-04-15T14:59:40.803+0700 writing tka.Barang to dump/tka/Barang.bson
2024-04-15T14:59:40.803+0700 done dumping teguhth.customer (6 documents)
2024-04-15T14:59:40.806+0700 done dumping tka.barang (6 documents)
2024-04-15T14:59:40.807+0700 done dumping teguhth.suplier (6 documents)
2024-04-15T14:59:40.808+0700 done dumping tka.Barang (0 documents)
[root@teguhth ~]#
Tuesday, April 9, 2024
.::: How to enable CDC (Change Data Capture) in PostgreSQL, EDB :::.
1. Enable WAL (Write-Ahead Logging): PostgreSQL uses Write-Ahead Logging for durability. Ensure that your PostgreSQL server is configured to use WAL.
2. Create Audit Table: Create an audit table where you will log the changes.
CREATE TABLE audit_table (
id SERIAL PRIMARY KEY,
table_name TEXT NOT NULL,
action_type TEXT NOT NULL,
old_data JSONB,
new_data JSONB,
changed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Saturday, April 6, 2024
.::: Convert pgaudit & pgauditlogtofile log insert into table in PostgreSQL EDB :::.
continue from http://teguhth.blogspot.com/2024/02/enable-pgaudit-pgauditlogtofile-in.html
1. Create table pgaudit_log
CREATE TABLE pgaudit_log (
log_time text,
user_name text,
dbname text,
process_id text,
connection_from text,
session_id text,
session_line_num text,
command_tag text,
session_start_time text,
virtual_transaction_id text,
transaction_id text,
error_severity text,
sql_state_code text,
message text,
detail text,
hint text,
internal_query text,
internal_query_pos text,
context text,
query text,
query_pos text,
location text,
application_name text,
backend_type text,
leader_pid text,
query_id text,
custom_1 text,
custom_2 text,
custom_3 text,
console text
);
1. Create table pgaudit_log
CREATE TABLE pgaudit_log (
log_time text,
user_name text,
dbname text,
process_id text,
connection_from text,
session_id text,
session_line_num text,
command_tag text,
session_start_time text,
virtual_transaction_id text,
transaction_id text,
error_severity text,
sql_state_code text,
message text,
detail text,
hint text,
internal_query text,
internal_query_pos text,
context text,
query text,
query_pos text,
location text,
application_name text,
backend_type text,
leader_pid text,
query_id text,
custom_1 text,
custom_2 text,
custom_3 text,
console text
);
Wednesday, March 20, 2024
.::: Check Status Backup & Restore Progress in % Percent MSSQL SQL Server :::.
A. Backup
1. Query 1
SELECT @@servername as ServerName, command, percent_complete,total_elapsed_time, estimated_completion_time, start_time
FROM sys.dm_exec_requests
WHERE command IN ('RESTORE DATABASE','BACKUP DATABASE')
Sunday, March 17, 2024
.::: How to enable CDC (Change Data Capture) in MariaDB, MySQL, MarinaDB in Table :::.
Enable Binary Logging
1. check table for sample
SELECT *,@@hostname,@@version FROM teguhth.pembelian
2. Create table for cdc
# create table
CREATE TABLE audit_table (
id INT AUTO_INCREMENT PRIMARY KEY,
table_name VARCHAR(100),
action_type ENUM('INSERT', 'UPDATE', 'DELETE'),
old_data JSON,
new_data JSON,
changed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
SELECT *,@@hostname,@@version FROM audit_table;
SELECT *,@@hostname,@@version FROM teguhth.pembelian
2. Create table for cdc
# create table
CREATE TABLE audit_table (
id INT AUTO_INCREMENT PRIMARY KEY,
table_name VARCHAR(100),
action_type ENUM('INSERT', 'UPDATE', 'DELETE'),
old_data JSON,
new_data JSON,
changed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
SELECT *,@@hostname,@@version FROM audit_table;
Saturday, March 16, 2024
.::: Script check cpu usage & memory usage & Total Memory Server SQL Server include using sqlcmd to monitoring NMS PRTG:::.
1. create store procedure cpu monitoring sql server for monitoring
CREATE PROCEDURE sp_total_usage_cpu_SQLProcessUtilization
AS
BEGIN
DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks)FROM sys.dm_os_sys_info);
SELECT TOP(1)
100 - SystemIdle - SQLProcessUtilization + SQLProcessUtilization AS [Total Usage CPU SQL Utilization]
CREATE PROCEDURE sp_total_usage_cpu_SQLProcessUtilization
AS
BEGIN
DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks)FROM sys.dm_os_sys_info);
SELECT TOP(1)
100 - SystemIdle - SQLProcessUtilization + SQLProcessUtilization AS [Total Usage CPU SQL Utilization]
.::: Script to check cpu & memory usage service in linux include custome service, mariadb, mysql, mongodb :::.
1. check custome cpu usage and memory usage
[root@teguhth special]# cat custom_service.sh
#!/bin/bash
echo "run custom_service.sh <name_service>"
PIDX=${1}
# Mendapatkan PID dari proses mariadbd
MARIADB_PID=$(pgrep $PIDX)
# Mendapatkan informasi tentang proses mariadbd dari top
TOP_INFO=$(top -n 1 -b -p "$MARIADB_PID" | tail -n +8 | head -n 1)
Mem_Total_mb=$(free -m | awk 'NR==2{printf "%.f", $2 }')
Mem_Total_gb=$(free -m | awk 'NR==2{printf "%.2f", $2/1024 }')
# Mengekstrak nilai CPU dan penggunaan memori dari output top
CPU_USAGE=$(echo "$TOP_INFO" | awk '{print $9}')
MEMORY_USAGE=$(echo "$TOP_INFO" | awk '{print $10}')
MEMORY_B=$(echo "$TOP_INFO" | awk '{print $6 }')
echo "CPU Usage(%) $PIDX : ${CPU_USAGE}%"
echo "Memory Usage(%) $PIDX: ${MEMORY_USAGE}%"
echo "Memory Usage $PIDX : ${MEMORY_B}"
echo "Memory Total Server : $Mem_Total_mb MB or $Mem_Total_gb GB"
[root@teguhth special]#
Thursday, February 29, 2024
.::: Study Kasus Praktis belajar Query create & insert table/Collection MongoDB (Data Warehouse) dengan Primary Key :::.
1. correlation with other post
http://teguhth.blogspot.com/2020/12/study-kasus-praktis-belajar-query.html
2. create collection with primarykey
use teguhth
show dbs
show collections
db.createCollection("barang")
db.createCollection("suplier")
db.createCollection("customer")
db.createCollection("pasok")
db.createCollection("pembelian")
show collections
http://teguhth.blogspot.com/2020/12/study-kasus-praktis-belajar-query.html
2. create collection with primarykey
use teguhth
show dbs
show collections
db.createCollection("barang")
db.createCollection("suplier")
db.createCollection("customer")
db.createCollection("pasok")
db.createCollection("pembelian")
show collections
Labels:
All Posts,
Data WareHouse MongoDB,
MongoDB
Wednesday, February 28, 2024
.::: Create User MongoDB role admin and readonly and authenticationRestrictions :::.
1. create user admin
use admin
db.createUser({ user: "admin",pwd: "admin",
roles: [{ role: "readAnyDatabase", db: "admin" },{ role: "readWriteAnyDatabase", db: "admin" }]});
show users;
Tuesday, February 27, 2024
.::: Create a dblink to a remote server MariaDB MySQL to PostgreSQL EDB and using metode SRCDEF :::.
1. install ODBC postgresql * configure
http://teguhth.blogspot.com/2024/01/install-postgresql-odbc-driver-on-linux.html
A. using dblink
1. create table dblink example table barang
CREATE TABLE table_edb_barang(
KODE_BARANG char(6) not null ,
NAMA_BARANG varchar(25),
SATUAN_BARANG varchar(20),
STOK_BARANG decimal(4),
primary key (KODE_BARANG)) ENGINE = CONNECT TABLE_TYPE=ODBC TABNAME='barang' CONNECTION='DSN=edbdb';
Subscribe to:
Posts (Atom)
Popular Posts
-
Sertifikasi profesional, kadang hanya disebut dengan sertifikasi atau kualifikasi saja, adalah suatu penetapan yang diberikan oleh ...
-
SQL atau Structured Query Language) adalah sebuah bahasa yang digunakan untuk mengakses data dalam basis data relasional. Bahasa ini sec...
-
bagaimana cara mengubah hostid di Solaris The Hostid is a globally unique ID for a Sun Solaris Machine. Sometimes, you need to change t...
-
DNSPerf and ResPerf are free tools developed by Nominum that make it simple to gather accurate latency and throughput metrics for Domain ...
-
1. Check Host ID Solaris The Hostid is a globally unique ID for a Sun Solaris Machine. Sometimes, you need to change this hostid for ...