Thứ Ba, 25 tháng 9, 2018

How to merge worksheets / workbooks into one worksheet?

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Sub Combine()
Dim J As Integer
On Error Resume Next
Sheets(1).Select
Worksheets.Add
Sheets(1).Name = "Combined"
Sheets(2).Activate
Range("A1").EntireRow.Select
Selection.Copy Destination:=Sheets(1).Range("A1")
For J = 2 To Sheets.Count
Sheets(J).Activate
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
Next
End Sub
3. Then press F5 key to run the code, and all the data in the workbook has been merged into a new worksheet named Combined which will add before all worksheets.
Read More

Thứ Ba, 18 tháng 9, 2018

Share LUN giữa các host

Từ bước 1 -> 5 các bước này thực hiện trên tất cả các host
1. Cài đặt
yum install pcs pacemaker fence-agents-all -y
2. allow firewall
# firewall-cmd --permanent --add-service=high-availability
# firewall-cmd --add-service=high-availability
3. Đặt passwork cho user hacluster
# passwd hacluster
4. Start pcsd
# systemctl start pcsd.service
# systemctl enable pcsd.service
5. Add authentication trên mỗi hosts
[root@ubqlvnn-app01-48  ~]# pcs cluster auth ubqlvnn-app01-48 ubqlvnn-app02-49 ubqlvnn-app03-50 ubqlvnn-app04-51
Username: hacluster
6. thực hiện trên 1 host -> create cluster
pcs cluster setup --start --name my_cluster ubqlvnn-app01-48 ubqlvnn-app02-49 ubqlvnn-app03-50 ubqlvnn-app04-51
7. Enable run cluster service mỗi khi reboot
pcs cluster enable --all
start cluster service manual bằng pcs cluster start
8.Kiểm tra trạng thái của cluster
[root@ubqlvnn-app03-50 ~]# pcs cluster status
Cluster Status:
 Stack: corosync
 Current DC: ubqlvnn-app02-49 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum
 Last updated: Fri Aug 31 23:18:42 2018
 Last change: Fri Aug 31 23:18:07 2018 by hacluster via crmd on ubqlvnn-app02-49
 4 nodes configured
 0 resources configured

PCSD Status:
  ubqlvnn-app03-50: Online
  ubqlvnn-app02-49: Online
  ubqlvnn-app04-51: Online
  ubqlvnn-app01-48: Online

8. Cấu hình STONITH trên cluster trên mỗi host
 pcs stonith create myapc fence_apc_snmp ipaddr="ubqlvnn-app01-48" pcmk_host_map="ubqlvnn-app01-48:1;ubqlvnn-app02-49:2;ubqlvnn-app03-50:3;ubqlvnn-app04-51:4" login="apc" passwd="apc"
 pcs stonith create myapc fence_apc_snmp ipaddr="ubqlvnn-app02-49" pcmk_host_map="ubqlvnn-app01-48:1;ubqlvnn-app02-49:2;ubqlvnn-app03-50:3;ubqlvnn-app04-51:4" login="apc" passwd="apc"
 pcs stonith create myapc fence_apc_snmp ipaddr="ubqlvnn-app03-50" pcmk_host_map="ubqlvnn-app01-48:1;ubqlvnn-app02-49:2;ubqlvnn-app03-50:3;ubqlvnn-app04-51:4" login="apc" passwd="apc" 
 pcs stonith create myapc fence_apc_snmp ipaddr="ubqlvnn-app04-51" pcmk_host_map="ubqlvnn-app01-48:1;ubqlvnn-app02-49:2;ubqlvnn-app03-50:3;ubqlvnn-app04-51:4" login="apc" passwd="apc"
9. Cài đặt trên tất cả các hosts
  yum install lvm2-cluster gfs2-utils
10. Set the global Pacemaker parameter no_quorum_policy to freeze.
  pcs property set no-quorum-policy=freeze
11. tạo 1 dlm resource trên 1 hosts
pcs resource create dlm ocf:pacemaker:controld op monitor interval=30s on-fail=fence clone interleave=true ordered=true
12. Thực hiện các câu lệnh sau trên tất cả các host
  /sbin/lvmconf --enable-cluster
13. Tạo 1 clvmd  resources
pcs resource create clvmd ocf:heartbeat:clvm op monitor interval=30s on-fail=fence clone interleave=true ordered=true
14.Tạo constrain clvmd phải start sau dlm và phải chạy trên cùng 1 host dlm.
# pcs constraint order start dlm-clone then clvmd-clone
# pcs constraint colocation add clvmd-clone with dlm-clone
15. tạo lvm
# pvcreate /dev/sdb1
# vgcreate -Ay -cy cluster_vg /dev/sdb1
# lvcreate -L5G -n cluster_lv cluster_vg
16. format
mkfs.gfs2 -j4 -p lock_dlm -t my_cluster:gfs2 /dev/cluster_vg/cluster_lv
chú ý tùy chọn -j bằng số host muốn mount và my_cluster
17. Mount
pcs resource create clusterfs Filesystem device="/dev/cluster_vg/cluster_lv" directory="/mnt/shares" fstype="gfs2" "options=noatime" op monitor interval=10s on-fail=fence clone interleave=true
18. Tạo constraint clusterfs phải chạy sau clvmd, và phải cùng host clvmd
# pcs constraint order start clvmd-clone then clusterfs-clone
# pcs constraint colocation add clusterfs-clone with clvmd-clone
Read More

Thứ Hai, 17 tháng 9, 2018

Using Powershell list of websites IIS using get-website

C:\Users\Administrator>powershell -ExecutionPolicy Bypass
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.

PS C:\Users\Administrator> import-module WebAdministration
PS C:\Users\Administrator> get-website | select name,id,state,physicalpath, @{n="Bindings"; e= { ($_.bindings | select -expa collection) -join ';' }} ,@{n="LogFile";e={ $_.logfile | select -expa directory}}, @{n="attributes"; e={($_.attributes | % { $_.name + "=" + $_.value }) -join ';' }} |Export-Csv -NoTypeInformation -Path C:\sites_list.csv
PS C:\Users\Administrator>
Read More

Thứ Sáu, 14 tháng 9, 2018

How To Reset Root Password CentOS 7

1 – In the boot grub menu select option to edit.
Selection_003
2 – Select Option to edit (e).
Selection_005
3 – Go to the line of Linux 16 and change ro with rw init=/sysroot/bin/sh.
Selection_006
4 – Now press Control+x to start on single user mode.
Selection_007
5 – Now access the system with this command.
chroot /sysroot
6 – Reset the password.
passwd root
7 – Update selinux information
touch /.autorelabel
8 – Exit chroot
exit
9 – Reboot your system
reboot
That’s it. Enjoy.
Read More