about 7 years ago

Ubuntu Server 剛灌完支援的語系可能不是那麼多,或是沒有你想要的,這篇將簡短的教您如何新增和更改系統預設語系。

  • 如果你想要看到所有的語系(locale)列表,可以到 /usr/share/i18n/SUPPORTED 這個檔案查看。
  1. 查詢目前已安裝的語系
    # locale -a
    
  2. 加入欲新增的語系,並安裝
    # sudo vim /var/lib/locales/supported.d/local  //在之中加入您想要的語系如下,可加入多個
    en_US.UTF-8 UTF-8
    zh_TW.UTF-8 UTF-8
    zh_TW.BIG5 BIG5
    # sudo locale-gen                              //安裝清單
    # dpkg-reconfigure locales
    
  3. 更改系統預設語系
    # sudo vim /etc/default/locale                 //如下,en_US.UTF-8可換成您想要的語系
    LANG="en_US.UTF-8"
    
  4. 也可以更改個人的預設語系

    • 在各自的Shell rc黨中加入環境變數即可,這裡示範ubuntu常用shell (bash) \# vim ~/.bashrc //在之中加入以下,en_US.UTF-8可換成您想要的語系 export LANG=en_US.UTF-8
  5. Reference
    Ubuntu 初建置的中文環境
    How to change language on ubuntu 12.04lts server edition

  6. Article update information

    • 2014/8/26 start Article
 
about 7 years ago

這裡只節錄使用的指令,詳細的敘述請參考Tsung's Blog,因裡面敘述的很詳細故不另外多做說明。
使用此方法須注意,遠端Server ssh 必須開啟PubkeyAuthentication,開啟方法可以到sshd的config裡,找到PubkeyAuthentication參數並改成yes

  1. 產生一組rsa key 過程中會要你輸入一些訊息,我是都略過,沒有給予特定的資訊。
    # ssh-keygen -t rsa
    
  2. 放入您的public key 到遠端的Server

    • 它會自動加入您的public key到遠端Server 您的帳號下.ssh/authorized_keys檔案裡
      # ssh-copy-id -i .ssh/id_rsa.pub [username]@[hostname]
      
  3. Reference
    Tsung's Blog

  4. Article update information

    • 2014/8/26 start Article
 
about 7 years ago

經常會遇到想要用的port被某服務佔走,而這篇講敘述兩個指令,如何找到占用某port的程式名稱。

  1. 找到占用某port的pid
    • 如果要列出所有的listening port
      netstat -nao
      
    • 如果想要知道某port是否被占用
      netstat -nao |find "0.0.0.0:[port]"
      
  2. 找到port 再利用其pid查詢程式名稱
    tasklist /fi "pid eq [pid]"
    
  3. 使用工作管理員關掉它
    按下Ctrl+Shift+Esc開啟工作管理員。找到程式並關閉他

  4. Article update information

    • 2014/8/26 finished
    • 2014/8/13 Begin writing this Article.
 
about 7 years ago

The follow will simply describe how to use ssh tunnels and what needs to notice something when connecting to Esxi server.
Esxi client 連線的port為443902,故需在本機端上與白名單IP建立tunnel,再使其連線到目的端(Esxi Server)。

  • 以下介紹將假設 Esxi Server IP為 10.0.0.1,白名單機器IP為140.113.0.1。
  • 需注視事項為,因VMware vsphere 是不能以127.0.0.1 或 localhost當作連線主機,故需要修改hosts做dns對應,只要不是"127.0.0.1 或 localhost" 即可。
  • 如本機端上443或902已成為listening port,可能無法使用以下方法,請關閉其執行程式(通常會被本機端的VMware workstation 占用)。
  1. 白名單機器必須安裝sshd,也就是ssh的服務端。
    • (因白名單機器可以是任何平台,在這不細說sshd。只舉例ubuntu 12.04 lts安裝方式)
      ubuntu 12.04 lts
      sudo apt-get install openssh-server
      sudo /etc/init.d/ssh start
      
  2. Use putty or Use command line
    • Putty
      輸入主機與port

      輸入兩個tunnel並add

      最後open,輸入您的帳號密碼即可建立tunnel
    • Command line(windows 需要安裝程式,內建並沒支援,這裡使用的是cygwin,請自行參考其他教學)
       Usage: ssh -L [localhost port]:(server IP or domain):remote port(server port) -p [white server port] -l [username]
      # ssh -L 443:10.0.0.1:443 -L 902:10.0.0.1:902 140.113.0.1 -l username   //port不打,預設22
      # password: (type your passwd) 
      
  3. 更改hosts C:\Windows\System32\drivers\etc\hosts
    • 這檔案是用來管理static dns其對應的IP,可能會有權限等等的問題導致無法更動,可以嘗試再複製一樣的檔案更動完後覆蓋上去。
  4. 使用VMware vsphere 連線 輸入剛剛對印的domain,以及您的帳號密碼即可
  5. Reference http://freddebostrom.wordpress.com/2009/04/10/ssh-tunnel-from-the-command-line/ http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2051575 http://www.emsperformance.net/2012/09/09/controlling-vmware-esxi-server-from-vsphere-client-via-ssh-tunnel/
  6. Article update information
    • 2014/8/26 finished
    • 2014/8/13 Begin writing this Article.
 
about 7 years ago

Archlinux Installation with Raid

I will show Archlinux installation with the following environment.

  • GPT is a standard for the layout of the partition table on a physical hard disk. And you can find the introduction in wiki
    CPU: 2
    RAM: 2G
    Harddisk: 20G*2
    GPT
    /boot - 128M, ext2
    swap - 1G
    /root - rest, ext4
    
  1. The first, you must download the live CD, and you can find it in official website. I choose nctu mirror in Taiwan. [download link 2014.08.01] And then let computer or VM select CD as its first boot-device.
  2. Set up the sshd to make it easy to install
    Network setup

    • Here, I use static and private IP.
    • If there is not static IP, you just use DHCP, and need to get its IP for ssh.
    • Or, you can go next step, and type command line in front of PC(VM).
      # dhcpcd -k                                        //stop the DHCP
      # ip link                                          //find network interface(NI) name
      # ip link set ens32 up                             //en32 is NI's name
      # ip addr add 192.168.10.50/24 dev ens32
      # ip route add default via 192.168.10.1
      # echo "nameserver 8.8.8.8" >> /etc/resolv.conf
      # passwd                                           //set up temporary password
      # systemctl start sshd
      # ping www.google.com                              //testing network
      
    • Then, you can use shell on linux workstation or use putty on windows to remotely login PC.
  3. Hard disk partition

    • You can use 'cgdisk' to create GPT partitions with description.
    • But I use 'gdisk' here
      # gdisk /dev/sda
      //Type '?', if you need to help. 
      // 'n' can add a new partition.
      // 'w' write table to disk and exit.
      // 'p' see your partition table.
      //And then, you need to partition it to like to below.
      Number  Start (sector)    End (sector)  Size       Code  Name
      1            6144          210943   100.0 MiB   FD00  Linux RAID
      2          210944         2308095   1024.0 MiB  8200  Linux swap
      3         2308096        41943006   18.9 GiB    FD00  Linux RAID
      128            2048            6143   2.0 MiB     EF02  BIOS boot partition
      
    • Then,copy partition table to /dev/sdb
      # sgdisk /dev/sda  -R=/dev/sdb
      # sgdisk -G /dev/sdb
      
  4. Raid

    • refer Archlinux wiki Raid page.
    • use mdadm to do software RAID. And I will make / and /boot do RAID1(mirror) in order to backup data.
      # mdadm --create --verbose /dev/md1 --level=mirror --raid-devices=2 /dev/sd{a,b}1
      # mdadm --create --verbose /dev/md3 --level=mirror --raid-devices=2 /dev/sd{a,b}3
      # mdadm --detail --scan | tee -a /etc/mdadm.conf  //save the profile
      
    • use 'cat /proc/mdstat' to check out progress of mdadm.
  5. Create filesystems and install base system

    • You can add mirror location or change the order in '/etc/pacman.d/mirrorlist', if you need.
    • Here, I set 'Server = http://linux.cs.nctu.edu.tw/archlinux/$repo/os/$arch' (NCTU mirror) to first.
      # mkswap /dev/sda2
      # mkswap /dev/sdb2
      # swapon /dev/sd{a,b}2
      # mkfs.ext2 /dev/md1
      # mkfs.ext4 /dev/md3
      # mount /dev/md3 /mnt && mkdir /mnt/boot && mount /dev/md1 /mnt/boot
      # pacstrap /mnt base base-devel  // install base and base-devel on /mnt
      
  6. Initially set system profile

    • you can refer to Fstab, Locale, Console font and keymap,and Time zone.
      # genfstab -p /mnt | tee /mnt/etc/fstab
      following table is my finally fstab,and you can modify it in /mnt/etc/fstab.
      /dev/md3                /               ext4            defaults,relatime       0 1
      /dev/md1                /boot           ext2            rw,relatime     0 2
      /dev/sda2               none            swap            defaults        0 0
      /dev/sdb2               none            swap            defaults,pri=-2 0 0
      # cp /etc/mdadm.conf /mnt/etc/ # arch-chroot /mnt # hostnamectl set-hostname [your hostname] # echo "KEYMAP=us" > /etc/vconsole.conf # ln -s /usr/share/zoneinfo/Asia/Taipei /etc/localtime # hwclock --systohc --utc --adjfile /etc/adjtime # vi /etc/locale.gen //To uncomment a line remove the '#' in the front, if your system needs it to support the locale(language). Following options are selected for my system.
      en_US.UTF-8 UTF-8 en_US ISO-8859-1 zh_TW.UTF-8 UTF-8 zh_TW BIG5
      # locale-gen # echo "LANG=en_US.UTF-8" > /etc/locale.conf
    • set up network
      # systemctl disable network
      # cd /etc/netctl
      # cp examples/ethernet-static ethernet
      # vi ethernet
      //Like to below. Here, using static IP to set my profile, if you use DHCP, you can refer to Network.
      Interface=ens32 Connection=ethernet IP=static Address=('192.168.10.51/24') Gateway='192.168.10.1' DNS=('140.113.235.1') IP6=stateless
      # netctl enable ethernet
    • Install ssh and create an initial ramdisk environment
      # pacman -S openssh
      # systemctl enable sshd.service
      # vi /etc/mkinitcpio.conf
      //add 'mdadm_udev' option to HOOKS. Look like to HOOKS="base udev autodetect modconf block filesystems keyboard fsck mdadm_udev"
      # mkinitcpio -p linux
      
  7. Install and configure a bootloader

    • Install 'Grub' to system, and seting boot option.
      # pacman -S grub
      # grub-install --target=i386-pc --recheck /dev/sda
      # grub-install --target=i386-pc --recheck /dev/sdb
      # cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo
      # vi /etc/default/grub
      //add 'nomodeset' option to GRUB_CMDLINE_LINUX_DEFAULT. Look like to GRUB_CMDLINE_LINUX_DEFAULT="quiet nomodeset".
      # grub-mkconfig -o /boot/grub/grub.cfg
      # passwd                     // Setting root's password.
      # exit
      # reboot
      
  8. Success and reboot system

    • You can 'ssh' immediate, if no any problem.
    • May be, you need to delete 'know_hosts' in your ssh profile, if you install with 'ssh'.
    • May be, your system have some problem such as network profile wrong, sshd not running, or /etc/fstab not correct, etc.
  9. My common pogram list
    -Just, for reference.

    pacman -Sy sudo vim screen bash-completion dnsutils net-tools git mercurial wget zip unzip zsh
    pacman -Sy vim
    pacman -Sy screen
    pacman -Sy bash-completion
    pacman -Sy dnsutils
    pacman -Sy net-tools
    pacman -Sy git
    pacman -Sy mercurial
    pacman -Sy wget
    pacman -Sy zip
    pacman -Sy unzip
    
  10. Notice: need to set up NTP

    # pacman -Sy ntp
    # vim /etc/ntp.conf
    # systemctl enable ntpd
    # systemctl start ntpd
    //Testing
    # date
    ==>Sun Apr 17 11:18:31 CST 2016
    

    Example ntp.conf

    server tock.stdtime.gov.tw prefer¬                                                  
    server tick.stdtime.gov.tw¬                                                         
    server time.stdtime.gov.tw
    restrict default kod limited nomodify nopeer noquery notrap¬                        
    restrict 127.0.0.1¬                                                                 
    restrict ::1
    driftfile /var/lib/ntp/ntp.drift
    
  11. Reference

  12. Article update information

    • 2014/8/21 finish process of installation
    • 2014/8/15 update
    • 2014/8/15 Begin writing this Article.
    • 2016/4/17 Add ntp set up
 
about 7 years ago

Opendaylight for openflow1.3 build on ubuntu 14.04-lts

Preparation

  1. INSTALL ORACLE JAVA 7

    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java7-installer
    export JAVA_HOME=/usr/lib/jvm/java-7-oracle/     //you can add it to your bashrc.
    

    Then, you can use 'java -version' to test install successfully.

  2. INSTALL maven

    sudo apt-get install maven
    

    Then, you can use 'mvn -v' to test install successfully.
    如果你完全安裝完,版本應該均要大於下面的範例,(我嘗試到最後這一版是最容易成功的)

    Apache Maven 3.0.5
    Maven home: /usr/share/maven
    Java version: 1.7.0_67, vendor: Oracle Corporation
    Java home: /usr/lib/jvm/java-7-oracle/jre
    Default locale: en_US, platform encoding: UTF-8
    OS name: "linux", version: "3.13.0-32-generic", arch: "amd64", family: "unix"
    
  3. INSTALL git

    sudo apt-get install git
    

    Start building opendaylight

  4. Pull code

    • Here, I use ssh to pull code. If you also want to use 'ssh', you have to register in opendaylight git link. And then, follow Gerrit_Setup to register SSH key.
    • Or, you can use http to git opendaylight file. Please refer to pull code.
    • But I didn't check these are same.
      export ODL_USERNAME=<username for the account you created at OpenDaylight>
      //for example export ODL_USERNAME=tutul
      
      mkdir opendaylight;cd opendaylight
      for PROJECT in affinity bgpcep controller defense4all dlux integration \
      lispflowmapping opendove openflowjava openflowplugin ovsdb vtn yangtools; \
      do git clone ssh://${ODL_USERNAME}@git.opendaylight.org:29418/${PROJECT}.git; \
      done
      
  5. Cmpiling code

    • Set up environment variables
      export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m"
      
      Then, start compiler.
    • May be, you need to step by step enforce each command, becouse compiler possibly appear error.
    • However, if controller can be compiled, the Opendaylight can run normally.
    • 因為osgi的架構,所有的專案可以被分開撰寫,但只編譯其中一個專案也是可以run,而核心的專案即是controller,因專案裡會放置基本可以運作的原件,故基本功能均可正常運行。
      (cd controller;mvn clean install)
      (cd affinity;mvn clean install)
      (cd bgpcep;mvn clean install)
      (cd lispflowmapping;mvn clean install)
      (cd openflowjava;mvn clean install)
      (cd openflowplugin;mvn clean install)
      (cd ovsdb/commons/parent;mvn clean install)
      (cd vtn;mvn clean install)
      (cd yangtools;mvn clean install)
      
    • 或這你的需求只是想先編譯稍微測試運作,那麼你可以只編譯下列地方,亦可正常運作。 (cd opendaylight/controller/opendaylight/distribution/opendaylight;mvn clean install)
  6. Run the controller and simply test

    ./controller/opendaylight/distribution/opendaylight/target/distribution.opendaylight-osgipackage/opendaylight/run.sh
    
    • And then, open the browser, input URL 'http://127.0.0.1:8080/'.
    • You will see opendaylight management web site. (default login user name: admin; passwd:admin )
  7. 未完... (還剩測試的部分)

  8. Reference
    http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
    http://www.jedelman.com/home/getting-opendaylight-installed
    https://wiki.opendaylight.org/view/GettingStarted:Pulling,_Hacking,_and_Pushing_All_the_Code_from_the_CLI

  9. Article update information

    • 2014/9/04 更改為以 14.04 編譯,才成功編過,完整的controller專案
    • 2014/8/02 Add "6.Run the controller and simply test"
    • 2014/7/26 Begin writing this Article.