1. check table server1
Teguh Triharto Learning Center
Best of Sharing Knowledge Number 1 In The World & In The Universe
Wednesday, June 18, 2025
.::: Shell Script to compare table Database MariaDB MySQL :::.
1. check table server1
.::: Shell Script to compare value table a Database MariaDB MySQL :::.
1. check value table barang server1
Tuesday, June 17, 2025
.::: Trial Backup & Restore MariaDB MySQL with crontab -l / crontab -e & /etc/crontab :::.
A. Prepare Script backup & Restore
1. create backup script
[root@teguhth cron]# pwd
/data/cron
[root@teguhth cron]# cat backup_test.sh
echo "backup full mulai" > log_backup.txt
date >> log_backup.txt
mysqldump -uroot -pxxx -CfQq --max-allowed-packet=1G --hex-blob --order-by-primary --single-transaction --routines=true --triggers=true --no-data=false teguhth | gzip -c > teguhth_ori.sql.gz ;
echo "backup full selesai " >> log_backup.txt
date >> log_backup.txt
[root@teguhth cron]#
Thursday, June 12, 2025
.::: Simulation Query Select from Java to MariaDB using mariadb-java-client-3.5.3.jar (MariaDB Driver) :::.
https://teguhth.blogspot.com/2025/06/simulation-connection-java-to-mariadb.html
1. Script java
[root@teguhth maria]# cat queryjoin.java
import java.sql.*;
public class queryjoin {
public static void main(String[] args) {
String url = "jdbc:mariadb://10.10.10.90:3306/teguhth"; // Ganti IP jika perlu
String user = "admin";
String pass = "admin";
try {
Connection conn = DriverManager.getConnection(url, user, pass);
// Jalankan query
// String query = "select b.NAMA_BARANG,s.NAMA_SUPLIER,p.TANGGAL_PASOK,p.JUMLAH_PASOK from barang b,suplier s,pasok p where b.KODE_BARANG=p.KODE_BARANG and s.KODE_SUPLIER=p.KODE_SUPLIER;";
//String query = "SELECT b.NAMA_BARANG, s.NAMA_SUPLIER, p.TANGGAL_PASOK, p.JUMLAH_PASOK, (SELECT SLEEP(20)) as DELAY FROM barang b, suplier s, pasok p WHERE b.KODE_BARANG = p.KODE_BARANG AND s.KODE_SUPLIER = p.KODE_SUPLIER;";
//String query ="select * from pembelian;";
Thursday, June 5, 2025
.::: Simulation connection java to MariaDB for Success & Fail using mysql-connector-j-8.0.33.jar (MySQL Driver) (com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure. The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.) :::..
https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/8.0.33/mysql-connector-j-8.0.33.jar
java -version
dnf install java-17-openjdk-devel -y # CentOS 9
2. check login mariadb
[root@teguhth ~]# mysql -h 10.10.10.90 -uadmin -p teguhth
mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 20
Server version: 11.4.4-MariaDB-log MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
.::: Simulation connection java to MariaDB for Success & Fail using mariadb-java-client-3.5.3.jar (MariaDB Driver) (java.sql.SQLNonTransientConnectionException: Socket fail to connect to 10.10.10.9. No route to host) :::.
1. Download (Platform independent)
https://mariadb.com/downloads/connectors/connectors-data-access/java8-connector
java -version
dnf install java-17-openjdk-devel -y # CentOS 9
2. check login mariadb
[root@teguhth ~]# mysql -h 10.10.10.90 -uadmin -p teguhth
mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 20
Server version: 11.4.4-MariaDB-log MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Monday, June 2, 2025
.::: Move TempDB to other folder (move SQL Server MDF and LDF Files location):::.
correlation https://teguhth.blogspot.com/2023/06/move-sql-server-mdf-and-ldf-files.html
1. check
sp_helpdb tempdb
USE tempdb;
GO
SELECT
name AS [Logical Name],
physical_name AS [File Path],
type_desc AS [File Type],
size * 8 / 1024 AS [Size (MB)],
max_size,
growth,
is_percent_growth
FROM sys.master_files
WHERE database_id = DB_ID('tempdb');
SELECT name, physical_name FROM sys.master_files WHERE database_id = DB_ID('tempdb');
Tuesday, May 27, 2025
.::: Quary query to simulation High CPU & High Memory Usage In EDB PostgreSQL :::.
A. Simulation High CPU
1. Contoh query untuk Simulasi CPU Tinggi
Untuk mensimulasikan CPU utilization tinggi di PostgreSQL menggunakan query, kamu bisa menjalankan perintah yang bersifat berat secara berulang, misalnya:
PERINGATAN!
Skrip di bawah akan membuat CPU usage PostgreSQL tinggi, gunakan di lingkungan development/test, bukan production.
CREATE OR REPLACE PROCEDURE cpu_hog()
LANGUAGE plpgsql
AS $$
DECLARE
start_time timestamp := clock_timestamp();
elapsed interval;
i integer := 0;
j double precision := 0;
BEGIN
LOOP
j := sqrt(i * random());
i := i + 1;
elapsed := clock_timestamp() - start_time;
EXIT WHEN elapsed >= interval '20 seconds';
END LOOP;
END;
$$;
Thursday, May 22, 2025
.::: Shell Script Kasir cashier with & Without MariaDB :::.
A. Simple Cashier without Database
1. Struktur File listbarang.txt
2. Script: kasir.sh
[root@teguhth program]# cat kasir.sh
#!/bin/bash
file_barang="listbarang.txt"
# Fungsi untuk menampilkan daftar barang
tampilkan_barang() {
echo -e "\nDaftar Barang:"
echo "---------------------------"
while IFS="|" read -r id nama harga
do
echo "$id. $nama - Rp$harga"
done < "$file_barang"
echo "---------------------------"
}
Monday, May 19, 2025
.::: Quary to simulation High CPU & High Memory Usage In MySQL MariaDB :::.
A. Simulation High CPU
1. Contoh untuk Simulasi CPU Tinggi
Untuk mensimulasikan CPU utilization tinggi di SQL Server menggunakan T-SQL, kamu bisa menjalankan perintah yang bersifat berat secara berulang, misalnya:
PERINGATAN!
Skrip di bawah akan membuat CPU usage SQL Server tinggi, gunakan di lingkungan development/test, bukan production.
USE teguhth;
DELIMITER $$
DROP PROCEDURE IF EXISTS CPU_HOG$$
CREATE PROCEDURE CPU_HOG()
BEGIN
DECLARE i INT DEFAULT 0;
DECLARE j DOUBLE DEFAULT 0;
WHILE i < 10000000 DO
SET j = SQRT(i * RAND());
SET i = i + 1;
END WHILE;
END$$
DELIMITER ;
Wednesday, May 14, 2025
.::: Quary T-SQL to simulation High CPU & High Memory Usage In SQL Server :::.
A. Simulation High CPU
1. Contoh T-SQL untuk Simulasi CPU Tinggi
Untuk mensimulasikan CPU utilization tinggi di SQL Server menggunakan T-SQL, kamu bisa menjalankan perintah yang bersifat berat secara berulang, misalnya:
PERINGATAN!
Skrip di bawah akan membuat CPU usage SQL Server tinggi, gunakan di lingkungan development/test, bukan production.
USE tempdb;
GO
IF OBJECT_ID('dbo.CPU_HOG') IS NOT NULL
DROP PROCEDURE dbo.CPU_HOG;
GO
CREATE PROCEDURE dbo.CPU_HOG
AS
BEGIN
DECLARE @i INT = 0;
DECLARE @j FLOAT = 0;
WHILE (@i < 10000000)
BEGIN
SET @j = SQRT(@i * RAND()); -- operasi matematika berat
SET @i = @i + 1;
END
END;
GO
Tuesday, May 6, 2025
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 ...