[NAS] Cài đặt hệ thống high-availability storage với GlusterFS trên Ubuntu server

1. GlusterFS là gì?
GlusterFS là 1 opensource cho phép mở rộng hệ thống lưu trữ file lên tới vài peta-byte và xử lý cùng lúc cho hàng ngàn client, nó tập hợp các server lưu trữ khác nhau trên Ethernet hoặc RDMA kết nối thành một hệ thống lưu trữ tập tin lớn và song song.
Trong một số trường hợp, GlusterFS được lựa chọn như một giải pháp mềm và ít tốn kém chi phí thay thế cho SAN (một giải pháp cứng trong vấn đề lưu trữ với chi phí cao hơn nhiều)
Các ưu điểm của GlusterFS cần phải kể đến bao gồm:

[Linux] Hướng dẫn cấu hình OpenVPN trên Ubuntu server

VPN (virtual private network) là công nghệ xây dựng hệ thống mạng riêng ảo nhằm đáp ứng nhu cầu chia sẻ thông tin, truy cập từ xa và tiết kiệm chi phí. Trước đây, để truy cập từ xa vào hệ thống mạng, người ta thường sử dụng phương thức Remote Access quay số dựa trên mạng điện thoại. Phương thức này vừa tốn kém vừa không an toàn. VPN cho phép các máy tính truyền thông với nhau thông qua một môi trường chia sẻ như mạng Internet nhưng vẫn đảm bảo được tính riêng tư và bảo mật dữ liệu.
Thông thường ở những công ty lớn, việc VPN sẽ do một thiết bị layer 3 có hỗ trợ VPN đảm nhiệm để đảm bảo tính ổn định và chuyên biệt cho 1 hệ thống VPN. Đối với một công ty vừa và nhỏ, khi mà chi phí trang bị cho hạ tầng hạn hẹp, chúng ta thường sẽ nghĩ ngay tới các giải pháp mềm để thay thế cho phần cứng đắt tiền và tốn kém.
Bài viết này mình sẽ hướng dẫn các bạn một giải pháp VPN mềm opensource, sử dụng để kết nối VPN vào private network thông qua server Ubuntu đã được cấu hình OpenVPN.

[Linux] Create and extract zip, tar, tar.gz and tar.bz2 in Linux (Ubuntu, Redhat, CentOS)

Linux has a variety of tools for working with compressed data. This article will describe how to use them, and why.

Compression programs look for patterns in the data, and then replace the original file with a file that describes those patterns. Nothing is lost--that description contains all the information needed to recreate the original file. The description will be smaller than the original file, but how much smaller will depend on the data itself and the compression scheme used.

[Linux] Setup bind9 làm DNS server và name server trên Ubuntu server 12.04 toàn tập

BIND hay là named, là phần mềm DNS được sử dụng rộng rãi nhất trên Internet. Ban đầu được viết bởi bốn sinh viên Nhóm nghiên cứu tốt nghiệp tại Đại học California, Berkeley (UCB), tên bắt nguồn như một từ viết tắt từ Berkeley Internet Name Domain, phản ánh sử dụng ứng dụng của UCB. BIND lần đầu tiên được phát hành với Berkeley Software Distribution. Paul Vixie bắt đầu duy trì nó trong năm 1988 trong khi làm việc cho Tổng công ty Thiết bị kỹ thuật số. Năm 2012, Internet Systems Consortium duy trì, cập nhật, và viết phiên bản mới của BIND. Phiên bản mới nhất của BIND, BIND 10 1.1.0 được phát hành vào ngày 6 tháng 6 2013, nhưng vẫn không hỗ trợ trên Windows, mặc dù BIND 9 có hỗ trợ Windows đầy đủ.
Bài viết này hướng dẫn cài đặt bind9 trên Ubuntu 12.04 làm DNS server và nameserver để quản lý các record cho public domain, phân giải record cho client theo phân vùng địa lý.

[Troubleshooting] apt-get error problem Ubuntu 12.04 and 14.04

How to fix some of the common errors encountered using ubuntu, if you get an error similar yet, please post immediately comment in this article, we will fix to you immediately.

[Linux] Ubuntu mount to folder shared on Windows

Step 1. Install smbfs
sudo apt-get install smbfs
Step 2. Create script file with content:
sudo mount -t smbfs -o username=user //192.168.2.12/qgs/Ins" "QGS/Documents/BA" "Team/Prototypes /var/www/mock
If you want auto mount smbfs after server restart
sudo nano /etc/fstab
Add line:
//192.168.2.12/qgs/Ins\040QGS/Documents/BA\040Team/Prototypes /var/www/mock cifs username=user,password=pass 0 0
Notes: \040 is space in patch for smbfs mount.

[Linux] Basic Linux command - Continuous update

hostname: hiển thị tên máy
netconf | hostname: thay đổi tên máy
whoami: hiển thị tên người dùng hiện tại
id: hiển thị id của các nhóm và người dùng
date: hiển thị ngày giờ hệ thống
date -s "2013-04-25 09:30:10AM": thay đổi ngày giờ hệ thống
top: hiển thị danh sách những tiến trình đang chiếm dụng CPU nhiều nhất
free: hiển thị thông tin bộ nhớ (ở dạng kilobytes, dùng thêm -m để hiển thị ở dạng megabytes)
df -h: hiển thị thông tin đĩa ở chế độ dễ đọc cho người dùng
cat /proc/cpuinfo: hiển thị thông tin CPU
cat /proc/version: hiển thị thông tin phiên bản Linux
lsb_release -a | cat /etc/issue | cat /etc/lsb-release : for ubuntu version
cat /etc/redhat-release: for centos version

[Linux] Logical Volume Snapshoot on Ubuntu server

1. Khái niệm
a. Khái niệm về volume
- Physical Volume: Là một cách gọi khác của partition trong kỹ thuật LVM, nó là những thành phần cơ bản được sử dụng bởi LVM. Một Physical Volume không thể mở rộng ra ngoài phạm vi một ổ đĩa.
- Logical Volume group: Nhiều Physical Volume trên những ổ đĩa khác nhau được kết hợp lại thành một Logical Volume Group, với LVM Logical Volume Group được xem như một ổ đĩa ảo.
- Logical Volumes: Logical Volume Group được chia nhỏ thành nhiều Logical Volume, mỗi Logical Volume có ý nghĩa tương tự như partition. Nó được dùng cho các mount point và được format với những định dạng khác nhau như ext2, ext3, ext4...
Nói một cách nôm na, LVM thực hiện nhóm các ổ vật lý (physical volume) lại thành nhóm volume (logical volume group) từ đó chia ra các logical volume để tiện quản lý.

[Linux] Setup NFS shared folder on Ubuntu server

1. On server
S1. Setup NFS Kernel server
sudo apt-get install nfs-kernel-server 
S2. Define shared folder
sudo nano /etc/exports
Add these line
/data    *(rw,sync,no_root_squash)
S3. Restart NFS Kernel server
sudo /etc/init.d/nfs-kernel-server start

2. On client
S1. Setup NFS common
sudo apt-get install nfs-common
S2. Mount to NFS server
sudo mount example.hostname.com:/ubuntu /local/ubuntu
S3. Mount after start:
sudo nano /etc/fstab
Add these line:
example.hostname.com:/ubuntu /local/ubuntu nfs rsize=8192,wsize=8192,timeo=14,intr

[NodeJS] Install NodeJS and forever package on Ubuntu server

1. Setup Nodejs
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
2. Run a nodejs project
Use cd command to project Nodejs folder
cd /data/nodejs
and type
node app.jss
3. Run nodejs in silent mode with forever package:
- Forever package:
+ Running in silent mode, non stop while press Ctrl-C on terminal
+ Auto restart server when crash.
- Installing:
Use cd command to project Nodejs folder
cd /data/nodejs
and type
npm config set registry http://registry.npmjs.org/
npm install forever
- Star nodejs project with log file:
cd /data/nodejs
./node_modules/forever/bin/forever start -l /data/nodejs/logs/server.log -a app.js

[Linux] Nén và giải nén file có đuôi .gz

1. Nén và giải nén file có đuôi .gz
1.1 Nén
#gzip [tên file]
1.2 Giải nén
#gunzip [tên file]
2. Gom và bung tập tin hoặc thư mục đuôi .tar
2.1 Gom
#tar -cvf [tênfile.tar] [file1] [file2] ...
2.2 Bung
#tar -xvf [file.tar]
2.3 Nén và Gom
#tar -zcvf [file.tar.gz] file1 file2 ...
2.4 Giải nén và bung
#tar -zxvf [file.tar.gz]
3. Giải nén file có đuôi .bz2
#tar xjvf [file.tar.bz2]

[Linux] How to use unison for synchronize files

Replication folder /tmp/srv238 (on 192.168.2.238) <-> /tmp/srv239 (on 192.168.2.239) (master-master) with user: super.
S1. Setup login ssh without password
- Create public key and private key in ssh client:
ssh-keygen -t dsa
- Copy public key from client to ssh server:
ssh-copy-id -i ~/.ssh/id_dsa super@webserver2
S2. Config file Unison, auto answer request
sudo nano /home/super/.unison/default.prf
Edit file
root = /tmp/server238
root = ssh://192.168.2.239//tmp/server239
auto=true
batch=true
S3. Start
Manual start:
unison default
Auto start every 1 minute:
crontab -e
and add line:
  1 * * * * unison default
S4. Log
tail -f /home/super/.ssh/unison.log