Tuesday, May 15, 2012

VirtualBox on headless CentOS 6

Due to the need to install a server which will be used mainly for hosting virtual machines, but also be capable to provide other services, such as being FTP and Samba server, I decided to go with the CentOS Linux, without having X windows and such unnecessary things installed, Oracle’s VirtualBox, and the PHP front-end for it called phpVirtualBox.
Anyway, to make a long story short, here’s how to do it.

First of, obviously, we’ll need to install CentOS on the machine. The only thing that should be highlighted about this phase is to choose the Basic Server installation method and let the installation process finish.

Once the installation is finished and the system is up and running the first thing that we should do is to login as root and update it:
yum -y update
After the update is finished reboot the machine to make it boot into the fresh new kernel.

Next, the regular user should be added to the system:
useradd reguser
and, to unlock newly created user account and set the password:
passwd reguser

The following two steps aren’t really necessary, but since I’m running this server inside the LAN, and don’t need SELinux and firewall to be enabled I disabled all of those.

Disable SELinux by editing the /etc/selinux/config file and changing the value of SELINUX variable from enforcing to disabled. This change will take effect after the machine is rebooted. To disable SELinux right away type:
setenforce 0

Disabling iptables firewall consists of the following commands:
service iptables save
service iptables stop
chkconfig iptables off
service ip6tables save
service ip6tables stop
chkconfig ip6tables off

After all that we will need to install Apache web server, PHP and PHP SOAP extension (which is needed by the phpVirtualBox to operate properly), start Apache web server and set it to start automatically on boot (didn’t need to edit the Apache config file, since the default one was just fine for me):
yum -y install httpd php php-soap
service httpd start
chkconfig httpd on

We will also need to install the Development Tools group, which is a prerequisite for VirtualBox kernel modules to compile:
yum -y groupinstall "Development Tools"

After that, we add the VirtualBox repository to the list of the repositories on our system.
wget -O /etc/yum.repos.d/virtualbox.repo http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo

Now it’s time to install VirtualBox:
yum -y install VirtualBox-4.1

Once the installation is done add the regular user to the vboxusers user group:
usermod -G vboxusers reguser

Download and unzip the latest version of the phpVirtualBox:
wget `wget -q -O - http://phpvirtualbox.googlecode.com/files/LATEST.txt`
unzip phpvirtualbox-*.zip

Then, copy the phpVirtualBox files to the Apache Documents Root directory:
cp -r phpvirtualbox-*/* /var/www/html/

Next, copy and edit the phpVirtualBox configuration file:
cp /var/www/html/config.php-example /var/www/html/config.php
vim /var/www/html/config.php
The username and password variables within this file should be changed to reflect the values set for regular user, under whose credentials we will run VirtualBox, for example:
var $username = 'reguser';
var $password = 'verycomplexpass';

If not already present create the config file for the VirtualBox web service (/etc/default/virtualbox). This file should contain at least the VBOXWEB_USER variable. My system didn’t have it so I just put this one variable into it:
echo "VBOXWEB_USER='reguser'" > /etc/default/virtualbox

Now start the vboxweb service and configure it to start automatically on boot:
service vboxweb-service start
chkconfig vboxweb-service on

Enable USB support in VirtualBox:
mkdir /vbusbfs
echo "none /vbusbfs usbfs rw,devgid=$(awk -F : '/vboxusers/ {print $3}' /etc/group),devmode=664 0 0" >> /etc/fstab
mount -a

Install the VirtualBox Extension Pack (has to be the same version as VirtualBox itself, and is required in order to be able to run the guest’s console through web interface):
wget http://download.virtualbox.org/virtualbox/4.1.10/Oracle_VM_VirtualBox_Extension_Pack-4.1.10-76795.vbox-extpack
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.1.10-76795.vbox-extpack

After all that, install the custom init script to start and stop virtual machines automatically on startup and shutdown:
wget http://www.dzinovic.net/dl-files/vmsctrl/vbox/vmsctrl.tar.gz
tar xvzf vmsctrl.tar.gz -C /etc/init.d/
chkconfig --add vmsctrl

Last, but not least, make your system automatically recompile VirtualBox kernel modules on kernel update:
wget http://www.dzinovic.net/dl-files/vmsctrl/vbox/VBoxCompileInstall
chmod +x VBoxCompileInstall
./VBoxCompileInstall
The original of the above script was found here and modified a bit to match CentOS.

That should be it, now reboot your machine once more for everything to settle up, and once it’s up connect to the phpVirtualBox interface by simply typing the IP address of your server into your web browser.
Default username/password combination is admin/admin.
<Sưu tầm Dzinovic>

Wednesday, September 28, 2011

Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)

How do I increase the maximum number of open files under CentOS Linux? How do I open more file descriptors under Linux?

The ulimit command provides control over the resources available to the shell and/or to processes started by it, on systems that allow such control. The maximum number of open file descriptors displayed with following command (login as the root user).

Tuesday, August 30, 2011

Apache Web using POP3 Auth

Install Auth mechanism.
cpan install Apache::AuthPOP3
cpan install Net::POP3

Apache configuration
httpd.conf
ServerName userweb.linuxreaders.com
DocumentRoot /home/userweb
DirectoryIndex index.html
PerlModule Apache::AuthDBI
AuthName "Enter your Email ID & Password"
AuthType Basic
PerlAuthenHandler Apache::AuthPOP3
PerlSetVar        MailHost pop.linuxreaders.com
#PerlSetVar        UserMap pop3user1=>realname1,pop3user2=>realname2
Require valid-user 
 
 

Wednesday, July 6, 2011

Mysql command

Join tables on common columns.

mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;

Wednesday, January 12, 2011

This is a linux command line reference for common operations.

CommandDescription
•apropos whatisShow commands pertinent to string. See also threadsafe
•man -t ascii | ps2pdf - > ascii.pdfmake a pdf of a manual page
 which commandShow full path name of command
 time commandSee how long a command takes
•time catStart stopwatch. Ctrl-d to stop. See also sw
dir navigation

Tuesday, December 28, 2010

Cài đặt và cấu hình Subversion


1-      Cài đặt apache và svn:  yum install --exclude=*.i386 httpd* mod_dav_svn
2-      Cấu hình web apache:  vi /etc/httpd/conf.d/subversion.conf

+ Đường dẫn lưu trú của repos : /var/www/svn/kimsach/
            Cách tạo:
            #mkdir /var/www/svn
            #svnadmin create /var/www/svn/kimsach

Thursday, December 16, 2010

Checking the file attributes using lsattr

lsattr is a command line program for listing the attributes on a Linux second extended file system
It is also a command to display attributes of devices on an AIX operating system

Tuesday, December 14, 2010

Quản lý tri thức-Một xu hướng của quản trị kinh doanh hiện đại

Trong điều kiện toàn cầu hóa kinh tế đang diễn ra một cách nhanh chóng trên toàn thế giới, cùng với sự phát triển với tốc độ chóng mặt của cuộc cách mạng khoa học kỹ thuật và công nghệ, các công ty đối mặt với rất nhiều cơ hội và thách thức do toàn cầu hóa và cuộc cách mạng khoa học - kỹ thuật - công nghệ mang lại. Nguồn nhân lực đã trở thành “một tài sản quý nhất, quan trọng nhất và quyết định nhất” cho sự tồn tại và phát triển của bất kỳ một tổ chức nào. Song, khi chúng ta nói về những nhận thức được hầu hết mọi người chấp nhận này thì cần phải hiểu đó là nguồn nhân lực có tri thức, có kỹ năng ở trình độ cao, biết lao động sáng tạo chứ không phải sức lao động cơ bắp dựa trên kinh nghiệm. Lực lượng lao động xã hội đã có sự chuyển biến rõ rệt từ những công nhân “cổ xanh” là chủ yếu thành những công nhân “cổ trắng” là chủ yếu.  Peter Drucker (1993)-một chuyên gia hàng đầu của lý luận quản lý- đã nhận xét rằng: “Trong thời kỳ 1880, khoảng chín phần mười số người lao động là lao động chân tay; ngày nay, con số này giảm xuống một phần năm. Bốn phần năm lực lượng lao động là những người lao động tri thức”.

Monday, December 6, 2010

Bandwidth, Network and Servers Monitoring tools with Installation Tutorials

Nagios

Nagios is a host and service monitor designed to inform you of network problems before your clients, end-users or managers do. It has been designed to run under the Linux operating system, but works fine under most *NIX variants as well. The monitoring daemon runs intermittent checks on hosts and services you specify using external "plugins" which return status information to Nagios. When problems are encountered, the daemon can send notifications out to administrative contacts in a variety of different ways (email, instant message, SMS, etc.). Current status information, historical logs, and reports can all be accessed via a web browser.

Installation and Configuration

http://www.debianhelp.co.uk/nagios.htm

Oreon

Oreon© is an Open Source monitoring solution based on Nagios. It offers to this monitoring standard a new front end and brings it a panel of new functionalities.

Installation and Configuration

Friday, November 5, 2010

The services of Centos

Stop unnecessary services for your system which are enabled on the default settings
NetworkManager The NetworkManager daemon attempts to keep an active network connection available at all times.  
acpid Advanced Configuration and Power Interface event daemon.  
anacron Anacron can be used to execute commands periodically, with a frequency specified in days.  
apmd Advanced Power Management (APM) BIOS utilities for laptops.  
atd atd runs jobs queued by at.  
auditd The audit package contains the user space utilities for storing and searching the audit records generate by the audit subsystem in the Linux 2.6 kernel. *
autofs autofs controls the operation of the automount(8) daemons running on the Linux system.  
avahi-daemon Avahi mDNS/DNS-SD daemon Avahi is a fully LGPL framework for Multicast DNS Service Discovery.  
avahi-dnsconfd avahi-dnsconfd is a small daemon which may be used to configure conventional DNS servers using mDNS in a DHCP-like fashion.  
bluetooth It provids wireless connections among computers.  
conman ConMan is a serial console management program designed to support a large number of console devices and simultaneous users.  
cpuspeed This program monitors the systemfs idle percentage and reduces or raises the CPUsf clock speeds and voltages accordingly to minimize power consumption when idle and maximize perfor-mance when needed.  
crond The daemon to execute scheduled commands. *
cups It's the print system.  
dund It's BlueZ Bluetooth dial-up networking daemon.  
firstboot It's a tool that we can configure basic settings ofthe system by it.  
gpm It's a cut and paste utility and mouse server for virtual consoles.  
haldaemon It searches infomations for hardwares.  
hidd It's Bluetooth HID daemon.  
ip6tables It's IPv6 packet filter administration.  
iptables It's administration tool for IPv4 packet filtering and NAT.  
irda IrDA is a complete implementation of the various IrDA protocols and IrDA drivers for Linux.  
irqbalance It distributes hardware interrupts across processors on a multiprocessor system. *
kudzu It detects and configures new and/or changed hardware on a system.  
lvm2-monitor Monitor LVM2 with using dmeventd.  
mcstrans It's the daemon for SELinux.  
mdmonitor It watches software-based RAID.  
mdmpd It watches software-based RAID.  
messagebus It sends messages between apprications. *
microcode_ctl It's microcode utility for Intel IA32 processors.  
multipathd Manage kernel's function called DeviceMapper.  
netfs It's NFS client.  
netplugd It's the daemon for network cable hotplug management.  
network It's the daemon for network system. *
nfs It's NFS server.  
nfslock It provids file lock function for NFS server.  
nscd Nscd is a daemon that provides a cache for the most common name service requests.  
oddjobd The oddjobd daemon provides the com.redhat.oddjob service on the system-wide message bus.  
pand The pand PAN daemon allows your computer to connect to ethernet networks using Bluetooth.  
pcscd It's PC/SC Smart Card Daemon.  
portmap Portmap is a server that converts RPC program numbers into DARPA protocol port numbers.  
psacct PSACCT is a standard process running on each node that generates daily usage logs containing information on the jobs that ran and how many resources they consumed.  
rawdevices The rawdevices is allocated in the block device.  
rdisc Detect routers in local subnet.  
readahead_early It reads files in page cache early.  
readahead_later It reads files in page cache early when system is running in GUI mode.  
restorecond It's the daemon that watches for file creation and then sets the default SELinux file context.  
rpcgssd It's the daemon which is used for network filesystem like NIS or NFS.  
rpcidmapd It's the daemon which is used for network filesystem like NIS or NFS.  
rpcsvcgssd It's the daemon which is used for network filesystem like NIS or NFS.  
saslauthd saslauthd is a daemon process that handles plaintext authentication requests on behalf of the SASL library.  
sendmail It's SMTP server.  
smartd It's SMART Disk Monitoring Daemon.  
sshd It's OpenSSH SSH daemon. *
syslog It reads and/or clears kernel message ring buffer; set console_loglevel. *
tcsd TrouSerS server daemon  
wpa_supplicant Provide IEEE 802.1x authentication.  
xfs It's X fonts server.  
ypbind ypbind finds the server for NIS domains and maintains the NIS binding information.  
yum-updatesd yum-updatesd provides notification of updates which are available to be applied to your system.

Tuesday, October 19, 2010

Những công nghệ sử dụng trên Facebook

Là một trong những mạng xã hội có số lượng thành viên lớn nhất thế giới, Facebook phải sử dụng những công nghệ cực kì hiện đại mới có thể vận hành cỗ máy khổng lồ như vậy.



Facebook - mạng xã hội quen thuộc với cộng đồng dân cư mạng

Thursday, October 7, 2010

Kiểm tra thông tin phần cứng trên Linux bằng dmidecode Command

dmidecode - đọc bảng DMI của hệ thống và hiển thị thông tin về phần cứng và BIOS

Ngoài /proc/cpuinfo, /proc/meminfo, lshw, ... lệnh này sẽ hữu ích trong một số trường hợp.

Wednesday, October 6, 2010

Bí kíp cảm thụ nhạc cổ điển

Với một bài văn là con thuyền “chở” ý thì bản nhạc tự nó đến với ta, không nhờ ai “chở” đi và có thể cũng không “chở” ai đi. Chúng ta thưởng thức bản thân âm thanh chứ không thưởng thức cái mà âm thanh mang đến.

Tuesday, October 5, 2010

OpenSSH SFTP with ChrootDirectory step by step

1- Cài đặt các gói hổ trợ
yum install --exclude=*.i386 gcc openssl-devel pam-devel rpm-build
2- Download các gói và import key
wget http://ftp.bit.nl/mirror/openssh/openssh-5.2p1.tar.gz
wget http://mirror.anl.gov/openssh/portable/openssh-5.2p1.tar.gz
wget http://mirror.anl.gov/openssh/portable/openssh-5.2p1.tar.gz.asc
wget -O- http://mirror.anl.gov/openssh/portable/DJM-GPG-KEY.asc | gpg --import
gpg openssh-5.2p1.tar.gz.asc

Sunday, October 3, 2010

Turn off some commonly unneeded services

Keeping a server appliance healthy can often mean nothing more than getting rid of services that absorb resources. These services are things that are installed by default, but are not used. Here is a quick BASH script to turn off some commonly unneeded services. While I titled this post Centos 5.x, you should be able to use it with most any distro that makes use of /etc/init.d/SCRIPT scripts.

Friday, October 1, 2010

Chống DOS đơn giản dạng SYN attack

If you want to block an ip when it reaches a limited number of connections then here is your solution
This script limits to 100 connections and on port 80, you can change both of them and run this at cron on every 1 minute.

#!/bin/bash

#Collecting list of ip addresses connected to port 80

netstat -plan|grep :80|awk {'print $5'}|cut -d: -f 1|sort|uniq -c|sort -nk 1 > /root/blocked.ip.txt

Sunday, September 26, 2010

Có tiền đầu tư vào đâu?


Bất động sản chưa tan băng, thị trường chứng khoán chưa có nhiều khởi sắc, trong khi giá USD đang dần ổn định sau đợt điều chỉnh tỷ giá tháng 8-2010. Liệu tiết kiệm và vàng có là kênh đầu tư hút tiền trong thời gian tới?
 

Khái niệm đơn giản về khẩu độ ống kính

Cơ cấu chỉnh khẩu độ chính là một loại van tiết lưu ánh sáng đặt trong ống kính , cấu tạo bởi các lá thép mỏng chồng so le với nhau, ở giữa mở ra một lỗ tròn đồng tâm với các thấu kính.

Các cánh thép này có thể trượt trên nhau khi ta điều chỉnh để tạo ra độ mở lớn hay nhỏ cho ánh sáng đi qua. Hoạt động bóp nhỏ/mở rộng khẩu độ khẩu độ của ống kính giống như sự điều tiết của con ngươi mắt. Độ mở lớn hay nhỏ sẽ cho ánh sáng đi vào phim hay CCD (của digital camera) nhiều hay ít. Trị số khẩu độ được sắp xếp theo chuỗi lớn dần gọi là f-number. Độ mở ống kính là giá trị được xác định bởi độ dài tiêu cự (focal length = khoảng cách từ tâm ống kính tới mặt phim hay CCD) của nó với đường kính lỗ xuyên sáng do các lá thép mở ra.

Sunday, October 25, 2009

SSH Port Forwarding

Introduction
SSH is typically used for logging into remote servers so you have shell access to do maintenance, read your email, restart services, or whatever administration you require. SSH also offers some other native services, such as file copy (using scp and sftp) and remote command execution (using ssh with a command on the command line after the hostname).

Saturday, October 17, 2009

Create a Hot Backup Server

The goal is to create a backup that will provide a server which has been replicated to act as a replacement if the original server goes down. This example is assuming exact same hardware and two servers on the same network.