Showing posts with label Linux Training: Day-7. Show all posts
Showing posts with label Linux Training: Day-7. Show all posts

Day 7 – NFS, CIFS, Chrony, Cron, Performance Monitoring & Troubleshooting in Linux

 Agenda – Day 7

  • NFS (Linux to Linux File Sharing)

  • CIFS (Linux to Windows File Sharing)

  • Chrony (Time Server Configuration)

  • Cron (Job Scheduling)

  • Performance Monitoring

  • Troubleshooting


File Sharing Using NFS (Network File System) 


What is NFS?

NFS allows Linux systems to share directories over a network.

  • 🗄 NFS Server → Central storage

  • 💻 NFS Client → Access shared storage

  • 📂 Shared Folder → Exported directory


NFS Server Configuration

# yum install nfs-utils -y
# mkdir /shared_folder
# vi /etc/exports

Add:

/shared_folder 192.168.1.0/24(rw,sync,no_subtree_check)

Restart:

# systemctl enable nfs-server
# systemctl restart nfs-server

NFS Client Configuration

# yum install nfs-utils -y
# showmount -e <server_ip>
# mount -t nfs server_ip:/shared_folder /mnt

Permanent:

# echo "server_ip:/shared_folder /mnt nfs defaults 0 0" >> /etc/fstab

Mounting Windows Shares Using CIFS


CIFS allows Linux to mount Windows shared folders.


CIFS Configuration

# yum install cifs-utils -y
# vi /root/.smbcredentials

Add:

username=Administrator
password=Pass@1234
domain=dorole.org

Secure:

# chmod 600 /root/.smbcredentials

Mount:

# mount -t cifs -o credentials=/root/.smbcredentials //win01/win-share /mnt

Permanent entry in /etc/fstab:

# //win01/win-share /mnt cifs credentials=/root/.smbcredentials 0 0

Chrony – Time Server Configuration

Time synchronization is critical for:

✔ Logs
✔ Database consistency
✔ Clusters
✔ Authentication

Modern Linux uses chronyd service.


Chrony Master (NTP Server)

# yum install chrony -y
# vi /etc/chrony.conf

Add:

allow 192.168.2.0/24
server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst

Start:

# systemctl enable chronyd
# systemctl restart chronyd

Allow firewall:

# firewall-cmd --permanent --add-service=ntp
# firewall-cmd --reload

Verify:

# chronyc sources
# chronyc tracking

Chrony Client

Edit:

# vi /etc/chrony.conf

Add:

server 192.168.1.100 iburst

Restart:

# systemctl restart chronyd

Check:

# chronyc tracking

Cron – Job Scheduling in Linux

Cron is used to schedule automated tasks in Linux.

Service:

crond

Crontab Format

* * * * * command
| | | | |
| | | | └── Day of Week (0-7)
| | | └──── Month
| | └────── Day of Month
| └──────── Hour
└────────── Minute

Example Cron Job

Run script every 5 minutes:

*/5 * * * * /usr/local/bin/script.sh

Edit crontab:

# crontab -e

List jobs:

# crontab -l

Check service:

# systemctl status crond

Performance Monitoring in Linux

Monitoring performance helps detect system bottlenecks.


📊 Important Commands

top

# top

vmstat

# vmstat 2

iostat

# iostat -x 2

sar

# sar -u 1 5

netstat

# netstat -tulnp

mpstat

# mpstat -P ALL 1

free

# free -h

Troubleshooting in Linux






🔥 Common Issues

High CPU

Use:

top
mpstat

Disk Full

df -h
du -sh *

Reset Root Password

  • Edit GRUB

  • Add rd.break

  • Use passwd

Recover Deleted LVM

vgcfgrestore

Clear RAM Cache

sync; echo 3 > /proc/sys/vm/drop_caches

DNS Issues

  • Check /etc/resolv.conf

  • Use nslookup

  • Use dig



7️⃣ Increasing CPU & Memory in Virtual Environments

In production, sometimes performance issues are resolved by scaling resources.


🖥 Increase CPU & RAM in VMware vCenter

Steps:

  1. Login to vCenter

  2. Right-click Virtual Machine

  3. Click Edit Settings

  4. Increase:

    • Number of CPUs

    • Memory (RAM)

  5. Click OK

If VM is running:

  • Ensure CPU Hot Add and Memory Hot Add are enabled

  • Otherwise power off VM before increasing resources

After increasing:

Inside Linux verify:

nproc
free -h
lscpu

☁ Increase CPU & RAM in Microsoft Azure


Used in cloud environments.

Steps:

  1. Login to Azure Portal

  2. Go to Virtual Machines

  3. Select your VM

  4. Click Size

  5. Choose larger VM size

  6. Click Resize

⚠ Sometimes VM must be stopped before resizing.

After resizing:

Verify inside Linux:

lscpu
free -h


🎯 Updated Key Takeaways – Day 7

✔ NFS – Linux-to-Linux sharing
✔ CIFS – Linux-to-Windows integration
✔ Chrony – Time synchronization
✔ Cron – Automation
✔ Performance monitoring tools
✔ Root password recovery
✔ LVM troubleshooting
✔ Resource scaling in VMware & Azure