Buscar este blog

Mostrando entradas con la etiqueta Centos 7. Mostrar todas las entradas
Mostrando entradas con la etiqueta Centos 7. Mostrar todas las entradas

sábado, 21 de noviembre de 2020

qperf - Monitoring network bandwidth and latency

 

I will use qperf: https://docs.oracle.com/cd/E86824_01/html/E54763/qperf-1.html

You can check a detailed example here: https://access.redhat.com/solutions/2122681


In destination machine you need to run the following command:

qperf &

You need to open ports 19765 and 19766 in this machine.


In source machine you need to create the following script, in my case, network-monitoring.sh:

#!/bin/sh

echo "$(date +'%Y/%m/%d %H:%M:%S') comprobando red"
HOSTNAME=$(hostname)
DESTINO=[destinationMachine]

ANCHO_BANDA=$(qperf -v -ip 19766  -t 5 --use_bits_per_sec  $DESTINO  tcp_bw | grep bw | awk '{print $3";"$4}' | sed -n '2 p')
LATENCIA=$(qperf -v -ip 19766  -t 5 --use_bits_per_sec  $DESTINO  tcp_lat | grep latency | awk '{print $3";"$4}')


echo "$(date +'%d/%m/%Y');$(date +'%H:%M:%S');$HOSTNAME;$DESTINO;$ANCHO_BANDA;$LATENCIA" >> /root/network-monitoring.csv

 

martes, 14 de abril de 2020

CentOS check system info

Show system inf for a CentOS server:
# CPU info
 more /proc/cpuinfo

# Memory info
 dmidecode -t memory
 dmidecode -t memory | grep -i "installed size"

# Operatin System
 cat /etc/os-release
 hostnamectl
 uname -r

viernes, 26 de julio de 2019

CentOS 7 - Increase swap memory


[root@archive ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           1839         124        1570           8         144        1554
Swap:          1227           0        1227

[root@archive ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  9.8G  1.6G  8.3G  17% /
devtmpfs                 909M     0  909M   0% /dev
tmpfs                    920M     0  920M   0% /dev/shm
tmpfs                    920M  8.4M  912M   1% /run
tmpfs                    920M     0  920M   0% /sys/fs/cgroup
/dev/sda1               1014M  143M  872M  15% /boot
tmpfs                    184M     0  184M   0% /run/user/0

[root@archive ~]# dd if=/dev/zero of=/root/vembuswap bs=1M count=2048
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 24.9862 s, 85.9 MB/s

[root@archive ~]# mv /root/vembuswap /root/customswap

[root@archive ~]# ls -l /root/customswap
-rw-r--r--. 1 root root 2147483648 Jul 26 12:25 /root/customswap

[root@archive ~]# chmod 600 /root/customswap

[root@archive ~]# mkswap /root/customswap
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=8b5f50f4-3c03-422a-946d-403afbcb3a22

[root@archive ~]# swapon /root/customswap

[root@archive ~]# vi /etc/fstab
Add the following line:
/root/customswap swap   swap    defaults        0 0
 

[root@archive ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/dm-1                               partition       1257468 0       -1
/root/customswap                        file    2097148 0       -2

[root@archive ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           1839         124          76           8        1638        1528
Swap:          3275           0        3275
[root@archive ~]#


domingo, 9 de junio de 2019

CentOS 7 - Port forwarding

I have three environments:
  1. Local, i.e, my PC
  2. Server 1, a remote CentOS 7 server
  3. Database Server, a remote Oracle Database server
Server 1 has access to Database Server.
Local has access to Server 1.
Local does not have access to Database Server.

By assuming Oracle Database is opened in port 1521 this is the configuration in Server 1 in order to redirect all requests in port 1521 to Database Server port 1521:
# sudo firewall-cmd --add-forward-port=port=1521:proto=tcp:toport=1521:toaddr=DatabaseServer

# sudo firewall-cmd --add-masquerade

# sudo firewall-cmd --zone=public --add-port=1521/tcp

# sudo firewall-cmd --list-all


domingo, 26 de mayo de 2019

Virtual Box Guest connect to Windows Host

You have a Windows Host running Virtual Box, and a CentOS 7 Guest as virtual machine.
Guest needs to connect to some service in Host. As an example, Host has an Apache web server running in port 80.


First, you have to determine the gateway used by the Guest.

enp0s3 is my "host only" network interface in VirtualBox.
In my case, it's 192.168.56.1. This is the IP the Guest knows as Host so, if you call for port 80, you should get Apache home page.

As you see Guest is not able to connecto to Host. In order to allow that, you need to configure Host firewall, in my case, Windows 10.
You can disable firewall for private networks as follow, but this is not a good solition due security concerns.



The proper solution is to configure a firewall rule for this port in the private network.





sábado, 30 de diciembre de 2017

Centos 7.x - Minimal network setup

This is a continuation of a previous post, but this time dedicated to CentOS 7 (our customer is evolving!!)

Environment:
  • Virtualbox 5.1.10
  • CentOS 7.4.1708
Before start with the installation, in Virtualbox you have to configure two network adapters:
  • Adapter 1: Host only
  • Adapter 2: NAT
The first one will be used to communicate host and guest, for example, by using a ssh connection. The second one will be used by the guest in order to gain direct access to the internet.

When CentOS starts for first time, you will already had internet access. But local network will be disabled. Execute the following command to check your network interfaces:
ip add

The result will be something like this:


Here you can see three interfaces:
  • lo: Loopback
  • enp0s3: Host-Only adapter
  • enp0s8: NAT adapter
If you have doubts about which is the host-only, you can check the MAC address and compare it with the Virtualbox adapter.


Once you are sure enp0s3 is your interface, go to /etc/sysconfig/network-scripts/ and edit ifcfg-enp0s3 file, for example with vi. You will have to make two changes:
  • Set BOOTPROTO=none
  • Set ONBOOT=yes
  • Add IPADDR=your IP

Then execute the following command:
systemctl restart network.service

Now you will have your interface up and with the IP address you set before.


Note

As stated in my previous post, remember to configure proxy settings for system and yum configuration:

System config

Edit ~/.bash_profile file and add the following lines:

# The Web proxy server used by this account
http_proxy="http://usuario:password@my.proxy:8080"
export no_proxy=localhost,127.0.0.1
export http_proxy

YUM config

Edit  /etc/yum.conf y add the following lines:

# The proxy server - proxy server:port number
proxy=http://my.proxy:8080
# The account details for yum connections
proxy_username=usuario
proxy_password=password

miércoles, 12 de noviembre de 2014

Client denied by server configuration: /usr/share/phpmyadmin - You don't have permission to access /phpmyadmin on this server

Al acceder a http://xxxxx/phpmyadmin/ se obtiene el siguiente error:
You don't have permission to access /phpmyadmin on this server.

Consultando los logs de Apache se muestra el siguiente mensaje;
client denied by server configuration: /usr/share/phpmyadmin

Esto me ha ocurrido durante la instalación en Centos7, siguiendo el tutorial de su wiki 

Solución
(Visto en el siguiente foro http://askubuntu.com/questions/483297/why-do-i-always-get-a-403-error-with-phpmyadmin)

Lo más probable es que ya se hayan revisado los millones de foros y blogs indicando como solucionar este error y la solución que proponían era la siguiente cambiar el fichero /etc/httpd/conf.d/phpmyadmin.conf de la siguiente forma (o en cualquiera de sus múltiples variantes con el allow):

<Directory "/usr/share/phpmyadmin">
  Order allow,deny
  Allow from all
</Directory>


Pero si se está usando apache 2.4.x la verdadera solución es la siguiente:


<Directory "/usr/share/phpmyadmin">
  Require all granted
</Directory>

Hay que usar Require all granted