10

How To Install OCS Inventory Server on CentOS 8

 2 years ago
source link: https://computingforgeeks.com/how-to-install-ocs-inventory-server-on-centos-8/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How To Install OCS Inventory Server on CentOS 8

OCS (Open Computers and Software Inventory Next Generation) is a free and open source assets management solution created for making software and hardware more powerful. OCS Inventory NG helps you manage all assets within an organization in a simpler and organized manner. It uses a client-server architecture where OCS Inventory NG asks its agents to know the software and hardware composition of every computer or server. It also has the capabilities of assets discovery without an agent.

This tutorial will show you how you can install and do initial configurations of OCS Inventory NG server on CentOS 8 Linux system. For agentless discovery, IP discovery discovery is used then SNMP is used to complete the data retrieved from the IP Discover scan. This is useful for network devices such printers, scanner, switches, routers e.t.c. Below is the architecture of OCS inventory.

ocs inventory architecture

Install OCS Inventory NG Server on CentOS 8

The OCS Inventory Server is made up of four main components:

  1. Database server: Stores inventory information.
  2. Communication server: Handles HTTP communications between database server and agents.
  3. Administration console: Allows administrators to query the database server using their favorite browser.
  4. Deployment server: Stores all package deployment configuration (requires HTTPS!).

The setup depends on the following pieces of software:

  • Database Server : Currently can only be MySQL 5.5 or MariaDB with InnoDB engine active
  • Communication server: Requires Apache Web Server 2.2.X / 2.4.X and is written in PERL as an Apache module.
  • Deployment server: Needs any Web Server with SSL enabled.
  • Administration console: Written in PHP 5.6 (or higher) and runs under Apache Web Server 2.2.X /2.4.X. It requires ZIP and GD support enabled in PHP in order to use package deployment.

Step 1: Update CentOS Server

As always we only work on an updated operating system.

sudo dnf -y update

If your updates requires a reboot perform at this point.

sudo reboot

Step 2: Install MariaDB Server

Install MariaDB database server from the AppStream repositories:

sudo dnf install -y @mariadb

Start mariadb service is started and set it to start at system boot.

sudo systemctl enable --now mariadb

Also hardening is key:

$ sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Create OCS Inventory database

Login to your MariaDB database as root user and create a database for OCS:

$ mysql -u root -p
CREATE DATABASE ocsweb;
GRANT ALL PRIVILEGES ON ocsweb.* TO ocs@localhost IDENTIFIED BY "StrongDBPassword";
FLUSH PRIVILEGES;
QUIT;

Step 3: Install PHP and Apache Web Server

OCS Inventory PHP and Apache requirements are:

  • Apache version 2.2 or higher
  • Mod_perl version 1.29 or higher.
  • PHP 5.5 or higher, with ZIP and GD. Other extensions are php_curl, php_mbstring, php_soap and php_xml

Let’s first add the EPEL and REMI repository:

sudo dnf  -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf  -y install  https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Enable PowerTools repository:

sudo dnf -y install dnf-utils
sudo dnf config-manager --set-enabled PowerTools

Install PHP and extensions required by OCS Inventory:

sudo yum-config-manager --enable remi
sudo dnf module reset php
sudo dnf -y module install php:remi-7.3
sudo dnf -y install php-{curl,zip,gd,soap,xml,mbstring}

Verify PHP is installed correctly:

$ php -v
PHP 7.3.19 (cli) (built: Jun  9 2020 08:06:30) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.19, Copyright (c) 1998-2018 Zend Technologies

Install httpd and Perl module:

sudo dnf -y install @httpd mod_perl

Start httpd and php-fpm services:

sudo systemctl enable --now php-fpm httpd

Service status should be running:

$ systemctl status php-fpm httpd
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2020-06-27 10:08:00 CEST; 17s ago
 Main PID: 18004 (php-fpm)
   Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec"
    Tasks: 6 (limit: 24392)
   Memory: 20.7M
   CGroup: /system.slice/php-fpm.service
           ├─18004 php-fpm: master process (/etc/php-fpm.conf)
           ├─18010 php-fpm: pool www
           ├─18011 php-fpm: pool www
           ├─18012 php-fpm: pool www
           ├─18013 php-fpm: pool www
           └─18014 php-fpm: pool www

Jun 27 10:08:00 centos.computingforgeeks.com systemd[1]: Starting The PHP FastCGI Process Manager...
Jun 27 10:08:00 centos.computingforgeeks.com systemd[1]: Started The PHP FastCGI Process Manager.

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/httpd.service.d
           └─php-fpm.conf
   Active: active (running) since Sat 2020-06-27 10:08:01 CEST; 17s ago
     Docs: man:httpd.service(8)
 Main PID: 18016 (/usr/sbin/httpd)
   Status: "Running, listening on: port 443, port 80"
    Tasks: 213 (limit: 24392)
   Memory: 37.7M
   CGroup: /system.slice/httpd.service
           ├─18016 /usr/sbin/httpd -DFOREGROUND
           ├─18017 /usr/sbin/httpd -DFOREGROUND
           ├─18018 /usr/sbin/httpd -DFOREGROUND
           ├─18019 /usr/sbin/httpd -DFOREGROUND
           └─18020 /usr/sbin/httpd -DFOREGROUND

Jun 27 10:08:01 centos.computingforgeeks.com systemd[1]: Starting The Apache HTTP Server...
Jun 27 10:08:01 centos.computingforgeeks.com systemd[1]: Started The Apache HTTP Server.
Jun 27 10:08:01 centos.computingforgeeks.com httpd[18016]: Server configured, listening on: port 443, port 80

Allow http and https ports in the firewall.

sudo firewall-cmd --zone=public --add-service=http --permanent
sudo firewall-cmd --zone=public --add-service=https --permanent
sudo firewall-cmd --reload

Step 4: Install OCS Inventory server

Now we can install OCS Inventory Server on CentOS 8. OCS repository is required for this purpose, add it with the commands below.

sudo dnf -y install https://rpm.ocsinventory-ng.org/ocsinventory-release-latest.el8.ocs.noarch.rpm

The repo provide the following packages:

  • ocsinventory: Meta package for ocsinventory-server and ocsinventory-reports
  • ocsinventory-server: Contain the server
  • ocsinventory-reports: Contain ocsreports, the Admin GUI
  • ocsinventory-agent: Meta package for ocsinventory-agent-core and full dependancies
  • ocsinventory-agent-core: Contain the agent with the minimal depandancies

Install the packages:

sudo dnf config-manager --set-enabled PowerTools
sudo yum install ocsinventory

Import database schema:

mysql -f -hlocalhost -uroot -p ocsweb < /usr/share/ocsinventory-reports/ocsreports/files/ocsbase.sql >log.log

Configuring OCS Inventory management server

Make some changes in PHP init file.

$ sudo vi /etc/php.ini

upload_max_filesize = 10M
post_max_size = 10M
max_execution_time = 300
max_input_time = 300
memory_limit = 256M

Restart httpd service:

sudo systemctl restart httpd php-fpm

open your favorite web browser and point it on URL http://ServerIP/ocsreports/install.php to connect the Administration server.

Fill in information to connect to MySQL database server with a user who has the ability to create database, tables, indexes, etc (usually root):

  • MySQL user name
  • MySQL user password
  • MySQL hostname

Go through the other steps to complete installation of OCS inventory on CentOS 8 Linux machine.

There you go. Enjoy using OCS Inventory on CentOS Linux.

Installation on other Linux systems.

How To Install OCS Inventory Server on Debian

How to Install OCS Inventory Server on Ubuntu


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK