如何在CentOS 8上安装OCS库存服务器

时间:2020-02-23 14:30:48  来源:igfitidea点击:

OCS(下一代开放式计算机和软件列表)是一种免费和开源的资产管理解决方案,旨在提高软件和硬件的功能。 OCS Inventory NG可以以更简单,更有条理的方式管理组织内的所有资产。它使用客户端-服务器体系结构,其中OCS Inventory NG要求其代理了解每台计算机或者服务器的软件和硬件组成。它还具有无需代理即可进行资产发现的功能。

本教程将向我们展示如何在CentOS 8 Linux系统上安装和进行OCS Inventory NG服务器的初始配置。对于无代理发现,使用IP发现发现,然后使用SNMP来完成从IP Discover扫描中检索到的数据。这对于网络设备(例如打印机,扫描仪,交换机,路由器等)很有用。以下是OCS列表的体系结构。

在CentOS 8上安装OCS库存NG服务器

OCS列表服务器由四个主要组件组成:

  • 数据库服务器:存储库存信息。
  • 通信服务器:处理数据库服务器和代理之间的HTTP通信。
  • 管理控制台:允许管理员使用他们喜欢的浏览器查询数据库服务器。
  • 部署服务器:存储所有程序包部署配置(需要HTTPS!)。

设置取决于以下软件:

  • 数据库服务器:当前只能是启用了InnoDB引擎的MySQL 5.5或者MariaDB
  • 通信服务器:需要Apache Web Server 2.2.X/2.4.X,并以PERL作为Apache模块编写。
  • 部署服务器:需要任何启用了SSL的Web服务器。
  • 管理控制台:用PHP 5.6(或者更高版本)编写,并在Apache Web Server 2.2.X /2.4.X下运行。它要求在PHP中启用ZIP和GD支持才能使用程序包部署。

更新CentOS服务器

与往常一样,我们仅在更新的操作系统上工作。

sudo dnf -y update

如果更新需要重新启动,请在此时执行。

sudo reboot

安装MariaDB服务器

从AppStream存储库安装MariaDB数据库服务器:

sudo dnf install -y @mariadb

启动mariadb服务已启动,并将其设置为在系统引导时启动。

sudo systemctl enable --now mariadb

强化也是关键:

$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!

创建OCS库存数据库

以root用户身份登录到MariaDB数据库,并为OCS创建数据库:

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

安装PHP和Apache Web服务器

OCS列表PHP和Apache的要求是:

  • Apache 2.2或者更高版本
  • Mod_perl 1.29版或者更高版本。
  • PHP 5.5或者更高版本,带有ZIP和GD。其他扩展名是php_curl,php_mbstring,php_soap和php_xml

首先添加EPEL和REMI存储库:

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

启用PowerTools存储库:

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

安装OCS库存所需的PHP和扩展:

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}

验证PHP是否已正确安装:

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

安装httpd和Perl模块:

sudo dnf -y install @httpd mod_perl

启动httpd和php-fpm服务:

sudo systemctl enable --now php-fpm httpd

服务状态应该正在运行:

$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 2017-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.theitroad.local systemd[1]: Starting The PHP FastCGI Process Manager...
Jun 27 10:08:00 centos.theitroad.local 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 2017-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.theitroad.local systemd[1]: Starting The Apache HTTP Server...
Jun 27 10:08:01 centos.theitroad.local systemd[1]: Started The Apache HTTP Server.
Jun 27 10:08:01 centos.theitroad.local httpd[18016]: Server configured, listening on: port 443, port 80

在防火墙中允许http和https端口。

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

安装OCS库存服务器

现在,我们可以在CentOS 8上安装OCS Inventory Server。为此,需要OCS存储库,并在下面的命令中添加它。

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

该仓库提供以下软件包:

  • ocsinventory:用于ocsinventory-server和ocsinventory-reports的元软件包
  • ocsinventory-server:包含服务器
  • ocsinventory-reports:包含ocsreports,即管理GUI
  • ocsinventory-agent:ocsinventory-agent-core和完整依赖项的元软件包
  • ocsinventory-agent-core:包含具有最小偏差的代理

安装软件包:

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

导入数据库架构:

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

配置OCS库存管理服务器

在PHP初始化文件中进行一些更改。

$sudo vi /etc/php.ini

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

重新启动httpd服务:

sudo systemctl restart httpd php-fpm

打开我们喜欢的Web浏览器,然后将其指向URL http://ServerIP/ocsreports/install.php以连接管理服务器。

填写信息以使用能够创建数据库,表,索引等(通常是root)的用户连接到MySQL数据库服务器:

  • MySQL用户名
  • MySQL用户密码
  • MySQL主机名

完成其他步骤以在CentOS 8 Linux机器上完成OCS列表的安装。