Rabu, 27 Februari 2019

CentOS 7 : How to setup yum repository using locally mounted iso


1. Copy iso file to some directory. For example /home/iso/

   
# cd /home
# mkdir iso
# cd iso

   Copy iso file to prepare directory, what ever methode you use
   list file on it

# ls
   

2. Mount the CentOS 7 installation media ISO to some directory. For example /media/CentOS

# mkdir -p /media/CentOS

   Edit file /etc/fstab make add line like this
  
/home/iso/CentOS-7-1810.iso    /media/CentOS iso9660    loop,ro        0 0

   Mount iso file to prepare directory

# mount -a

   if No Error you can check on folder /media/CentOS
  
# cd /media/CentOS
# ls

3. remove/backup all repo on /etc/yum.repo.d/

# cd /etc/yum.repo.d
# mv *.repo /root/

   copy back file CentoOS-Media.repo to /etc/yum.repo.d/

# cd
# cp CentOS-Media.repo /etc/yum.repo.d/

   edit fiel /etc/yum.repo.d/CentOS-Media.repo
  
# vi /etc/yum.repo.d/CentOS-Media.repo

   edit like this

[c7-media]
name=CenOS-$releasever - Media
baseurl=file:///media/CentOS/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7


4. Make sure you clear the related caches by yum clean all and subscription-manager clean once.
  
# yum clean all


Kamis, 31 Januari 2019

Deploy java API as service in linux CentOS 6


For sample i use uereka microservices

  1. Create user for running API

    # useradd api
    # passwd api

  2. login as api create directory eureka for put jar file, copy jar file to /home/api/eureka

    # mkdir eureka

  3. Create script wrapper for system V init in /home/api/eureka


    #!/bin/sh
    ### BEGIN INIT INFO
    # chkconfig: 345 98 01
    # description: Startup Script for Eureka API
    # Provides:          Eureka
    ### END INIT INFO

    SCRIPT="nohup java -jar -DSpring.profiles.active=cloud1 /home/api/eureka/eureka-service.jar"
    RUNAS=api

    PIDFILE=/home/api/eureka/eureka-api.pid
    LOGFILE=/home/api/eureka/eureka-api.log

    start() {
      if [ -f $PIDFILE ] && [ -s $PIDFILE ] && kill -0 $(cat $PIDFILE); then
        echo 'Eureka already running' >&2
        return 1
      fi
      cd /home/api/eureka
      echo 'Starting service… Eureka' >&2
      local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
      su -c "$CMD" $RUNAS > "$PIDFILE"
        
      # Try with this command line instead of above if not workable
      # su -s /bin/sh $RUNAS -c "$CMD" > "$PIDFILE"
      # or
      # nohup java -jar -DSpring.profiles.active=cloud1 /home/api/eureka/eureka.jar &> /home/api/eureka/eureka-api.log & echo $! > $PIDFILE

      PID=$(cat $PIDFILE)
        if pgrep -u $RUNAS -f eureka-service.jar > /dev/null
        then
          echo "API Eureka is now running, the PID is $PID"
        else
          echo ''
          echo "Error! Could not start Eureka !"
        fi
    }
      
    stop() {
      if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
        echo 'Service Eureka not running' >&2
        return 1
      fi
      echo 'Stopping service…' >&2
      kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
      echo 'Service Eureka stopped' >&2
    }
      
    uninstall() {
      echo -n "Are you really sure you want to uninstall this service? That cannot be undone. [yes|No] "
      local SURE
      read SURE
      if [ "$SURE" = "yes" ]; then
        stop
        rm -f "$PIDFILE"
        echo "Notice: log file was not removed: $LOGFILE" >&2
        update-rc.d -f eureka remove
        rm -fv "$0"
      fi
    }
      
    status() {
        printf "%-50s" "Checking Eureka ..."
        if [ -f $PIDFILE ] && [ -s $PIDFILE ]; then
           PID=$(cat $PIDFILE)
                if [ -z "$(ps axf | grep ${PID} | grep -v grep)" ]; then
                    printf "%s\n" "The process appears to be dead but pidfile still exists"
                else  
                    echo "Running, the PID is $PID"
                fi
        else
            printf "%s\n" "Service Eureka not running"
        fi
    }
      
      
    case "$1" in
      start)
        start
        ;;
      stop)
        stop
        ;;
      status)
        status
        ;;
      uninstall)
        uninstall
        ;;
      restart)
        stop
        start
        ;;
      *)
        echo "Usage: $0 {start|stop|status|restart|uninstall}"
    esac
      

  4. Enable service in system V and start eureka

    # sudo ln -s /home/api/eureka/eureka /etc/init.d/eureka
    # sudo chkconfig --add eureka
    # sudo chkconfig eureka on
    # sudo service eureka start

  5. Firewall

    # iptables -I INPUT -p tcp --destination-port 8761 -j ACCEPT
    # service iptables save

Rabu, 30 Januari 2019

Install Tomcat 8 on a CentOS 6


In the following tutorial you will learn how to install and set-up Apache Tomcat 8 on your CentOS 6

What is Tomcat?

Apache Tomcat (before known as Jakarta Tomcat) is an application server developed by the Apache Software Foundation that executes Java servlets and renders Web pages that include Java Server Page coding.


UPDATE THE SYSTEM


Make sure you are in a your CentOS 6 based Linux Server is up-to-date by running:

# yum update


INSTALL JAVA 8


Download the latest JAVA 8 from  here or use the following command to download JAVA JDK

# wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.rpm" \
-O /tmp/jdk-8u201-linux-x64.rpm

once the JAVA package has been downloaded, install it using rpm as follows:

# rpm -Uvh /tmp/jdk-8u201-linux-x64.rpm

CONFIGURE JAVA

configure the newly installed JAVA package using alternatives as in:

# alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_201-amd64/jre/bin/java 20000
# alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0_201-amd64/bin/jar 20000
# alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_201-amd64/bin/javac 20000
# alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.8.0_201-amd64/jre/bin/javaws 20000
# alternatives --set java /usr/java/jdk1.8.0_201-amd64/jre/bin/java
# alternatives --set javaws /usr/java/jdk1.8.0_201-amd64/jre/bin/javaws
# alternatives --set javac /usr/java/jdk1.8.0_201-amd64/bin/javac
# alternatives --set jar /usr/java/jdk1.8.0_201-amd64/bin/jar

check the JAVA version running on your system:

# java -version

INSTALL TOMCAT 8

Create a separate user which will run the Tomcat server:

# useradd tomcat8

Download the latest Tomcat 8 version from here or use the following command to download Tomcat

# wget https://www-eu.apache.org/dist/tomcat/tomcat-8/v8.5.37/bin/apache-tomcat-8.5.37.tar.gz -P /tmp

Extract the contents of the Tomcat archive to /opt using the following command:

# tar zxf /tmp/apache-tomcat-8.5.37.tar.gz -C /opt

make symbolic link

# ln -s /opt/apache-tomcat-8.5.37 /opt/tomcat8

change permission

# chown -hR tomcat8: /opt/tomcat8 /opt/apache-tomcat-8.5.37
# cd /opt/tomcat8/bin
# chmod +x *.sh


START THE TOMCAT 8 SERVICE

Create the following init script in /etc/init.d/tomcat8

#!/bin/sh
### BEGIN INIT INFO
# chkconfig: 345 84 16
# description: Tomcat Jakarta JSP Server
# Provides: Tomcat
### END INIT INFO

JAVA_HOME=/usr/java/jdk1.8.0_201-amd64
export JAVA_HOME

## IF NEEDED 
#JAVA_OPTS="-Dfile.encoding=UTF-8 \
#  -Dnet.sf.ehcache.skipUpdateCheck=true \
#  -XX:+UseConcMarkSweepGC \
#  -XX:+CMSClassUnloadingEnabled \
#  -XX:+UseParNewGC \
#  -XX:MaxPermSize=128m \
#  -Xms512m -Xmx512m"
# export JAVA_OPTS

PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/opt/tomcat8

STARTSCRIPT="/opt/tomcat8/bin/startup.sh"
STOPSCRIPT="/opt/tomcat8/bin/shutdown.sh"
RUNAS=tomcat8

PIDFILE=/opt/tomcat8/tomcat8.pid
LOGFILE=/opt/tomcat8/tomcat8.log

start() {

  TOMCATLIVE=$(pgrep -u tomcat8 -f bootstrap.jar | wc -l)
  if [ "$TOMCATLIVE" -eq 0 ]; then
    echo 'Starting Jakarta Tomact service …' >&2
    local CMD="$STARTSCRIPT &> \"$LOGFILE\" & echo \$!"
    su -l $RUNAS -c "$CMD" > "$PIDFILE"
  sleep 2
  PID=$(cat $PIDFILE)

    if pgrep -u $RUNAS -f bootstrap.jar > /dev/null
    then
      echo "Jakarta Tomcat is now running, the PID is $PID"
    else
      echo ''
      echo "Error! Could not start Jakarta Tomcat!"
    fi

  else
    echo 'Service Jakarta Tomcat all ready running' >&2
    return 1
  fi
  
}

stop() {

  TOMCATLIVE=$(pgrep -u tomcat8 -f bootstrap.jar | wc -l)
  if [ "$TOMCATLIVE" -eq 0 ]; then
    echo 'Service Jakarta Tomcat not running' >&2
    return 1
  fi
  echo 'Stopping Jakarta Tomcat service …' >&2
  su -l $RUNAS -c $STOPSCRIPT
  rm -f "$PIDFILE"
  echo 'Service Jakarta Tomcat stopped' >&2

}

uninstall() {
  echo -n "Are you really sure you want to uninstall this service? That cannot be undone. [yes|No] "
  local SURE
  read SURE
  if [ "$SURE" = "yes" ]; then
    stop
    rm -f "$PIDFILE"
    echo "Notice: log file was not removed: $LOGFILE" >&2
    update-rc.d -f tomcat8 remove
    rm -fv "$0"
  fi
}

status() {

TOMCATLIVE=$(pgrep -u tomcat8 -f bootstrap.jar | wc -l)
TOMCATPIDLIVE=$(pgrep -u tomcat8 -f bootstrap.jar )
if [ "$TOMCATLIVE" -eq 0 ]; then
  echo -n "Jakarta Tomcat Stopped"
  echo
else
  echo "Jakarta Tomcat Running, the PID is $TOMCATPIDLIVE "
fi

}


case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
    status
    ;;
  uninstall)
    uninstall
    ;;
  restart)
    stop
    start
    ;;
  *)
    echo "Usage: $0 {start|stop|status|restart|uninstall}"
esac

make the script executable using chmod

# chmod +x /etc/init.d/tomcat8

Add the Tomcat 8 service to system startup:

# chkconfig --add tomcat8
# chkconfig tomcat8 on

Start the Tomcat 8 server using:

# service tomcat8 start

Configuring Firewall

# iptables -I INPUT -p tcp --destination-port 8080 -j ACCEPT
# service iptables save
# ip6tables -I INPUT -p tcp --destination-port 8080 -j ACCEPT
# service ip6tables save

Access your newly installed Tomcat at http://YOUR_IP:8080

Minggu, 27 Januari 2019

How to Disable SELinux on CentOS


By default in CentOS 7, SELinux is enabled and in enforcing mode.

It is recommended to keep SELinux in enforcing mode, but in some cases, you may need to set it to permissive mode or disable it completely.

In this tutorial, we will show you how to disable SELinux on CentOS 7 systems.


Disable SELinux

You can temporarily change the SELinux mode from targeted to permissive with the following command:

# setenforce 0

However, this change will be valid for the current runtime session only.

To permanently disable SELinux on your CentOS 7 system, follow the steps below:

Open the /etc/selinux/config file and set the SELINUX mod to disabled:

# 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 these two values:
#       targeted - Targeted processes are protected,
#       mls - Multi Level Security protection.
SELINUXTYPE=targeted

Save the file and reboot your CentOS system with:

# shutdown -r now

Once the system boots up, verify the change with the sestatus command:

# sestatus

The output should look like this:

SELinux status:                 disabled

Conclusion

In this tutorial, you learned how to permanently disable SELinux on a CentOS 7 machine.
You may wish to visit the CentOS SELinux guide and learn more about the powerful features of SELinux.


Kamis, 17 Januari 2019

Quit Bash Shell Without Saving Bash History


Sometimes it is very useful to delete / remove Bash history partially or completely when log out. Here is my favourite methods howto log out / quit / exit Bash shell without saving Bash history.

Remove Only Current Session Bash History and Leave Older History Untouched

  1. Quit Bash Shell Without Saving History: Unset HISTFILE

  2. # unset HISTFILE && exit

  3. Quit Bash by Killing you Current Consolel Without Saving History: Kill Console

  4. # kill -9 $$

  5. Quit Bash Shell Without Saving History: Clear History Option

  6. #history -c && exit

  7. Set your Bash Shelll history to Zero(0):  Set HISTSIZE 0

  8. #HISTSIZE=0 && exit


Remove/Delete Bash History Completely

  1. Quit Bash Shell Without Saving History: Delete HISTFILE and Unset HISTFILE

  2. #rm -f $HISTFILE && unset HISTFILE && exit


If you want make these commands more permanent then these commands could be added on ~/.bash_logout file or used with aliases.

echo "alias nohistory='history -c && exit'" >> ~/.bash_logout


Run the remote linux graphics application locally


Overview

The X Window System (also known as X11, or just X) is a software package and network protocol that lets you interact locally,
using your personal computer's display, mouse, and keyboard, with the graphical user interface (GUI) of an application running on a remote networked computer.

Requirements

For X forwarding in SSH to work your personal computer must be running an X server program.
The X server program manages the interaction between the remote application (the X client) and your computer's graphics hardware and input devices.

Most Linux distributions have the X server installed,
but if your personal computer is running Windows, you will most likely need to install and run an X server application, for example:

  • Xming, download and install Xming. For X forwarding to work, you'll need to start Xming before connecting to the remote system with your SSH client (for example, PuTTY).

  • MobaXTerm, download and install MobaXTerm

but now we will only focus Xming

Additionally, your personal computer's SSH terminal application must have X11 forwarding enabled:

  • In Linux, the SSH terminal supports X forwarding by default.

  • if not you can edit the sshd_config file

vi /etc/ssh/sshd_config

change for the lines below:

X11Forwarding yes
X11UseLocalhost yes

Restart the ssh srever, if you have made changes:

service sshd restart

  • In PuTTY for Windows, you can enable X forwarding new or saved SSH sessions by selecting Enable X11 forwarding in the "PuTTY Configuration" window ( Connection  > SSH > X11).
Also, the remote computer's SSH application must be configured to accept X server connections.


Use SSH with X forwarding

Linux

To use SSH with X forwarding from your Linux personal computer to run an X client application installed on remote server:

  1. Open the SSH terminal client.

  2. On the command line, enter (replacing username with your username):

  3. ssh -Y username@host

    note
    The -Y option turns on trusted X forwarding. You should use it only when connecting to secure systems.

  4. Log in with your password

  5. To test if X forwarding is working, try running xclock; on the command line, enter:

    xclock

    If X forwarding is working, the xclock graphical clock will appear on your personal computer's desktop.

PuTTY for Windows

To use SSH with X forwarding in PuTTY for Windows:

  1. Launch your X server application (for example, Xming).

  2. Make sure your connection settings for the remote system have Enable X11 forwarding selected; in the "PuTTY Configuration" window, see Connection > SSH > X11

     

  3. Open an SSH session to the desired remote system:

  4. Log in normally with your username and password.

To test if X forwarding is working, try running xclock; on the command line, enter:

If X forwarding is working, the xclock graphical clock will appear on your personal computer's desktop.

 How to start X application from SSH [simple way]
 
A short command

ssh -X username@host xapplication

note
The -X  is Enable X11 Forwarding.

Rabu, 18 Mei 2016

SymmetricDS

SymmetricDS

SymmetricDS adalah tools Open Source dalam hal Distributed database, replikasi dan/atau transformasi data.
Tools ini juga cross platform baik database maupun operatin System nya, jadi bisa di aplikasikan di Windows
maupun linux dan juga hampir semua mainstream database sudah di support.

OK tanpa berlama-lama lagi, ikuti saja langkah-langkahnya. dalam tutorial di bawah ini saya menggunakan
OS linux dan database oracle dengan asumsi 1 server sebagai HQ dan 1 lagi sebagai server store

* Download SymmetricDS dari Webnya
 
  http://www.symmetricds.org/download

  pada saat tutorial ini di buat symmetrcds sudah versi 3.7.33

* buat folder /opt/symds di kedua node (server HQ dan server Store)

* extract source symmetric DS kemudian move ke folder yg telah kita sediakan di kedua node (server HQ dan server Store)

* copy file /opt/symds/samples/corp-000.properties ke /opt/symds/engines/hq-0000.properties
  di node HQ

* edit hq-0000.properties sesuaikan dengan settinga database kita

    engine.name=hq-0000
    # The class name for the JDBC Driver
    db.driver=oracle.jdbc.driver.OracleDriver

    # The JDBC URL used to connect to the database
    db.url=jdbc:oracle:thin:@192.168.9.6:1521:orcl

    # The user to login as who can create and update tables
    db.user=symds

    # The password for the user to login as
    db.password=symds

    registration.url=
    sync.url=http://192.168.9.6:31415/sync/hq-0000

    # Do not change these for running the demo
    group.id=hq
    external.id=0000

    # Don't muddy the waters with purge logging
    job.purge.period.time.ms=7200000

    # This is how often the routing job will be run in milliseconds
    job.routing.period.time.ms=5000
    # This is how often the push job will be run.
    job.push.period.time.ms=10000
    # This is how often the pull job will be run.
    job.pull.period.time.ms=10000
    # Kick off initial load
    initial.load.create.first=true

* copy file /opt/symds/samples/store-001.properties ke /opt/symds/engines/store-0001.properties
  di node Store

* edit store-0001.properties sesuaikan dengan settinga database kita di server store

    engine.name=store-0001

    # The class name for the JDBC Driver
    db.driver=oracle.jdbc.driver.OracleDriver

    # The JDBC URL used to connect to the database
    db.url=jdbc:oracle:thin:@192.168.9.29:1521:orcl

    # The user to login as who can create and update tables
    db.user=symds

    # The password for the user to login as
    db.password=symds

    # The HTTP URL of the root node to contact for registration
    registration.url=http://192.168.9.6:31415/sync/hq-0000

    # Do not change these for running the demo
    group.id=store
    external.id=0001

    # This is how often the routing job will be run in milliseconds
    job.routing.period.time.ms=5000
    # This is how often the push job will be run.
    job.push.period.time.ms=10000
    # This is how often the pull job will be run.
    job.pull.period.time.ms=10000
* Siapkan database HQ di server, dan sesuaikan dengan setting di edit tadi, nama databasenya orcl
  di sini kita cretae schema dengan nama symds dan password symds, jika perlu kita juga boleh
  persiapkan table table yg akan kita gunakan nanti.

* Siapkan database Store di server, dan sesuaikan dengan setting di edit tadi, nama databasenya orcl
  di sini kita cretae schema dengan nama symds dan password symds, jika perlu kita juga boleh
  persiapkan table table yg akan kita gunakan nanti.

* jika kita ingin mencoba dengan sample yg di sediakan dari symmetricds kita bisa import ke system kita

    ../bin/dbimport --engine corp-000 --format XML --alter-case create_sample.xml

  perintah di atas jika kita menggunakan sample data dari symds dan engine kita bernama corp-000
  tapi karena kita pakai sample data sendiri bisa kita skip

* jalankan script import SymmedtricDS Tables

    ../bin/symadmin --engine hq-0000 create-sym-tables

* jalankam script import sample data HQ

    ../bin/dbimport --engine hq-0000 insert_config.sql

  file insert_config.sql

    delete from sym_trigger_router;
    delete from sym_trigger;
    delete from sym_router;
    delete from sym_channel where channel_id in ('sale_transaction', 'item');
    delete from sym_node_group_link;
    delete from sym_node_group;
    delete from sym_node_host;
    delete from sym_node_identity;
    delete from sym_node_security;
    delete from sym_node;

    insert into sym_channel 
    (channel_id, processing_order, max_batch_size, enabled, description,last_update_time,create_time)
    values('sales', 1, 100000, 1, 'sales transactional data from store',current_timestamp,current_timestamp);

    insert into sym_channel 
    (channel_id, processing_order, max_batch_size, enabled, description,last_update_time,create_time)
    values('master', 1, 100000, 1, 'master data to store',current_timestamp,current_timestamp);

    insert into sym_node_group (node_group_id,description,last_update_time,create_time)
    values ('hq','Server Group on HQ',current_timestamp,current_timestamp);
    insert into sym_node_group (node_group_id,description,last_update_time,create_time)
    values ('store','Node Group on Store',current_timestamp,current_timestamp);

    insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action)
    values ('hq', 'store', 'W');
    insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action)
    values ('store', 'hq', 'P');

    insert into sym_trigger 
    (trigger_id,source_table_name,channel_id,last_update_time,create_time)
    values('m_price','M_PRICE','master',current_timestamp,current_timestamp);

    insert into sym_trigger 
    (trigger_id,source_table_name,channel_id,last_update_time,create_time)
    values('m_item','M_ITEM','master',current_timestamp,current_timestamp);

    insert into sym_trigger 
    (trigger_id,source_table_name,channel_id,last_update_time,create_time)
    values('m_outlet_price','M_OUTLET_PRICE','master',current_timestamp,current_timestamp);

    insert into sym_trigger 
    (trigger_id,source_table_name,channel_id,last_update_time,create_time)
    values('t_pos_bill','T_POS_BILL','sales',current_timestamp,current_timestamp);

    insert into sym_trigger 
    (trigger_id,source_table_name,channel_id,last_update_time,create_time)
    values('t_pos_bill_item','T_POS_BILL_ITEM','sales',current_timestamp,current_timestamp);

    insert into sym_router 
    (router_id,source_node_group_id,target_node_group_id,router_type,create_time,last_update_time)
    values('hq_2_store', 'hq', 'store', 'default',current_timestamp, current_timestamp);

    insert into sym_router 
    (router_id,source_node_group_id,target_node_group_id,router_type,create_time,last_update_time)
    values('store_2_hq', 'store', 'hq', 'default',current_timestamp, current_timestamp);

    insert into sym_trigger_router 
    (trigger_id,router_id,initial_load_order,last_update_time,create_time)
    values('m_item','hq_2_store', 100, current_timestamp, current_timestamp);

    insert into sym_trigger_router 
    (trigger_id,router_id,initial_load_order,last_update_time,create_time)
    values('m_price','hq_2_store', 100, current_timestamp, current_timestamp);

    insert into sym_trigger_router 
    (trigger_id,router_id,initial_load_order,last_update_time,create_time)
    values('m_outlet_price','hq_2_store', 100, current_timestamp, current_timestamp);

    insert into sym_trigger_router 
    (trigger_id,router_id,initial_load_order,last_update_time,create_time)
    values('t_pos_bill','store_2_hq', 200, current_timestamp, current_timestamp);

    insert into sym_trigger_router 
    (trigger_id,router_id,initial_load_order,last_update_time,create_time)
    values('t_pos_bill_item','store_2_hq', 200, current_timestamp, current_timestamp);

    insert into sym_node
    (node_id,node_group_id,external_id,sync_enabled,sync_url,schema_version,symmetric_version,
    database_type,database_version,heartbeat_time,timezone_offset,batch_to_send_count,
    batch_in_error_count,created_at_node_id) 
    values ('0000','hq','0000',1,null,null,null,null,null,current_timestamp,null,0,0,'0000');

    insert into sym_node
    (node_id,node_group_id,external_id,sync_enabled,sync_url,schema_version,symmetric_version,
    database_type,database_version,heartbeat_time,timezone_offset,batch_to_send_count,
    batch_in_error_count,created_at_node_id) 
    values ('0001','store','0001',1,null,null,null,null,null,current_timestamp,null,0,0,'0000');

    insert into sym_node_security (node_id,node_password,registration_enabled,registration_time,
    initial_load_enabled,initial_load_time,created_at_node_id) 
    values ('0000','5d1c92bbacbe2edb9e1ca5dbb0e481',0,current_timestamp,0,current_timestamp,'0000');

    insert into sym_node_identity values ('0000');
  jika ingin menggunakan sample bawaan dari symmetricds

    ../bin/dbimport --engine corp-000 insert_sample.sql

* jika kita ingin mencoba dengan sample yg di sediakan dari symmetricds kita bisa import ke system kita

    ../bin/dbimport --engine store-001 --format XML --alter-case create_sample.xml

  perintah di atas jika kita menggunakan sample data dari symds dan engine kita bernama corp-000
  tapi karena kita pakai sample data sendiri bisa kita skip

* jalankan HQ service SymmetricDS

    ../bin/sym --engine hq-0000 --port 31415

* jalankan store 0001 service

    ../bin/sym --engine store-0001 --port 31415

* baca dan amati log di screen daemon

* Simulasikan registrasi node store-0001 di HQ

    ../bin/symadmin --engine hq-0000 open-registration store 0001

* simulasikan penulisan data di server Corp (pull). ini contoh data jika menggunakan sample bawaan symmetricds
  sedangkan sample data untuk table yg penulis buat (maaf bukan untuk konsumsi public)

    insert into "item" ("item_id", "name") values (110000055, 'Soft Drink');
    insert into "item_selling_price" ("item_id", "store_id", "price") values (110000055, '001', 0.65);
    insert into "item_selling_price" ("item_id", "store_id", "price") values (110000055, '002', 1.00);

  amati apakah ada perubahan baik di log maupun di database client

* simulasikan penulisan data di store 001 (push). ini contoh data jika menggunakan sample bawaan symmetricds
  sedangkan sample data untuk table yg penulis buat (maaf bukan untuk konsumsi public)

    insert into "sale_transaction" ("tran_id", "store_id", "workstation", "day", "seq")
    values (1000, '001', '3', '2007-11-01', 100);
    insert into "sale_return_line_item" ("tran_id", "item_id", "price", "quantity")
    values (1000, 110000055, 0.65, 1);

* Ada 3 table yg penting untuk memahami cara kerja symmetricds. di sisi pengirim perhatikan table berikut

    * sym_data
      table yg akan merekam semua perubahan data
       
        select * from sym_data order by data_id desc;

    * sym_data_event
      perubahn di eksekusi oleh bath bath yg ada pada table ini

        select * from sym_outgoing_batch where batch_id = x;    -- ganti x dengan angka

    * sym_outgoing_batch
      pastikan perubahan data terekam,terkirim dan terkonfirmasi di server
      gunakan batch id di table sebelumnya

        select * from sym_outgoing_batch where batch_id = ?;    -- ganti x dengan angka

      batch awalnya berstatus "NE" kalau belum terkirim. ketika node penerima mengkonfirmasi pengiriman,
      statusnya berganti "OK" atau "ER" kalau Error

* Disisi penerima, cek table ini
   
    * sym_incoming_batch
      periksa penerimaan data di tabel ini

        select * from sym_incoming_batch where batch_id = ?;    -- ganti x dengan angka

* Sedangkan untuk membuat suatu trigger berikut table yg harus di configurasi

    sym_channel   
    sym_node
    sym_node_group
    sym_node_group_link
    sym_router
    sym_trigger
    sym_trigger_router

* Encrypted Passwords

  properti db.users dan db.password bisa dalam bentuk encrypted text, ini untuk meningkatkan keamanan system.
  text yang di awali dengan enc: menandakan bahwa itu ter encrypt. untuk meng encrypt text ikuti command berikut

    symadmin -e {engine name} encrypt-text text-to-encrypt

  atau

    symadmin -p {properties file} encrypt-text text-to-encrypt

Sementara sekian dulu yah. kritik dan saran sangant saya harapkan

Senin, 05 Januari 2015

How to Rsync from window to Linux

How to Rsync from window to Linux

Install

Linux Ubuntu
#apt-get install rsync

Linux RHEL
#yum install rsync

Windows
-Install Cygwin
  - Net
      - OpenSSH
      - rsync

  - Admin
      - cygrunsrv

Run Cygwin bash
Clik start -> Cygwin -> Cygwin Terminal

#ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
90:c3:0e:c1:47:67:2b:23:f5:39:e7:1d:e6:4f:5f:b4 user@yourpc
The key’s randomart image is:
+–[ DSA 1024]—-+
| …o o |
| .+.= o |
| o.B = . o .|
| + = + + . ..|
| . S . o .E.|
| o ..|
| . .|
| |
| |
+—————–+

#scp /home/user/.ssh/id_rsa.pub root@192.168.10.9:~

On server linux

#touch /root/.ssh/authorized_keys
#cat /root/id_rsa.pub >> /root/.ssh/authorized_keys

On Windows at Cygwin bash shell

test rsync
#rsync -avz root@192.168.10.9:/data/backup/ /cygdrive/c/backup/

Create script/bat command start-from-windows.cmd at c:\opt\scripts\

c:\cygwin\bin\bash.exe -l -c "/cygdrive/c/opt/scripts/rsyncbck.sh

Create script/bash script rsyncbck.sh at c:\opt\scripts\

rsync -avz root@192.168.10.9:/data/backup/ /cygdrive/c/backup/

you can add schedule task on your windows

Kamis, 14 Agustus 2014

Cara mengetahui password Speedy

Untuk mengetahui password speedy kita harus bisa login ke modem ADSL kita
maksudnya adalah kita mengetahui user dan passowrd modem ADSL/Speedy kita

buka command promt jalankan perintah berikut (start->run-> lalu ktik cmd)

    telnet 192.168.1.1 (ini adalah ip default modem speedy sesuaikan dengan modem anda)

setelah ini biasanya akan ada permintaan untuk mengisi password
setelh promt telnet muncul kita hanya perlu ketik show all dan tada muncul deh
username dan password Speedy kita

cara ke dua adalah dengan bantuan aplikasi asterisk key, untuk cara yang cari sendiri aja yah di google

Cara manual update definitions untuk Managed Symantec Endpoint Protection CLient menggunakan .jdb file

Untuk meng Update Managed Client dengan .jdb file:

1. Dari Symantec Endpoint Manager (SEPM), klik Clients
2. Pilih Group yang akan kita update secara manual
3. Edit LiveUpdate Setting Policy
4. Di LiveUpdate Policy, pilih Server Settings di pane kiri
5. DI Pane sebelah kakan, di bawah Third Party Management, enable option
   "Enable third party content managemnt"
6. Di SEP Client, yakinkan client menerima perbuahan policy dengan mengechek
   keberadaan folder 'inbox' di directory di bawah ini

    %ALLUSERSPROFILE%\Symantec\Symantec Endpoint Protection\CurrentVersion\inbox

7. Download .jdb file dari Symantec Security Respon Website:
   
    http://www.symantec.com/security_response/definitions/download/detail.jsp?gid=sep
    http://www.symantec.com/avcenter/defs.download.html    untuk Certified Definitions
    http://www.symantec.com/avcenter/rapidrelease.download.html    untuk Rapid Release Definitions

   Note: rubah extention filw menjadi .jdb file karena biasanya di download dalam zip file
8. untuk mengupdate setiap client, copy .jdb file ke dalam folder di di directory berikut
   
    C:\Program Files\Symantec\Symantec Endpoint Protection Manager\data\inbox\content\incoming untuk 32 bit
    C:\Program Files(x86)\Symantec\Symantec Endpoint Protection Manager\data\inbox\content\incoming    untuk 64 bit

9. setelah beberapa menit .jdb file akan otomatis di proses
   biasanya jika proses sudah berhasil semua file .jdb yang ada akan di remove dari incoming folder

Selasa, 28 Januari 2014

Bagaimana mengubah subnet mask pada Scope DHCP Server

Kadang kala kita butuh untuk expand dari subnet(SuperNetting) dari DHCP Server kita.
Berikut cara mudah untuk melakukannya


Pertama dengan export DHCP scope ke text file.

    netsh dhcp server \\JKTDC001 scope 192.168.1.0 dump  >  c:\dhcpdump.txt

(dimana JKTDC001 adalah nama dari DHCP server dan 192.168.1.0 adalh nama dari scope.)

Kemudian, edit text file dan buat perubahan sesuai dengan yang anda inginkan.
Subnet mask ada di baris pertama.

Ingat untuk merubah nama dari Scope. sebagai contoh, Client menggunakan 192.168.1.0 dengan subnet mask 255.255.255.0 . dan kita ingin merubah ke subnet mask 255.255.252.0 . saya mencoba hanya meribah subnet mask nya saja dan import file dan kita mendapatkan errors.  Ini di karenakan 192.168.1.0 tidak lagi sebagai awal dari subnet, sekarang adalah 192.168.0.0.  kita harus merubah setiap baris dari scope tersebut.   Find and replace adalah cara yang baik.


Kemudian hapus original scope dari DHCP. catatan ini akan menghapus selurus Leases.

Sekarang kita siap untuk import scope baru dari text file.

    netsh exec c:\dhcpdump.txt

Refresh DHCP Server dan anda bisa melihat scope baru.