Saturday, May 10, 2014

0 Setup ntpdate to run hourly

Create the myntpdate under /etc/cron.hourly. In side the file, contains ntpdate command :

ntpdate sgc

The file also needs to be executable.

chmod 755 myntpdate

image

The cron job log is at /var/log/cron

image

0 Lastlog size is huge ….

/var/lastlog show the huge size from ls output.

image

This does not make sense because df only show used size last than 1G

image

It turns out, the du would give more accurate size.

image

It is because the lastlog file is sparse file, it contain many empty space . Using –s option in the ls would show the actual size instead of pre allocated size. 

image

Wednesday, May 7, 2014

0 CrypTool

Very useful open source application that can help visualize cryptography … I wish I know this years ago when I still in school .

Download from here 

image

image

Pretty cool

2 Setup Replication for Mongo DB on Windows

Here are some notes for setting up the replication in Mongo DB. Unlike other DBMS, mongodb’s replication more like the database mirroring . You can  not pick or choice what column get replicate .

 

prerequisite

Configure three Mongo DB run as service. Below are my configure file.

There files are identical except the service name and port number. I use port 27017, 27018 and 27019. The key thing here is the replSet. This is the replication set name. 

MongoDB1

dbpath=D:\mongoDB\data\mongo1
logpath=D:\mongoDB\DBAREPORT\mongo1-server.log
logappend=true
verbose=vvvvv
directoryperdb=true
journal=true
bind_ip=127.0.0.1
port=27017
serviceDescription=mongo1
serviceDisplayName=mongo1
serviceName=mongo1
replSet=mongorep

MongoDB1

dbpath=D:\mongoDB\data\mongo2
logpath=D:\mongoDB\DBAREPORT\mongo2-server.log
logappend=true
verbose=vvvvv
directoryperdb=true
journal=true
bind_ip=127.0.0.1
port=27018
serviceDescription=mongo2
serviceDisplayName=mongo2
serviceName=mongo2
replSet=mongorep

MongoDB3

dbpath=D:\mongoDB\data\mongo3
logpath=D:\mongoDB\DBAREPORT\mongo3-server.log
logappend=true
verbose=vvvvv
directoryperdb=true
journal=true
bind_ip=127.0.0.1
port=27019
serviceDescription=mongo3
serviceDisplayName=mongo3
serviceName=mongo3
replSet=mongorep

From procexp, you can see three service are using the same binary but of course, they all have its own database directory.

image

Tuesday, May 6, 2014

2 Install Mongo DB on Windows

Install Mongo DB on windows is easy . 4 steps and you are in business.

  • Download the software.
  • Unzip the software
  • Create the data folder
  • run the daemon mongod.exe .

image

Simply control + C would shutdown the mongo DB gracefully.


RUN mongo DB as windows service

Create the configuration file:
dbpath=D:\mongoDB\data\mongo1
logpath=D:\mongoDB\DBAREPORT\mongo1-server.log
logappend=true
verbose=vvvvv
directoryperdb=true
journal=true
bind_ip=127.0.0.1
port=27017
serviceDescription=mongo1
serviceDisplayName=mongo1
serviceName=mongo1
  • options are case sensitive . The best way to find the options are check the mongod –help
  • quote on the path does not work. EX: can not use “C:\data\db”

Use below command to install as service .

mongod.exe --install --config D:\mongoDB\DBACONFIG\mongodb1.conf

image

Then we can find mongo db list in the service manager.

image

 

Errors

Failed to connect to 127.0.0.1:27017, reason: errno:10061 No connection could be made because the target machine actively refused it. 

This is because the you are running on the non-privilege session. change to the administrator command line would resolve this. 

 

 

Reference

http://docs.mongodb.org/manual/reference/configuration-options/

Monday, May 5, 2014

0 Centos 6.5 join Windows Domain and Kerberos authentication

This is my note for configure Linux intergrade windows domain authentication with Kerberos

 

Package Require

  • yum install samba
  • yum install krb5-server
  • yum install krb5-workstation
  • yum install samba-winbind
  • yum install ntpdate    --> This is required for sync time
  • yum install cifs-utils

 

Setup the Host Name on Linux

Setup the host name in /etc/sysconfig/network

image

Sunday, May 4, 2014

0 tmux

tmux is terminal multiplexer. Similar to the screen that I use at office.

Here are few advantages/reasons that using tmux over screen.

  • tmux is under activity development and with BSD license.
  • tmux use less resource.
  • Flexible control the pane.
  • Scroll back history

image


Installation

It is not part of centos yum repository. To install it, we need to set up the EPEL.

yum install tmux

CONFIG:

The user configure tmux configure file is located at ~/.tmux.conf

Here is my binding and below cheat sheet is base on that.

# Lower escape timing from 500ms to 50ms for quicker response to scroll-buffer access.
set -s escape-time 50
 
# use UTF8
set -g utf8
set-window-option -g utf8 on
 
# set scrollback history to 100000 (100k)
set -g history-limit 100000
 
# Use something easier to type as the prefix.
set -g prefix C-x
unbind C-b
bind C-x send-prefix
 
# reload config without killing server
bind r source-file ~/.tmux.conf \; display-message "Config reloaded..."
 
# Enable auto renaming
setw -g automatic-rename on
 
# rebind the spilt keys
unbind %
bind \ split-window -h
bind - split-window -v
 
# Pane setting
 
bind -n F9 resizep -U 1
bind -n F10 resizep -D 1
bind -n F11 resizep -L 1
bind -n F12 resizep -R 1
 
set-option -g pane-border-fg green
set-option -g pane-border-bg black
 
set-option -g pane-active-border-fg green
set-option -g pane-active-border-bg yellow
 
# pane movement
bind-key j command-prompt -p "join pane from:"  "join-pane -s '%%'"
bind-key s command-prompt -p "send pane to:"  "join-pane -t '%%'"
 
# 256 colors please
set -g default-terminal "screen-256color"
 
# colorize messages in the command line
set-option -g message-bg black
set-option -g message-fg brightred
 
# set color for status bar, use prefix + : to enter status command bar
set-option -g status-bg black
set-option -g status-fg yellow #yellow
set-option -g status-attr dim
 
# set window list colors - cyan for inactive
set-window-option -g window-status-fg cyan
set-window-option -g window-status-bg black
set-window-option -g window-status-attr dim
 
# set window list colors - Blue for active
setw -g window-status-current-format '#[bg=red,fg=cyan,bold](#I:#F#W)'
setw window-status-current-attr underscore
 
# Fix putty/pietty function key problem
#set -g terminal-overrides "xterm*:kf1=\e[11~:kf2=\e[12~:kf3=\e[13~:kf4=\e[14~:kf5=\e[15~:kf6=\e[17~:kf7=\e[18~:kf8=\e[19~"
 
# set the status bar message
set -g status-left ' #[bold]#H ⣿'
set -g status-right '#[bold]#(whoami)#(uptime|cut -d "," -f 4-)#[fg=green]%D-%H:%M#[default] '
 
# Activity
setw -g monitor-activity on
set -g visual-activity on
 
 
#
# Mouse Behivor
#
# allow mouse to select which pane to use
set -g mouse-select-pane on
 
# Allow mouse to select windows
set -g mouse-select-window on
 
set-option -g mouse-resize-pane on
set-option -g mouse-select-window on
 
# mouse scroll in tmux -> also go to the copy mode
set -g mode-mouse on
 
set-window-option -g mode-keys vi
unbind [
bind Escape copy-mode
unbind p
# This allow copy vmux buffer to the vi
bind p paste-buffer
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
 
# buffer
bind Space choose-buffer

 

 

Cheat sheet

List tmux session tmux lis
Attached the session tmux a –t <session id>
Kill the current window prefix + &
pane to window prefix + !
next pane prefix + o
next window prefix + n
copy mode prefix + <ESC>
copy to the vmux buffer use mouse select the text  or
copy mode –> prefix + v to select the text –> prefix + y to copy
copy to vi prefix + p
copy from putty to notepad shift key and select as normally putty

putty

This is tricky one. I use putty to my linux box and I like the putty function that can just select the text and copy paste. However, because tumx buffer is independent outside the system buffer and tmux would also take the signal about the putty for the mouse resize. To achieve this goal, we have 2 ways to do it.

1. complete disable the signals from putty .

Terminal –> Features –> Disable xterm-style mouse reporting

By check this box, we can no longer use mouse to resize or pane or enter the copy mode, and copy tmux buffer.

image

2. Press shift key while copy paste

I decided to use the 2nd approach It will take some time to get used to it.

Another challenge is to copy the content of pane into notepad. At this point, I will just move the pane into its own window and use the shift key to do it.

 

 

reference

Saturday, May 3, 2014

1 Install EPEL on Centos 6.5

EPEL is Fedora Repository. By default, the Centos does not configure to use it.

Below command list what is current yum repository.

yum repolist

image

To install it:

 

image

Re run the yum repolist again, this will update the repository.

image

 

 

Reference

 http://www.rackspace.com/knowledge_center/article/installing-rhel-epel-repo-on-centos-5x-or-6x

 

SQL Panda Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates