Tuesday, 1 November 2022
Manage Linux Services with systemctl
`systemctl` is the command-line interface to **systemd**, the modern init system used by most major Linux distributions (like Ubuntu, CentOS, RHEL, Debian, Arch, Fedora).
You use `systemctl` to:
- Start and stop services
- Enable services to run at boot
- Check service status
- View logs
- Troubleshoot failures
- Manage dependencies
Real-World Example: Creating a Custom Service
Let’s say you have a Python web application that you want to run as a systemd service.
Create Your Application Directory
sudo mkdir -p /opt/mywebapp
sudo chown $USER:$USER /opt/mywebapp
Add your app file (for example, app.py) inside /opt/mywebapp/.
Create the systemd Service File
sudo nano /etc/systemd/system/mywebapp.service
Paste this configuration:
[Unit]
Description=My Python Web Application
After=network.target
[Service]
ExecStart=/usr/bin/python3 /opt/mywebapp/app.py
WorkingDirectory=/opt/mywebapp
Restart=always
RestartSec=20
User=webuser
Group=webgroup
Environment="ENV=production"
[Install]
WantedBy=multi-user.target
Explanation:
After=network.target ensures the network is up before starting.
Restart=always and RestartSec=20 ensures the app auto-recovers on failure.
User and Group ensure minimal privileges.
WantedBy=multi-user.target ensures the service starts at system boot.
Reload systemd
sudo systemctl daemon-reload
Complete systemctl Command Reference
Action Command
Start sudo systemctl start <service>
Stop sudo systemctl stop <service>
Restart sudo systemctl restart <service>
Reload sudo systemctl reload <service>
Status sudo systemctl status <service>
Enable/Disable Services at Boot
Action Command
Enable sudo systemctl enable <service>
Disable sudo systemctl disable <service>
Check Enabled systemctl is-enabled <service>
Masking Services
Action Command
Mask sudo systemctl mask <service>
Unmask sudo systemctl unmask <service>
Editing Services Safely
Action Command
Edit sudo systemctl edit <service>
Revert sudo systemctl revert <service>
List Services and Units
Action Command
Running Services systemctl list-units --type=service
All Unit Files systemctl list-unit-files
Enabled Units systemctl list-unit-files --state=enabled
View Logs (journalctl)
Action Command
View Logs journalctl -u <service>
Follow Logs journalctl -fu <service>
Today’s Logs journalctl -u <service> --since today
Saturday, 15 October 2022
ValueError: cannot set a frame with no defined index and a scalar
This error message typically occurs when trying to assign a scalar value to a DataFrame without specifying the index or columns. Here's an example:
python
import pandas as pd
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
# This line will raise the ValueError
df.loc[0] = 7
In this example, we have a DataFrame with two columns 'A' and 'B' and three rows. The df.loc[0] = 7
line is trying to set the first row of the DataFrame to the value 7. However, since we haven't specified which columns to update, Pandas is trying to set all columns to the scalar value 7, which isn't possible.
To fix this error, we need to specify which columns we want to update. For example:
python
df.loc[0, 'A'] = 7
This will set the value of the 'A' column in the first row to 7. Alternatively, we can specify the columns to update using a list:
python
df.loc[0, ['A', 'B']] = [7, 8]
This will set the values of both the 'A' and 'B' columns in the first row to 7 and 8, respectively.
Default ports for major products and services
HTTP: 80
HTTPS: 443
HTTP/3 (QUIC): 443
Database Systems
MySQL: 3306
PostgreSQL: 5432
MongoDB: 27017
Redis: 6379
Microsoft SQL Server: 1433
Oracle Database: 1521
Cassandra: 9042
CouchDB: 5984
InfluxDB: 8086
Elasticsearch: 9200
Message Brokers & Queues
Apache Kafka: 9092
RabbitMQ: 5672 (AMQP), 15672 (Management UI)
Apache ActiveMQ: 61616
Amazon SQS: 443 (HTTPS)
Application Servers & Frameworks
Apache Tomcat: 8080
Jetty: 8080
Node.js (Express): 3000 (common default)
Django: 8000
Flask: 5000
Spring Boot: 8080
Ruby on Rails: 3000
Email Services
SMTP: 25 (unencrypted), 587 (TLS), 465 (SSL)
POP3: 110 (unencrypted), 995 (SSL)
IMAP: 143 (unencrypted), 993 (SSL)
File Transfer & Remote Access
FTP: 21
SFTP/SSH: 22
Telnet: 23
RDP (Remote Desktop): 3389
VNC: 5900
DNS & Network Services
DNS: 53
DHCP: 67/68
SNMP: 161
NTP: 123
LDAP: 389 (unencrypted), 636 (SSL)
Cloud & Container Services
Docker: 2376 (secure), 2375 (insecure)
Kubernetes API: 6443
etcd: 2379 (client), 2380 (peer)
Consul: 8500
Vault: 8200
Monitoring & Observability
Prometheus: 9090
Grafana: 3000
Jaeger: 16686 (UI), 14268 (collector)
Zipkin: 9411
New Relic: 443
Development Tools
Jenkins: 8080
GitLab: 80/443
SonarQube: 9000
Nexus Repository: 8081
JFrog Artifactory: 8081
Gaming & Entertainment
Minecraft: 25565
Steam: 27015
Discord: 443
IoT & Smart Home
MQTT: 1883 (unencrypted), 8883 (SSL)
CoAP: 5683
Monday, 3 October 2022
Linux basic commands
Here are some basic Linux commands along with their full forms and brief descriptions:
- ls (List): Lists files and directories in the current working directory. Example: ls -l (long format listing), ls -a (include hidden files), ls -h (human-readable sizes).
- cd (Change Directory): Changes the current working directory. Example: cd /path/to/directory.
- pwd (Print Working Directory): Displays the current working directory. Example: pwd.
- cp (Copy):
Copies files and directories. Example: cp
file.txt destination/.
copy file with same timestamp
cp -p oldfile newfile - mv (Move): Moves or renames files and directories. Example: mv file.txt new_location/, mv old_name.txt new_name.txt.
- rm (Remove): Deletes files and directories. Example: rm file.txt, rm -r directory/ (recursively delete a directory).
- mkdir (Make Directory): Creates a new directory. Example: mkdir new_directory.
- rmdir (Remove Directory): Deletes an empty directory. Example: rmdir empty_directory.
- cat (Concatenate): Displays the contents of a file. Example: cat file.txt.
- more or less: Pager commands to view text files page by page. Example: more file.txt, less file.txt.
- head and tail: Display the first or last part of a file. Example: head file.txt (displays the first few lines), tail file.txt (displays the last few lines).
- grep (Global Regular Expression Print): Searches for a pattern in a file or input. Example: grep "keyword" file.txt.
- find: Searches for files and directories based on different criteria. Example: find /path/to/search -name "filename".
- chmod (Change Mode): Modifies file permissions. Example: chmod +x script.sh (adds execute permission), chmod 644 file.txt (sets read-write permissions for owner, read-only for group and others).
- chown (Change Ownership): Changes the owner of a file or directory. Example: chown user:group file.txt.
- ps (Process Status): Displays information about currently running processes.
Example: ps aux (lists all processes), ps -ef | grep process_name (search for a specific process).
- kill: Sends a signal to terminate a process. Example: kill PID (PID is the process ID).
- df (Disk Free): Shows disk space usage on file systems. Example: df -h ,df -g(displays sizes in human-readable format).
- free: Shows system memory usage. Example: free -h,free-g (displays sizes in human-readable format).
- top and htop: Displays real-time system resource usage and processes. Example: top, htop (htop is an improved version of top).
- ifconfig : Interface Configuration: Displays and configures network interfaces (deprecated on modern systems).
- ip - IP: A modern alternative to ifconfig for network configuration.
- ping : Sends an ICMP echo request to a host to check network connectivity.
- ssh - Secure Shell: Allows secure remote login to another machine over a network.
- scp - Secure Copy: Securely copies files between hosts over a network.
- tar - Tape Archive: Used to archive multiple files into a single tarball file.
- gzip - GNU Zip: Compresses files to reduce their size.
- unzip - Unzip: Extracts files from a zip archive.
- who - Who: Displays a list of currently logged-in users.
- history
- History: Shows a list of previously executed commands.
Saturday, 1 October 2022
Move a Database to an Oracle Home with a different patch level( 19.8 to 19.12) Using dbaascli in Exacs
This post covers detailed steps to move a database to an Oracle Home with a different patch level( 19.8 to 19.12) Using dbaascli in Exacs.
High Level Steps:
--> Verify present db version and components list from registry
--> Gather invalid objects details and try to compile
--> Run Prechecks for db home move
--> Move db to different oracle home with different patch level
--> Verify db present version and components list from registry , Invalid objects
Verify Present db Version:
SQL> select INSTANCE_NAME,host_name,status,logins,version,VERSION_FULL,to_char(STARTUP_TIME,'DD/MM/YYYY HH24:MI:SS') "STARTUP_TIME" from gv$instance;
INSTANCE_NAME HOST_NAME STATUS LOGINS VERSION VERSION_FULL STARTUP_TIME
---------------- ------------------- ------------ ---------- ----------------- ----------------- -------------------
stgdb011 ociexacs-node1 OPEN ALLOWED 19.0.0.0.0 19.8.0.0.0 22/08/2022 04:04:03
stgdb012 ociexacs-node2 OPEN ALLOWED 19.0.0.0.0 19.8.0.0.0 22/08/2022 04:04:03
Verify installed components and component version:
SQL> select COMP_ID,COMP_NAME,VERSION,VERSION_FULL,STATUS from dba_registry;
COMP_ID COMP_NAME VERSION VERSION_FULL STATUS
-------------- ------------------------------------ ---------------- ------------------------------ --------
CATALOG Oracle Database Catalog Views 19.0.0.0.0 19.8.0.0.0 VALID
CATPROC Oracle Database Packages and Types 19.0.0.0.0 19.8.0.0.0 VALID
RAC Oracle Real Application Clusters 19.0.0.0.0 19.8.0.0.0 VALID
JAVAVM JServer JAVA Virtual Machine 19.0.0.0.0 19.8.0.0.0 VALID
XML Oracle XDK 19.0.0.0.0 19.8.0.0.0 VALID
CATJAVA Oracle Database Java Packages 19.0.0.0.0 19.8.0.0.0 VALID
APS OLAP Analytic Workspace 19.0.0.0.0 19.8.0.0.0 VALID
XDB Oracle XML Database 19.0.0.0.0 19.8.0.0.0 VALID
OWM Oracle Workspace Manager 19.0.0.0.0 19.8.0.0.0 VALID
CONTEXT Oracle Text 19.0.0.0.0 19.8.0.0.0 VALID
ORDIM Oracle Multimedia 19.0.0.0.0 19.8.0.0.0 VALID
SDO Spatial 19.0.0.0.0 19.8.0.0.0 VALID
XOQ Oracle OLAP API 19.0.0.0.0 19.8.0.0.0 VALID
OLS Oracle Label Security 19.0.0.0.0 19.8.0.0.0 VALID
DV Oracle Database Vault 19.0.0.0.0 19.8.0.0.0 VALID
15 rows selected.
Check Invalid objects:
SQL> select OWNER,OBJECT_NAME,OBJECT_TYPE from dba_objects where STATUS='INVALID';
no rows selected
Check installed DB Home details on Exacs nodes:
[root@ociexacs-node1 ~]# dbaascli system getDBHomes
DBAAS CLI version 22.3.1.1.0
Executing command system getDBHomes
Job id:
{
"OraHome3" : {
"id" : "",
"homePath" : "/u02/app/oracle/product/19.0.0.0/dbhome_1",
"homeName" : "OraHome3",
"version" : "19.12.0.0.0",
"createTime" : 1664597038000,
"updateTime" : 1664597038000,
"ohNodeLevelDetails" : {
"ociexacs-node2" : {
"nodeName" : "ociexacs-node2",
"version" : "19.12.0.0.0"
},
"ociexacs-node1" : {
"nodeName" : "ociexacs-node1",
"version" : "19.12.0.0.0"
}
},
"messages" : [ ]
},
"OraHome100" : {
"id" : "",
"homePath" : "/u02/app/oracle/product/19.0.0.0/dbhome_2",
"homeName" : "OraHome100",
"version" : "19.8.0.0.0",
"createTime" : 1664596819000,
"updateTime" : 1664596819000,
"ohNodeLevelDetails" : {
"ociexacs-node2" : {
"nodeName" : "ociexacs-node2",
"version" : "19.8.0.0.0"
},
"ociexacs-node1" : {
"nodeName" : "ociexacs-node1",
"version" : "19.8.0.0.0"
}
},
"messages" : [ ]
}
}
dbaascli execution completed
19.12 version already installed on Exacs nodes, if target version not installed follow steps in https://www.dbops-tech.com/2021/08/install-oracle-rdbms-on-oracle-cloud.html to installed required db version.
Execute Pre-checks for db move:
[root@ociexacs-node1 ~]# dbaascli database move --dbname stgdb01 --ohome /u02/app/oracle/product/19.0.0.0/dbhome_1 --executePrereqs
DBAAS CLI version 22.3.1.1.0
Executing command database move --ohome /u02/app/oracle/product/19.0.0.0/dbhome_1 --executePrereqs
Job id: cf0a124f-6131-4a11-86af-767175292a27
Loading PILOT...
Session ID of the current execution is: 4
Log file location: /var/opt/oracle/log/stgdb01/database/move/pilot_2022-09-28_09-12-02-PM_90184
-----------------
Running initialization job
Completed initialization job
-----------------
Running validate_user_input job
Completed validate_user_input job
-----------------
Running validate_database job
Completed validate_database job
-----------------
Running validate_creg_file_existence job
Completed validate_creg_file_existence job
-----------------
Running validate_source_home job
Completed validate_source_home job
-----------------
Running validate_major_version job
Completed validate_major_version job
-----------------
Running validate_oracle_home_type job
Completed validate_oracle_home_type job
-----------------
Running check_target_source_home_not_same job
Completed check_target_source_home_not_same job
-----------------
Running validate_home_existence job
Completed validate_home_existence job
-----------------
Running validate_home_consistency job
Completed validate_home_consistency job
-----------------
Running validate_home_options job
Completed validate_home_options job
-----------------
Running validate_disk_space job
Completed validate_disk_space job
dbaascli execution completed
[root@ociexacs-node1 ~]#
Move db to different home using dbaascli:
[root@ociexacs-node1 ~]# dbaascli database move --dbname stgdb01 --ohome /u02/app/oracle/product/19.0.0.0/dbhome_1
DBAAS CLI version 22.3.1.1.0
Executing command database move --ohome /u02/app/oracle/product/19.0.0.0/dbhome_1
Job id: 5bd5403b-0bb4-4db3-8bee-aeca7eebf327
Loading PILOT...
Session ID of the current execution is: 5
Log file location: /var/opt/oracle/log/stgdb01/database/move/pilot_2022-09-28_09-17-09-PM_156886
-----------------
Running initialization job
Completed initialization job
-----------------
Running validate_user_input job
Completed validate_user_input job
-----------------
Running validate_database job
Completed validate_database job
-----------------
Running validate_creg_file_existence job
Completed validate_creg_file_existence job
-----------------
Running validate_source_home job
Completed validate_source_home job
-----------------
Running validate_major_version job
Completed validate_major_version job
-----------------
Running validate_oracle_home_type job
Completed validate_oracle_home_type job
-----------------
Running check_target_source_home_not_same job
Completed check_target_source_home_not_same job
-----------------
Running validate_home_existence job
Completed validate_home_existence job
-----------------
Running validate_home_consistency job
Completed validate_home_consistency job
-----------------
Running validate_home_options job
Completed validate_home_options job
-----------------
Running validate_disk_space job
Completed validate_disk_space job
-----------------
Running acquire_lock job
Completed acquire_lock job
-----------------
Running copy_config_files job
Completed copy_config_files job
-----------------
Running stop_database_instance-ociexacs-node1 job
Completed stop_database_instance-ociexacs-node1 job
-----------------
Running update_database_resource-ociexacs-node1 job
Completed update_database_resource-ociexacs-node1 job
-----------------
Running start_database_instance-ociexacs-node1 job
Completed start_database_instance-ociexacs-node1 job
-----------------
Running stop_database_instance-ociexacs-node2 job
Completed stop_database_instance-ociexacs-node2 job
-----------------
Running update_database_resource-ociexacs-node2 job
Completed update_database_resource-ociexacs-node2 job
-----------------
Running start_database_instance-ociexacs-node2 job
Completed start_database_instance-ociexacs-node2 job
-----------------
Running exacs_post_patch_node_updation job
Completed exacs_post_patch_node_updation job
-----------------
Running update_dba_directories job
Completed update_dba_directories job
-----------------
Running datapatch_and_recompile_invalid_objects job
Datapatch execution on database 'stgdb01' is in progress
Datapatch execution on database 'stgdb01' is complete
Recompilation of invalid objects on database 'stgdb01' is in progress
Recompilation of invalid objects on database 'stgdb01' is complete
Completed datapatch_and_recompile_invalid_objects job
-----------------
Running release_lock job
Completed release_lock job
-----------------
Running invoke_backup_asst job
Completed invoke_backup_asst job
-----------------
Running post_move_validation job
Completed post_move_validation job
-----------------
Running generate_dbsystem_details job
Completed generate_dbsystem_details job
dbaascli execution completed
Post validations:
SQL> select INSTANCE_NAME,host_name,status,logins,version,VERSION_FULL,to_char(STARTUP_TIME,'DD/MM/YYYY HH24:MI:SS') "STARTUP_TIME" from gv$instance;
INSTANCE_NAME HOST_NAME STATUS LOGINS VERSION VERSION_FULL STARTUP_TIME
---------------- ------------------ ------------ ---------- ----------------- ----------------- -------------------
stgdb011 ociexacs-node1 OPEN ALLOWED 19.0.0.0.0 19.12.0.0.0 28/09/2022 21:18:18
stgdb012 ociexacs-node1 OPEN ALLOWED 19.0.0.0.0 19.12.0.0.0 28/09/2022 21:20:22
SQL> select COMP_ID,COMP_NAME,VERSION,VERSION_FULL,STATUS from dba_registry;
COMP_ID COMP_NAME VERSION VERSION_FULL STATUS
-------------- ------------------------------------ ---------------- ------------------------------ --------
CATALOG Oracle Database Catalog Views 19.0.0.0.0 19.12.0.0.0 VALID
CATPROC Oracle Database Packages and Types 19.0.0.0.0 19.12.0.0.0 VALID
RAC Oracle Real Application Clusters 19.0.0.0.0 19.12.0.0.0 VALID
JAVAVM JServer JAVA Virtual Machine 19.0.0.0.0 19.12.0.0.0 VALID
XML Oracle XDK 19.0.0.0.0 19.12.0.0.0 VALID
CATJAVA Oracle Database Java Packages 19.0.0.0.0 19.12.0.0.0 VALID
APS OLAP Analytic Workspace 19.0.0.0.0 19.12.0.0.0 VALID
XDB Oracle XML Database 19.0.0.0.0 19.12.0.0.0 VALID
OWM Oracle Workspace Manager 19.0.0.0.0 19.12.0.0.0 VALID
CONTEXT Oracle Text 19.0.0.0.0 19.12.0.0.0 VALID
ORDIM Oracle Multimedia 19.0.0.0.0 19.12.0.0.0 VALID
SDO Spatial 19.0.0.0.0 19.12.0.0.0 VALID
XOQ Oracle OLAP API 19.0.0.0.0 19.12.0.0.0 VALID
OLS Oracle Label Security 19.0.0.0.0 19.12.0.0.0 VALID
DV Oracle Database Vault 19.0.0.0.0 19.12.0.0.0 VALID
15 rows selected.
SQL> select OWNER,OBJECT_NAME,OBJECT_TYPE from dba_objects where STATUS='INVALID';
no rows selected
Thursday, 29 September 2022
Layers of the OSI Model
7 Layers of the OSI Model
The OSI model is organized into 7 distinct layers, each with specific responsibilities. Data flows from the top layer (Application) down to the bottom layer (Physical) when sending, and from bottom to top when receiving.
🔝 Layer 7: Application Layer
What it does: Interface between user applications and the network
Examples: HTTP/HTTPS, FTP, SMTP, DNS, DHCP
Function: Provides network services directly to applications
Real-world example: When you browse a website, your browser uses HTTP/HTTPS protocols
📋 Layer 6: Presentation Layer
What it does: Data translation, encryption, and compression
Examples: SSL/TLS, JPEG, GIF, ASCII, EBCDIC
Function: Ensures data is readable by the receiving system
Real-world example: Encrypting your password when logging into a website
🔗 Layer 5: Session Layer
What it does: Manages communication sessions between applications
Examples: NetBIOS, RPC, SQL sessions
Function: Establishes, maintains, and terminates connections
Real-world example: Maintaining your login session on a website
🚚 Layer 4: Transport Layer
What it does: Reliable data transfer and error correction
Examples: TCP, UDP
Function: Ensures complete data transfer with error checking
Real-world example: TCP ensures all parts of a file download arrive correctly
🗺️ Layer 3: Network Layer
What it does: Routing and logical addressing
Examples: IP (IPv4/IPv6), ICMP, OSPF, BGP
Function: Determines the best path for data across multiple networks
Real-world example: Routers use IP addresses to forward data packets
🔌 Layer 2: Data Link Layer
What it does: Node-to-node delivery and error detection
Examples: Ethernet, Wi-Fi (802.11), PPP
Function: Handles communication between directly connected devices
Real-world example: Your computer communicating with your router via Ethernet or Wi-Fi
⚡ Layer 1: Physical Layer
What it does: Raw data transmission over physical medium
Examples: Cables, fiber optics, radio waves, electrical signals
Function: Transmits raw bits over the physical medium
Real-world example: Electrical signals traveling through an Ethernet cable
🔄 How Data Flows Through the OSI Model
Sending Data (Top to Bottom)
Application → User creates data (email, web request)
Presentation → Data is encrypted/compressed
Session → Session is established
Transport → Data is segmented and prepared for reliable delivery
Network → Routing information is added
Data Link → Frame headers are added for local delivery
Physical → Data becomes electrical/optical signals
Sunday, 4 September 2022
zsh: no matches found
"zsh: no matches found" typically occurs in the Zsh shell when you use wildcard characters (such as *, ?, or []) in a command, and there are no files or directories that match the specified pattern in the current directory.
Here are a few common scenarios where you might encounter this error:
Using a command with a wildcard pattern that doesn't match any files:
$ ls *.xyz
zsh: no matches found: *.xyz
In this example, Zsh couldn't find any files in the current directory with the ".xyz" extension.
Using a command with a wildcard pattern, but the pattern itself doesn't match anything:
$ echo [a-z]
zsh: no matches found: [a-z]
If there are no lowercase letters in the current directory, the [a-z] pattern won't match anything.
To resolve this issue, you can do the following:
1.Double-check your command or wildcard pattern to ensure it matches existing files or directories in the current directory.
2.Use proper escaping or quoting if necessary. For example, if you want to list files with a literal asterisk in their names, you can use single or double quotes to prevent globbing:
$ ls '*.*'
If you want to use a wildcard pattern to match files in subdirectories as well, consider enabling the globstar option in Zsh:
$ setopt globstar
$ ls **/*.txt
The ** pattern will match files in subdirectories.
How to Delete a Primary Key Index in Oracle
Deleting a primary key index can be a complex task, as it involves modifying the structure of the database table. Here are the steps you can follow to delete a primary key index:
Identify the name of the primary key index:
SELECT index_name FROM dba_constraints WHERE table_name = 'table_name' AND constraint_type = 'P';
Drop the primary key constraint: Before you can drop the primary key index, you must first drop the primary key constraint.
ALTER TABLE table_name DROP PRIMARY KEY;
Drop the primary key index: Once the primary key constraint has been dropped, you can then drop the primary key index
DROP INDEX index_name ON table_name;
It's important to note that deleting a primary key index will also remove the associated primary key constraint, which can have implications for data integrity and referential integrity in your database. Be sure to fully understand the implications of removing a primary key index before proceeding.
Saturday, 27 August 2022
How to Increase the max_map_count Kernel Parameter in Linux to Optimize Vector Server Performance
How to Increase max_map_count:
1. Edit the sysctl.conf File
vi /etc/sysctl.conf
Add the following line to the file:
vm.max_map_count=map_count
Replace map_count with an appropriate value based on your system’s memory. As a general guideline, set map_count to approximately 1 per 128 KB of system memory. For instance, on a system with 256 GB of RAM, you might set:
vm.max_map_count=2097152
2. Reload the Configuration
After updating the sysctl.conf file, apply the new settings by reloading the configuration:
sudo sysctl -p
3. Verify the New Setting
cat /proc/sys/vm/max_map_count
This command should display the updated value you set in the sysctl.conf file.
4. Restart Vector
sudo systemctl restart vector
or whatever service management command is appropriate for your setup.
How to Remove Exited Docker Containers
Docker containers can sometimes exit unexpectedly or remain in an "exited" state, taking up valuable system resources. In this guide, we'll explore different methods to identify and remove these exited containers.
Identifying Exited Containers
First, let's see how to identify exited containers. You can use the following command to list all containers, including exited ones:
docker ps -a
To specifically filter for exited containers, use:
docker ps -a | grep "Exited"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9b65cedfc4b3 d0eadfcacdc2 "/bin/sh -c 'apt-get…" 10 months ago Exited (1) 10 months ago stupefied_kirch
c3edc0a8c3c6 7aa9bc2b797e "/bin/bash" 10 months ago Exited (0) 10 months ago wonderful_mirzakhani
7f20f353fa7b 7aa9bc2b797e "/bin/sh -c 'apt-get…" 10 months ago Exited (1) 10 months ago zen_payne
Methods to Remove Exited Containers
Using docker container prune:
simplest way to remove all stopped containers is using the docker container prune command:
docker container prune -f
Deleted Containers:
9b65cedfc4b37b5754e0a16709b387a2c5c39999412908be0a4f6c23da72c29d
c3edc0a8c3c6c2d46712637c58be22e801f46a140608c89fb0ff38d968837a06
7f20f353fa7b7a7c3ae3b6780bfc96021792a9761d99aff88f4503f30df53c95
Total reclaimed space: 310.1MB
The -f flag forces the removal without asking for confirmation. This command will:
1.Remove all stopped containers
Show you which containers were deleted
Display the total space reclaimed
2. Removing Specific Containers
If you want to remove a specific exited container, you can use its container ID:
docker rm <container_id>
3. Removing All Exited Containers
To remove all containers that are not running, use:
docker rm $(docker ps -a -q -f status=exited)
Verifying the Cleanup
After removing the containers, you can verify that all exited containers have been removed:
docker ps -a | grep "Exited"
Troubleshooting Dispatcher Issues in Oracle Database
Troubleshooting Oracle Dispatchers involves diagnosing issues related to performance, connectivity, or server processes. Dispatchers are crucial for routing client requests to shared server processes, and any issues with Dispatcher config can affect overall database performance and client access. Below is a detailed guide on how to troubleshoot Oracle Dispatchers, including common issues and solutions.
1. Dispatcher Process Not Starting
Symptoms:
The Dispatcher process does not appear to be running.
Errors in the log files related to the Dispatcher process (e.g., ORA-12500: TNS:listener failed to start a dedicated server process).
Where to Look:
Listener Logs: Check the Oracle Listener log (listener.log) for errors related to Dispatcher processes.
Database Alert Log: Check the database alert log for any errors related to process startup or configuration.
V$DISPATCHER View: Query the V$DISPATCHER view to check if the Dispatchers are registered with the database.
Common Causes and Solutions: Listener Configuration Issue: Ensure that the listener.ora file is correctly configured and the listener is running.
Incorrect DISPATCHERS Parameter: Double-check the DISPATCHERS parameter in spfile.ora or init.ora for any syntax errors or incorrect configurations.
Example of a correct entry:
DISPATCHERS = '(PROTOCOL=TCP)(SERVICE=orcl)(DISPATCHERS=4)'
2. Dispatcher is Overloaded or Not Handling Requests Efficiently
Symptoms:
High CPU usage by Dispatcher processes.
Slow client responses or timeout issues.
Clients experience delays in receiving responses due to Dispatcher bottlenecks.
Where to Look:
SELECT * FROM V$DISPATCHER; To monitor the number of active Dispatcher processes and their load.
SELECT * FROM V$SHARED_SERVER;Check for an imbalance between Dispatchers and shared servers.
Check if sessions are waiting for Dispatchers to process requests.
SELECT SID, SERIAL#, STATUS, EVENT FROM V$SESSION WHERE EVENT LIKE 'dispatcher%';
Common Causes and Solutions:
Insufficient Dispatchers: If there are more requests than available Dispatchers, they will queue up, causing delays. Increase the number of Dispatchers using the ALTER SYSTEM command.
ALTER SYSTEM SET DISPATCHERS = '(PROTOCOL=TCP)(SERVICE=orcl)(DISPATCHERS=6)' SCOPE=BOTH;
Imbalance Between Dispatchers and Shared Servers: Check if there are enough shared server processes to handle the incoming requests. Adjust the SHARED_SERVERS parameter accordingly.
ALTER SYSTEM SET SHARED_SERVERS=10 SCOPE=BOTH;
3. Clients Cannot Connect to the Database (ORA-12500, ORA-12545, ORA-12514 Errors)
Symptoms:Clients cannot establish a connection to the database.
Errors like:
ORA-12500: TNS:listener failed to start a dedicated server process
ORA-12545: Connect failed because target host or object does not exist
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor.
Check Listener Log: Look for any connection or listener-related errors in the listener log & Alert Log
Common Causes and Solutions: Listener Not Running or Misconfigured: Ensure the listener is up and properly configured. Restart the listener and ensure the correct service is registered.
Incorrect SERVICE_NAME or SID: Verify that the SERVICE_NAME or SID specified in the tnsnames.ora file or connection string is correct.
Listener Unable to Start Shared Server: Ensure that the listener is correctly configured to handle shared server processes. In the listener.ora file, ensure the SID_LIST includes the shared server configurations.
4. Dispatcher Hanging or Not Responding to Client Requests (ORA-12535)
Symptoms:
Clients experience long delays or timeouts while waiting for responses from the Dispatcher.
Errors like ORA-12535: TNS:operation timed out or client hangs.
Common Causes and Solutions:
Network Issues: Check for network latency or firewalls blocking communication between clients and Dispatchers. Use network diagnostic tools like ping or traceroute to verify the path.
Increase Timeout: Increase the timeout values for client connections and Dispatchers to allow more time for processing.
Adjust the SQLNET.INBOUND_CONNECT_TIMEOUT parameter if necessary.
ALTER SYSTEM SET SQLNET.INBOUND_CONNECT_TIMEOUT=180;
Dispatcher Load: Check if Dispatchers are overloaded and adjust the number of Dispatchers or shared servers as needed.
5. Poor Performance or Latency in Dispatcher Handling
Symptoms:
Slower performance during peak usage times.
Latency in query processing or client response time.
Common Causes and Solutions:
Increase Dispatcher or Shared Server Processes: Increase the number of Dispatchers if the load is high.
ALTER SYSTEM SET DISPATCHERS = '(PROTOCOL=TCP)(SERVICE=orcl)(DISPATCHERS=8)' SCOPE=BOTH;
Review System Resources: Ensure the system has enough CPU, memory, and disk space for the expected load. Overutilization of system resources can cause slow response times.
Review Execution Plans: Slow queries can cause delays in processing. Use SQL Trace and Explain Plan to identify and optimize slow queries.
6. General Connection Issues (ORA-12170, ORA-12541)
Symptoms:
Clients fail to connect and report network-related errors like ORA-12170: TNS:Connect timeout occurred or ORA-12541: TNS:no listener.
Common Causes and Solutions: Listener Configuration: Ensure that the listener is properly configured and the required services are registered. Restart the listener to fix any issues.
Network Configuration: Ensure there are no firewall or network configuration issues preventing the client from reaching the database server.