Thursday, August 28, 2025

.::: Install MariaDB GTID Mirroring Monitoring using php :::.

 


install php https://infotechys.com/install-php-8-3-on-rhel-9-centos-9/

1. create bash monitoring 

[root@teguhth03 web]# cat /data/web/server31.sh
#!/bin/bash

# Variabel koneksi
USER="admin"
PASS="xxxxx"
HOST="10.10.10.31"
PORT="3306"

# Test koneksi ke MySQL server
mysql --skip-ssl -u$USER -p$PASS -h$HOST -P$PORT -e "SELECT 1;" >/dev/null 2>&1

 if [ $? -ne 0 ]; then
    echo "{ \"connections\": \"\", \"role\": \"Down\", \"gtid\": \"\",\"hostname\": \"$hostnamex\", \"host\": \"$HOST\", \"port\": \"$PORT\",\"dbv\": \"$versionx\",\"osv\": \"$osx\" }"
    exit 0
fi
 

Thursday, August 21, 2025

.::: Install Microsoft SQL Server 2022 in Centos 9 / Redhat 9 / Almalinux 9 :::.

 

1. disable selinux

2. enable repo 


curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/$(rpm -E %{rhel})/mssql-server-2022.repo

curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repo

curl https://packages.microsoft.com/config/rhel/9/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repo

[root@teguhth data]# curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/$(rpm -E %{rhel})/mssql-server-2022.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   444  100   444    0     0    199      0  0:00:02  0:00:02 --:--:--   199
[root@teguhth data]#
[root@teguhth data]#
[root@teguhth data]# cat /etc/yum.repos.d/mssql-server.repo
[packages-microsoft-com-mssql-server-2022]
name=Microsoft SQL Server 2022
baseurl=https://packages.microsoft.com/rhel/9/mssql-server-2022/
enabled=1
gpgcheck=1
repo_gpgcheck=1
# If installing the bare repo file consider installing the gpg key once and then updating
# this to point to the on-disk location. For example:
# gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Microsoft
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
sslverify=1
[root@teguhth data]#

Wednesday, August 20, 2025

.::: Install MariaDB 10.6 in Ubuntu 22 :::.

  

1. Tambahkan GPG Key mariadb

sudo apt install -y curl software-properties-common gnupg
curl -fsSL https://mariadb.org/mariadb_release_signing_key.asc | sudo gpg --dearmor -o /usr/share/keyrings/mariadb-keyring.gpg

2. Tambahkan Repository mariadb 10.6

deb [arch=amd64,arm64 signed-by=/usr/share/keyrings/mariadb-keyring.gpg] http://mirror.mariadb.org/repo/10.6/ubuntu noble main
 

Friday, August 15, 2025

Thursday, August 14, 2025

.::: Query Check day, hour & early time, check time, different time in MSSQL, MariaDB MySQL, PostgreSQL EDB, Oracle DB to Get the Start of the Current Hour and the Previous Hour :::.

  


A. MSSQL

1. one day before

select @@servername as ServerName, GETDATE() as Currentdate, CAST(CONVERT(date, GETDATE() - 1) AS datetime) as datebefore , CAST(CONVERT(date, GETDATE()) AS datetime) as datecurrent 

INSERT INTO target_table (col1, col2, col3, tanggal)
SELECT col1, col2, col3, tanggal
FROM source_table
WHERE tanggal >= CAST(CONVERT(date, GETDATE() - 1) AS datetime) 
  AND tanggal <  CAST(CONVERT(date, GETDATE()) AS datetime);

Tuesday, July 22, 2025

.::: Simulation Query Select from Java to MariaDB using mariadb-java-client-3.5.3.jar (MariaDB Driver) using MariaDB SSL Certificate :::.

 

openssl pkcs12 -export -in /home/user/certs/client-cert.pem -inkey /home/user/certs/client-key.pem -out /home/user/certs/client-cert.p12 -name client -CAfile /home/user/certs/ca-cert.pem -caname root -passout pass:root

.::: Create User MariaDB MySQL using SSL / Certificate :::.

 

Mengaktifkan TLS/SSL pada MariaDB 10.6 dan jika sudah nanti akan di test dengan user 'adminssl' password 'adminssl' 

Berikut adalah panduan mengaktifkan TLS/SSL di MariaDB 10.6 dan menguji koneksi dengan user adminssl:

1. Buat Direktori & Sertifikat SSL

mkdir -p /etc/mysql/ssl

cd /etc/mysql/ssl


2. Create Certificate 
 

Friday, July 4, 2025

.::: Script Daily Backup MongoDB using Date or Compress :::.

  


1. Script backup full 


#[root@teguhth mongod]# cat backup_mongodb_full_script.sh
##-bash-4.2$ cat backup_mongodb_full_script.sh
echo ""
Server=$(hostname)
ip_address=$(ip a | awk '/inet / && $2 !~ /^127\./ {gsub("addr:","",$2); print $2}')
# Print the IP address
 

Tuesday, June 24, 2025

.::: Sample shell script integration MariaDB to Redis :::.

 



1. run script using mariadb
sh compare_maria_redis.sh mariadb
 


2. run script using redis
sh compare_maria_redis.sh redis
 

.::: Install MongoDB 8 in Centos 9 (mongodb-org-server, mongodb-mongosh) :::.

  
1. download

wget https://repo.mongodb.org/yum/redhat/9/mongodb-org/8.0/x86_64/RPMS/mongodb-org-server-8.0.10-1.el9.x86_64.rpm

2. create repository

[root@teguhth ~]# cat /etc/yum.repos.d/mongodb-org.repo
[mongodb-org-6.0]
name=MongoDB Repository
#baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/6.0/x86_64/
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/9.0/x86_64/
gpgcheck=0
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc
[root@teguhth ~]#

Monday, June 23, 2025

.::: Start the SQL Server Import and Export Wizard From MariaDB to MSSQL using Write a query to specify the data to transfer & compare with Open Query :::.

 

correlation with https://teguhth.blogspot.com/2025/06/start-sql-server-import-and-export.html

A. Prepare

1. MariaDB check sample query 

select * from products where product_name='laptop' or product_name='tablet';

2. create view mariadb 

create view view_produk select * from products where product_name='laptop' or product_name='tablet';

3. test if using open query

select * from openquery([MARIALOCAL],'select * from erpdb.view_produk;')
select * from openquery([MARIALOCAL],'select * from erpdb.products where product_name=''laptop'' or product_name=''tablet'';')

  

Friday, June 20, 2025

.::: Start the SQL Server Import and Export Wizard From MSSQL to MariaDB :::.

 

1. Install ODBC Driver MariaDB MySQL (32 bits) for this case install mysql-connector-odbc-8.0.42-win32

mysql-connector-odbc-8.0.42-win32
mariadb-connector-odbc-3.2.6-win32


2. Setup DSN MariaDB Using MySQL Driver 

# using mysql driver 32 >> pakai yang ini 
Dsn=mysql321;Driver={MySQL ODBC 8.0 Unicode Driver};server=10.10.10.7;uid=admin;pwd=admin;database=erpdb;port=3306

# using maridb driver32
Dsn=maria;Driver={MariaDB ODBC 3.2 Driver};server=10.10.10.7;uid=admin;pwd=admin;database=erpdb;port=3306
 

Wednesday, June 18, 2025

Popular Posts