Thứ Sáu, 7 tháng 7, 2017

Đổi được mật khẩu bằng lệnh passwd báo lỗi " cannot identify you"

Sau khi boot vào chế độ single mode và tiến hành đổi mật khẩu tài khoản root bằng lệnh passwd thì báo lỗi: " cannot identify you"

Để xử lý lỗi này ta tiến hành tắt dịch vụ SELINUX bằng cách mở tập tin /etc/sysconfig/selinux

Trong mục SELINUX chỉnh thành "disabled"

Khởi động lại máy chủ và vào lại chế độ single mode để tiến hành đổi mật khẩu bằng lệnh passwd

Thứ Tư, 14 tháng 6, 2017

Quản lý và giới hạn CPU trên từng process trên Ubuntu






Bước 1: Cài công cụ CPUTool

Code:
$ sudo apt install cputool
Bước 2: giới hạn CPU dựa trên ID của tiến trình

Code:
# cputool --cpu-limit 50 -p 8275
Nghĩa là: giới hạn 50% CPU cho tiến trình có ID là 8275

Bước 3: Để giới hạn CPU của một nhóm các tiến trình liên quan

Tìm các tiến trình liên quan đến ứng dụng

Code:
# pidof apache2
9592 3643 3642 3641 3640 3638 3637 1780
Giới hạn CPU nhóm các tiến trình

Code:
# cputool --cpu-limit 20 -P 1780
Bước 4: Cấu hình chạy rsync khi load máy chủ nhỏ hơn 3.5

Code:
# cputool --load-limit 3.5 --rsync -av /home/tecmint /backup/`date +%Y-%m-%d`/

Các cách phòng chống WANNACRY ransomware




Cách 1. Cập nhật Windows
Đây là điều đầu tiên các bạn cần làm đối với máy tính hay VPS/Server của mình. Trong một số trường hợp, việc cập nhật tốn quá nhiều thời gian và có thể gây ra lỗi do mất kết nối. Các bạn có thể tải các bản cập nhật đặc biệt theo các đường dẫn dưới đây.
Windows Server 2003, Windows Server 2003, Datacenter Edition (x64 system for Windows Server 2003 security update custom support)
http://download.windowsupdate.com/c/csa/csa/secu/2017/02/windowsserver2003-kb4012598-x64-custom-cht_23a0e14eee3320955b6153ed7fab2dd069d39874.exe
Windows Server 2003, Windows Server 2003, Datacenter Edition, Windows Server 2003 Security Update Custom Support) 
http://download.windowsupdate.com/c/csa/csa/secu/2017/02/windowsserver2003-kb4012598-x86-custom-Cht_71a7359d308c8bda7638b4dc4ea305e7e22cc4c2.exe
Cách 2. Tắt SMB trong Windows
Để tắt SMB trong Windows các bạn có thể sử dụng 1 trong 2 cách sau đây
Sử dụng Power Shell với quyền Administrator
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" SMB1 -Type DWORD -Value 0 -Force
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" SMB2 -Type DWORD -Value 0 -Force
Sử dụng CMD với quyền Administrator
sc.exe config lanmanworkstation depend= bowser/mrxsmb20/nsi
sc.exe config mrxsmb10 start= disabled
sc.exe config lanmanworkstation depend= bowser/mrxsmb10/nsi
sc.exe config mrxsmb20 start= disabled
Sau khi thực hiện xong các bạn nên restart lại máy để cập nhật cấu hình.
Cách 3. Cài đặt Anti Ransomware của Bitdefender
Đây là bản miễn phí, các bạn có thể tải về tại https://www.bitdefender.com/solutions/anti-ransomware-tool.html

Thứ Hai, 12 tháng 6, 2017

Nâng cấp Virtuozzo Automator

Bước 1: Nâng cấp Virtuozzo Automator Management Panel, ta ssh vào máy ảo container đang chạy Virtuozzo Automator và gõ lệnh sau: 

Code:
# yum groupupdate "VA Management Node" "VA Control Center"
Bước 2: Nâng cấp Virtuozzo Automator Agent, ta thực hiện trên từng máy chủ Hardware node

Code:
# yum groupupdate "VA Agent"

Thứ Sáu, 19 tháng 5, 2017

Hướng dẫn cài đặt Zend Optimizer cho PHP 5.2.x trên Windows

Bước 1: Để cài Zend optimizer vào link này tải :http://www.zend.com/en/products/load...r?package=1453

Bước 2: Giải nén ra và chép file ZendOptimizer.dll vào thư mục ext tại vị trí C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5\ext\

Bước 3: Mở file php.ini của PHP 5.2.x và thêm vào cuối file dòng sau

[Zend]
zend_extension_ts="C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5\ext\Zen dOptimizer.dll"

Thứ Tư, 17 tháng 5, 2017

Hướng dẫn cấu hình switch Juniper EX2200

Vào chế độ cấu hình
sw> configure 
sw# 

Hiển thị thông tin tất cả các cổng switchsw# show | display set 

Tạo một VLAN cho switchsw#set vlans Vinacis-Metro-1 vlan-id 1217
sw#commit 

Gán cổng switch vào VLAN
sw#set interfaces ge-0/0/10 unit 0 family ethernet-switching port-mode access
sw#set interfaces ge-0/0/10 unit 0 family ethernet-switching vlan members Vinacis-Metro-1
sw#commit 

Xóa cổng khỏi VLAN

sw#delete interfaces ge-0/0/10 unit 0 family ethernet-switching vlan members Vinacis-Metro-1
sw#commit 

Cấu hình trunk trên một interface
sw#set interfaces ge-0/0/22 unit 0 family ethernet-switching port-mode trunk
sw#set interfaces ge-0/0/22 unit 0 family ethernet-switching vlan members Vinacis-Metro-SPT-1
sw#set interfaces ge-0/0/22 unit 0 family ethernet-switching vlan members Vinacis-Metro-SPT-2
sw#commit 

Bật SNMP trên switch
sw#set snmp contact "VinaCIS"
sw#set snmp name “Private” 
sw#set snmp description “Office”
sw#set snmp location “Rack SE30” contact “email@vinacis.com”
sw#set snmp community public authorization read-only
sw#set snmp client-list list0 210.211.x.x/32
sw#set snmp community public client-list-name list0
sw#commit
sw#show snmp

Thứ Tư, 10 tháng 5, 2017

Cài đặt tính năng S3 Object storage cho Virtuozzo 6.0

Tính năng S3 Object Storage bao gồm các role sau:

Object server: lưu trữ dữ liệu được nhận từ S3 gateway. Dữ liệu thực chất được lưu trên virtuozzo storage để bảo đảm tính HA
Name server: lưu thông tin metada của bucket bao gồm object name, ACL, dung lượng, vị trí, người sở hữu. Dữ liệu thực chất được lưu trên virtuozzo storage để bảo đảm tính HA
S3 gateway: đóng vai trò là proxy giữa người dùng cuối và các máy chủ object. Nó nhận và xử lý các yêu cầu bằng giao thức Amazon S3 và sử dụng nginx Web server cho các kết nối từ bên ngoài. S3 gateway quản lý việc chứng thực tài khoản user và kiểm tra phân quyền ACL checks. Bản thân nó không sinh ra dữ liệu
Block level: là virtuozzo storage

Với bài lab này ta triển khai cài đặt 3 role Object Server, Name Server và S3 gateway trên 3 hardware node đang chạy thuộc cụm Virtuozzo 6.0 với thông tin 3 node như sau

Server name: rs00360 - Storage IP: 172.16.10.24 - WAN IP: 103.199.9.24
Server name: rs00361 - Storage IP: 172.16.10.25 - WAN IP: 103.199.9.25
Server name: rs00362 - Storage IP: 172.16.10.26 - WAN IP: 103.199.9.26

Cài đặt Object Server

Bước 1 (thực hiện trên cả 3 node): 
add thông tin vào file /etc/hosts để phân giải hostname ra IP storage

172.16.10.24 rs00360 rs00360.dinodata.vn
172.16.10.25 rs00361 rs00361.dinodata.vn
172.16.10.26 rs00362 rs00362.dinodata.vn

Bước 2 (thực hiện trên cả 3 node): cài đặt gói pstorage-ostor

Code:
# yum install pstorage-ostor
Bước 3 (thực hiện trên 1 node sẽ chạy role object server) : Tạo configure service mới và chỉ định số lượng máy chủ sẽ làm object server và name server

Code:
ostor-ctl create -n <hostname> -r /var/lib/ostor/configuration -c 
"pstorage://<cluster_name>/<ostor_dir> 4 5"
<hostname> là tên node đang tiến hành tạo configure service
<cluster_name> là tên cluster của virtuozzo 6.0
<ostor_dir> là thư mục chứa các tập tin của dịch vụ object storage
4 là số lượng node sẽ cài name server
5 là số lượng node sẽ cài storage object

Bước này hệ thống sẽ yêu cầu đặt mật khẩu

Trong bài này ta gõ lệnh sau:
Code:
ostor-ctl create -n rs00360 -r /var/lib/ostor/configuration -c "pstorage://minicloudt9/s3-t9 3 3"
Bước 4: khởi động configure service

Code:
# service ostor-cfgd start
# chkconfig ostor-cfgd on
Bước 5 (thực hiện trên 1 node sẽ chạy role object server): Khởi tạo kho lưu trữ object storage
Code:
ostor-ctl init-storage -n <hostname> -s <cluster_mount_point>
Thư mục <ostor_dir> đã qui định ở bước 3 sẽ được tạo tại bước này. Đồng thời bạn cần nhập mật khẩu đã đặt ở bước 3

Trong bài này ta gõ lệnh sau:
Code:
ostor-ctl init-storage -n rs00361 -s /pstorage/minicloudt9

Bước 6 (
thực hiện trên các node sẽ chạy role object server): thêm các host vào cụm

Code:
# ostor-ctl add-host -r <cluster_mount_point>/<ostor_dir>
Trong bài này ta gõ lệnh sau:
Code:
ostor-ctl add-host -r /pstorage/minicloudt9/s3-t9
Bước 7 (thực hiện trên tất cả các node sẽ làm S3 gateway): 

Code:
# ostor-ctl add-s3gw -a <storage_IP>:9000
Trong bài này ta gõ ba lệnh sau trên 3 node

Code:
ostor-ctl add-s3gw -a 172.16.10.24:9000 
ostor-ctl add-s3gw -a 172.16.10.25:9000 
ostor-ctl add-s3gw -a 172.16.10.26:9000
Bước 8 (thực hiện trên tất cả các node sẽ làm S3 gateway): Khởi động agent

Code:
# service ostor-agentd start
# chkconfig ostor-agentd on
Bước 9: Kiểm tra trạng thái của hệ thống

Code:
# ostor-ctl agent-status
Bước 10 (thực hiện trên tất cả các node sẽ làm S3 gateway): Cài đặt và cấu hình Nginx

Cài đặt Nginx
Code:
#  wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
# yum install nginx -y

Cấu hình Nginx: 
Mở file /etc/nginx/conf.d/default.conf và nhập nội dung như bên dưới


Code:
upstream s3 {
    server 172.16.10.24:9000; #S3 gateway 1 internal IP address
    server 172.16.10.25:9000; #S3 gateway 2 internal IP address
     server 172.16.10.26:9000; #S3 gateway 3 internal IP address
        # Optional load balancing parameters (see http://nginx.org/en/docs/http/load_balancing.html)
 }
server {
   listen       80;
  server_name  s3.vinacis.com;      #S3 endpoint. If you have DNS configured, replace the IP address with the corresponding hostname.
  client_max_body_size 5g;
  #charset koi8-r;
  #access_log  /var/log/nginx/log/host.access.log  main;
  location / {
  fastcgi_pass_header Connection-close;
  fastcgi_pass s3;
  fastcgi_no_cache 1;
  include fastcgi_params;
  fastcgi_request_buffering off;
  fastcgi_max_temp_file_size 0;
     }
}
Bước 11: Tạo DNS record s3.vinacis.com trỏ về 3 IP Public của 3 node đang chạy S3 gateway

Bước 12: Khởi động dịch vụ Nginx
Code:
# service nginx start 
# chkconfig nginx on
Bước 13 (thực hiện một trong những node chạy S3) : Tạo tài khoản người dùng S3

Code:
# ostor-s3-admin  create-user -e user@email.com
Ghi lại thông tin Access Key và Secret Access Key dùng để kết nối tạo Bucket

Bước 14: Khởi tạo Bucket mới

Hệ thống Virtuozo 6.0 không có công cụ để khởi tạo Bucket nên ta cần dùng công cụ của hãng thứ 3. Tải về và cài đặt công cụ CloudBerry Explorer for Amazon S3 tại địa chỉ: http://www.cloudberrylab.com/downloa...prod=cbes3free

Mở phần mềm CloudBerry Explorer for Amazon S3 --> File --> Add New Account --> S3 Compatible --> Điền các thông tin như sau

Display name: đặt tên cho kết nối. VD: vinacis
Service point: điền thông tin kết nối đến S3 Gateway. Trong trường hợp này là s3.vinacis.com:80Access key: điền access key lấy được ở bước 13
Secret key: điền Secret access key lấy được ở bước 13

Lưu ý bỏ dấu check ở hai tùy chọn "Use SSL" và "Use native multipath.."

Sau khi kết nối thì tạo Bucket mới
__________________

Thứ Ba, 9 tháng 5, 2017

Cấu hình NFS server và client trên Virtuozzo Container

Hệ thống gồm 2 máy chủ

Container đóng vai trò NFS Server có IP là: 192.168.100.1 (container ID: 101) - OS: Centos 6.8 64bit
Container đóng vai trò NFS Client có IP là: 192.168.100.2 (container ID: 102) - OS: Centos 6.8 64bit
Thư mục cần chia sẻ NFS nằm trên NFS Server tên là: /data

Cài đặt NFS Server 
Bước 1: Trên máy chủ Virtuozzo hardware node chạy lệnh sau để load module nfsd 

Code:
# modprobe nfsd
Bước 2: Trên máy chủ Virtuozzo hardware node chạy lệnh sau để kích hoạt tính năng nfsd cho container 101 

Code:
# vzctl stop 101
# vzctl set 101 --features nfsd:on --save
# vzctl start 101
Bước 3: Trong container, gõ lệnh sau để cài đặt các gói NFS Server

Code:
# yum install rpcbind nfs-utils
Bước 4: Trong container gõ lệnh

Code:
# chkconfig rpcbind on
# service rpcbind start
Bước 5: Trong container, tắt các cảnh báo liên quan đến nfsd bằng cách mởi tập tin /etc/sysconfig/nfs, sau đó thêm các dòng bên dưới vào vị trị cuối file
Code:
MOUNTD_NFS_V3="yes"
RPCNFSDARGS="-N 4"
NFSD_MODULE="noload"
Bước 6: Khởi động dịch vụ NFS
Code:
# chkconfig nfs on
# service nfs start
Bước 7: Trong container, khởi tạo thư mục /data và share thư mục này cho máy client với quyền read write

Code:
# mkdir /data
# vi /etc/exports

/home           192.168.100.2(rw,sync,no_root_squash,no_subtree_check)

# export -a
Cài đặt NFS Client

Bước 1: 
Trên máy chủ Virtuozzo hardware node chạy lệnh sau để load module nfsd
Code:
# modprobe nfs
Bước 2: Trên máy chủ Virtuozzo hardware node chạy lệnh sau để kích hoạt tính năng nfsd cho container 102

Code:
# vzctl stop 102
# vzctl set 102 --features nfs:on --save # vzctl start 102
Bạn có thể dùng lệnh sau để kiểm tra module nfs đã được load bên trong container hay chưa

Code:
# cat /proc/filesystems
Bước 3: Trong container, cài đặt các gói NFS client như sau

Code:
# yum install nfs-utils nfs-utils-lib rpcbind
Bước 4: Khởi động các dịch vụ nfs

Code:
# chkconfig rpcbind on
# /etc/init.d/rpcbind start
# chkconfig nfs on
# /etc/init.d/nfs start
Bước 5: Tiến hành mount đến thư mục /data đang được share trên NFS Server

Tạo thư mục /data trên máy NFS client

Code:
# mkdir /data
Tiến hành mount thư mục /data của NFS Server vào thư mục /data của NFS client
Code:
mount 192.168.100.1:/data /data
Bước 6: Tạo fstab

Code:
192.168.100.1:/data       /data      nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0

Giám sát băng thông bằng công cụ iftop

Bước 1: Cài đặt các gói dịch vụ liên quan

Code:
# yum -y install libpcap libpcap-devel ncurses ncurses-devel
Bước 2: Tải về gói iftop

Code:
# wget http://www.ex-parrot.com/pdw/iftop/download/iftop-0.17.tar.gz
Bước 3: Tiến hành cài đặt iftop

Code:
# tar -zxvf iftop-0.17.tar.gz
# cd iftop-0.17
# ./configure
# make
# make install

Bước 4
: Để giám sát mạng với iftop ta sử dụng lệnh sau

Xem trạng thái của tất cả các cạc mạng
Code:
# iftop
Xem trạng thái của một cổng mạng cụ thể

Code:
# iftop -i eth0

Thứ Sáu, 5 tháng 5, 2017

Cài đặt owncloud 9.1 trên Ubuntu 16.04

Bước 1: Cài đặt các gói dịch vụ Apache, MariaDB, PHP
Code:
# sudo apt-get update
# sudo apt-get install apache2 mariadb-server libapache2-mod-php7.0
# sudo apt-get install php7.0-gd php7.0-mysql php7.0-curl
#  sudo apt-get install php7.0-intl php7.0-mcrypt php-imagick
#  sudo apt-get install php7.0-zip php7.0-xml php7.0-mbstring
Bước 2: Khởi động dịch vụ MariaDB và đặt mật khẩu root
Code:
# sudo mysql_secure_installation
Enter current password for root (enter for none): --> gõ Enter
Set root password? [Y/n] Y
New password: --> đặt mật khẩu cho tài khoản root của database
Chọn Yes với tất cả các câu hỏi còn lại
Bước 3: Mặc định khi cài đặt MariaDB thì tài khoản quản trị root không thể đăng nhập vào MariaDB bằng mật khẩu mà nó chứng thực bằng plugin. Do đó ta cần disable chế độ chứng thực bằng plugin bằng cách gõ các lệnh sau

Code:
# sudo mysql -u root
MariaDB [(none)]> use mysql;
Hiển thị cột plugin trong cơ sở dữ liệu user
Code:
MariaDB [mysql]> SELECT user, plugin FROM user;
Chỉnh sửa lại giá trị plugin thành trống thay vì unix_socket 
Code:
MariaDB [mysql]> UPDATE user SET plugin="";
Đặt lại mật khẩu cho tài khoản quản tri root

Code:
MariaDB [mysql]> UPDATE user SET password=PASSWORD("password_taikkhoanroot") WHERE user="root";
MariaDB [mysql]> FLUSH PRIVILEGES;
MariaDB [mysql]> quit
Bước 4: Truy cập vào link: http://download.owncloud.org/downloa.../9.1/owncloud/ để tải gói repo và cài đặt owncloud

Code:
# sudo wget -nv https://download.owncloud.org/download/repositories/9.1/Ubuntu_16.04/Release.key -O Release.key
# sudo apt-key add - < Release.key
# sudo sh -c "echo 'deb http://download.owncloud.org/download/repositories/9.1/Ubuntu_16.04/ /' > /etc/apt/sources.list.d/owncloud.list"
# sudo apt-get update
# sudo apt-get install owncloud
Bước 5: Tiến hành cài đặt các thông số về tài khoản quản trị, vị trí lưu dữ liệu và loại cơ sở dữ liệu sẽ sử dụng cho owncloud bằng cách truy cập đến địa chỉ http://<IP_cua_server>/owncloud/

Phần "Tạo tài khoản quản trị" --> tạo tên đăng nhập và mật khẩu cho tài khoản sẽ giữ quyền quản trị owncloud

Phần "Thư mục dữ liệu" --> điền vào nơi sẽ lưu trữ dữ liệu của người dùng (có thể để mặc định là /var/www/owncloud/data)

Phần "Cấu hình cơ sở dữ liệu" --> Chọn "MySQL/MariaDB" --> nhập thông tin tài khoản quản trị root của MariaDB đã tạo ở bước 2 phía trên --> nhập tên cơ sở dữ liệu dành cho owncloud (đặt tên tùy ý)

Tham khảo thêm tại: https://doc.owncloud.org/server/late...tallation.html

Bước 6
: Để có thể truy cập vào owncloud từ một tên miền ví dụ owncloud.offices.vn thì ta cần chỉnh trong /var/www/owncloud/config/config.php bằng cách thêm tên miền như bên dưới

Code:
'trusted_domains' =>
  array (
    0 => '113.199.8.32',
    1 => 'owncloud.offices.vn',
  ),