Mastering Date Manipulation in Oracle Database: Oracle change sysdate Tips and Tricks

In this tutorial

How to change sysdate for Oracle Database server. Oracle gets the system day from OS server data. You can change Oracle SYSDATE for testing.

In Oracle Database, the SYSDATE function returns the current date and time of the database server. However, you cannot directly change the value of SYSDATE as it is a read-only function that always provides the current timestamp. It reflects the system time when the query or statement is executed.

If you want to manipulate or change dates in Oracle, you can use various date manipulation functions and arithmetic operations. For example, you can use the ADD_MONTHS, TO_DATE, TRUNC, DATEADD, and other functions to perform date calculations and transformations.

Oracle change sysdate Tips and Tricks

Oracle change SYSDATE.

SQL> ALTER SYSTEM SET fixed_date = '2018-01-28-13:00:00' SCOPE = MEMORY;
  • Compatibility and Availability: The use of fixed_date is available only in Oracle Database releases before Oracle Database 21c. Starting from Oracle Database 21c, the fixed_date parameter has been desupported and cannot be used to alter the system date and time.
  • Scope: The SCOPE parameter determines whether the change takes effect immediately (MEMORY scope) or at the next database startup (SPFILE scope).
  • Format: The fixed_date parameter expects the date and time in the YYYY-MM-DD-HH24:MI:SS format.
  • Privileges: Modifying system parameters typically requires administrative privileges, such as the ALTER SYSTEM privilege.

Oracle Reset SYSDATE

SQL> ALTER SYSTEM SET fixed_date=NONE;

Beware! Changing Oracle sysdate for testing. After you can reset sysdate for the Oracle database server.

Checking the change SYSDATE Oracle.

SQL> select sysdate from dual;

Conclusion

You have used Oracle change sysdate for testing. My topic is another  “Install Oracle Database 12c on Centos 7”. I hope will this your helpful.

Jenkins tutorial

What does Jenkins mean?

Jenkins is a powerful application allow continuous integration and continuous delivery. It is a free open source.

In this tutorial, who would like to learn how to build an test for the project. Jenkins the essential for DevOps Roles.

The simple WORKFLOW of how Jenkins works.

  1. Check source code from git or svn, so forth.
  2. Jenkins pick up the changed source code and trigger a build and run any test if required.
  3. The build output available in the Jenkins dashboards.

Jenkins tutorial

Install Jenkins

System requirements

  • JDK is version 1.5 or above
  • Memory recommended is 2GB ( minimum)

you can ref to link install jenkins here.

Jenkins git plugin

From Jenkins Dashboard, Click the Manage Jenkins as the picture below

In the next screen, click “Manage Plugins’ as the picture below

In this next screen, click the Available tab. This tab list all available for downloading. In this ‘Filter’ tab type ‘Git plugin’.

Click on the button ‘Install without restart’

In this next screen, click the ‘Installed’ tab. I have installed Git plugin as below

jenkins maven plugin

From Jenkins Dashboard, Click the Manage Jenkins. Click ‘Global Tool Configuration’ as below

Scroll down till you see Maven section and then click ‘Add Maven’ Button as below

Click ‘Save’ Button

Jenkins configuration

From Jenkins Dashboard, Click the Manage Jenkins. Click ‘Configure System’ as below
You can configure Jenkins home, JDK so on.

jenkins create job

Step 1: Go to Jenkins Dashboard and click ‘New Item’ as below
Step 2: Enter the item name and example select ‘Freestyle project option’. Click OK button
You set up and configure job Jenkins this screen
The finish, run job Jenkins as below

Conclusion

Thought the article, you can use Jenkins tutorial for the beginner as above. I hope will this your helpful.

A Beginner’s Guide to Git Clone Repository

Introduction

In this tutorial, we will guide you on how to git clone a repository and sync it to your server. Git is a popular version control system used by developers to manage source code and collaborate on projects efficiently.

To clone a Git repository, you need to have Git installed on your system. Follow these steps to clone a repository:

Prerequisites

  • Target: gitlab repository
  • Source: Server Linux

Steps to Clone a Git Repository

1. Install Git

Ensure Git is installed on your system. If not, install it using the following command:

sudo apt-get install git

2. Clone the Repository

To create a clone or copy of the target repository on your server, use the following command:

git clone https://huupv@https://gitlab.com/DevopsRoles/devopsroles.git

3. Switch Branches

To switch from the master branch to the develop branch, use:

git checkout develop

4. List All Branches

To list all the branches in your repository, execute:

git branch

5. Fetch and Merge Changes

To fetch and merge changes from the remote server to your working directory, run:

git pull

Conclusion

By following this guide, you can successfully clone a Git repository to your local machine. You can now navigate into the cloned repository and start working with the code or files it contains. We hope this guide is helpful. Thank you for reading the DevopsRoles page!

Export and Import in Oracle

Introduction

In this tutorial, you will learn how to Export and Import in Oracle 11g. This process is essential for database administrators to backup, transfer, and restore database schemas efficiently.

  1. Create DBA Directory
  2. Export all SCHEMA using expdp
  3. Import all SCHEMA using impd

Export and Import in Oracle

Syntax for IMPDP command

IMPDP TABLE_EXISTS_ACTION PARAMETER EXPLAINED

TABLE_EXISTS_ACTION

  • SKIP: The default value for this parameter is SKIP.
  • APPEND: the dump will be appended to the table and the existing data will remain unchanged.
  • TRUNCATE: This option truncates the existing rows in the table and inserts the rows from the dump
  • REPLACE: This option drops the current table and creates the table as it is in the dump file. Both SKIP and REPLACE options are not valid if you set the CONTENT=DATA_ONLY for the impdp.

Create a DBA Directory in Oracle

Login into SQL Plus with user sys.

[oracle@DBOracle ~]$ sqlplus / as sysdba

Creating folder DBA MY_BACKUP_DIR in /tmp folder

SQL> create or replace directory MY_BACKUP_DIR AS '/tmp/oraclebackup';

DBA Directory is created by the user system. Only users grant DBA to use this folder. you can assign grant Other_User.

SQL> grant read,write on directory MY_BACKUP_DIR to Other_User;

Export all SCHEMA using expdp

Using expdp command to export all schema into a dump file.

[oracle@DBOracle ~]$ expdp \"sys/123456789@DEVOPSROLES AS SYSDBA\" DIRECTORY=MY_BACKUP_DIR DUMPFILE=exp_ora.dmp SCHEMAS=huupv LOGFILE=exp_ora.log

Import all SCHEMA using impd

The first, create a user huupv

SQL> create user huupv identified by 123456789;

Import from sysadmin

[oracle@DBOracle ~]$ impdp \"sys/123456789@DEVOPSROLES AS SYSDBA\" schemas=huupv directory=MY_BACKUP_DIR dumpfile=exp_ora.dmp logfile=imp_ora.log

Note:

  • File dump: exp_ora.dmp
  • Service Name: DEVOPSROLES
  • To schema: huupv

Conclusion

Through this article, you have learned how to use the Export and Import in Oracle 11g to manage database schemas. These tools are crucial for database backup, restoration, and migration tasks. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Docker error solve problems

In this tutorial, I’m sharing the docker in the builder and running Docker. Solve problem Docker error. Docker skill needed for DevOps.

“Build, Manage and Secure Your Apps Anywhere. Your Way.” Quote from docker!

Docker error

ERROR 1: Unsupported config option in docker-compose.yml

ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for networks: 'bridge'
Unsupported config option for DB01: 'networks'
Unsupported config option for WEB01: 'networks'
Unsupported config option for volumes: 'web_mnt_nfs'

Solved Problem: version 2.0 support in file docker-compose.yml

version: '2.0'

ERROR 2: Unable to set mem_limit with docker-compose version 3.x

Solved Problem: version ‘2’ support mem_limit. Docker version “3” support memory limit as below

Version 3:
deploy:
   resources:
     limits:
        memory: 512M

ERROR 3: docker database is uninitialized and password option is not specified

error: database is uninitialized and password option is not specified
db01 | error: database is uninitialized and password option is not specified
db01 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db01 | error: database is uninitialized and password option is not specified
db01 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db01 | error: database is uninitialized and password option is not specified
db01 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db01 | error: database is uninitialized and password option is not specified
db01 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db01 | error: database is uninitialized and password option is not specified
db01 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db01 | error: database is uninitialized and password option is not specified
db01 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db01 | error: database is uninitialized and password option is not specified
db01 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db01 | error: database is uninitialized and password option is not specified
db01 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db01 | error: database is uninitialized and password option is not specified
db01 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db01 | error: database is uninitialized and password option is not specified
db01 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD

Solve the problem: the Set environment for docker MYSQL

   environment:
      MYSQL_ROOT_PASSWORD: 123456789
      #MYSQL_USER=huupv
      #MYSQL_PASSWORD=passforhuupv
      #MYSQL_DATABASE=DevopsRolesDB

Docker errors solve problems. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Docker compose example

Introduction

Docker compose is used to run multiple containers. In this tutorial, Using Docker compose example for NGINX and MYSQL. I used Docker compose version “3”

In today’s digital era, Docker has become an essential tool for developers and DevOps professionals. With its ability to package and deploy applications easily, Docker has revolutionized the way software is managed and deployed. However, as applications grow more complex, managing multiple containers simultaneously can be challenging. This is where Docker Compose shines. This article will guide you through Docker Compose with a practical example, making it easier to manage and coordinate multiple containers within the same application.

“Build, Manage and Secure Your Apps Anywhere. Your Way.” Quote from docker!

Docker compose example

Creating Docker-compose file. All docker compose file is a YAML file. Now, let’s go create the docker-compose.yml file as below

[root@DevopsRoles ~]# mkdir docker-instance
[root@DevopsRoles ~]# cd docker-instance/
[root@DevopsRoles docker-instance]# vim docker-compose.yml

The content docker-compose file as below

version: '3'

services:
 WEB01:
   image: nginx:latest
   container_name: "web01"
   hostname: web01
   ports:
        - "8888:80"
        - "8443:443"
        - "2233:22"
   #deploy:
   # resources:
   # limits:
   # memory: 512M
   #mem_limit: 512m
   volumes:
     - ./data_web01:/mnt_nfs
   networks:
     - bridge
   restart: always

 DB01:
   image: mysql:latest
   container_name: "db01"
   hostname: db01
   ports:
        - "33306:3306"
        - "2234:22"
   command: --default-authentication-plugin=mysql_native_password
   environment:
      MYSQL_ROOT_PASSWORD: 123456789
      #MYSQL_USER=huupv
      #MYSQL_PASSWORD=passforhuupv
      #MYSQL_DATABASE=DevopsRolesDB
   #deploy:
   # resources:
   #    limits:
   #      memory: 512M
   volumes:
      - ./data_db01:/mnt_nfs
   networks:
      - bridge
   restart: always

volumes:
   web_mnt_nfs:
     driver: local
networks:
   bridge:
     driver: bridge
     ipam:
       config:
          - subnet: 192.168.12.0/24

Creating and starting a container

[root@DevopsRoles docker-instance]# docker-compose up -d

The screen output terminal:

Creating network "docker-instance_bridge" with driver "bridge"
Creating db01 ... done
Creating web01 ... done

The result, Docker compose example

Access browser Nginx server

Checking running containers for nginx and mysql

Conclusion

Thought the article, you can use “Docker compose example” as above. Docker Compose is not just a convenient tool but also a key to simplifying and enhancing container management in any software project. Continue reading the article to gain a deeper understanding of how to use this tool in real-world scenarios! I hope will this your helpful. Thank you for reading the DevopsRoles page!

Docker compose command

Docker compose is a tool to define and running multiple container Docker applications. In this tutorial, to learn more about docker compose command. Docker the essential for DevOps Roles.

“Build, Manage and Secure Your Apps Anywhere. Your Way.” Quote from docker!

Docker compose command

Start existing containers

[root@DevopsRoles ~]# docker-compose start

The screen output terminal:

[root@DevopsRoles docker-instance]# docker-compose start
Starting DB01 ... done
Starting WEB01 ... done

Stop existing containers

[root@DevopsRoles ~]# docker-compose stop

The screen output terminal:

[root@DevopsRoles docker-instance]# docker-compose stop
Stopping db01 ... done
Stopping web01 ... done

Pauses running containers

[root@DevopsRoles ~]# docker-compose pause

The screen output terminal:

[root@DevopsRoles docker-instance]# docker-compose pause
Pausing web01 ... done
Pausing db01 ... done

Unpause all processes containers

[root@DevopsRoles ~]# docker-compose unpause

The screen output terminal:

[root@DevopsRoles docker-instance]# docker-compose unpause
Unpausing db01 ... done
Unpausing web01 ... done

List all running containers.

[root@DevopsRoles ~]# docker-compose ps

The screen output terminal:

Creating and starting a container

[root@DevopsRoles ~]# docker-compose up

Stop and remove containers, networks, images, and volumes

[root@DevopsRoles ~]# docker-compose down

The screen output terminal:

[root@DevopsRoles docker-instance]# docker-compose down
Stopping db01 ... done
Stopping web01 ... done
Removing db01 ... done
Removing web01 ... done
Removing network docker-instance_bridge

Conclusion

Thought the article, you can use “Docker compose command as above”. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Bash script recursive file list

In this tutorial, How do I use BASH script to recursively list files directories and subdirectories? Bash script the essential for DevOps Roles. Bash script recursive file list example.

Example List all files in directories and files in subdirectories as below

[huupv@huupv devopsroles]$ pwd
/home/huupv/devopsroles
[huupv@huupv devopsroles]$ tree /home/huupv/devopsroles
/home/huupv/devopsroles
├── bash_arguments_function2.sh
├── bash_arguments_function.sh
├── bash_colors_formatting.sh
├── bash_print_recurse.sh
├── bash_sleep.sh
├── bash_string_compare.sh
├── bash_substitution_string.sh
├── file.txt
├── folder
│   └── file.txt
├── link_folder -> /home/huupv/devopsroles/folder
├── README.TXT
├── test2.sh
└── test.sh

2 directories, 12 files

My Bash script recursive file list

#!/bin/bash
# Colourise the output on terminal
RED='\033[0;31m' # Red
GRE='\033[0;32m' # Green
NCL='\033[0m' # No Color

print_file_recursively() {
   FILE_NAME="$(basename "${entry}")"
   printf "%*s\t[FILE]:\t${GRE} $FILE_NAME %s${NCL}\n"
}

# loop and print all file and folder recusively,
print_recursively() {
   local indent="${2:-0}"
   printf "\n%*s${RED}%s${NCL}\n\n" "$indent" '[DIR]: ' "$1"
for entry in "$1"/*; do
   [[ -f "$entry" ]] && print_file_recursively
done
for entry in "$1"/*; do
   [[ -d "$entry" ]] && print_recursively "$entry" $((indent+4))
done
}

# Check folder
PATH_FOLDER=""
if [ -d "$1" ]; then
PATH_FOLDER=$1;
fi
print_recursively $PATH_FOLDER

The screen output terminal:

Conclusion

Thought the article, you can use Bash script recursive file list as above. I hope will this your helpful. More details refer to Bash script.

Bash string comparison

Introduction

In Bash scripting, comparing strings is an essential skill that allows you to check and manipulate input data. Unlike other programming languages, Bash has its own syntax and rules for handling string comparisons. In this article, we will explore how to use conditional expressions to compare strings in Bash. We will learn about common comparison operators, string handling techniques, and how to test strings under different conditions.

This guide aims to help you grasp the basics and provides practical examples that you can apply to your daily tasks. How do I use bash string comparison? In the bash shell use the if statement “==” to check equality and “!=” to check the inequality of the string. String comparison examples. The bash script is essential for DevOps Roles.

In bash, you can compare strings using various operators. Here are some common string comparison operators in bash:

  • = : Checks if two strings are equal
  • != : Checks if two strings are not equal
  • -z : Checks if a string is empty (has zero length)
  • -n : Checks if a string is not empty
  • < : Checks if one string is less than another string (in lexicographical order)
  • > : Checks if one string is greater than another string (in lexicographical order)

Bash string comparison use “==” operator

#!/bin/bash
STRA=huu
STRB="www.devopsroles.com"
if [[ "$STRA" == "$STRB" ]]; then
   echo "$STRA equal $STRB"
else
   echo "$STRA not equal $STRB"
fi

The screen output terminal:

Bash script string compare use “!=” operator

#!/bin/bash
STRA=huu
STRB="www.devopsroles.com"
if [[ "$STRA" != "$STRB" ]]; then
   echo "$STRA not equal $STRB"
else
   echo "$STRA equal $STRB"
fi

The screen output terminal:

Bash script string compare use wildcards

#!/bin/bash
STRA=huu
STRB="www.devopsroles.com"
if [[ "$STRA" == *$STRB* ]]; then
   echo "$STRA equal $STRB"
else
   echo "$STRA not equal $STRB"
fi

The screen output terminal:

Examples of string comparison in bash

Conclusion

In summary, comparing strings in Bash is a crucial skill that every Bash programmer needs to master. By using comparison operators and conditional expressions, you can effectively and accurately perform string checks and manipulations. Understanding how to compare strings not only helps you write more powerful scripts but also improves your ability to handle data and automate complex tasks.

Hopefully, this article has given you a comprehensive overview and the necessary knowledge to apply to your Bash projects. I hope will this your helpful. For more details refer to the Bash script.

Bash substitution string example

Introduction

Bash, the popular shell scripting language in the Unix and Linux world, offers a variety of powerful tools for string manipulation. Among these tools, “Bash String Substitution” stands out as a crucial technique that allows you to easily modify and transform strings. Whether you are a software developer, system administrator, or a beginner learning Bash, mastering this technique can significantly boost your productivity and efficiency. In this article, we will explore the different methods of string substitution in Bash, from basic to advanced, to help you harness the full potential of this tool. The bash script is essential for DevOps Roles.

Bash substitution string

From the beginning #
Remove the first matching pattern from the beginning of the string

#!/bin/bash

FILE="/usr/local/www/DevopsRoles.com/foo.txt"
echo "Path File: $FILE"

echo ${FILE#*.}
echo ${FILE#*/}
echo ${FILE#*m}

The screen output terminal:

Remove the last matching pattern from the beginning of the string

#!/bin/bash

FILE="/usr/local/www/DevopsRoles.com/foo.txt"
echo "Path File: $FILE"

echo ${FILE##*.}
echo ${FILE##*/}
echo ${FILE##*m}

The screen output terminal:

From the end equal %
Remove the first matching pattern from the end of the string

#!/bin/bash

FILE="/usr/local/www/DevopsRoles.com/foo.txt"
echo "Path File: $FILE"

echo ${FILE%.*}
echo ${FILE%/*}
echo ${FILE%m*}

The terminal screen output:

Remove the last matching pattern from the end of the string

#!/bin/bash

FILE="/usr/local/www/DevopsRoles.com/foo.txt"
echo "Path File: $FILE"

echo ${FILE%%.*}
echo ${FILE%%/*}
echo ${FILE%%m*}

The terminal screen output:

Conclusion

Bash substitution string is a valuable and versatile technique that makes complex string manipulations straightforward. Mastering these substitution methods not only enables you to write more powerful and efficient scripts but also helps optimize your daily tasks.

We hope this article has provided you with a clear and comprehensive understanding of Bash String Substitution, equipping you to apply it effectively in your real-world projects. Keep exploring and experimenting to become a true expert in this field. I hope will this your helpful. For more details refer to Bash script.

Devops Tutorial

Exit mobile version