Thursday, August 5, 2021

.::: Install MongoDB 5.x on Centos/Redhat 7 using repository :::.

 
1. Create repo the /etc/yum.repos.d/mongodb-org-5.0.repo file for MongoDB.

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

Monday, August 2, 2021

.::: Change Standby Slave Database to Master/Normal on PostgreSQL ERROR: cannot execute CREATE DATABASE in a read-only transaction :::.

 
 
A. Change Database Standby/Slave to Normal /Master

1. test create database for test write
teguhth=# create database tka;
ERROR:  cannot execute CREATE DATABASE in a read-only transaction
teguhth=# 

2. Promote Standby/Slave

/usr/pgsql-13/bin/pg_ctl promote -D /var/lib/pgsql/13/data

[root@teguhth02 ~]# su - postgres
Last login: Sun Aug  1 15:14:46 WIB 2021 on pts/0
-bash-4.2$ /usr/pgsql-13/bin/pg_ctl promote -D /var/lib/pgsql/13/data
waiting for server to promote.... done
server promoted
-bash-4.2$

.::: How to Setting Streaming replication Redundant / Mirroring (Master Slave) postgreSQL 13 on Centos 7 :::.

 
A. 

B. Setting di Master Node
1. Create user replication

su - postgres

CREATE USER replicate REPLICATION LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD 'admin'

[root@teguhth01 13]# su - postgresq;
su: user postgresq does not exist
[root@teguhth01 13]# su - postgres
Last login: Sun Aug  1 13:38:09 WIB 2021 on pts/0
-bash-4.2$ 
-bash-4.2$ 
-bash-4.2$ psql
psql (13.3)
Type "help" for help.

Saturday, July 24, 2021

.::: Install postgreSQL Linux using Repository Centos 7 & PostgreSQL 14 :::.

 
A. Install progress using Repository CentOS 7.
1. Update Server (optional)
[root@teguhth01 ~]# yum -y update

2. Install PostgreSQL
[root@teguhth01 ~]# yum install postgresql-server postgresql-contrib -y

3. Inisialisasi Database
[root@teguhth01 ~]# postgresql-setup initdb
Initializing database ... OK
systemctl start postgresql

Thursday, July 8, 2021

.::: Importing Exsiting server or cluster MySQL/MariaDB using Severalnines :::.

 1. Generate an SSH key to be used by ClusterControl when connecting to all managed hosts. In this example, we are using the root user to connect to the managed hosts. To generate an SSH key for the root user

[root@teguhth ~]# ssh-keygen -t rsa

2. Before creating or importing a database server/cluster into ClusterControl, set up passwordless SSH from the ClusterControl host to the database host(s). Use the following command to copy the SSH key to the target hosts

Wednesday, July 7, 2021

.::: Install & Configuration Cluster control Severalnines for HA MariaDB, MySQL :::.

A. Setup ClusterControl repository 
1. Manually import the Severalnines repository public key into your RPM keyring:
[root@teguhth data]# wget http://repo.severalnines.com/severalnines-repos.asc
[root@teguhth data]# rpm --import severalnines-repos.asc 
[root@teguhth data]# 

Tuesday, July 6, 2021

.::: How to Create HA (High Availability) MariaDB/MySQL uting Galera Cluster on Linux (Include trouble shoot Crash case :::.

A. Installation Galera Cluster (example on 3 node = node1, node2, node3)
1. Disable selinux
[root@teguhth01 ~]# sestatus
SELinux status:                 disabled
[root@teguhth01 ~]# cat /etc/selinux/config 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 

[root@teguhth01 ~]# 
 

Wednesday, June 30, 2021

.::: Implementation Store Procedure on Datawarehouse SQL Server ( Sample table barang, customer, suplier, pasok & pembelian) :::.

 
1. add table barang
-- if using Query SQL
select * from barang;
insert into barang(KODE_BARANG,NAMA_BARANG,SATUAN_BARANG,STOK_BARANG) values('ELK-01','RICE COOKER','BUAH',20);
insert into barang(KODE_BARANG,NAMA_BARANG,SATUAN_BARANG,STOK_BARANG) values('ELK-02','LEMARI ES','UNIT',8);
insert into barang(KODE_BARANG,NAMA_BARANG,SATUAN_BARANG,STOK_BARANG) values('ELK-03','TELEVISI','UNIT',30);
insert into barang(KODE_BARANG,NAMA_BARANG,SATUAN_BARANG,STOK_BARANG) values('ELK-04','RADIO/TAPE','BUAH',35);
insert into barang(KODE_BARANG,NAMA_BARANG,SATUAN_BARANG,STOK_BARANG) values('ELK-05','KOMPUTER','UNIT',28);
insert into barang(KODE_BARANG,NAMA_BARANG,SATUAN_BARANG,STOK_BARANG) values('ELK-06','KIPAS ANGIN','BUAH',38);
select * from barang;

.::: Create table Inventory Datawarehouse SQL Server Original (Converting script from SQL Studio :::.


A. Create Database & Table 

create database teguhth
go

1. Table barang

-- table barang with index
CREATE TABLE [dbo].[barang](
[KODE_BARANG] [char](6) NOT NULL,
[NAMA_BARANG] [varchar](25) NULL,
[SATUAN_BARANG] [varchar](20) NULL,
[STOK_BARANG] [decimal](4, 0) NULL,
PRIMARY KEY CLUSTERED ([KODE_BARANG] ASC))

Monday, June 28, 2021

.::: Create Stored Procedure & Function Using SQL Server (Sample database moonton Mobile Legend) :::.

Stored Procedure

Stored Procedure merupakan sekumpulan perintah-perintah SQL yang tersimpan dengan nama tertentu dan diproses sebagai sebuah kesatuan. Bisa diakatan sebuah sub program yang tersimpan di database.

Membuat Function

Function adalah suatu blok SQL yang memiliki konsep sama dengan procedure, hanya saja pada function terdapat pengembalian nilai (return value)

A. Create database
create database mobile_legend
go

Thursday, June 24, 2021

.::: Basic Store Procedure SQL Server :::.


1. Sample 1
-- SQL Query 1
select kode_barang, stok_barang from barang;

-- Store Procedure 1
create procedure kodestokbarang 
as 
select kode_barang, stok_barang from barang;

Thursday, May 20, 2021

.::: Create Linked Server MSSQL to use Open Query (to another MSSQL) insert, update, delete :::.


A. Preconfigurasi

1. Konfiguration ODBC Data Source (64)
No Need Configuration ODBC

2. create Linked Server
Server Objects -> Linked Servers -> New Linked Server
General
Linked Server: MSSQL
Server Type: SQL Server
or 
Linked Server: MSSQL\instance
Linked Server: IP_SQLServer\instance

.::: Create Linked Server MSSQL to use Open Query (Oracle) insert, update, delete :::.


A. Preconfigurasi
1. Konfiguration ODBC Data Source (64)

No Need Configuration ODBC


2. create Linked Server
Server Objects -> Linked Servers -> New Linked Server
General
Linked Server: Oracle
Provider: Oracle Provider for OLE DB
Product name: Oracle
Data Source: localhost:1521/tka

Popular Posts