2012-09-30

Ubuntu -- Learning

@How to configure network setting to use static IP address
sudo vi /etc/network/interfaces


 1 auto lo
 2 iface lo inet loopback
 3
 4 auto eth0
 5 iface eth0 inet static
 6 address 192.168.0.1 # 固定 IP 位址
 7 netmask 255.255.255.0   # 網路遮罩
 8 gateway 192.168.0.254 # 預設閘道

 sudo /etc/init.d/networking restart #重啓網路服務

@How to configure DNS server setting
sudo vim /etc/resolv.conf


 1# DNS of Google
 2#nameserver  8.8.4.4
 3#nameserver  8.8.8.8
 4
 5# DNS of HiNet
 6#nameserver  168.95.1.1
 7#nameserver  168.95.192.1

sudo /etc/init.d/networking restart #重啓網路服務

@How to install LAMP
sudo apt-get install tasksel
sudo  tasksel

#select LAMP to install
$sudo vi /var/www/info.php #to vi info.php

<?php
phpinfo();
?>
$sudo /etc/init.d/apache2 restart  #to restart Apache service
Visit http://192.168.0.1/info.php

@How to install phpmyadmin
sudo  apt-get  install  phpmyadmin

http://ip/phpmyadmin #to test


Linux -- 檔案系統樹狀標準


  • 根目錄 (/):為整個檔案系統樹狀結構的根,也就是整個檔案系統的根目錄。
  • /bin: 此目錄中存放著許多的 Binary 執行檔案,為一般及啟動時常常會使用到的檔案,例如 ls、cp、rm ...等指令。
  • /sbin:此目錄中存放著許多的 System Binary 執行檔案,為系統管理時常常會使用到的檔案,例如 shutdown、fsck、quotacheck...等指令。
  • /etc:此為 Linux 系統中相當重要得目錄,大部份的設定檔都存放於此,例如檔案系統掛載設定檔 /etc/fstab、IPTables 防火牆設定檔 /etc/sysconfig/iptables...等。
  • /lib:存放 Linux 系統中各種共用的 Library 函式庫檔案,類似於 Windows 作業系統的 DLL 動態連結函式庫一樣的功能。
  • /dev:Linux 系統是以 Everything is Files 的觀念來進行管理 Device 硬體裝置,因此硬體設備及週邊設備也不例外,此目錄中存放著所偵測到的相關硬體檔案,例如 光碟機為 /dev/cdrom、SCSI 硬碟為 /dev/sda...等,為相容舊版系統而存在。
  • /sys:存放 System-Device 相關資訊 (由 RHEL 4 開始才有此資料夾),如 PnP...等,會將偵測到的 Device 資訊回寫至 /dev 對應的檔案內以相容舊版,所以舉例來說當主機插入 USB 隨身碟時會同時建立 /sys/block/sdb 以及回寫至 /dev/sdb 內。
  • /selinux:存放 Linux 增強安全性機制 SELinux (Security Enhanced Linux) 相關檔案。
  • /var 具備 Variable 也就是變動特性的檔案將存放於此,例如 系統的各式日誌檔案 /var/log、使用者電子信箱 /var/mail、正在執行的執行序 /var/run/*.pid ...等。
  • /srv:存放相關的 Server-data。(由 RHEL 4 開始才有此資料夾)
  • /usr:Linux 系統中大部份的 安裝套件及相關應用程序 都存放於此,例如其它網路服務的執行程序 /usr/sbin、核心原始碼檔案 /usr/src...等,類似於 Windows 作業系統的Program Files 資料夾。
  • /opt:Optional 通常非預設安裝的套件會安裝於此,例如 Oracle 資料庫...等。
  • /lost+found: 在每個獨立的掛載點內都會有此資料夾,當 Linux 系統不正常關機時相關資料便會暫存於此。
  • /mnt: 用於 臨時掛載的目錄,通常會手動執行將外接設備掛載於此。(Kernel 2.4.x 使用)
  • /media: 若 RunLevel 為 5 也就是進入圖形介面時 (由 RHEL 4 開始才有此資料夾),若主機有插入 USB 或其它外接設備時則會自動掛載於此目錄上 (不需手動掛載)。(Kernel 2.6.x 使用)
  • /misc、/net: 用於 autofs 自動掛載時所使用的資料夾,例如 Linux 主機成為 LDAP、NIS Client 時便會將相關資料夾自動掛載於此,類似於 Windwos 作業系統中網路芳鄰的概念。
  • /tmp: 暫存資料夾,存放暫時性的資料夾及檔案,通常 Linux 系統重新啟動或關機以及排程會自動清空此資料夾內容。
  • /proc: Linux 系統中目前所執行的 執行序 Process 即存放於此資料夾,當該執行序停止執行則位於此資料夾中的 Process ID 或檔案將消失 (事實上此資料夾就是 Memory 中的暫存資料),至於有些檔案的大小為何是 0? 例如 meminfo、cpuinfo 則只是為了要達成 Everything is Files 的觀念而以,但仍可查看及檔案內容。
  • /boot: 存放 Linux 系統開機時相關引導檔案,例如 Boot Loader 設定檔 /boot/grub/grub.conf、初始化映像檔 .img...等。
  • /home: 所有 一般使用者帳號的家目錄,例如 使用者帳號 weithenn 的家目錄為 /home/weithenn。
  • /root: Linux 系統超級管理者的家目錄。

CentOS -- Learning

&configure NIC&
#su
#Enter password for root
#service NetworkManager stop
#chkconfig NetworkManager off
#chkconfig NetworkManager --list
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"

NM_CONTROLLED="yes"
ONBOOT=yes
TYPE=Ethernet
IPADDR=x.x.x.x
NETMASK=255.255.255.0
GATEWAY=x.x.x.x
DNS1=8.8.8.8
DEFROUTE=yes
#service network restart

&system update&
#yum update --skip-broken

&Disable SELinux&
#getenforce
Enforcing
#vi /etc/selinux/config
SELINUX=disabled
#reboot
#getenforce
Disabled

Connecting to the Console Port with Mac OS X


Connecting to the Console Port with Mac OS X

This procedure describes how to connect a Mac OS X system USB port to the console using the built-in OS X Terminal utility.

Step 1 Use the Finder to go to Applications > Utilities > Terminal.

Step 2 Connect the OS X USB port to the router.

Step 3 Enter the following commands to find the OS X USB port number:

macbook:user$ cd /dev
macbook:user$ ls -ltr /dev/*usb*
crw-rw-rw-  1 root    wheel       9,  66 Apr  1 16:46 tty.usbmodem1a21
DT-macbook:dev user$

Step 4 Connect to the USB port with the following command followed by the router USB port speed:

macbook:user$ screen /dev/tty.usbmodem1a21 9600
To Disconnect the OS X USB Console from the Terminal Window

Enter Ctrl+A followed by Ctrl+\

2012-09-29

MRBS -- the steps of installation

@安裝
tar zxvf mrbs-1.4.6.tar.gz
cd mrbs-1.4.6
cp -r web /var/www/mrbs
配置timezone。找到config.inc.php文件。去掉$timezone = "XXXXXXX"的註釋,並修改成$timezone = "Asia/Taipei"。
配置數據庫。還是config.inc.php文件。修改以下參數,分別對應數據庫類型、主機、數據庫實例、用戶名、密碼、表前綴。例如:
$dbsys = "mysql";
$db_host = "localhost";
$db_database = "mrbs";
$db_login = "root";
$db_password = 'xxxxxxxx';
$db_tbl_prefix = "mrbs_";
配置用戶授權類型。
在config.inc.php文件的尾部添加$auth["type"]="db";

@配置mysql數據庫
mysql -uroot -p111111
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '111111' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;
mysql>CREATE DATABASE `mrbs` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
退出數據庫,返回到mrbs-1.4.6目錄
mysql -uroot -p111111 mrbs < tables.my.sql
mysql -uroot -p111111 mrbs < sample-data.sql
全部部署完畢。

@LDAP的部分,於config.inc.php內增加
$auth["type"] = "ldap";
$ldap_host = "LDAP的IP位址";
$ldap_port = 389;
$ldap_v3 = true;
$ldap_tls = false;
$ldap_base_dn = "DC=abc,DC=com";
$ldap_user_attrib = "sAMAccountName";
$ldap_dn_search_attrib = "sAMAccountName";
$ldap_dn_search_dn = "CN=adminaccount,CN=Users,DC=abc,DC=com";需使用正確的adminaccount帳號的LDAP distinguishedName
$ldap_dn_search_password = "adminpassword";查詢LDAP的adminaccount密碼不能包含$#@等字眼
@訪問http://localhost/mrbs

2012-09-22

VMware vSphere 5.1

http://www.vmware.com/files/pdf/products/vsphere/vmware-what-is-new-vsphere51.pdf

OB2D -- Learning (1) -- Installation

OB2D
http://www.phcno1.net/modules/tad_book3/page.php?tbdsn=292

How to use Virtualbox to build a ob2d server.
http://myip.tw/itsmw/index.php?title=Ob2d_2010

1. Download and install Oracle Virtualbox.
2. Settings for ob2d:
    OS:Linux
    Version:bebian
    RAM: 800MB
    HD:10GB

2012-09-15

Powershell -- 1st experience


#Set-ExecutionPolicy RemoteSigned
# VMware vSphere PowerCLI
if (((Get-PSSnapin -Name "VMware.VimAutomation.Core" -ErrorAction SilentlyContinue) -eq $null ) -and ((Get-PSSnapinregistered -Name "VMware.VimAutomation.Core") -ne $null))
{
   Write-Host "Adding VMware vSphere PowerCLI" -ForegroundColor Green
   Add-PSSnapin -name VMware.VimAutomation.Core
   ."C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"
}
$vmmodule = Get-PSSnapin -Name "VMware.VimAutomation.Core"
if (!$vmmodule) {
    [System.Reflection.Assembly]::LoadwithPartialName("System.windows.Forms")
    [System.windows.Forms.MessageBox]::Show("We dont got the VM powerCLI module.")
    exit
} else {
    echo "Module $vmmodule loaded successfully"
}
# SSH-Sessions Module load
$sshmodule = Get-Module -List 'SSH-Sessions'
if (!$sshmodule) {
    [System.Reflection.Assembly]::LoadwithPartialName("System.windows.Forms")
    [System.windows.Forms.MessageBox]::Show("We dont got the SSh-Sessions module.")
    exit
} else {
    Import-Module SSH-Sessions
    echo "Module $sshmodule loaded successfully"
}
#Connect to Vcenter
$Viserver = Connect-VIServer -Server 'IP' -User 'username' -Password 'password'
If (!$viserver) {
   [System.Reflection.Assembly]::LoadwithPartialName("System.windows.Forms")
   [System.windows.Forms.MessageBox]::Show("We dont connect to FTvcenter01.")
   exit
} else {
    echo "Connect to vcenter success"
}
Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"} | Where-Object {$_.Name -ne "vcenter"} | Shutdown-VMGuest -Confirm:$false
Start-
#Get-VM
#Start-Sleep -s 600
#Get-VMHost | Stop-VMHost -Confirm:$false
#Get-VMHost
#Start-Sleep -s 300
#SSH to NetApp
$naserver = New-SshSession -ComputerName 'IP for 1st','IP for 2nd' -Username 'username' -Password 'password'
If (!$naserver) {
    [System.Reflection.Assembly]::LoadwithPartialName("System.windows.Forms")
    [System.windows.Forms.MessageBox]::Show("We dont connect to NetApp Controller.")
   exit
} else {
echo "Connect to NetApp Controller success"
}
exit 
#Invoke-Sshcommand -InvokeOnAll -Command 'halt -t 0 -f'
#Invoke-Sshcommand -InvokeOnAll -Command 'ifconfig -a'
#Remove-SshSession -RemoveAll

2012-09-06

SQLSchedule

To Backup SQL Express


Features:

  • Supports all versions of SQL Server 2000, 2005, and 2008
  • Supports unlimited SQL Server instances with an unlimited number of jobs.
  • Allows to easily schedule SQL Server maintenance tasks: backups, index rebuilds, integrity checks, etc.
  • Runs as Windows Service
  • Email notifications on job success and failure
  • And more...

http://www.lazycoding.com/products.aspx

LogParser -- (3)

logparser.exe -o:datagrid "SELECT TimeGenerated, Message FROM security WHERE EventID=680 AND Message LIKE 'username'"

PStool GUI

http://www.davitools.com/fepstools/documentation.aspx