在CentOS 8上安裝OCS-NG清單

在本指南中,我們將學習如何在CentOS 8上安裝OCS-NG庫存。 下一代OCS(開放計算機和軟件)庫存 是用於盤點IT資產的開源工具。它收集有關運行OCS客戶端程序(“ OCS庫存代理”)的聯網計算機的硬件和軟件的信息。 OCS可用於通過Web界面可視化庫存。它部署在代理服務器架構中,在該服務器中,將OCS NG代理安裝在要清點的資產上以收集有關該資產的信息。如果無法像在路由器,交換機中那樣安裝代理,則可以使用SNMP輪詢來收集資產信息。

在CentOS 8上安裝OCS-NG清單

先決條件

OCS-NG清單是一個Web應用程序,因此需要LAMP / LEMP堆棧。如上所述,它還需要許多perl庫和PHP擴展。 先決條件頁面

更新系統軟件包

dnf update

在本演示中,我們將LAMP用於OCS-NG,因此,LAMP堆棧組件的安裝如下:

在CentOS 8上安裝Apache Web服務器

dnf install httpd -y

如果FirewallD正在運行,請允許Apache外部訪問。

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

啟動並啟用Apache服務。

systemctl enable --now httpd

在CentOS 8上安裝MariaDB數據庫服務器

dnf install mariadb mariadb-server -y

啟動並啟用MariaDB服務。

systemctl enable --now mariadb

創建OCS-NG庫存數據庫和數據庫用戶

首先運行MySQL初始安全腳本。

mysql_secure_installation

接下來,登錄並創建OCS-NG數據庫。相應地替換數據庫的名稱。

mysql -u root -p
create database ocsdb;

之後,創建OCS-NG數據庫用戶並分配OCS-NG數據庫的所有權限。相應地替換用戶名和密碼。

grant all on ocsdb.* to [email protected] identified by 'ocsDBpassW0rd';

重新加載特權表並退出數據庫。

flush privileges;
quit

安裝PHP和OCS-NG清單所需的擴展

為了避免我們在其他版本的PHP(如OCS-NG黑屏)中遇到的問題,OCS-NG停留在 處理中… 使用PHP 7.3 本指南將繼續使用PHP 7.2,它是CentOS 8上的默認可用版本。如果您知道如何解決此問題,請將線索移至注釋部分。

為了安裝所有必需的PHP模塊,請安裝PHP Remi repos。

dnf install epel-release
dnf install remi-release

啟用PHP 7.2 Remi存儲庫;

dnf module reset -y php
dnf module enable php:remi-7.2

接下來,安裝PHP和所需的PHP模塊。

dnf install php php-domxml php-gd php-imap php-ldap php-mbstring php-mysqlnd php-opcache php-pdo php-pear php-pecl-apcu php-pecl-zip php-soap php-xmlrpc php-gd php-xml php-zip php-fpm php-bcmath php-intl

啟動並啟用PHP-FPM;

systemctl enable --now php-fpm

安裝Perl和構建工具

運行以下命令以安裝Perl,perl模塊和所需的構建工具。

dnf install -y make gcc perl-Archive-Zip perl-Compress-Zlib perl-DBD-MySQL perl-DBI perl-Mojolicious perl-Net-IP perl-Plack perl-SOAP-Lite perl-Switch perl-XML-Entities perl-XML-Simple perl-Apache-DBI perl-Digest-SHA1 perl-Apache2-SOAP

下載OCS-NG清單服務器存檔

導航 OCS下載頁面 並下載OCS Server。您只需運行以下命令即可獲取OCS 2.7。確保相應地替換版本。

wget https://github.com/OCSInventory-NG/OCSInventory-ocsreports/releases/download/2.7/OCSNG_UNIX_SERVER_2.7.tar.gz

完成下載後,解壓縮存檔。

tar xzf OCSNG_UNIX_SERVER_2.7.tar.gz

安裝OCS-NG清單

導航到OCS源目錄。

cd OCSNG_UNIX_SERVER_2.7/

執行安裝腳本。

sh setup.sh

按照提示安裝相應的OCS-NG庫存。按 輸入 接受默認值。

+----------------------------------------------------------+
|                                                          |
|  Welcome to OCS Inventory NG Management server setup !   |
|                                                          |
+----------------------------------------------------------+

Trying to determine which OS or Linux distribution you use
+----------------------------------------------------------+
| Checking for Apache web server binaries !				|
+----------------------------------------------------------+

CAUTION: If upgrading Communication server from OCS Inventory NG 1.0 RC2 and
previous, please remove any Apache configuration for Communication Server!

Do you wish to continue ([y]/n)?y
Assuming Communication server 1.0 RC2 or previous is not installed
on this computer.

Starting OCS Inventory NG Management server setup from folder /root/OCSNG_UNIX_SERVER_2.7
Storing log in file /root/OCSNG_UNIX_SERVER_2.7/ocs_server_setup.log

+----------------------------------------------------------+
| Checking for database server properties...			  |
+----------------------------------------------------------+

Your MySQL client seems to be part of MySQL version 10.3.
Your computer seems to be running MySQL 4.1 or higher, good ;-)

Which host is running database server [localhost] ?
OK, database server is running on host localhost ;-)

On which port is running database server [3306] ?
OK, database server is running on port 3306 ;-)


+----------------------------------------------------------+
| Checking for Apache web server daemon...				|
+----------------------------------------------------------+

Where is Apache daemon binary [/usr/sbin/httpd] ?
OK, using Apache daemon /usr/sbin/httpd ;-)


+----------------------------------------------------------+
| Checking for Apache main configuration file...		  |
+----------------------------------------------------------+

Where is Apache main configuration file [/etc/httpd/conf/httpd.conf] ?
OK, using Apache main configuration file /etc/httpd/conf/httpd.conf ;-)


+----------------------------------------------------------+
| Checking for Apache user account...					 |
+----------------------------------------------------------+

Which user account is running Apache web server [apache] ?
OK, Apache is running under user account apache ;-)


+----------------------------------------------------------+
| Checking for Apache group...							|
+----------------------------------------------------------+

Which user group is running Apache web server [apache] ?
OK, Apache is running under users group apache ;-)


+----------------------------------------------------------+
| Checking for Apache Include configuration directory...   |
+----------------------------------------------------------+

Setup found Apache Include configuration directory in
/etc/httpd/conf.d.
Setup will put OCS Inventory NG Apache configuration in this directory.
Where is Apache Include configuration directory [/etc/httpd/conf.d] ?
OK, Apache Include configuration directory /etc/httpd/conf.d found ;-)


+----------------------------------------------------------+
| Checking for PERL Interpreter...						|
+----------------------------------------------------------+

Found PERL interpreter at  ;-)
Where is PERL interpreter binary [/usr/bin/perl] ?
OK, using PERL interpreter /usr/bin/perl ;-)


Do you wish to setup Communication server on this computer ([y]/n)?y


+----------------------------------------------------------+
|             Checking for Make utility...                 |
+----------------------------------------------------------+

OK, Make utility found at  ;-)

+----------------------------------------------------------+
|        Checking for Apache mod_perl version...           |
+----------------------------------------------------------+

Checking for Apache mod_perl version 1.99_22 or higher
Found that mod_perl version 1.99_22 or higher is available.
OK, Apache is using mod_perl version 1.99_22 or higher ;-)

+----------------------------------------------------------+
|    Checking for Communication server log directory...    |
+----------------------------------------------------------+

Communication server can create detailed logs. This logs can be enabled
by setting integer value of LOGLEVEL to 1 in Administration console
menu Configuration.
Where to put Communication server log directory [/var/log/ocsinventory-server] ?
OK, Communication server will put logs into directory /var/log/ocsinventory-server ;-)

+----------------------------------------------------------------------------+
|    Checking for Communication server plugins configuration directory...    |
+----------------------------------------------------------------------------+

Communication server need a directory for plugins configuration files. 
Where to put Communication server plugins configuration files [/etc/ocsinventory-server/plugins] ?
OK, Communication server will put plugins configuration files into directory /etc/ocsinventory-server/plugins ;-)

+-------------------------------------------------------------------+
|   Checking for Communication server plugins perl directory...     |
+-------------------------------------------------------------------+

Communication server need a directory for plugins Perl modules files.
Where to put Communication server plugins Perl modules files [/etc/ocsinventory-server/perl] ?
OK, Communication server will put plugins Perl modules files into directory /etc/ocsinventory-server/perl ;-)


+----------------------------------------------------------+
| Checking for required Perl Modules...					|
+----------------------------------------------------------+

Checking for DBI PERL module...
Found that PERL module DBI is available.
Checking for Apache::DBI PERL module...
Found that PERL module Apache::DBI is available.
Checking for DBD::mysql PERL module...
Found that PERL module DBD::mysql is available.
Checking for Compress::Zlib PERL module...
Found that PERL module Compress::Zlib is available.
Checking for XML::Simple PERL module...
Found that PERL module XML::Simple is available.
Checking for Net::IP PERL module...
Found that PERL module Net::IP is available.
Checking for SOAP::Lite Perl module...
Found that PERL module SOAP::Lite is available.
Checking for Archive::Zip Perl module...
Found that PERL module Archive::Zip is available.

+----------------------------------------------------------+
|         Checking for optional Perl Modules...            |
+----------------------------------------------------------+

Checking for Apache2::SOAP PERL module...
Found that PERL module SOAP::Apache2 is available.
Checking for XML::Entities PERL module...
Found that PERL module XML::Entities is available.


Do you wish to setup Rest API server on this computer ([y]/n)?y

+----------------------------------------------------------+
| Checking for REST API Dependencies ...              		 |
+----------------------------------------------------------+

Found that PERL module Mojolicious::Lite is available.
Found that PERL module Switch is available.
Found that PERL module Plack::Handler is available.

+----------------------------------------------------------+
| Configuring REST API Server files ...               		 |
+----------------------------------------------------------+

Where do you want the API code to be store [/usr/lib64/perl5/vendor_perl] ?
Copying files to /usr/lib64/perl5/vendor_perl

+----------------------------------------------------------+
| Configuring REST API Server configuration files ...  		 |
+----------------------------------------------------------+


+----------------------------------------------------------+
|                 OK, looks good ;-)                       |
|                                                          |
|     Configuring Communication server Perl modules...     |
+----------------------------------------------------------+

Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Apache::Ocsinventory
Writing MYMETA.yml and MYMETA.json

+----------------------------------------------------------+
|                 OK, looks good ;-)                       |
|                                                          |
|      Preparing Communication server Perl modules...      |
+----------------------------------------------------------+


+----------------------------------------------------------+
|                 OK, prepare finshed ;-)                  |
|                                                          |
|     Installing Communication server Perl modules...      |
+----------------------------------------------------------+


+----------------------------------------------------------+
| OK, Communication server Perl modules install finished;-)|
|                                                          |
|     Creating Communication server log directory...       |
+----------------------------------------------------------+

Creating Communication server log directory /var/log/ocsinventory-server.

Fixing Communication server log directory files permissions.
Configuring logrotate for Communication server.
Removing old communication server logrotate file /etc/logrotate.d/ocsinventory-NG
Writing communication server logrotate to file /etc/logrotate.d/ocsinventory-server


+----------------------------------------------------------------------+
|        OK, Communication server log directory created ;-)            |
|                                                                      |
|   Creating Communication server plugins configuration directory...   |
+----------------------------------------------------------------------+

Creating Communication server plugins configuration directory /etc/ocsinventory-server/plugins.


+----------------------------------------------------------------------+
| OK, Communication server plugins configuration directory created ;-) |
|                                                                      |
|        Creating Communication server plugins Perl directory...       |
+----------------------------------------------------------------------+

Creating Communication server plugins Perl directory /etc/ocsinventory-server/perl.


+----------------------------------------------------------------------+
|     OK, Communication server plugins Perl directory created ;-)      |
|                                                                      |
|               Now configuring Apache web server...                   |
+----------------------------------------------------------------------+

To ensure Apache loads mod_perl before OCS Inventory NG Communication Server,
Setup can name Communication Server Apache configuration file
'z-ocsinventory-server.conf' instead of 'ocsinventory-server.conf'.
Do you allow Setup renaming Communication Server Apache configuration file
to 'z-ocsinventory-server.conf' ([y]/n) ?y
OK, using 'z-ocsinventory-server.conf' as Communication Server Apache configuration file
Removing old communication server configuration to file /etc/httpd/conf.d/ocsinventory.conf
Writing communication server configuration to file /etc/httpd/conf.d/z-ocsinventory-server.conf

+----------------------------------------------------------------------+
|       OK, Communication server setup successfully finished ;-)       |
|                                                                      |
| Please, review /etc/httpd/conf.d/z-ocsinventory-server.conf |
|         to ensure all is good. Then restart Apache daemon.           |
+----------------------------------------------------------------------+


Do you wish to setup Administration Server (Web Administration Console)
on this computer ([y]/n)?y

+----------------------------------------------------------+
|    Checking for Administration Server directories...     |
+----------------------------------------------------------+

CAUTION: Setup now install files in accordance with Filesystem Hierarchy
Standard. So, no file is installed under Apache root document directory
(Refer to Apache configuration files to locate it).
If you're upgrading from OCS Inventory NG Server 1.01 and previous, YOU
MUST REMOVE (or move) directories 'ocsreports' and 'download' from Apache
root document directory.
If you choose to move directory, YOU MUST MOVE 'download' directory to
Administration Server writable/cache directory (by default
/var/lib/ocsinventory-reports), especially if you use deployment feature.

Do you wish to continue ([y]/n)?y
Assuming directories 'ocsreports' and 'download' removed from
Apache root document directory.

Where to copy Administration Server static files for PHP Web Console
[/usr/share/ocsinventory-reports] ?
OK, using directory /usr/share/ocsinventory-reports to install static files ;-)

Where to create writable/cache directories for deployment packages,
administration console logs, IPDiscover and SNMP [/var/lib/ocsinventory-reports] ?
OK, writable/cache directory is /var/lib/ocsinventory-reports ;-)


+----------------------------------------------------------+
|         Checking for required Perl Modules...            |
+----------------------------------------------------------+

Checking for DBI PERL module...
Found that PERL module DBI is available.
Checking for DBD::mysql PERL module...
Found that PERL module DBD::mysql is available.
Checking for XML::Simple PERL module...
Found that PERL module XML::Simple is available.
Checking for Net::IP PERL module...
Found that PERL module Net::IP is available.

+----------------------------------------------------------+
|      Installing files for Administration server...       |
+----------------------------------------------------------+

Creating PHP directory /usr/share/ocsinventory-reports/ocsreports.
Copying PHP files to /usr/share/ocsinventory-reports/ocsreports.
Fixing permissions on directory /usr/share/ocsinventory-reports/ocsreports.
Creating database configuration file /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php.
Creating IPDiscover directory /var/lib/ocsinventory-reports/ipd.
Fixing permissions on directory /var/lib/ocsinventory-reports/ipd.
Creating packages directory /var/lib/ocsinventory-reports/download.
Fixing permissions on directory /var/lib/ocsinventory-reports/download.
Creating snmp mibs directory /var/lib/ocsinventory-reports/snmp.
Fixing permissions on directory /var/lib/ocsinventory-reports/snmp.
Creating Administration server log files directory /var/lib/ocsinventory-reports/logs.
Fixing permissions on directory /var/lib/ocsinventory-reports/logs.
Creating Administration server scripts log files directory /var/lib/ocsinventory-reports/scripts.
Fixing permissions on directory /var/lib/ocsinventory-reports/scripts.
Configuring IPDISCOVER-UTIL Perl script.
Installing IPDISCOVER-UTIL Perl script.
Fixing permissions on IPDISCOVER-UTIL Perl script.
Writing Administration server configuration to file /etc/httpd/conf.d/ocsinventory-reports.conf

+----------------------------------------------------------------------+
|        OK, Administration server installation finished ;-)           |
|                                                                      |
| Please, review /etc/httpd/conf.d/ocsinventory-reports.conf
|          to ensure all is good and restart Apache daemon.            |
|                                                                      |
| Then, point your browser to http://server//ocsreports
|        to configure database server and create/update schema.        |
+----------------------------------------------------------------------+


Setup has created a log file /root/OCSNG_UNIX_SERVER_2.7/ocs_server_setup.log. Please, save this file.
If you encounter error while running OCS Inventory NG Management server,
we can ask you to show us its content !

DON'T FORGET TO RESTART APACHE DAEMON !

Enjoy OCS Inventory NG ;-)

對於任何安裝問題,您可以檢查日誌文件, $HOME/OCSNG_UNIX_SERVER_2.7/ocs_server_setup.log

配置OCS-NG數據庫連接設置

編輯OCS-NG Web服務器配置以配置數據庫連接設置。

vim /etc/httpd/conf.d/z-ocsinventory-server.conf
...
  # Master Database settings
  # Replace localhost by hostname or ip of MySQL server for WRITE
  PerlSetEnv OCS_DB_HOST localhost
  # Replace 3306 by port where running MySQL server, generally 3306
  PerlSetEnv OCS_DB_PORT 3306
  # Name of database
  PerlSetEnv OCS_DB_NAME ocsdb
  PerlSetEnv OCS_DB_LOCAL ocsdb
  # User allowed to connect to database
  PerlSetEnv OCS_DB_USER ocsadmin
  # Password for user
  PerlSetVar OCS_DB_PWD ocsDBpassW0rd
...
vim /etc/httpd/conf.d/zz-ocsinventory-restapi.conf
...

  $ENV{PLACK_ENV} = 'production';
  $ENV{MOJO_HOME} = '/usr/lib64/perl5/vendor_perl';
  $ENV{MOJO_MODE} = 'deployment';
  $ENV{OCS_DB_HOST} = 'localhost';
  $ENV{OCS_DB_PORT} = '3306';
  $ENV{OCS_DB_LOCAL} = 'ocsdb';
  $ENV{OCS_DB_USER} = 'ocsadmin';
  $ENV{OCS_DB_PWD} = 'ocsDBpassW0rd';
  $ENV{OCS_DB_SSL_ENABLED} = 0;
#  $ENV{OCS_DB_SSL_CLIENT_KEY} = '';
#  $ENV{OCS_DB_SSL_CLIENT_CERT} = '';
#  $ENV{OCS_DB_SSL_CA_CERT} = '';
  $ENV{OCS_DB_SSL_MODE} = 'SSL_MODE_PREFERRED';

...
vim /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php
$_SESSION["SERVEUR_SQL"]="localhost";
$_SESSION["COMPTE_BASE"]="ocsdb";
$_SESSION["PSWD_BASE"]="ocsDBpassW0rd";
?>

進行更改後,保存並退出配置文件。

設置OCS配置文件的適當權限和所有權。

chmod -R 766 /usr/share/ocsinventory-reports
chown -R apache:apache /usr/share/ocsinventory-reports
chown -R apache:apache /var/lib/ocsinventory-reports

還可以調整Web服務器配置文件上的SELinux權限。

chcon -R -t httpd_sys_rw_content_t /usr/share/ocsinventory-reports

刪除安裝腳本。

mv /usr/share/ocsinventory-reports/ocsreports/install.php /usr/share/ocsinventory-reports/ocsreports/install.php.old

重新啟動Apache,MariaDB和PHP-FPM服務。

systemctl restart httpd mariadb php-fpm

通過Web界面完成OCS-NG配置

導航 http:// server-hostname-or-IP / ocsreports 在瀏覽器上訪問OCS。

配置OCS庫存數據庫連接,然後單擊 發送

接下來,點擊 點擊此處進入OCS-NG GUI 登錄到OCS Web界面。使用默認憑據:login =admin 和密碼=admin

在CentOS 8上安裝OCS-NG清單

如果提示您運行數據庫更新,請繼續並進入OCS登錄界面。

在CentOS 8上安裝OCS-NG清單

OCS-NG用戶界面。

在CentOS 8上安裝OCS-NG清單

重設密碼: 設置齒輪>我的帳戶>密碼。

這標誌着我們有關如何在CentOS 8上安裝OCS-NG清單的指南的結尾。

然後,您可以學習如何安裝OCS-NG庫存代理,以收集有關聯網機器的硬件和軟件的信息。

在Debian 10 / Ubuntu 18.04上安裝OCS庫存代理

參考:

OCS-NG清單文件

Sidebar