Disable recent file nautilus

Open a terminal and type the following:
 
1. echo "" > ~/.local/share/recently-used.xbel

2. sudo chattr +i ~/.local/share/recently-used.xbel

Enable recent files nautilus

1. sudo chattr +i ~/.local/share/recently-used.xbel


Good Luck~

docker-ce fedora 26

dnf install https://download.docker.com/linux/fedora/25/x86_64/stable/Packages/docker-ce-17.06.0.ce-1.fc25.x86_64.rpm
 --allowerasin
 
 more info

git-completion bash

[1] install dulu bash_completion

Centos / Fedora
dnf install -y bash_completion

Debian / Ubuntu
sudo apt-get install bash-completion

[2] rubah .bashrc

https://raw.githubusercontent.com/helmuthdu/dotfiles/master/.bashrc

[3] download git-prompt & git-completion 

https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh

taro di /etc/bash_completion.d 

[4] rubah .bashrc

cari /usr/share/git/completion/ dan /usr/share/git/ di .bashrc dan rubah ke /etc/bash_completion.d/

source ~/.bashrc

jenkins rsync for send script to server

Jenkins is a service account, it doesn't have a shell by design. It is generally accepted that service accounts. shouldn't be able to log in interactively.

To resolve "Jenkins Host key verification failed", do the following steps. I have used mercurial with jenkins.

1)Execute following commands on terminal

sudo su -s /bin/bash jenkins
2)Generate public private key using the following command:

ssh-keygen -N  "" -f ~/.ssh/id_rsa -t rsa -b 4096
or
ssh-keygen -N "" -f  ~/.ssh/id_rsa -o -a 100 -t ed25519
https://blog.g3rt.nl/upgrade-your-ssh-keys.html#multi-key-aware-ssh-client

3) Disable prompt Yes/No Authenticity host

echo -e "StrictHostKeyChecking no \nUserKnownHostsFile=/dev/null" > ~/.ssh/config

4)Go to --> cat /var/lib/jenkins/.ssh/id_rsa.pub
5)Copy key from id_rsa.pub to server production or you can use this script

https://denzfarid.blogspot.co.id/2016/12/automate-pushing-of-ssh-copy-id-to.html#

6) open jenkins dashboar , go to your project , cofigure, and in build -> add build step -> execute shell
rsync -e "ssh" -a -P -z --force --include=".htaccess" --include="uploads/" --exclude=".*" . user@production:/var/www/html








source : http://stackoverflow.com/questions/15174194/jenkins-host-key-verification-failed

Install Thumbor Centos and Nginx aliasing url

  1. Update System & install development tools
    yum update -y ; yum groupinstall "development tools" -y
  2. Install Package
    yum install -y epel-release deltarpm openssl-devel sqlite-devel bzip2-devel
  3. Install & config nginx
    yum install -y nginx ; /sbin/chkconfig nginx on;
    create file thumbor.conf
    nano /etc/nginx/conf.d/thumbor.conf
    upstream thumbor  {
        server 127.0.0.1:8000;
        server 127.0.0.1:8001;
        server 127.0.0.1:8002;
        server 127.0.0.1:8003;
    }
    
    server {
        listen       80;
        server_name  <INSERT YOUR DOMAIN NAME>;
        client_max_body_size 10M;
    
        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header HOST $http_host;
            proxy_set_header X-NginX-Proxy true;
    
            proxy_pass http://thumbor;
            proxy_redirect off;
        }
    }
  4. Install Thumbor Lib
    yum install libjpeg-turbo-devel.x86_64 libjpeg-turbo-utils.x86_64 libtiff-devel.x86_64 libpng-devel.x86_64 pngcrush jasper-devel.x86_64 libwebp-devel.x86_64 python-pip -y
    pip install pycurl numpy
    pip install thumbor==4.12.2
    
  5. create file optimizer plugins pngcrush for png
    nano /usr/local/lib64/python2.7/site-packages/thumbor/optimizers/pngcrush.py
    paste this
    #!/usr/bin/python
    # -*- coding: utf-8 -*-
    
    # thumbor imaging service
    # https://github.com/thumbor/thumbor/wiki
    
    # Licensed under the MIT license:
    # http://www.opensource.org/licenses/mit-license
    
    
    import os
    import subprocess
    
    from thumbor.optimizers import BaseOptimizer
    from thumbor.utils import logger
    
    
    class Optimizer(BaseOptimizer):
        def __init__(self, context):
            super(Optimizer, self).__init__(context)
    
            self.runnable = True
            self.pngcrush_path = self.context.config.PNGCRUSH_PATH
            if not (os.path.isfile(self.pngcrush_path) and os.access(self.pngcrush_path, os.X_OK)):
                logger.error("ERROR pngcrush path '{0}' is not accessible".format(self.pngcrush_path))
                self.runnable = False
    
        def should_run(self, image_extension, buffer):
            return 'png' in image_extension and self.runnable
    
        def optimize(self, buffer, input_file, output_file):
            command = '%s -reduce -q %s %s ' % (
                self.pngcrush_path,
                input_file,
                output_file,
            )
            with open(os.devnull) as null:
                subprocess.call(command, shell=True, stdin=null)
    Generate Config file
    thumbor-config > /etc/thumbor.conf
    change LOADER in file thumbor.conf for load file image from server
    LOADER = 'thumbor.loaders.file_loader'
    
  6. enable Optimizer in thumbor.conf
    OPTIMIZERS = [
        'thumbor.optimizers.jpegtran',
        'thumbor.optimizers.pngcrush',
    ]
    
    JPEGTRAN_PATH = '/usr/bin/jpegtran'
    PNGCRUSH_PATH = '/usr/bin/pngcrush'
  7. Install & configure supervisor
    easy_install supervisor
    create file /etc/init.d/supervisord
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides:          supervisord
    # Required-Start:    $remote_fs
    # Required-Stop:     $remote_fs
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Supervisor init script
    # Description:       Supervisor init script    
    ### END INIT INFO
    
    # Supervisord auto-start
    #
    # description: Auto-starts supervisord
    # processname: supervisord
    # pidfile: /var/run/supervisord.pid
    
    SUPERVISORD=/usr/local/bin/supervisord
    SUPERVISORCTL=/usr/local/bin/supervisorctl
    ARGS="-c /etc/supervisord.conf"
    
    case $1 in
    start)
            echo -n "Starting supervisord: "
            $SUPERVISORD $ARGS
            echo
            ;;
    stop)
            echo -n "Stopping supervisord: "
            $SUPERVISORCTL shutdown
            echo
            ;;
    restart)
            echo -n "Stopping supervisord: "
            $SUPERVISORCTL shutdown
            echo
            echo -n "Starting supervisord: "
            $SUPERVISORD $ARGS
            echo
            ;;
    esac
    
    create file /etc/supervisord.conf and paste
    [unix_http_server]
    file=/tmp/supervisor.sock   ; (the path to the socket file)
    
    [supervisord]
    logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)  
    logfile_maxbytes=50MB        ; (max main logfile bytes b4 rotation;default 50MB)  
    logfile_backups=10           ; (num of main logfile rotation backups;default 10)  
    loglevel=info                ; (log level;default info; others: debug,warn,trace)  
    pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)  
    nodaemon=false               ; (start in foreground if true;default false)  
    minfds=1024                  ; (min. avail startup file descriptors;default 1024)  
    minprocs=200                 ; (min. avail process descriptors;default 200)
    
    ; the below section must remain in the config file for RPC
    ; (supervisorctl/web interface) to work, additional interfaces may be
    ; added by defining them in separate rpcinterface: sections
    [rpcinterface:supervisor]
    supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
    
    [supervisorctl]
    serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket
    
    [program:thumbor]
    ; The following command uses a different thumbor config file for each
    ; processes, however we want the same setup for each so that isn't necessary
    ; command=thumbor --ip=127.0.0.1 --port=800%(process_num)s --conf=/etc/thumbor800%(process_num)s.conf
    ; Instead we'll use this command to use just the one conf file
    command=/usr/local/bin/thumbor --ip=127.0.0.1 --port=800%(process_num)s --conf=/etc/thumbor.conf  
    process_name=thumbor800%(process_num)s  
    numprocs=4  
    autostart=true  
    autorestart=true  
    startretries=3  
    stopsignal=TERM  
    ; Output logs for each of our processes
    stdout_logfile=/var/log/thumbor.stdout.log  
    stdout_logfile_maxbytes=1MB  
    stdout_logfile_backups=10  
    stderr_logfile=/var/log/thumbor.stderr.log  
    stderr_logfile_maxbytes=1MB  
    stderr_logfile_backups=10
    
    start supervisord and nginx
    chmod +x supervisord ; /etc/init.d/supervisord start; /etc/init.d/nginx start
  8. optional for custom or change unsafe url add in nginx thumbor configuration
      location ~* /thumb/(.*)/(.*\.(jpg|jpeg|png|gif|JPG))$ {

            proxy_pass http://localhost:8000/unsafe/$1/$2;
        }
     change url http://localhost:8000/unsafe/300x300/file.jpg to
    http://localhost:8000/thumb/300x300/file.jpg

    complate installation in here source

    thank you

Centos 6 Upgrade python 2.6 to python 2.7



Install Paket yang di butuhkan
yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel gcc
yum groupinstall -y 'development tools'
Download Source Python
cd /usr/src;wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz
Extrack and Compile
tar xzf Python-2.7.12.tgz;cd Python-2.7.12;./configure;make -j4;make install;make altinstall
 Optional with Threads and shared
./configure --with-threads --enable-shared;make -j4;make install;make altinstall
error libpython2.7.so.1.0 not found
ln -s /usr/local/lib/libpython2.7.so.1.0 /usr/lib/libpython2.7.so.1.0
ln -s /usr/src/Python-2.7.12/libpython2.7.so.1.0  /usr/lib/libpython2.7.so.1.0

Good Luck

mariadb replication master slave all databases on CentOS

sebelum memulai sebaiknya kita berdoa terlebih dahulu

selesai

setelah berdoa saatnya kita menginstall service mariadb terlebih dahulu pada kedua server tersebut,

buat file repo terlebih dahulu


vi /etc/yum.repos.d/MariaDB.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1


yum install MariaDB-server MariaDB-client -y
systemctl start mariadb
systemctl enable mariadb

jika terdapat konfik atau error dengan maria-libs-xxx

yum remove mariadb-libs*

start service 

 /etc/init.d/mysql start
  
 setup mysql login

mysql_secure_installation

setelah itu pada master

 

Redis snmp monitoring & redis prtg monitoring sensors

setelah install redis lalu bagaimana cara memoitoring redis tersebut, berapa jumlah koneksi yang ada pada redis, berapa jumlah konsumsi memori oleh redis, di sini saya akan membahas monitoring redis menggunakan snmp, dan nanti akan ada lanjutan untuk monitoring PRTG atau cacti nantinya


oke langsung saja

1. install cpan dan snmp perl untuk modulenya untuk depedensi perl, cpan ini seperti layaknya pip atau easy_install pada python
yum install cpan net-snmp-perl -y
2. install module perl yang lain yang di butuhkan oleh aplikasi
cpan -I Unix::Syslog
cpan -I IO::Socket::INET
3. clone redis-snmp dan compile dari github
 git clone https://github.com/masterzen/redis-snmp.git;cd;redis-snmp/;make install
4.  jalankan service redis-snmp
redis-snmp --host=127.0.0.1
jika redis menggunakan auth maka gunakan perintah berikut
redis-snmp --host=127.0.0.1 -p <your pass redis>
5. reconfigure snmpd.conf tambahkan ini dan restart
master agentx
view    systemview    included   .1.3.6.1
view    systemview    included   .1.3.6.1.2.1
service snmpd restart
 6. test outuput
snmpbulkwalk -m 'REDIS-SERVER-MIB' -v 2c -c public 127.0.0.1 .1.3.6.1.4.1.20267.400
hasil
REDIS-SERVER-MIB::redisConnectedClients.0 = Gauge32: 1
REDIS-SERVER-MIB::redisConnectedSlaves.0 = Gauge32: 0
REDIS-SERVER-MIB::redisUsedMemory.0 = Counter64: 41466936 Bytes
atau gunakan -o untuk melihat OIDs untuk prtg
snmpbulkwalk -m 'REDIS-SERVER-MIB' -v 2c -O n -c public 127.0.0.1 .1.3.6.1.4.1.20267.400 
hasil
 .1.3.6.1.4.1.20267.400.1.1.0 = Gauge32: 1
.1.3.6.1.4.1.20267.400.1.2.0 = Gauge32: 0
.1.3.6.1.4.1.20267.400.1.3.0 = Counter64: 41466936 Bytes
untuk prtg silakan menggunakan OIDs tersebut berikut list nya
.1.3.6.1.4.1.20267.400.1.1.0  (redisConnectedClnts)
.1.3.6.1.4.1.20267.400.1.2.0  (redisConnectedSlavs)
.1.3.6.1.4.1.20267.400.1.3.0  (redisUsedMemory)
.1.3.6.1.4.1.20267.400.1.4.0  (redisChangsSncLstSv)
.1.3.6.1.4.1.20267.400.1.5.0  (redisTotalConnectns)
.1.3.6.1.4.1.20267.400.1.6.0  (redisCommandsPrcssd)
untuk PRTG gunakan custom sensors  dan gunakan aplikasi PRTG REDIS SENSORS Prtg version 15-16

Good Luck

Automate pushing of ssh-copy-id to multiple servers

kadang suka aga aga males kalo harus masukin ssh key ke server, ya kalo 1-2 server si ga apa, gimana kalo servernya itu lebih dari 10?
udah males ngetik satu satu, plus harus masukin passwordnya pula, kalo passwordnya panjang gimana?, akhirnya scripting dikit buat mempercepet aja si sebenernya cekidot gan!

buat file ~/.ssh/config isi dengan ini
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
itu gunanya biar ga ketik yes jika keluar
The authenticity of host 'yourserver.com.sg (192.168.1.1)' can't be established.
RSA key fingerprint is 8d:e7:92:ef:86:1a:fb:4a:01:00:6a:fc:8c:23:ed:15.
Are you sure you want to continue connecting (yes/no)?
 setelah itu kita buat file dengan nama host_list yang di mana isinya adalah host/server yang ingin kita copy ssh key milik kita
192.168.1.1
192.168.1.2
192.168.1.3
192.168.1.4
192.168.1.5
192.168.1.6
192.168.1.7
ect..
selanjutnya kita buat bash script yang isinya menggunakan perulangan for
for i in `cat ~/host_list`;    
    do
       sshpass -p 'SERVER_PASSWD' ssh-copy-id -i .ssh/id_rsa.pub root@${i}
    done
pada for terdapat petik ` ` , petik tersebut di gunakan untuk membaca file host_list dengan menggunakan cat
pada sshpass -p 'SERVER_PASSWD' server_passwd ganti dengan password user pada server tujuan tersebut, *Sukur" passwd usernya sama ga beda beda"
jika ingin menggunakan port yang berbeda bukan port 22 maka tambahkan -p <port> pada belakang ${i}
maka nanti akan menjadi seperti ini
for i in `cat ~/host_list`;    
 do
  sshpass -p 'SERVER_PASSWD' ssh-copy-id -i .ssh/id_rsa.pub root@${i} -p <port>
 done
kemudian chmod +x file bash dan eksekusi file tersebut

sekian :D

Inode problems and full disks , how to free inode usage

cannot create temp file for here-document: No space left on device
 
coba cek dengan df -h 
 
 df -h
Filesystem                   Size  Used Avail Use% Mounted on
udev                         1.9G  4.0K  1.9G   1% /dev
tmpfs                        379M  416K  379M   1% /run
/dev/mapper/vol_root  7.3G  2.2G  4.7G  32% /
 
di sana terlihat bahwa size masih lega, tapi kita ga bisa nulis dan system memberitahu bahwa udah penuh?? 

cek df dengan inode df -i atau df -Thi

 df -i
Filesystem                  Inodes  IUsed  IFree IUse% Mounted on
udev                        209623    445 209178    1% /dev
tmpfs                       214814    381 214433    1% /run
/dev/mapper/vol_root 488640 488640      0  100% /

ternyata yang penuh adalah inode nya maka system tidak dapat menulis karena inodenya penuh

faq:
1. terus clean up inode bisa?
2. apa harus di buat partisi baru? liat dr errornya itu adalah temp nya penuh

jawab
1. bisa, clean up dengan cara mencari file yang memakan inode banyak lalu menghapus file tersebut
pertama kita cari dulu file mana yg memakan inode banyak dari / a.k.a root


find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n
 
nanti akan keluar banyak file yang memakan inode pada disk, cari aja yg paling banyak kasus di sini adalah
 /var/lib/php5/sessions/ yg memakai inode sebanyak 387204
setelah udah tau penyebabnnya selanjutnya adalah hapus semua file yg ada di dalam folder itu sebagian, bisa dengan penghapusan file mulai dr yg terlama masanya atau bisa dari yg terbaru sesuai kebutuhan

pada kasus ini nama file atau string file terlalu panjang jika penghapusan dengan cara biasa aliias dengan perintah rm maka akan keluar

rm: Argument list too long
contoh nama file di sini seperti ini

ls /var/lib/php5/sessions/ci_session1aca9c05635d1b32ffdd87b9f274b1124eeb93fb
maka penghapusan file dengan cara agar tidak keluar list to long

find /var/lib/php5/sessions/ -name "ci_session*"  -print0 | xargs -0 rm
2. ga perlu karena /tmp menyatu pada / a.k.a root maka error yang keluar seperti itu


kesimpulannya alangkah baiknya menggunakan filesystem xfs

rujukan