Oracle Export data rows = 0

29 Sep

Agar oracle exp sukses, untuk export semua table walaupun row table tersebut masih kosong, lakukan langkah – langkah sebagai berikut :

  1. Jalankan perintah berikut : SELECT ‘ALTER TABLE ‘||table_name||’ ALLOCATE EXTENT;’ FROM user_tables WHERE segment_created = ‘NO’;

2. jalankan hasil query langkah 1 = ALTER TABLE ……… ALLOCATE EXTENT;

install offline ntp

29 Jun

  1. download file – file deb
    libevent-core-2.1-6_2.1.8-stable-4_armhf.deb
    libopts25_1%3a5.18.12-4_armhf.deb
    ntpdate_1%3a4.2.8p12+dfsg-4_armhf.deb
    libevent-pthreads-2.1-6_2.1.8-stable-4_armhf.deb
    ntp_1%3a4.2.8p12+dfsg-4_armhf.deb
    sntp_1%3a4.2.8p12+dfsg-4_armhf.deb
  2. install = sudo dpkg -i *.deb
  3. backup konfigurasi
    sudo mv /etc/ntp.conf /etc/ntp.conf.asli
  4. konfigurasi = sudo nano /etc/ntp.conf
    driftfile /var/lib/ntp/ntp.drift
    server 172.20.33.42 iburst
    restrict -4 default kod notrap nomodify nopeer noquery
    restrict -6 default kod notrap nomodify nopeer noquery
    restrict 127.0.0.1
    restrict ::1
  5. jalankan service ntp nya = sudo /etc/init.d/ntp restart
  6. test ntp nya = ntpq -pn remote refid st t when poll reach delay offset jitter 172.20.33.42 103.28.56.14 3 u 1 64 1 0.533 -0.553 0.002
  7. pastikan sistem sudah mengaktifkan ntp = timedatectl status
    Local time: Sel 2021-06-29 09:38:10 WIB
    Universal time: Sel 2021-06-29 02:38:10 UTC
    RTC time: Sel 2021-06-29 02:37:21
    Time zone: Asia/Jakarta (WIB, +0700)
    System clock synchronized: no
    NTP service: inactive
    RTC in local TZ: no
  8. jika belum diaktifkan ntp nya = sudo timedatectl set-ntp true
  9. test time sistem dan bandingkan dengan server = date

menambahkan nama domain di dns server lokal

8 Jun

# nano /etc/named.conf

zone “jitsiubs.ubslinux.com” IN {
type master;
file “/var/named/jitsiubs.ubslinux.com.zone”;
allow-update { none; };
};

# cp /var/named/jitsi.ubsupdates.com.zone /var/named/jitsiubs.ubslinux.com.zone

# nano /var/named/jitsiubs.ubslinux.com.zone

$TTL 86400
@ IN SOA jitsiubs.ubslinux.com. root.jitsiubs.ubslinux.com. (
100 ; serial
1H ; refresh
1M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS ns1.jitsiubs.ubslinux.com.
@ IN A 172.20.140.90
ns1 IN A 172.20.140.90
@ IN MX 10 mail.jitsiubs.ubslinux.com.
mail IN A 172.20.140.90
WWW IN A 172.20.140.90

# service named restart

# nslookup jitsiubs.ubslinux.com

Server: 172.20.33.42
Address: 172.20.33.42#53

Name: jitsiubs.ubslinux.com
Address: 172.20.140.90

Timbangan berbasiskan IP (IP based scales) menggunakan raspberry pi

28 May





1. Raspberry pi difungsikan sebagai interface antara timbangan dengan IP
a. pasang usb to serial converter dari raspberry pi ke timbangan
b. raspberry pi semisal terhubung dengan IP 172.20.35.222
c. membuat coding python untuk akses timbangan
pi@it01:/var/www/html $ nano /var/www/html/timbangan3.py

d. membuat coding php untuk API akses timbangan

pi@it01:/var/www/html $ nano api_timbangan.php
<?php
$data[] = floatval(shell_exec(‘sudo /var/www/html/timbangan3’));
$json = json_encode($data);
echo $json;
?>

2. Webserver memanggil API akses timbangan 172.20.35.222

# nano test.php
<?php
$url = “http://172.20.35.222/api_timbangan.php&#8221;;
$json = file_get_contents($url);
$json = json_decode($json);
$hasil = $json[0];
echo “Berat: ” . $hasil ;
?>

3. Laptop Client mengakses webserver misalkan dengan alamat http://172.20.33.42/monitor/timbangan/test.php

Cetakan esc/pos menggunakan mike42 pada server Centos 7.9

28 May

A. Server Centos 7.9 sudah diinstal dengan lengkap dan benar
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)

# rpm -qa | grep php
php-gd-7.4.19-1.0.1.el7.x86_64
php-opcache-7.4.19-1.0.1.el7.x86_64
php-xml-7.4.19-1.0.1.el7.x86_64
php-zip-7.4.19-1.0.1.el7.x86_64
php-intl-7.4.19-1.0.1.el7.x86_64
php-cli-7.4.19-1.0.1.el7.x86_64
php-mbstring-7.4.19-1.0.1.el7.x86_64
php-json-7.4.19-1.0.1.el7.x86_64
php-7.4.19-1.0.1.el7.x86_64
php-pdo-7.4.19-1.0.1.el7.x86_64
php-devel-7.4.19-1.0.1.el7.x86_64
oracle-php-release-el7-1.0-5.el7.x86_64
php-mysqlnd-7.4.19-1.0.1.el7.x86_64
php-common-7.4.19-1.0.1.el7.x86_64
php-bcmath-7.4.19-1.0.1.el7.x86_64
php-process-7.4.19-1.0.1.el7.x86_64
php-pear-1.10.12-1.0.3.el7.noarch
php-ldap-7.4.19-1.0.1.el7.x86_64

B. INSTALL Printer Thermal WINDOWS10
1. Gunakan driver POS 58
2. Set printer share
3. Control Panel\Network and Internet\Network and Sharing Center\Advanced sharing settings
4. Pastikan smb 1.0 check

C. INSTALL Linux samba client (server Centos)
1. Ingat gunakan samba versi 3.xxx
# smbclient -V
Version 3.6.23-35.0.1.el6_8

# smbclient -V
Version 3.5.8
2. yum install samba samba-client samba-common
3. test print
# nano testing123.txt
1234567890
setijo agus

Perintah ini hanya bisa digunakan di samba 3.xx
# smbclient //172.20.247.23/thermal11 -c “print testing123.txt” -u root
# smbclient //172.20.247.23/thermal11 -c “print testing123.txt” -N
# echo “hello world” | smbclient ‘//172.20.247.23/thermal11’ -c ‘print -‘ -N

Perintah ini bisa digunakan di samba 3.xx maupun samba 4.xx, setelah menambahkan user pada windows misal user = print, password = 123456
# smbclient //172.20.247.23/thermal11 -c “print testing123.txt” -U print 123456

D. menggunakan mike42
# yum install git
# yum install composer
# cd /var/www/html/
# git clone https://github.com/mike42/escpos-php
# cd escpos-php
# yum install php-cli php-zip wget unzip
# php -r “copy(‘https://getcomposer.org/installer&#8217;, ‘composer-setup.php’);”
# HASH=”$(wget -q -O – https://composer.github.io/installer.sig)”
# php -r “if (hash_file(‘SHA384’, ‘composer-setup.php’) === ‘$HASH’) { echo ‘Installer verified’; } else { echo ‘Installer corrupt’; unlink(‘composer-setup.php’); } echo PHP_EOL;”
# chown oracle.apache /var/www/html/escpos-php -R
# su – oracle
~ cd /var/www/html/escpos-php
~ composer install

E. test mike42
~ cd /var/www/html/escpos-php/example/
~ nano test.php
text(“setijo agus\n”);
$printer -> text(“123456\n”);
$printer -> text(“123456\n”);
$printer -> text(“123456\n”);
$printer -> text(“\n”);
$printer -> text(“\n”);
$printer -> text(“\n”);
/* Close printer */
$printer -> close();
} catch (Exception $e) {
echo “Couldn’t print to this printer: ” . $e -> getMessage() . “\n”;
}
?>

$ php test.php

Raspberry Pi – Sensor Temperatur DS18B20

17 Nov

  1. Cek module
    $ sudo modprobe w1-gpio
    $ sudo modprobe w1-therm
  2. Tambahkan module, sehingga setiap booting module selalu di load
    $ sudo nano /etc/modules
    w1-gpio
    w1-therm
  3. Aktifkan 1-wire
    $ sudo raspi-config
  1. Ambil data suhu
    $ cd /sys/bus/w1/devices/
    $ ls
    28-01192a4f2f15 w1_bus_master1
    $ cd /sys/bus/w1/devices/28-01192a4f2f15
    $ cat w1_slave | tail -1 | cut -d’=’ -f2
    25062
  2. Python program
    $ nano /home/pi/ds1b20.py
    import os
    import glob
    import time These tow lines mount the device: os.system(‘modprobe w1-gpio’)
    os.system(‘modprobe w1-therm’) base_dir = ‘/sys/bus/w1/devices/’ Get all the filenames begin with 28 in the path base_dir. device_folder = glob.glob(base_dir + ’28*’)[0]
    device_file = device_folder + ‘/w1_slave’
    def read_rom():
    name_file=device_folder+’/name’
    f = open(name_file,’r’)
    return f.readline() def read_temp_raw():
    f = open(device_file, ‘r’)
    lines = f.readlines()
    f.close()
    return lines def read_temp():
    lines = read_temp_raw()
    # Analyze if the last 3 characters are ‘YES’.
    while lines[0].strip()[-3:] != ‘YES’:
    time.sleep(0.2)
    lines = read_temp_raw()
    # Find the index of ‘t=’ in a string.
    equals_pos = lines[1].find(‘t=’)
    if equals_pos != -1:
    # Read the temperature .
    temp_string = lines[1][equals_pos+2:]
    temp_c = float(temp_string) / 1000.0
    temp_f = temp_c * 9.0 / 5.0 + 32.0
    return temp_c, temp_f print(‘ rom: ‘+ read_rom())
    while True:
    print(‘ C=%3.3f F=%3.3f’% read_temp())
    time.sleep(1)
  3. Running python Program
    $ sudo python /home/pi/ds1b20.py
    rom: 28-01192a4f2f15
    C=25.062 F=77.112
    C=25.062 F=77.112
    C=25.062 F=77.112
    C=25.062 F=77.112
    C=25.062 F=77.112
    C=25.062 F=77.112
  4. Running python Program

Raspberry zero W – external Antena

13 Nov

Perbandingan penambahan antena external pada raspberry zero W

Hasil nya seperti dibawah ini :

Oracle Client – Raspberry Pi

18 Sep

1. install java
pi@raspberrypi:~ $ sudo apt-get update
pi@raspberrypi:~ $ sudo apt-get install openjdk-8-jdk
pi@raspberrypi:~ $ java -version
openjdk version “1.8.0_222”
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1~deb9u1-b10)
OpenJDK Client VM (build 25.222-b10, mixed mode)

2. pilih sqlcl yang cocok
pi@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME=”Raspbian GNU/Linux 9 (stretch)”
NAME=”Raspbian GNU/Linux”
VERSION_ID=”9″
VERSION=”9 (stretch)”
ID=raspbian
ID_LIKE=debian
HOME_URL=”http://www.raspbian.org/&#8221;
SUPPORT_URL=”http://www.raspbian.org/RaspbianForums&#8221;
BUG_REPORT_URL=”http://www.raspbian.org/RaspbianBugs&#8221;

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux

3. download di oracle.com
https://download.oracle.com/otn/java/sqldeveloper/sqlcl-17.4.0.354.2224-no-jre.zip
unzip sqlcl-17.4.0.354.2224-no-jre.zip

4. test
pi@raspberrypi:~ $ alias sqlcl=’/home/pi/sqlcl/bin/sql’
pi@raspberrypi:~ $ sqlcl SCOTT/TIGER@192.168.33.42:1521/servertest

SQLcl: Release 17.4.0 Production on Mon Sep 16 14:28:16 2019
Copyright (c) 1982, 2019, 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> select * from dept;
DEPTNO DNAME LOC
———- ————– ————-
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORA-03113: end-of-file on communication channel

28 Aug

[oracle@production ~]$ sqlplus / as sysdba
SQL> startup;
ORACLE instance started.

Total System Global Area 6680915968 bytes
Fixed Size 2213936 bytes
Variable Size 5033166800 bytes
Database Buffers 1610612736 bytes
Redo Buffers 34922496 bytes
Database mounted.
ORA-03113: end-of-file on communication channel
Process ID: 23383
Session ID: 96 Serial number: 3
SQL> exit

[oracle@production ~]$ sqlplus / as sysdba
SQL> startup mount;

SQL> alter database clear unarchived logfile group 1;
Database altered.

SQL> alter database clear unarchived logfile group 2;
Database altered.

SQL> alter database clear unarchived logfile group 3;
Database altered.
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area 6680915968 bytes
Fixed Size 2213936 bytes
Variable Size 5033166800 bytes
Database Buffers 1610612736 bytes
Redo Buffers 34922496 bytes
Database mounted.
Database opened.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

INSERT / CREATE TABLE ANTAR DATABASE (BEDA DATABASE) ORACLE TANPA DBLINK

22 May

INSERT / CREATE TABLE ANTAR DATABASE (BEDA DATABASE) ORACLE TANPA DBLINK

1. pastikan tnsnames.ora sudah benar dengan mendaftarkan database_source dan database_target
$ cat /u01/app/odatabase_sourcele/product/11.1.0/db_1/network/admin/tnsnames.ora
database_source =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.12)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = database_source)
(INSTANCE_NAME = database_source)
)
)

database_target =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.13)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = database_target)
)
)

2. cek isi table sebelum proses
$ sqlplus SCOTT/TIGER@database_source
SQL> select * from dept;

DEPTNO DNAME LOC
———- ————– ————-
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
41 IT SURABAYA

SQL> exit

$ sqlplus SCOTT/TIGER@database_target
SQL> select * from dept;
DEPTNO DNAME LOC
———- ————– ————-
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> exit

3. test create table baru dari database_source ke database_target
$ sqlplus SCOTT/TIGER@database_target
SQL> copy from scott/TIGER@database_source to scott/TIGER@database_target create dept2 using select * from DEPT where DEPTNO = 41;
Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
Table DEPT2 created.

1 rows selected from scott@database_source.
1 rows inserted into DEPT2.
1 rows committed into DEPT2 at scott@database_target.

SQL> select * from dept;
DEPTNO DNAME LOC
———- ————– ————-
41 IT SURABAYA
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

4. test insert table dari database_source ke database_target
SQL> copy from scott/TIGER@database_source to scott/TIGER@database_target insert dept using select * from DEPT where DEPTNO = 41;
Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
1 rows selected from scott@database_source.
1 rows inserted into DEPT.
1 rows committed into DEPT at scott@database_target.

SQL> select * from dept2;
DEPTNO DNAME LOC
———- ————– ————-
41 IT SURABAYA
SQL> exit