Showing posts with label CentOS/RHEL. Show all posts
Showing posts with label CentOS/RHEL. Show all posts

Wednesday, July 26, 2023

CentOS/RHEL: Installing the Zabbix server

To install Zabbix server on Linux platform CentOS/RHEL follow these steps:

1. First, install the latest security updates for your OS
dnf update --security

and reload
reboot

2. Next, connect all the necessary additional Zabbix repositories and PostgreSQL databases
rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-1.el9.noarch.rpm
rpm -Uvh https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
dnf repolist
dnf clean all


3. Install the PostgreSQL database
dnf install -y postgresql15-server

4. Initialize the database and set up automatic startup
/usr/pgsql-15/bin/postgresql-15-setup initdb
systemctl enable postgresql-15
systemctl start postgresql-15


5. Create a user "zabbix" and when prompted enter a password for it, create a database "zabbix"
sudo -u postgres createuser --pwprompt zabbix
sudo -u postgres createdb -O zabbix zabbix


6. Install Nginx web server and PHP modules
dnf install php
dnf install nginx


7. Configure Web Server service startup and firewall
systemctl start php-fpm
systemctl start nginx
systemctl enable php-fpm nginx
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --permanent --zone=public --add-port=8080/tcp
firewall-cmd --reload


8. Test PHP modules by creating "index.php" page
echo '<?php phpinfo(); ?>' > /usr/share/nginx/html/index.php

and checking access to the page through the browser
http://<hostname>/index.php

9. Then install the Zabbix server with the necessary scripts
dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent

10. Run the script for the initial configuration of the Zabbix server database
zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix

11. Edit the configuration file "/etc/zabbix/zabbix_server.conf", specify the password to access the Zabbix database:
DBPassword=password

12. Edit the Zabbix configuration file "/etc/nginx/conf.d/zabbix.conf", uncomment and specify the parameters:
#listen 8080;
#server_name example.com;


13. Set up Zabbix server autoload and run
systemctl start zabbix-server zabbix-agent
systemctl enable zabbix-server zabbix-agent
systemctl restart zabbix-server zabbix-agent php-fpm nginx


14. Set up rules for SELinux:
to view rules run this
getsebool -a | grep zabbix
to set the value do for example
setsebool -P zabbix_can_network=1

15. Verify that it works, open "http://<hostname:8080>/" in a browser and complete the initial configuration. To log in, use the login "Admin" and the password "zabbix".

Thursday, May 18, 2023

Brocade: Setting up a periodic backup of the configuration of an optical switch using the SCP protocol

To perform the task of creating periodic backups of switch configurations, we will use a host with an installed SSH server. 

Let's go through the following steps:

1. For the convenience of connecting via SSH using a script, install the "sshpass" utility.

2. Let's create a user in the server OS, which will have the rights to connect via the SCP protocol and write to the required directory of the configuration file.

3. Create a script, for example "brocade.sh", and add commands for backing up optical switches in the following form:

sshpass -p Switch_Pass ssh Switch_Address -l Switch_User configupload -all -p scp -P 22 -cra Server_Address,Server_User,config-o-rez-$(date -I).txt,Server_Pass;exit

where Switch_Address - optical switch address;
Switch_User - optical switch user;
Switch_Pass - optical switch user's password;
Server_Address - SSH server address;
Server_User - user to connect to the server via SSH;
Server_Pass - SSH server user's password.

4. Add to the task scheduler ("cron") the execution of this script with the necessary periodicity. For example, to run on the first Monday of every month at 7 am:

0 7 1-7 * 1 /path/to/brocade.sh

 

Tuesday, October 1, 2019

CentOS/RHEL: Setting up the system for working with a proxy server

For CentOS / RHEL utilities to use a proxy server instead of direct access, add the following lines to the end of the file "/etc/profile":

MY_PROXY_URL="http://user:password@proxyserver:8080"
HTTP_PROXY=$MY_PROXY_URL
HTTPS_PROXY=$MY_PROXY_URL
FTP_PROXY=$MY_PROXY_URL
http_proxy=$MY_PROXY_URL
https_proxy=$MY_PROXY_URL
ftp_proxy=$MY_PROXY_URL
export HTTP_PROXY HTTPS_PROXY FTP_PROXY http_proxy https_proxy ftp_proxy


Run to apply: "source /etc/profile".

If you need to make settings for a specific user, add these lines to the end of the file ".bash_profile", located in the user home directory ("cd ~"). Apply with the command "source ~/.bash_profile".

Monday, September 30, 2019

CentOS/RHEL: Setting up CURL for working through a proxy

Go to current user profile "cd ~" and create or edit file ".curlrc". Add the following line:

proxy=http://IP_ADDRESS:PORT_NUMBER

where IP_ADDRESS - proxy ip address and PORT_NUMBER - port number.

Friday, September 27, 2019

CentOS/RHEL: Configuring NTP time synchronization using the CHRONY utility

Run to install chrony:

dnf install chrony
systemctl enable chronyd
systemctl start chronyd

Configure as NTP server:

1. Edit file "/etc/chrony.conf". Uncomment and configure the parameter "allow 192.168.1.0/24", which gives permission to synchronize time with the NTP server to your subnets.
2. Configure firewall:

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

3. Restart chrony:

systemctl restart chronyd

4. Run to check if clients are connecting to the NTP service:

chronyc clients

Configure as NTP client:

1. Edit file "/etc/chrony.conf". Add the parameter "server 192.168.1.2", where ip address is the NTP server.
2. Restart chrony:

systemctl restart chronyd

3. Run to check if your host is connecting to an NTP server:

chronyc sources

Thursday, September 26, 2019

CentOS/RHEL: Removing old unused Linux kernels

After OS updates, old Linux kernels begin to accumulate in the boot partition, taking up extra space. To remove them from the system, follow these steps:

1. Determine the current kernel under which the system is loaded:
uname -a 

Output:
Linux clear-centos8.rc.nbrb.by 4.18.0-80.7.1.el8_0.x86_64 #1 SMP Sat Aug 3 15:14:00 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

2. Checking available kernels:
rpm -q kernel

Output:
kernel-4.18.0-80.7.1.el8_0.x86_64
kernel-4.18.0-80.el8_0.x86_64

3. Run to clean up "kernel-4.18.0-80.el8_0.x86_64" kernel:
yum remove kernel-4.18.0-80.el8_0.x86_64

4. Remove kernel from grub:
ls /boot/vmlinuz*

Determine which file corresponds to the removed kernel.
vmlinuz-0-rescue-40f768414b694ee0a57971f91b470de0
vmlinuz-4.18.0-80.7.1.el8_0.x86_64
vmlinuz-4.18.0-80.el8.x86_64

In example it's "vmlinuz-4.18.0-80.el8.x86_64".

Run:
grubby --remove-kernel=/boot/vmlinuz-4.18.0-80.el8.x86_64

5. Clear the boot section from the old image and its configuration files:
rm /boot/*-4.18.0-80.el8.x86_64*

In our case, we use the filter according to the kernel version ("-4.18.0-80.el8_0.x86_64").

P.S. There is another less flexible, but faster way to automatically clean old kernels: "yum autoremove kernel".

CentOS/RHEL: Configuring and working with the YUM utility

Yum is a utility for working with RPM packages for CentOS and RedHat OS. 

All settings are carried out in the configuration file:

vim /etc/yum.conf

By default, there are the following settings:

[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True

gpgcheck - yum will authenticate packets;
installonly_limit - maximum number of versions that can be installed for a specific package;
clean_requirements_on_remove - when deleting a package, delete and all its dependencies;
best - when updating, always try to install the latest version of the package.

To configure yum to work through a proxy, add the following parameters:

proxy=http://proxyhost:8080
proxy_username=proxyname
proxy_password=proxypass
proxy_auth_method=basic

where proxy - proxy server address and port;
proxy_username - username for authentication;
proxy_password - user password;
proxy_auth_method - authentication method ("any" by default).

Basic operations with yum:

"yum list" - display all installed packages and available in repositories packages;
"yum list installed" - display all installed packages only;
"yum list available" - display available in repositories packages only;
"yum check-update" - checking for updates for packages;
"yum update package_name" - updating the version of the specified package;
"yum update" - updating all installed packages;
"yum install package_name" - installation of the specified package;
"yum remove package_name" - delete specified package.