1. Giới thiệu
OpenVZ là hệ thống máy ảo sử dụng phương pháp ảo hóa hệ điều hành dựa trên nhân Linux và hệ điều hành. OpenVZ cho phép một máy chủ vật lý chạy nhiều hệ điều hành độc lập gọi là Containers. OpenVZ hỗ trợ nhiều nền tảng vi xử lý hơn là các bản luân phiên. VMware Server và Xen có thể dùng được cho dòng x86, AMD 64; còn OpenVZ được chấp nhận ở dòng x86, AMD64, Itanium (IA64), PowerPC, và UltraSPARC.
Chú ý là hiện nay chưa có các kernel (nhân hệ điều hành) PowerPC xây dựng trước cho Debian, nhưng OpenVZ được hỗ trợ trên PowerPC. 3.1
2. Cài đặt
Phần này hướng dẫn cài đặt một hệ thống OpenVZ để cung cấp máy ảo, được quản trị thông qua công cụ nguồn mở ISPConfig 3.
ISConfig 3 và giải pháp nguồn mở chuyên dụng dành riêng cho hosting, email, DNS và OpenVZ. ISPConfig 3 hỗ trợ giao diện web-based để thực hiện các thao tác quản trị, vận hành đối với các dịch vụ hosting, email, DNS và OpenVZ.
==== Mô hình cài đặt
Hình 1: Mô hình cài đặt
Mô hình sử dụng hai máy ảo được cài đặt bằng chương trình Virtual Box gồm các tính năng
o Master Server: Có chức năng làm server chạy các tính năng chính của ISPConfig 3 dưới dạng All-in-one và cung cấp giao diện Web cho người dùng.
o OpenVZ Server: Có chức năng tạo và lưu trữ các máy ảo, được kết nối chức năng với Master Server thông qua ISPConfig 3, sử dụng chung giao diện Web và CSDL
Lưu ý: mô hình triển khai bao gồm 2 máy, tuy nhiên mô hình này hoàn toàn có khả năng mở rộng ra được mà không hề ảnh hưởng đến hiệu năng. Ví dụ: có thể triển khai thêm các server cung cấp dịch vụ OpenVZ hoặc các server cung cấp dịch vụ hosting website, MySQL, email hoặc DNS.
Cả hai máy ảo sử dụng hệ điều hành: Debian 6 phiên bản 64bit
==== Cài đặt Master Server
o Thêm repository để cài đặt các gói
1 |
#nano /etc/apt/sources.list |
1 2 3 4 5 |
[...] # deb cdrom:[Debian GNU/Linux 6.0.7 _Squeeze_ - Oficial amd64 CD Binary-1 20130223-14:06]/ squeeze main [...] deb http://ftp.hk.debian.org/debian/ squeeze main contrib non-free deb-src http://ftp.hk.debian.org/debian/ squeeze main contrib non-free |
o Cấu hình địa chỉ IP
1 |
#nano /etc/network/interfaces |
1 2 3 4 5 6 7 8 |
auto eth0 iface eth0 inet static address 10.0.1.10 netmask 255.255.255.0 network 10.0.1.0 broadcast 10.0.1.255 gateway 10.0.1.1 dns-nameservers 8.8.8.8 |
o Khởi động lại network để cập nhật cấu hình
1 |
#/etc/init.d/networking restart |
o Cấu hình file hosts
1 |
#nano /etc/hosts |
1 2 3 |
[...] 10.0.1.10 master.blogit.edu.vn master 10.0.1.20 openvz.blogit.edu.vn openvz |
o Cập nhật hệ thống
1 2 |
#apt-get update #apt-get upgrade |
o Thay đổi Shell mặc định
1 2 |
#dpkg-reconfigure dash Use dash as the default system shell (/bin/sh)? <-- No |
o Cài đăt NTP, Postfix, Dovecot, Saslauthd, MySQL, phpMyAdmin, rkhunter, binutils
1 |
#apt-get install postfix postfix-mysql postfix-doc mysql-client mysql-server openssl getmail4 rkhunter binutils dovecot-imapd dovecot-pop3d sudo ntp ntpdate |
Trong quá trình cài đặt, trả lời các câu hỏi như sau:
1 2 3 4 |
General type of mail configuration: <-- Internet Site System mail name: <-- master.blogit.edu.vn New password for the MySQL "root" user: <-- yourrootsqlpassword Repeat password for the MySQL "root" user: <-- yourrootsqlpassword |
o Cấu hình TLS/SSL và submission ports cho Postfix
1 |
#nano /etc/postfix/master.cf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[...] submission inet n - - - - smtpd -o syslog_name=postfix/submission -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject # -o milter_macro_daemon_name=ORIGINATING smtps inet n - - - - smtpd -o syslog_name=postfix/smtps -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject # -o milter_macro_daemon_name=ORIGINATING [...] |
o Khởi động lại Postfix
1 |
#/etc/init.d/postfix restart |
o Cấu hình để MySQL lắng nghe trên tất cả các interfaces
1 |
#nano /etc/mysql/my.cnf |
1 2 3 4 5 |
[...] # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. #bind-address = 127.0.0.1 [...] |
o Khởi động lại MySQL
1 |
#/etc/init.d/mysql restart |
o Cài đặt amavisd-new, SpamAssassin, ClamAV
1 |
#apt-get install amavisd-new spamassassin clamav clamav-daemon zoo unzip bzip2 arj nomarch lzop cabextract apt-listchanges libnet-ldap-perl libauthen-sasl-perl clamav-docs daemon libio-string-perl libio-socket-ssl-perl libnet-ident-perl zip libnet-dns-perl |
Trong lúc cài đặt, ISPConfig 3 sẽ tự tải SpamAssassin filter library, nên cần
Stop SpamAssassin để giải phóng RAM
1 2 |
#/etc/init.d/spamassassin stop #update-rc.d -f spamassassin remove |
o Cài đặt Apache2, PHP5, phpMyAdmin, FCGI, suExec, Pear, mcrypt
1 |
#apt-get install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap phpmyadmin php5-cli php5-cgi libapache2-mod-fcgid apache2-suexec php-pear php-auth php5-curl php5-mcrypt mcrypt php5-imagick imagemagick libapache2-mod-suphp libruby libapache2-mod-ruby libapache2-mod-python libapache2-mod-perl2 |
Trong lúc cài đặt, trả lời các câu hỏi như sau
1 2 |
Web server to reconfigure automatically: <-- apache2 Configure database for phpmyadmin with dbconfig-common? <-- No |
o Bật các module chức năng Apache như suexec, rewrite, ssl, actions và include
1 2 |
#a2enmod suexec rewrite ssl actions include #a2enmod dav_fs dav auth_digest |
o Khởi động lại Apache
1 |
#/etc/init.d/apache2 restart |
o Cài đặt PureFTPd và Quota
1 |
#apt-get install pure-ftpd-common pure-ftpd-mysql quota quotatool |
o Cấu hình chế độ khởi động và virtualchroot của PureFTP
1 |
#nano /etc/default/pure-ftpd-common |
1 2 3 4 5 |
[...] STANDALONE_OR_INETD=standalone [...] VIRTUALCHROOT=true [...] |
o Cấu hình để inetd không khởi động ftp (comment dòng ftp stream .. nếu có)
1 |
#nano /etc/inetd.conf |
1 2 3 4 |
[...] #:STANDARD: These are standard services. #ftp stream tcp nowait root /usr/sbin/tcpd /usr/sbin/pure-ftpd-wrapper [...] |
o Khởi động lại inetd nếu có thay đổi
1 |
#/etc/init.d/openbsd-inetd restart |
**Tùy chọn: FTP là giao thức kém bảo mật do tất cả mật khẩu và dữ liệu khi truyền tải đều ở dạng clear text, vì vậy cần sử dụng TLS để bảo mật
o Kích hoạt TLS cho FPT
1 |
#echo 1 > /etc/pure-ftpd/conf/TLS |
o Tạo chứng thư SSL
1 2 |
#mkdir –p /etc/ssl/private/ #openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem<span style="line-height: 1.71429; color: #444444; font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 1rem; background-color: #ffffff;"> </span> |
1 2 3 4 5 6 7 |
Country Name (2 letter code) [AU]: <-- VN State or Province Name (full name) [Some-State]: <-- DN Locality Name (eg, city) []: <-- DN Organization Name (eg, company) [Internet Widgits Pty Ltd]: <-- Blogit Organizational Unit Name (eg, section) []: <-- Blogit Common Name (eg, YOUR name) []: <-- vuht Email Address []: <-- ENTER |
o Thay đổi permission của chứng chỉ SSL
1 |
#chmod 600 /etc/ssl/private/pure-ftpd.pem |
o Khởi động lại PureFTPd
1 |
#/etc/init.d/pure-ftpd-mysql restart |
o Cấu hình fstab để kích hoạt chế độ partition quota cho / partition
1 |
#nano /etc/fstab |
1 2 3 |
[...] UUID=92bceda2-5ae4-4e3a-8748-b14da48fb297 / ext3 errors=remount-ro,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 0 1 [...] |
o Remount để cập nhật cấu hình
1 2 3 |
#mount –o remout / #quotacheck –avugm #quotaon –avug |
o Cài đặt BIND DNS Server
1 |
#apt-get install bind9 dnsutils |
o Cài đặt Vlogger, Webalizer và Awstats để thống kê lưu lượng truy cập cho Web Service
1 |
#apt-get install vlogger webalizer awstats geoip-database |
o Cài đặt Jailkit
1 2 3 4 5 6 7 8 9 |
#apt-get install build-essential autoconf automake1.9 libtool flex bison debhelper #cd /tmp #wget http://olivier.sessink.nl/jailkit/jailkit-2.15.tar.gz #tar xvfz jailkit-2.15.tar.gz #cd jailkit-2.15 #./debian/rules binary #cd .. #dpkg -i jailkit_2.15-1_*.deb #rm -rf jailkit-2.15* |
o Cài đặt fail2ban để quản lý log
1 |
#apt-get install fail2ban |
o Cấu hình cho phép fail2ban quản lý PureFTPd và Dovecot
1 |
#nano /etc/fail2ban/jail.local |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[pureftpd] enabled = true port = ftp filter = pureftpd logpath = /var/log/syslog maxretry = 3 [dovecot-pop3imap] enabled = true filter = dovecot-pop3imap action = iptables-multiport[name=dovecot-pop3imap, port="pop3,pop3s,imap,imaps", protocol=tcp] logpath = /var/log/mail.log maxretry = 5 |
o Tạo file pureftpd trong fail2ban
1 |
#nano /etc/fail2ban/filter.d/pureftpd.conf |
1 2 3 |
[Definition] failregex = .*pure-ftpd: \(.*@<HOST>\) \[WARNING\] Authentication failed for user.* ignoreregex = |
o Tạo file dovecot trong fail2ban
1 |
#nano /etc/fail2ban/filter.d/dovecot-pop3imap.conf |
1 2 3 |
[Definition] failregex = (?: pop3-login|imap-login): .*(?:Authentication failure|Aborted login \(auth failed|Aborted login \(tried to use disabled|Disconnected \(auth failed|Aborted login \(\d+ authentication attempts).*rip=(?P<host>\S*),.* ignoreregex = |
o Khởi động lại fail2ban
1 |
#/etc/init.d/fail2ban restart |
o Cài đặt Squidrrel Mail để làm Web mail client
1 |
#apt-get install squirrelmail |
o Tạo symlink từ Squirrelmail tới Webmail
1 |
#ln -s /usr/share/squirrelmail/ /var/www/webmail |
o Cấu hình SquirrelMail
1 |
#squirrelmail |
1 2 3 4 5 6 7 8 9 10 11 12 |
SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- [...] Command >> <-- D [...] Command >> <-- dovecot [...] Press any key to continue... <-- press a key [...] Command >> <-- S [...] Command >> <-- Q |
o Tải về giải nén source code ISPConfig 3
1 2 3 4 |
#cd /tmp #wget http://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz #tar xfz ISPConfig-3-stable.tar.gz #cd ispconfig3_install/install/ |
o Cài đặt ISPConfig 3
1 |
#php –q install.php |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[...] Select language (en,de) [en]: <-- ENTER Installation mode (standard,expert) [standard]: <-- ENTER Full qualified hostname (FQDN) of the server, eg server1.domain.tld [master.blogit.edu.vn]: <-- ENTER MySQL server hostname [localhost]: <-- ENTER MySQL root username [root]: <-- ENTER MySQL root password []: <-- yourrootsqlpassword MySQL database to create [dbispconfig]: <-- ENTER MySQL charset [utf8]: <-- ENTER [...] Country Name (2 letter code) [AU]: <-- ENTER State or Province Name (full name) [Some-State]: <-- ENTER Locality Name (eg, city) []: <-- ENTER Organization Name (eg, company) [Internet Widgits Pty Ltd]: <-- ENTER Organizational Unit Name (eg, section) []: <-- ENTER Common Name (eg, YOUR name) []: <-- ENTER Email Address []: <-- ENTER [...] ISPConfig Port [8080]: <-- ENTER |
Đến đây quá trình cài đặt ISPConfig 3 All-in-one (Master Server) đã kết thúc. Trong các phần tiếp theo, chúng ta sẽ tiến hành cài đặt OpenVZ cũng như cấu hình ISPConfig 3.
Pingback: OpenVZ & ISPConfig – Phần 2: Cài đặt OpenVZ | Blog IT
DianeJaibe
- Edit
To ensure exclusivity and assurance that each customer gets the attention they are entitled to, our VIP escort service is for members only.
visit website http://www.fontspace.com/profile/philipsencarlsson4