2016年6月30日 星期四

dracut debug 相關參數

dracut boot parameters

The following boot parameters are also available to further assist with debugging boot issues.

rd.shell
    Drop to a shell, if the initramfs fails.
rd.debug
    set -x for the dracut shell.
rd.break=[cmdline|pre-udev|pre-trigger|initqueue|pre-mount|mount|pre-pivot|cleanup]
    drop the shell on defined breakpoint (use egrep 'rd.?break' /usr/lib/dracut/modules.d/99base/init.sh to find the breakpoints supported by your dracut version)
rdudevinfo
    set udev to loglevel info
rdudevdebug
    set udev to loglevel debug
rdnetdebug
    debug network scripts in dracut. Output is written to /tmp

mknod /dev/mem /dev/kmem

mknod /dev/mem c 1 1
chown root.mem /dev/mem

mknod /dev/kmem c 1 2
chown root.kmem /dev/kmem

udev 使用的文件

/sys/*

/dev/*

/etc/udev/udev.conf    udev主要設定檔

/etc/udev/rules.d/*    udev 事件規則

/usr/lib/tmpfiles.d/  /etc/tmpfiles.d/    static dev 規則

/usr/lib/udev/*        udev 規則

2016年6月28日 星期二

Linux RAM Disk modules

The RAM Disk is created when the "brd" module is loaded (brd=block ram disk)
modprobe brd

rd_nr:Maximum number of brd devices (int)
rd_size:Size of each RAM disk in kbytes. (int)
max_part:Maximum number of partitions per RAM disk (int)

example
modprobe brd rd_size=1024000 max_part=2 rd_nr=1

核心支援版本
 2.0.40, 2.2.26, 2.4.37, 2.6.18, 2.6.24

核心 modules 支援版本
2.6.25,2.6.28, 2.6.30.1, 2.6.39 ,3.9 ,3.10, 3.11 ,3.12 ,3.13, 3.14, 3.15 ,3.16, 3.17, 3.18 ,3.19, 4.0 ,4.1, 4.2 ,4.3 4.4

2016年6月20日 星期一

Bash 列出所有 Char Device

# Char Device
for i in /sys/bus/*/devices/*/dev /sys/class/*/*/dev;
do :;
    if [ -f "$i" ] ;then :;
      OIFS=IFS;
      IFS=:;
      t=($(cat "$i"));
      IFS=$OIFS;
      i=${i%/dev};
      i=${i##*/};
      echo name=$i  major=${t[0]} minor=${t[1]};
    fi;
done;

Bash 列出所有 Block Device

#!/bin/sh

# Block Device
for i in /sys/block/*/dev /sys/block/*/*/dev ;
do :;
    if [ -f $i ]; then :;
      OIFS=IFS;
      IFS=:;
      t=($(cat $i));
      IFS=$OIFS;
      i=${i%/dev};
      i=${i##*/};
      echo name=$i  major=${t[0]} minor=${t[1]};
    fi;
done;

Linux 取得 SMBIOS uuid

dmidecode --type system

2016年6月16日 星期四

BASH script :dirname & basename

function fun_basename { :; echo ${1##*/}; };

function fun_dirname { :; _t=${1%*/*};  [ $1 = $_t ] && echo "." || echo $_t; }

2016年6月14日 星期二

Keepalived 設定筆記

Global definitions synopsis

global_defs{
  notification_email{
    email
    email
  }
  notification_email_from
    email smtp_server host
    smtp_connect_timeout num
    lvs_id
}


Keyword:Definition  Type 

  • global_defs: identify the global def configuration block
  • notification_email: email accounts that will receive the notification mail List
  • notification_email_from: email to use when processing “MAIL FROM:” SMTP command   List
  • smtp_server: remote SMTP server to use for sending mail notifications alphanum
  • smtp_connection_timeout: specify a timeout for SMTP stream processing numerical
  • lvs_id: specify the name of the LVS director alphanum 

VRRP Instance definitions synopsis

vrrp_sync_group string {
  group{
    string
    string
  }
  notify_master /path_to_script/script_master.sh
               (or notify_master “/path_to_script/script_master.sh ”)
  notify_backup /path_to_script/script_backup.sh
               (or notify_backup “/path_to_script/script_backup.sh
”)
  notify_fault /path_to_script/script_fault.sh
               (or notify_fault “/path_to_script/script_fault.sh
”)
}


vrrp_instance string {
  state MASTER|BACKUP
  interface string
  mcast_src_ip @IP
  lvs_sync_daemon_interface string
  virtual_router_id num
  priority num
  advert_int num
  smtp_alert
  authentication {
    auth_type PASS|AH
    auth_pass string
  }

  virtual_ipaddress {   # Block limited to 20 IP addresses
    @IP
    @IP
    @IP
  }
  virtual_ipaddress_excluded { # Unlimited IP addresses number
    @IP
    @IP
    @IP
  }
  notify_master /path_to_script/script_master.sh
                (or notify_master “/path_to_script/script_master.sh
”)
   notify_backup /path_to_script/script_backup.sh
                (or notify_backup “/path_to_script/script_backup.sh
”)
   notify_fault /path_to_script/script_fault.sh
                (or notify_fault “/path_to_script/script_fault.sh
”)
}

Keyword:Definition  Type 
  • vrrp_instance :identify a VRRP instance definition block
  • State :specify the instance state in standard use
  • Interface :specify the network interface for the instance to run on string
  • mcast_src_ip :specify the src IP address value for VRRP adverts IP header
  • lvs_sync_daemon_inteface :specify the network interface for the LVS sync_daemon to run on string
  • Virtual_router_id :specify to which VRRP router id the instance belongs numerical
  • Priority :specify the instance priority in the VRRP router numerical
  • advert_int :specify the advertisement interval in seconds (set to 1)  numerical
  • smtp_alert :Activate the SMTP notification for MASTER state transition
  • authentication :identify a VRRP authentication definition block
  • auth_type :specify which kind of authentication to use (PASS|AH)
  • auth_pass :specify the password string to use string
  • virtual_ipaddress :identify a VRRP VIP definition block
  • virtual_ipaddress_excluded :identify a VRRP VIP excluded definition block (not protocol VIPs)
  • notify_master :specify a shell script to be executed during transition to master state path
  • notify_backup :specify a shell script to be executed during transition to backup state path
  • notify_fault :specify a shell script to be executed during transition to fault state path
  • vrrp_sync_group :Identify the VRRP synchronization instances group string 


Master 設定
global_defs {
   notification_email {
      user@example.com
   }

   notification_email_from mail@example.org
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}


vrrp_instance VI_1 {
    state MASTER #狀態為 MASTER
    interface eth1
    virtual_router_id 51
    priority 101   #MASTER 權重高於 BACKUP
    advert_int 1
    mcast_src_ip 192.168.10.101 #vrrp IP

    authentication {
        auth_type PASS #認證方式
        auth_pass 1111
    }

    #VIP
    virtual_ipaddress {
        192.168.10.100 #virtual IP
    }
}

Backup 設定
global_defs {
   notification_email {
       user@example.com
   }

   notification_email_from mail@example.org
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_instance VI_1 {
    state BACKUP #狀態為 BACKUP
    interface eth1
    virtual_router_id 51
    priority 100  #權重低於 MASTER
    advert_int 1
    mcast_src_ip 192.168.10.102 #vrrp IP

    authentication {
        auth_type PASS
        auth_pass 1111
    }

    #VIP
    virtual_ipaddress {
        192.168.10.100 #virtual IP
    }
}

2016年6月6日 星期一

MySQL Table 匯出csv

SELECT *
INTO OUTFILE '/tmp/data.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM table

2016年6月4日 星期六

常用Joomla 模組

下拉式選單模組
ARI YUI Menu
Maximenu CK

圖片/影片輪播模組
Slideshow CK

文章中增加附加檔案
Attachments for Joomla!
http://jmcameron.net/attachments/
限制副檔名,不能上傳的副檔名設定  修改 內容->媒體->選項->合法的副檔名  

JCE
https://www.joomlacontenteditor.net/

PHP CSS HTML 等原始碼
Sourcerer
https://www.regularlabs.com/extensions/sourcerer#tutorial

Email 通知文章異動
Content Update Notifications
http://extensions.joomla.org/extension/content-update-notifications

NotificationAry
http://gruz.org.ua/en/extensions/notificationary.html
 
最新消息
News Show Pro GK5
https://www.gavick.com/news-show-pro

Mini Frontpage
https://www.templateplazza.com/items/mini-frontpage-joomla-module

Latest News+ Date
http://extensions.joomla.org/extension/latest-news-date

2016年6月2日 星期四

LXC 常用指令

lxc-ls 列出所有容器

lxc-top 監視已啟動容器狀態

lxc-info 顯示狀態

lxc-start 開啟容器

lxc-stop 關閉容器

lxc-console (離開 Ctrl-A Q)

lxc-monitor 監視容器狀態

lxc-execute 執行容器內指令
exp:lxc-execute -n 113 /bin/ls

lxc-checkconfig 檢查 kernel 是否支援 LXC

LXC 更改 Linux 密碼

lxc-stop -n lxc-execute -n passwd