Minggu, 17 November 2019
Value '0000-00-00' can not be represented as java.sql.Timestamp IN PENTAHO (PDI)
In Kettle (Pentaho Data Integration), when you use a "Table Input" component, you have to create a database connection.
In the database connection form, fill the fields of your mysql database, and test it.
If successfull, go to Options (left tab)
In the right tab, below defaultFetchSize and useCursorFetch, add zeroDateTimeBehavior and it's value convertToNull
Hope this helps !
Rabu, 28 Agustus 2019
How do you create a read only user in postgresql
Grant usage/select to a single table
If you only grant CONNECT to a database, the user can connect but has no other privileges. You have to grant USAGE on namespaces (schemas) and SELECT on tables and views individually like so:
GRANT CONNECT
ON DATABASE postgres TO user1; GRANT USAGE ON SCHEMA public TO user1; GRANT SELECT ON table01 TO user1; |
Multiple tables/views
you can grant permissions on all tables/views/etc in the schema using a single command rather than having to type them one by one:
GRANT SELECT ON ALL TABLES IN SCHEMA public TO user1; |
This only affects tables that have already been created. More powerfully, you can automatically have default roles assigned to new objects in future:
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO user1; |
Or you can create role before creating a user, like i usually do
-- Create a
group CREATE ROLE read_access_dwh; -- Grant access to existing tables GRANT USAGE ON SCHEMA dwh TO read_access_dwh; GRANT SELECT ON ALL TABLES IN SCHEMA dwh TO read_access_dwh; -- Grant access to future tables ALTER DEFAULT PRIVILEGES IN SCHEMA dwhp GRANT SELECT ON TABLES TO read_access_dwh; -- Create a final user with password CREATE USER report_dwh WITH PASSWORD 'yourpassword'; GRANT CONNECT ON DATABASE postgres TO report_dwh; GRANT read_access_dwh TO report_dwh; |
Postgres Command Line Connection from shell
This article describes how to connect to a PostgreSQL database from the shell using the psql program.
You can use the psql program as a quick and easy way to access your databases directly.
PSQL Commands: Connect to PostgreSQL from shell
To connect to PostgreSQL cli:
- login to the server with SSH where the postgres database is located.
- At the shell, type the following command. Replace DBNAME
with the name of the database, and USERNAME with the database username:
psql DBNAME USERNAME - At the Password prompt, type the database user's password. When you type the correct password, the psql prompt appears.
- After you access a PostgreSQL database, you can run SQL queries and more. Here are some common psql commands:
- To view help for psql commands, type \?.
- To view help for SQL commands, type \h.
- To view information about the current database connection, type \conninfo.
- To list the database's tables and their respective owners, type \dt.
- To list all of the tables, views, and sequences in the database, type \z.
- To exit the psql program, type \q.
Senin, 19 Agustus 2019
How to install SubversionEdge or CollabNet SVN on Centos
For any company in IT Department, versioning is a darn important part of the development process.
Software versioning is important because:
- It maintains the history of your code and the sequence in which changes were made
- It maintains the latest copy of your code in case your computer crashes
- It helps manage code properly when collaborating with other developers
Trust me that happens.
In this article, I’m going to talk about installing this very software on Centos
Installing SubversionEdge
because we will install CSVN in user mode, for that we must create CSVN user first.
[root@localhost
~]# adduser csvn [root@localhost ~]# passwd csvn Changing password for user csvn. New password: Retype new password: passwd: all authentication tokens updated successfully. |
Step #1 The Prerequisites
So, we start with the prerequisites. The prerequisite for SubversionEdge is Java. Hence, to begin with, we’ll have to install Java.
Now, if you’re not sure if Java is already installed, you can fire the below command to check the same:
[root@localhost
~]# java -version openjdk version "1.8.0_121" OpenJDK Runtime Environment (build 1.8.0_121-b13) OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode) |
If Java is installed the Java version should be displayed. if java is not installed on your system, you can install java in the following url:
Step #2 Installing CollabNet SVN
Download the latest version of Subversion Edge from CollabNet. It should be a tar.gz file.
Then, use the below commands to install the software. Do remember to replace CollabNetSubversionEdge-5.2.4_linux-x86_64.tar.gz with the tar.gz file you’ve downloaded from CollabNet. and put the downloaded file into the folder /home
[root@localhost
~]# cd /home [root@localhost home]# [root@localhost home]# gzip -d CollabNetSubversionEdge-5.2.4_linux-x86_64.tar.gz [root@localhost home]# tar xf CollabNetSubversionEdge-5.2.4_linux-x86_64.tar [root@localhost home]# cd /home/csvn/bin/ [root@localhost bin]# ./csvn install Detected RHEL or Fedora: Installing the CSVN Console daemon.. Setting RUN_AS_USER to: 'root'. Please edit '../data/conf/csvn.conf' if this needs to be adjusted Setting JAVA_HOME to: ''. Please edit '../data/conf/csvn.conf' if this needs to be adjusted. [root@localhost bin]# ./csvn-httpd install Detected RHEL or Fedora: Installing the Subversion Edge Apache Server daemon.. [root@localhost bin]# cd /home/ [root@localhost home]# chown csvn:csvn csvn/ -Rf |
login as csvn user and edit file csvn.conf
[csvn@localhost ~]$ vi data/conf/csvn.conf |
Setting RUN_AS_USER to: csvn
and back to root account again
CollabNet SVN should now be installed. All we need to do, is start their console and start using the application.
To start their console, fire the command
[root@localhost
~]# service csvn start Starting CSVN Console... ... CSVN Console started Waiting for application to initialize (this may take a minute)............................... CSVN Console is ready at http://localhost:3343/csvn |
Once this command runs successfully, you can view CollabNet SVN at work by heading over to http://localhost:3343/csvn
That’s it! Hope you’ve got the service up and running. and you can adjust the server settings to the existing conditions
Good luck managing your repositories!
Install Java on Centos
INSTALL JAVA
Download the latest JAVA from here or use the following command to download JAVA JDK
# wget --no-cookies \ --no-check-certificate \ --header "Cookie: oraclelicense=accept-securebackup-cookie" \ "https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.rpm" \ -O /tmp/jdk-8u201-linux-x64.rpm |
once the JAVA package has been downloaded, install it using rpm as follows:
# rpm -Uvh /tmp/jdk-8u201-linux-x64.rpm |
CONFIGURE JAVA
configure the newly installed JAVA package using alternatives as in:
# alternatives --install
/usr/bin/java java /usr/java/jdk1.8.0_201-amd64/jre/bin/java 20000 # alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0_201-amd64/bin/jar 20000 # alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_201-amd64/bin/javac 20000 # alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.8.0_201-amd64/jre/bin/javaws 20000 # alternatives --set java /usr/java/jdk1.8.0_201-amd64/jre/bin/java # alternatives --set javaws /usr/java/jdk1.8.0_201-amd64/jre/bin/javaws # alternatives --set javac /usr/java/jdk1.8.0_201-amd64/bin/javac # alternatives --set jar /usr/java/jdk1.8.0_201-amd64/bin/jar |
check the JAVA version running on your system:
# java -version |
Jumat, 16 Agustus 2019
Fix ORA-03113: end-of-file on communication channel
One day my server died suddenly due to a power problem, this caused a problem with my Oracle database,
ORA-03113: end-of-file on communication channel.
[oracle@localhost
~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Fri Aug 16 14:22:01 2019 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area 4993982464 bytes Fixed Size 2261808 bytes Variable Size 1006636240 bytes Database Buffers 3976200192 bytes Redo Buffers 8884224 bytes Database mounted. ORA-03113: end-of-file on communication channel Process ID: 4903 Session ID: 237 Serial number: 26032 |
After searching for ways to repair the server, I finally found the solution. Here are the steps:
[oracle@localhost
~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Fri Aug 16 14:22:01 2019 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup mount; ORACLE instance started. Total System Global Area 4993982464 bytes Fixed Size 2261808 bytes Variable Size 1006636240 bytes Database Buffers 3976200192 bytes Redo Buffers 8884224 bytes Database mounted. SQL> SELECT GROUP# FROM V$LOG; GROUP# ---------- 1 3 2 SQL> alter database clear unarchived logfile group 1; Database altered. SQL> alter database clear unarchived logfile group 2; Database altered. SQL> alter database clear unarchived logfile group 3; Database altered. SQL> shutdown immediate; ORA-01109: database not open Database dismounted. ORACLE instance shut down. SQL> startup ORACLE instance started. Total System Global Area 4993982464 bytes Fixed Size 2261808 bytes Variable Size 1006636240 bytes Database Buffers 3976200192 bytes Redo Buffers 8884224 bytes Database mounted. Database opened. SQL> |
If this method still fails, then there is a second method, which is as follows
Now, go into sqlplus without opening the database, just mounting it.
[oracle@localhost
~]$ sqlplus /nolog SQL*Plus: Release 11.2.0.4.0 Production on Fri Aug 16 14:45:09 2019 Copyright (c) 1982, 2013, Oracle. All rights reserved. SQL> connect / as sysdba Connected to an idle instance. SQL> startup mount ORACLE instance started. Total System Global Area 4993982464 bytes Fixed Size 2261808 bytes Variable Size 1006636240 bytes Database Buffers 3976200192 bytes Redo Buffers 8884224 bytes Database mounted. SQL> |
Now, you can increase your current db_recovery_file_dest_size, increased to 100G in my case:
SQL>
alter system set db_recovery_file_dest_size = 100G scope=both; System altered. |
Now, you can shutdown and startup again and that previous error should be gone. The proper fix is to get rid of the recovery files. You do that using RMAN
[oracle@localhost
~]$ rman target / Recovery Manager: Release 11.2.0.4.0 - Production on Fri Aug 16 14:49:39 2019 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: DB11G (DBID=432722608, not open) RMAN> backup archivelog all delete input; Starting backup at 16-AUG-19 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=156 device type=DISK specification does not match any archived log in the repository backup cancelled because there are no files to backup Finished backup at 16-AUG-19 RMAN> exit Recovery Manager complete. |
Wait a long time and your archivelog (that was using up all that space) will be gone. So, you can shutdown/startup your database and be back in business.
[oracle@jktdi009
~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Fri Aug 16 14:52:16 2019 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> shutdown immediate; ORA-01109: database not open Database dismounted. ORACLE instance shut down. SQL> startup ORACLE instance started. Total System Global Area 4993982464 bytes Fixed Size 2261808 bytes Variable Size 1006636240 bytes Database Buffers 3976200192 bytes Redo Buffers 8884224 bytes Database mounted. Database opened. SQL> |
Minggu, 11 Agustus 2019
vsftpd configuration of the ftp server in my company
Just to remember the vsftpd configuration of the ftp server in my company
The following configuration is on centos 6
anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 dirmessage_enable=YES xferlog_enable=YES xferlog_file=/var/log/vsftpd.log log_ftp_protocol=YES connect_from_port_20=YES xferlog_std_format=YES nopriv_user=ftp pam_service_name=vsftpd listen=YES tcp_wrappers=YES pasv_enable=YES pasv_max_port=1200 pasv_min_port=1026 port_enable=YES ascii_upload_enable=YES ascii_download_enable=YES ftpd_banner=Welcome to Private FTP Server. secure_chroot_dir=/home one_process_model=NO chroot_local_user=YES allow_writeable_chroot=YES guest_enable=NO use_localtime=YES #rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem #rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key seccomp_sandbox=NO |
This works since 2011 after upgrading from Centos 5
Minggu, 04 Agustus 2019
If there are ORA-01092 and ORA-30012 errors together
Errors like this
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-30012: undo tablespace 'UNDOTBS01' does not exist or of wrong type
if there are ORA-01092 and ORA-30012 errors together, here's how to resolve them
[oracle@localhost
~]$ sqlplus /nolog SQL*Plus: Release 11.2.0.3.0 Production on Mon Aug 5 10:23:32 2019 Copyright (c) 1982, 2011, Oracle. All rights reserved. SQL> connect sys as sysdba Enter password: Connected to an idle instance. SQL> |
SQL>
startup mount ORACLE instance started. Total System Global Area 535662592 bytes Fixed Size 1375792 bytes Variable Size 331350480 bytes Database Buffers 197132288 bytes Redo Buffers 5804032 bytes Database mounted. |
SQL>
select * from v$tablespace; TS# NAME INC BIG FLA ENC ---------- ------------------------------ --- --- --- --- 0 SYSTEM YES NO YES 1 SYSAUX YES NO YES 4 USERS YES NO YES 3 TEMP NO NO YES 6 EXAMPLE YES NO YES 9 RCRMAN YES NO YES 10 USERS_TBS YES NO YES 5 UNDOTBS2 YES NO YES 19 TESTTBS YES NO YES 14 TESTTB YES NO YES TS# NAME INC BIG FLA ENC ---------- ------------------------------ --- --- --- --- 15 TESTDB YES NO YES 12 rows selected. |
SQL>
create pfile='/oracle/product/11.2.0/db_1/dbs/initbckorcl.ora' from
spfile; File created. |
SQL>
shutdown immediate ORA-01109: database not open Database dismounted. ORACLE instance shut down. |
Edit Pfile UNDO_TABLESPACE PARAMETER
ORCL.undo_tablespace='UNDOTBS01' orcl.undo_tablespace='UNDOTBS01' *.undo_tablespace='UNDOTBS02' |
Change like this
ORCL.undo_tablespace='UNDOTBS02' orcl.undo_tablespace='UNDOTBS02' *.undo_tablespace='UNDOTBS02' |
Startup with new pfile
SQL>
startup pfile='/oracle/product/11.2.0/db_1/dbs/initbckorcl.ora'; ORACLE instance started. Total System Global Area 535662592 bytes Fixed Size 1375792 bytes Variable Size 331350480 bytes Database Buffers 197132288 bytes Redo Buffers 5804032 bytes Database mounted. Database opened. SQL> |
SQL>
create spfile from pfile; File created. SQL> create spfile from pfile='/oracle/product/11.2.0/db_1/dbs/initbckorcl.ora'; File created. |
SQL>
shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. |
SQL>
startup ORACLE instance started. Total System Global Area 535662592 bytes Fixed Size 1375792 bytes Variable Size 331350480 bytes Database Buffers 197132288 bytes Redo Buffers 5804032 bytes Database mounted. Database opened. |
SQL>
show parameter undo; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ undo_management string AUTO undo_retention integer 900 undo_tablespace string UNDOTBS2 |
Selasa, 16 Juli 2019
How to Install Nginx on CentOS 7
How to Install Nginx on CentOS 7
Nginx [engine x] is free and open source high-performance web server. It also acts as a reverse proxy server, as well as. This page shows how to install Nginx server on a CentOS 7 or RHEL 7 and configure a static web site.
In this article, we will explain how to install, configure and manage Nginx HTTP web server on a CentOS 7 or RHEL 7 server using command line.
Install Nginx Web Server
- First update the system software packages to the latest version.
- Next, install Nginx HTTP server from the EPEL repository using the YUM package manager, or if you have not installed the epel repository you can install the nginx repository.
# yum -y update |
Configure EPEL repo
# yum install epel-release |
Configure Nginx repo for CentOS 7 & RHEL (Red Hat Enterprise Linux) version 7.x
# vi /etc/yum.repos.d/nginx.repo |
Append following for CentOS 7.x:
[nginx] name=nginx repo baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/ gpgcheck=0 enabled=1 |
Append following for RHEL (Red Hat Enterprise Linux) version 7.x:
[nginx] name=nginx repo baseurl=http://nginx.org/packages/mainline/rhel/7/$basearch/ gpgcheck=0 enabled=1 |
Next, install Nginx
# yum install nginx |
Manage Nginx HTTP Server
- Once Nginx web server installed, you can start it first time and enable it to start automatically at system boot.
# systemctl
start nginx # systemctl enable nginx # systemctl status nginx |
Configure firewalld to Allow Nginx Traffic
- By default, CentOS 7 and RHEL 7 built-in firewall is set to block Nginx traffic. To allow web traffic on Nginx, update the system firewall rules to permit inbound packets on HTTP and HTTPS using the commands below.
#
firewall-cmd --zone=public --permanent --add-service=http # firewall-cmd --zone=public --permanent --add-service=https # firewall-cmd --reload |
Test Nginx Server on CentOS 7 and RHEL 7
- Now you can verify Nginx server by going to the following URL, a default nginx page will be shown.
http://SERVER_DOMAIN_NAME_OR_IP |
You can also use the curl command to get same info using the cli:
$ curl -I
http://10.21.136.13 $ curl http://10.21.136.13 |
Nginx Important Files and Directories
- The default server root directory (top level directory containing configuration files): /etc/nginx.
- The main Nginx configuration file: /etc/nginx/nginx.conf.
- Server block (virtual hosts) configurations can be added in: /etc/nginx/conf.d.
- The default server document root directory (contains web files): /usr/share/nginx/html.
Kamis, 04 Juli 2019
Changing DNS Search Order
Changing DNS Search Order
/etc/nsswitch.conf
Open /etc/nsswitch.conf file using text editor:
# vi /etc/nsswitch.conf |
Look for hosts:
hosts: files dns mdns4 |
Set above order as per your requirement. Close and save the file.
host.conf – resolver configuration file
The file /etc/host.conf contains configuration information specific to the resolver library. It should contain one configuration keyword per line, followed by appropriate configuration information.
Open /etc/host.conf file
# vi /etc/host.conf |
Find order line which specifies how host lookups are to be performed. It should be followed by one or more lookup methods, separated by commas. Valid methods are bind (dns server), hosts (/etc/hosts file), and nis (old method).
order hosts,bind |
conclusion
The file
/etc/nsswitch.conf
will let you
reconfigure the order of the name resolution. By default, the host file
is the first, then the configured DNS. There could be more options.
The file
/etc/hosts
only lists IP
addresses and hostnames (multiple names for one IP if you want)
The file /etc/resolv.conf
will list
the default search domains, and will also list in sequence the name
servers to use.
Minggu, 12 Mei 2019
How to monitor MySQL using Nagios
How to configuring Nagios to monitor your MySQL server. Before we begin, there are a few prerequisites that you have to fulfill
Prerequisites
- Operating System - CentOS.
- Nagios Core - Installed and configured.
- Nagios Plugins should be installed.
- MySQL server(or MariaDB) should be installed on your server.
- Log in to your MySQL server with the following command.
- Type in the following commands.
# mysql -u root -p |
mysql>
CREATE USER 'nagios'@'localhost' IDENTIFIED BY 'nagiospasswd'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'nagios'@'localhost'; mysql> CREATE USER 'nagios'@'%' IDENTIFIED BY 'nagiospasswd'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'nagios'@'%'; mysql> flush privileges; |
These commands create a user "nagios" that can be used by local host as well as remotely. We have also granted all privileges to the user.
Install of the perl-modules DBI and DBD::mysql
Log in to nagios server use the following command to install perl-modules DBI and DBD::mysql
# yum -y
install perl-DBI # yum -y install "perl(DBD::mysql)" |
MySQL Plugin Installation
- Run the following command to download the "check_mysql_health-2.2.2.tar.gz" package.
- Extract the downloaded package.
- Change into the check_mysql_health-2.2.2 directory.
- Run the following commands to configure and install the plugin.
# wget https://labs.consol.de/assets/downloads/nagios/check_mysql_health-2.2.2.tar.gz |
# tar -zxvf check_mysql_health-2.2.2.tar.gz |
# cd check_mysql_health-2.2.2 |
# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios
--with-nagios-group=nagios --with-perl=/usr/bin/perl # make # make install |
Nagios Configuration for MySQL Monitoring
- "check_mysql_health" Command Definition
- "check_mysql_health" Service Definition
- Restart the Nagios server.
The following file contains all the commands pertaining to Nagios. Open it in any text editor of your choice("vi" in this case).
# vi /usr/local/nagios/etc/objects/commands.cfg |
Edit the file and add the "check_mysql_health" command block.
define
command{ command_name check_mysql_health command_line $USER1$/check_mysql_health -H $ARG1$ --username $ARG2$ --password $ARG3$ --port $ARG4$ --mode $ARG5$ } |
Open the file "hosttomonitor.cfg" to add the service definition to the host that will be monitored.
# vi /usr/local/nagios/etc/servers/hosttomonitor.cfg |
Add the following service blocks of Connection-time, io thread and sql thread. This will perform different tasks.
define service{ use local-service host_name hosttomonitor service_description MySQL connection-time check_command check_mysql_health!192.168.30.10!nagios!nagiospasswd!3306!connection-time! } define service{ use local-service host_name hosttomonitor service_description MySQL slave-io-running check_command check_mysql_health!192.168.30.10!nagios!nagiospasswd!3306!slave-io-running! } define service{ use local-service host_name hosttomonitor service_description MySQL slave-sql-running check_command check_mysql_health!192.168.30.10!nagios!nagiospasswd!3306!slave-sql-running! } |
# service nagios restart |
https://labs.consol.de/nagios/check_mysql_health/index.html
Kamis, 09 Mei 2019
How to Install Nagios Plugins in CentOS
Prerequisites - Common
These are the common set of packages required for compiling most of the plugins. SNMP and required modules are included here are they are one of the most common types of network monitoring.
CentOS 6.x / 7.x
yum install -y
gcc glibc glibc-common make gettext automake autoconf wget
openssl-devel net-snmp net-snmp-utils epel-release yum install -y perl-Net-SNMP |
Download latest nagios-plugins source and install using following commands
cd /opt wget http://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz tar xzf nagios-plugins-2.2.1.tar.gz cd nagios-plugins-2.2.1 |
Now compile and install nagios plugins
./configure
--with-nagios-user=nagios --with-nagios-group=nagios make make install |
Setup the nagios user:
useradd nagios passwd nagios |
Plugin Installation Location
The plugins will now be located in /usr/local/nagios/libexec/.
Selasa, 07 Mei 2019
How to Install - Oracle Plugin check_oracle_health (CentOS 6)
Prerequisites
Oracle software
The Oracle database server or instant client must be up and running.
CentOS packages
yum -y install cpan sharutils |
Perl packages
Find out the absolute path of ORACLE_HOME and set the Oracle environment.
This is required for the installation of DBD::Oracle.
if Oracle 11gR2 server installated
export
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 export LD_LIBRARY_PATH=$ORACLE_HOME/lib |
if Oracle Instantclient installated
export
ORACLE_HOME=/usr/lib/oracle/11.2/client64 export LD_LIBRARY_PATH=$ORACLE_HOME/lib |
Install Perl DBD::Oracle module
wget
http://www.cpan.org/modules/by-module/DBD/DBD-Oracle-1.74.tar.gz tar zxvf DBD-Oracle-1.74.tar.gz cd DBD-Oracle-1.74 perl Makefile.PL -l make && make test make install |
Download and install the check_oracle_health plugin
Check for the latest version at http://labs.consol.de/lang/en/nagios/check_oracle_health/, scroll down to "Download".
cd /tmp wget https://labs.consol.de/assets/downloads/nagios/check_oracle_health-3.1.0.3.tar.gz tar xzf check_oracle_health-3.1.0.3.tar.gz cd /tmp/check_oracle_health-* ./configure make make install cp /usr/local/nagios/libexec/check_oracle_health /usr/lib64/nagios/plugins/ |
Set up the Oracle user "nagios" in target server
# as root: su - oracle sqlplus / as sysdba CREATE USER nagios IDENTIFIED BY oradbmon; GRANT CREATE SESSION TO nagios; GRANT SELECT any dictionary TO nagios; GRANT SELECT ON V_$SYSSTAT TO nagios; GRANT SELECT ON V_$INSTANCE TO nagios; GRANT SELECT ON V_$LOG TO nagios; GRANT SELECT ON SYS.DBA_DATA_FILES TO nagios; GRANT SELECT ON SYS.DBA_FREE_SPACE TO nagios; exit # leave SQL*Plus exit # back to root |
Test locally
Please replace the path to ORACLE_HOME and the connect string as appropriate. In the following example,
the connect string refers to the alias in $ORACLE_HOME/network/admin/tnsnames.ora if your install server version
if you install instantclient connect string refers to the alias in /etc/tnsnames.ora
/usr/local/nagios/libexec/check_oracle_health --connect XE --user nagios --password oradbmon --environment ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe --mode tablespace-usage |
Now you have to configure the check command in nagios. For the command to work, it needs to have the oracle client paths added to the environment variables – ORACLE_HOME, LD_LIBRARY_PATH,PATH. To avoid all sorts of issues in passing environment variables in nagios and altering the startup script of nagios to set them (as described on the author’s site), just pass the variables directly in the command. The latest version of check_oracle_health allows that.
Define command in /usr/local/nagios/etc/objects/command.cfg
vi /usr/local/nagios/etc/objects/command.cfg |
# Oracle
Database check health command # check_oracle_health ! SID ! USER ! Pass ! Warn ! crit ! mode define command { command_name check_oracle_health command_line $USER1$/check_oracle_health --environment PATH=$PATH:$ORACLE_HOME/bin --environment LD_LIBRARY_PATH=$ORACLE_HOME/lib --connect $ARG1$ --user $ARG2$ --password $ARG3$ --mode $ARG4$ } # Oracle Check Tablespace per name # check_oracle_health_tbs_name ! SID ! USER ! Pass ! Warn ! crit ! mode ! tbs_name define command { command_name check_oracle_health_tbs_name command_line $USER1$/check_oracle_health --environment PATH=$PATH:$ORACLE_HOME/bin --environment LD_LIBRARY_PATH=$ORACLE_HOME/lib --connect $ARG1$ --user $ARG2$ --password $ARG3$ --mode $ARG4$ --name $ARG5$ } |
Define service in /usr/local/nagios/etc/servers/oracledbtest.cfg
define host{ use linux-server host_name oracledbtest alias oracledbtest address 192.168.xx.yy max_check_attempts 5 check_period 24x7 notification_interval 30 notification_period 24x7 } ### Change last argument to the different modes ### tns-ping , process-usage , sga-shared-pool-free define service { use local-service host_name oracledbtest service_description Oracle Connection Time check_command check_oracle_health!XE!nagios!oradbmon!connection-time notifications_enabled 1 } define service { use local-service host_name oracledbtest service_description Oracle Connected Users check_command check_oracle_health!XE!nagios!oradbmon!connected-users notifications_enabled 1 } ### Change last argument to the different tablespace ### users, undotbs define service { use local-service host_name oracledbtest service_description Oracle Tablespace Usage Users check_command check_oracle_health_tbs_name!XE!nagios!oradbmon!tablespace-usage!users notifications_enabled 1 } |
You can add all the modes you want. You can manually test the command like so. It’s very important that the ORACLE_HOME and other variables are set. They can be passed to the command directly, this way you don’t need to modify your nagios startup script to set the vars in the nagios user enviornment.
Install Oracle Instant Client on Linux CentOS
The installation of an Oracle client on a server is always a tedious task and although you have done it many times, there are always things to review.
In this case we are going to install an Oracle InstantClient of version 11 for the CentOS operating system.
As we also want to be able to compile applications that will be used by Oracle libraries, we will also have to install the header files.
Download installation packages
The installation files can be found at this URL:
https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
The client version to be used is 11.2.0.4.0
The packages to download are:
oracle-instantclient11.2-basic-11.2.0.4.0–1.x86_64.rpm oracle-instantclient11.2-devel-11.2.0.4.0–1.x86_64.rpm oracle-instantclient11.2-sqlplus-11.2.0.4.0–1.x86_64.rpm |
The package with sqlplus is only needed to check that the installation was correct
Installing the RPM files
We proceed to the installation of previously downloaded packages
$ sudo yum
localinstall -y
oracle-instantclient11.2-basic-11.2.0.4.0–1.x86_64.rpm $ sudo yum localinstall -y oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm $ sudo yum localinstall -y oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm |
Environment Variables
We will need to define some environment variables for the Oracle client to work correctly
$ export
ORACLE_HOME=/usr/lib/oracle/11.2/client64 $ export TNS_ADMIN=$ORACLE_HOME/network/admin $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib $ export PATH=$PATH:$ORACLE_HOME/bin |
To be able to work with the tnsnames.ora file, we will have to copy it to the directory defined in the environment variable
$ sudo mkdir -p /usr/lib/oracle/11.2/client64/network/admin |
Create new /usr/lib/oracle/11.2/client64/network/admin/tnsnames.ora like this:
TEST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (Host = testdboracle) (Port = 1521) ) ) (CONNECT_DATA = (SID = ORCL) ) ) |
Installation test
To verify that the installation was correct, we will open a sqlplus session against one of our databases
Connect to Your database with:
$ sqlplus scott/tiger@TEST |
You can also use the Easy Connect connection string format (does not use TNSNAMES):
$ sqlplus scott/tiger@testdboracle:1521/ORCL |
Kamis, 02 Mei 2019
Monitor ssh on non-default port with Nagios
In ssh pluging config /usr/local/nagios/etc/objects/commands.cfg, there an alias named check_ssh_port.
if it not existe you may define it like above:
define command{ command_name check_ssh_port command_line $USER1$/check_ssh -p $ARG1$ $HOSTADDRESS$ } |
in the service file /usr/local/nagios/etc/servers/hosttomonitor.cfg, define you ssh service to monitor like this:
define host{ use linux-server host_name hosttomonitor.localnet alias hosttomonitor address 10.10.10.19 max_check_attempts 5 check_period 24x7 notification_interval 30 notification_period 24x7 } define service { use generic-service host_name hosttomonitor.localnet service_description SSH2 check_command check_ssh_port!1422 notifications_enabled 0 } |
replace 1422 by you default ssh port and server by your target.
finally restart nagios service
Senin, 22 April 2019
How to solve the problem "caching_sha2_password" problem
How to solve the problem "caching_sha2_password" problem ?
if you log in to MySQL and find an error like below
[root@localhost ~]# mysql -h
127.0.0.1 -P 3306 -u root -p Enter password: ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory |
So I found the reason for that error message (at least for my case). It's because MySQL as of version 8.04 and onwards uses caching_sha2_password as default authentication plugin where previously mysql_native_password has been used.
This obviously causes compatibility issues with older services that expect mysql_native_password authentication.
Solutions:
- Check for an updated version of the client service you are using (most recent workbench for instance).
- Downgrade the MySQL Server to a version below that change.
- Change the authentication plugin on a per user basis (I didn't find a global option, maybe there exists one though).
mysql> ALTER USER root IDENTIFIED WITH mysql_native_password BY 'password'; |
or when creating the user:
mysql> CREATE USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; |
Selasa, 09 April 2019
How to FIX ORA-00257: archiver error. Connect internal only, until freed.
How to FIX ORA-00257: archiver error. Connect internal only, until freed.
Cause: The archiver process received an error while trying to archive a redo log. If the problem is not resolved soon, the database will stop executing transactions. The most likely cause of this message is the destination device is out of space to store the redo log file.
ORA-00257 is a common error in Oracle. You will usually see ORA-00257 upon connecting to the database because you have encountered a maximum in the flash recovery area (FRA), or db_recovery_file_dest_size .
First, make sure your automatic archiving is enabled. To check the archive lo made, try:
SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 2671 Next log sequence to archive 2676 Current log sequence 2676 |
Now, note that you can find archive destinations if you are using a destination of USE_DB_RECOVERY_FILE_DEST by:
SQL>
show parameter db_recovery_file_dest; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_recovery_file_dest string /oracle/fast_recovery_area db_recovery_file_dest_size big integer 32G |
The next step in resolving ORA-00257 is to find out what value is being used for db_recovery_file_dest_size, use:
SQL>
SELECT * FROM V$RECOVERY_FILE_DEST; NAME SPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES ---------------------------------------- ----------- ---------- ----------------- --------------- /oracle/fast_recovery_area 3.8174E+10 3.8174E+10 0 327 |
You may find that the SPACE_USED is the same as SPACE_LIMIT,
The first step to fixing this issue would be to log into your server and see if you have run out of physical space on one of your disks or mounts. If you have run out of physical space you have a few options.
You can backup your archivelogs and delete input, or
# rman target / RMAN> BACKUP ARCHIVELOG ALL DELETE ALL INPUT; |
you can just delete the archivelogs if you won’t need them to restore your database.
# rman target / RMAN> DELETE NOPROMPT ARCHIVELOG ALL; |
you can Increase db_recovery_file_dest_size
SQL> alter system set db_recovery_file_dest_size=64g scope=both; |
After all you can restart database
SQL>
shutdown immediate; SQL> startup |
Setting up NSQ as a Service on CentOS 7 (SystemD)
In this tutorial I will give an example of making nsqlookup, nsqd and nsqadmin run as service in centos 7 (systemD)
first create a configuration file for each of these services and all configurations are placed in the /etc/nsq directory
for the nsqlookupd configuration file it is nsqlookupd.conf and make it like the file below
# cd /etc/nsq # vi nsqlookupd.conf |
## log
verbosity level: debug, info, warn, error, or fatal log-level = "info" ## <addr>:<port> to listen on for TCP clients tcp_address = "0.0.0.0:4160" ## <addr>:<port> to listen on for HTTP clients http_address = "0.0.0.0:4161" ## address that will be registered with lookupd (defaults to the OS hostname) broadcast_address = "main" ## duration of time a producer will remain in the active list since its last ping inactive_producer_timeout = "300s" ## duration of time a producer will remain tombstoned if registration remains tombstone_lifetime = "45s" |
for the nsqd configuration file it is nsqd.conf and make it like the file below
# vi nsqd.conf |
## log
verbosity level: debug, info, warn, error, or fatal #log-level = "info" ## unique identifier (int) for this worker (will default to a hash of hostname) # id = 5150 ## <addr>:<port> to listen on for TCP clients tcp_address = "0.0.0.0:4150" ## <addr>:<port> to listen on for HTTP clients http_address = "0.0.0.0:4151" ## <addr>:<port> to listen on for HTTPS clients # https_address = "0.0.0.0:4152" ## address that will be registered with lookupd (defaults to the OS hostname) broadcast_address = "127.0.0.1" ## cluster of nsqlookupd TCP addresses nsqlookupd_tcp_addresses = [ "127.0.0.1:4160" ] ## duration to wait before HTTP client connection timeout http_client_connect_timeout = "2s" ## duration to wait before HTTP client request timeout http_client_request_timeout = "5s" ## path to store disk-backed messages data_path = "/var/lib/nsq" ## number of messages to keep in memory (per topic/channel) mem_queue_size = 10000 ## number of bytes per diskqueue file before rolling max_bytes_per_file = 104857600 ## number of messages per diskqueue fsync sync_every = 2500 ## duration of time per diskqueue fsync (time.Duration) sync_timeout = "2s" ## duration to wait before auto-requeing a message msg_timeout = "60s" ## maximum duration before a message will timeout max_msg_timeout = "15m" ## maximum size of a single message in bytes max_msg_size = 1024768 ## maximum requeuing timeout for a message max_req_timeout = "1h" ## maximum size of a single command body max_body_size = 5123840 ## maximum client configurable duration of time between client heartbeats max_heartbeat_interval = "60s" ## maximum RDY count for a client max_rdy_count = 2500 ## maximum client configurable size (in bytes) for a client output buffer max_output_buffer_size = 65536 ## maximum client configurable duration of time between flushing to a client (time.Duration) max_output_buffer_timeout = "1s" ## UDP <addr>:<port> of a statsd daemon for pushing stats # statsd_address = "127.0.0.1:8125" ## prefix used for keys sent to statsd (%s for host replacement) statsd_prefix = "nsq.%s" ## duration between pushing to statsd (time.Duration) statsd_interval = "60s" ## toggle sending memory and GC stats to statsd statsd_mem_stats = true ## the size in bytes of statsd UDP packets # statsd_udp_packet_size = 508 ## message processing time percentiles to keep track of (float) e2e_processing_latency_percentiles = [ 1.0, 0.99, 0.95 ] ## calculate end to end latency quantiles for this duration of time (time.Duration) e2e_processing_latency_window_time = "10m" ## path to certificate file tls_cert = "" ## path to private key file tls_key = "" ## set policy on client certificate (require - client must provide certificate, ## require-verify - client must provide verifiable signed certificate) # tls_client_auth_policy = "require-verify" ## set custom root Certificate Authority # tls_root_ca_file = "" ## require client TLS upgrades tls_required = false ## minimum TLS version ("ssl3.0", "tls1.0," "tls1.1", "tls1.2") tls_min_version = "" ## enable deflate feature negotiation (client compression) deflate = true ## max deflate compression level a client can negotiate (> values == > nsqd CPU usage) max_deflate_level = 6 ## enable snappy feature negotiation (client compression) snappy = true |
for the nsqadmin configuration file it is nsqadmin.conf and make it like the file below
# vi nsqadmin.conf |
## log verbosity level: debug, info, warn, error, or fatal log-level = "info" ## <addr>:<port> to listen on for HTTP clients http_address = "0.0.0.0:4171" ## graphite HTTP address graphite_url = "" ## proxy HTTP requests to graphite proxy_graphite = false ## prefix used for keys sent to statsd (%s for host replacement, must match nsqd) statsd_prefix = "nsq.%s" ## format of statsd counter stats statsd_counter_format = "stats.counters.%s.count" ## format of statsd gauge stats statsd_gauge_format = "stats.gauges.%s" ## time interval nsqd is configured to push to statsd (must match nsqd) statsd_interval = "60s" ## HTTP endpoint (fully qualified) to which POST notifications of admin actions will be sent notification_http_endpoint = "" ## nsqlookupd HTTP addresses nsqlookupd_http_addresses = [ "127.0.0.1:4161" ] ## nsqd HTTP addresses (optional) #nsqd_http_addresses = [ # "127.0.0.1:4151" #] |
let's make a service for all nsq service
- nsqlookupd
- nsqd
- nsqadmin
# cd
/etc/systemd/system # vim nsqlookupd.service |
[Unit] Description=nsqlookup daemon Service After=network.target [Service] PrivateTmp=yes ExecStart=/usr/local/nsq/bin/nsqlookupd -config /etc/nsq/nsqlookupd.conf Restart=always [Install] WantedBy=multi-user.target |
# vim nsqd.service |
[Unit] Description=Realtime distributed messaging (nsqd) After=network.target [Service] PrivateTmp=yes ExecStart=/usr/local/nsq/bin/nsqd -config /etc/nsq/nsqd.conf Restart=always [Install] WantedBy=multi-user.target |
v# vim nsqadmin.service |
[Unit] Description=nsqadmin daemon Service (nsqadmin) After=network.target [Service] PrivateTmp=yes ExecStart=/usr/local/nsq/bin/nsqadmin -config /etc/nsq/nsqadmin.conf Restart=always [Install] WantedBy=multi-user.target |
enable all nsq service
# systemctl
enable nsqlookupd.service Created symlink from /etc/systemd/system/multi-user.target.wants/nsqlookupd.service to /etc/systemd/system/nsqlookupd.service. |
# systemctl
enable nsqd.service Created symlink from /etc/systemd/system/multi-user.target.wants/nsqd.service to /etc/systemd/system/nsqd.service. |
# systemctl
enable nsqadmin.service Created symlink from /etc/systemd/system/multi-user.target.wants/nsqadmin.service to /etc/systemd/system/nsqadmin.service. |
here we go start the service
# systemctl
start nsqlookupd # systemctl start nsqd # systemctl start nsqadmin |
to check service run or not
# systemctl
status nsqlookupd ● nsqlookupd.service - nsqlookup daemon Service Loaded: loaded (/etc/systemd/system/nsqlookupd.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2019-04-09 03:38:40 EDT; 1h 41min ago Main PID: 5193 (nsqlookupd) CGroup: /system.slice/nsqlookupd.service └─5193 /usr/local/nsq/bin/nsqlookupd -config /etc/nsq/nsqlookupd.c... Apr 09 05:18:06 main.coba.net nsqlookupd[5193]: [nsqlookupd] 2019/04/09 05:1...) Hint: Some lines were ellipsized, use -l to show in full. |
# systemctl
status nsqd ● nsqd.service - Realtime distributed messaging (nsqd) Loaded: loaded (/etc/systemd/system/nsqd.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2019-04-09 04:58:21 EDT; 22min ago Main PID: 5234 (nsqd) CGroup: /system.slice/nsqd.service └─5234 /usr/local/nsq/bin/nsqd -config /etc/nsq/nsqd.conf Apr 09 04:58:21 main.coba.net nsqd[5234]: [nsqd] 2019/04/09 04:58:21.319327 ...0 Hint: Some lines were ellipsized, use -l to show in full. |
# systemctl
status nsqadmin ● nsqadmin.service - nsqadmin daemon Service (nsqadmin) Loaded: loaded (/etc/systemd/system/nsqadmin.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2019-04-09 04:59:13 EDT; 21h ago Main PID: 5249 (nsqadmin) CGroup: /system.slice/nsqadmin.service └─5249 /usr/local/nsq/bin/nsqadmin -config /etc/nsq/nsqadmin.conf Apr 09 04:59:13 main.coba.net systemd[1]: Started nsqadmin daemon Service (n.... Apr 09 04:59:13 main.coba.net nsqadmin[5249]: [nsqadmin] 2019/04/09 04:59:13...) Hint: Some lines were ellipsized, use -l to show in full |
That all's
Langganan:
Postingan (Atom)