OTOBO安装

本章讲述了OTOBO构架核心部分的安装和基本设置。

按照本章的详细步骤在你的服务器上安装OTOBO,而后你就可以从网络接口登陆并管理系统了。

Note

As of OTOBO version 10.0.7, we recommend Docker and Docker Compose for the OTOBO installation. By using the provided Docker images, all recommended dependencies (such as Elasticsearch, Redis Cache, etc.) are installed and configured automatically. Updates are thus greatly simplified and the performance has been improved. You can find the instructions for Docker-based installation at https://doc.otobo.org/manual/installation/10.1/en/content/installation-docker.html .

准备工作:SELinux完成安装和激活后,关闭它

Note

如果你的系统是SELinux,需要禁用它,否则OTOBO不能正确运行。

如果你不能确认SELinux是否已经在你的系统上安装激活,可以试一下命令``sestatus`` 和 getenforce

命令``sestatus`` 可以返回SELinux的状态和应用的策略。SELinux的状态如果返回“被激活”,就说明SELinux已经激活;当前模式如果返回“强制模式”就说明SELinux是运行在强制模式下;配置文件策略如果返回“目标”,就说明SELinux的目标策略已经激活。

这里是如何在RHEL/CentOS/Fedora中禁用SELinux。

  1. 在``/etc/selinux/config``文件中设置 SELINUX=disabled

    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #       enforcing - SELinux security policy is enforced.
    #       permissive - SELinux prints warnings instead of enforcing.
    #       disabled - No SELinux policy is loaded.
    SELINUX=disabled
    # SELINUXTYPE= can take one of these two values:
    #       targeted - Targeted processes are protected,
    #       mls - Multi Level Security protection.
    SELINUXTYPE=targeted
    
  2. 重启你的系统,重启后,确认一下``getenforce`` 命令返回的是不是“禁用”:

    root> getenforce
    Disabled
    

步骤1:打开OTOBO封装和安装

从https://ftp.otobo.org/pub/otobo/下载最新的OTOBO版本软件,打开封装文档(例如使用``tar``命令),并存到目录``/root/otobo-update``:

root> mkdir /opt/otobo-install && mkdir /opt/otobo                      # Create a temporary install directory
root> cd /opt/otobo-install                                             # Change into the update directory
root> wget https://ftp.otobo.org/pub/otobo/otobo-latest-10.1.tar.gz     # Download he latest OTOBO 10 release
root> tar -xzf otobo-latest-10.1.tar.gz                                 # Unzip OTOBO
root> cp -r otobo-10.x.x/* /opt/otobo                                     # Copy the new otobo directory to /opt/otobo

步骤2:安装其他程序和Perl模块

用下面的脚本可以对所有已经安装的,以及必须要的CPAN模块和其他外部环境,有一个通盘的了解。

Note

On Debian systems you may need to manually install some perl packages:

apt-get install -y libarchive-zip-perl libtimedate-perl libdatetime-perl libconvert-binhex-perl libcgi-psgi-perl libdbi-perl libdbix-connector-perl libfile-chmod-perl liblist-allutils-perl libmoo-perl libnamespace-autoclean-perl libnet-dns-perl libnet-smtp-ssl-perl libpath-class-perl libsub-exporter-perl libtemplate-perl libtext-trim-perl libtry-tiny-perl libxml-libxml-perl libyaml-libyaml-perl libdbd-mysql-perl libapache2-mod-perl2 libmail-imapclient-perl libauthen-sasl-perl libauthen-ntlm-perl libjson-xs-perl libtext-csv-xs-perl libpath-class-perl libplack-perl libplack-middleware-header-perl libplack-middleware-reverseproxy-perl libencode-hanextra-perl libio-socket-ssl-perl libnet-ldap-perl libcrypt-eksblowfish-perl libxml-libxslt-perl libxml-parser-perl libconst-fast-perl
root> perl /opt/otobo/bin/otobo.CheckModules.pl -list
Checking for Perl Modules:
  o Archive::Tar.....................ok (v1.90)
  o Archive::Zip.....................ok (v1.37)
  o Crypt::Eksblowfish::Bcrypt.......ok (v0.009)
...

Note

请注意OTOBO需要一个安装了所有*核心*模块的可以运行的Perl,例如``version``模块。脚本不会对这些模块进行核查,所以针对一些像RHEL的系统,他们不会去默认安装Perl核心模块,你可能需要自己去安装这些 ``perl-core``软件包。

你可以用CPAN或者Linux的软件包管理系统,安装必须的以及可选的软件模块。

执行这个命令就可以取得一个安装命令,去安装那些缺失的外部环境软件:

root> /opt/otobo/bin/otobo.CheckModules.pl --inst

Note

有一些可选的或者可替换的模块,在大多数定制化的OTOBO版本中,也可以安装上。调用CheckModules.pl 毫无疑问可以列出所有功能。

步骤3:创建OTOBO用户

在用户自己的组中,创建一个专用的OTOBO用户:

root> useradd -r -U -d /opt/otobo -c 'OTOBO user' otobo -s /bin/bash

把这个用户加入网站服务器组(如果网站服务器不是作为OTOBO用户运行):

root> usermod -G www-data otobo
(SUSE=www, Red Hat/CentOS/Fedora=apache, Debian/Ubuntu=www-data)

步骤4:激活默认的配置文件

有一个OTOBO配置文件是捆绑在``$OTOBO_HOME/Kernel/Config.pm.dist``中的,你需要拷贝这个文件并去掉``.dist`` ,以便激活它。

root> cp /opt/otobo/Kernel/Config.pm.dist /opt/otobo/Kernel/Config.pm

步骤5:配置Apache网站服务器

首先,你需要安装Apache2网站服务器和mod_perl:通常你会通过系统的软件管理系统来进行。在下面你看会看到在当前流行的Linux版本上,安装Apache需要的一些命令。

# RHEL / CentOS:
root> yum install httpd mod_perl

# SuSE:
root> zypper install apache2-mod_perl

# Debian/Ubuntu:
root> apt-get install apache2 libapache2-mod-perl2

A critical setting of the Apache web server is the choice of the multi-processing module. For running OTOBO, the recommended choice is the module mpm_prefork. Like other Apache modules the multi-processing module can be managed with the tools a2dismod and a2enmod.

root> # check which MPM is active
root> apache2ctl -M | grep mpm_

All is fine whem mpm_prefork already is enabled.

Disable mpm_event when it is currently active.

root> a2dismod mpm_event

Disable mpm_worker in case that MPM is enabled.

root> a2dismod mpm_worker

Finally activate mpm_prefork.

root> a2enmod mpm_prefork

OTOBO requires a few more Apache modules to be active for optimal operation. Again, on most platforms you can make sure they are active via the tool a2enmod.

root> a2enmod perl
root> a2enmod deflate
root> a2enmod filter
root> a2enmod headers

Note

在一些平台上,不是所有的Apache模块都存在,这样在安装的时候就会显示错误信息。这种情况不用着急,继续完成安装,大部分情况下,没有成功安装的模块往往都不需要。

大部分的Apache安装都包括一个``conf.d``目录,在Linux系统中你可以在``/etc/apache`` 或者 ``/etc/apache2``下面找到这个目录。

在没有SSL支持的情况下配置Apache

Copy the template file /opt/otobo/scripts/apache2-httpd.include.conf to the apache sites-available directory. In most cases no further editing of the template is required. Then enable the new configuration.

# Debian/Ubuntu:
root> cp /opt/otobo/scripts/apache2-httpd.include.conf /etc/apache2/sites-available/zzz_otobo.conf
root> a2ensite zzz_otobo.conf
root> systemctl restart apache2

SSL 支持的情况下配置Apache

Copy the template files /opt/otobo/scripts/apache2-httpd-vhost-80.include.conf and /opt/otobo/scripts/apache2-httpd-vhost-443.include.conf to the apache sites-available directory.

# Debian/Ubuntu:
root> cp /opt/otobo/scripts/apache2-httpd-vhost-80.include.conf /etc/apache2/sites-available/zzz_otobo-80.conf
root> cp /opt/otobo/scripts/apache2-httpd-vhost-443.include.conf /etc/apache2/sites-available/zzz_otobo-443.conf

请编辑文件并加入一些必须的信息,例如SSL认证存储路径。之后,激活OTOBO Apache配置:

root> a2ensite zzz_otobo-80.conf
root> a2ensite zzz_otobo-443.conf

现在你可以重启你的网站服务器,载入新的配置设定了。在多数系统中,你可以用下面的命令来实现:

root> systemctl restart apache2

步骤6:设置文件许可

请执行下面的命令设置OTOBO的文件和目录许可。系统会尝试为你检测正确的用户和组。

root> /opt/otobo/bin/otobo.SetPermissions.pl

步骤7:建立数据库

首先,你需要安装数据库软件。建议使用你的Linux系统自带的MySQL或者MariaDB,也可以使用PostgreSQL或者Oracle。

你可以通过系统的软件管理进行安装,下面是在常用的Linux版本上安装MySQL数据库的一些命令。

# RHEL / CentOS:
root> yum install mysql-server

# SuSE:
root> zypper install mysql-community-server

# Debian/Ubuntu:
root> apt-get install mysql-server

安装了MySQL服务器后,需要进行配置。

在MySQL 5.7及更高版本中,激活了一个新的认证模块,这样就不能用OTOBO的网络安装软件建立数据库了。这种情况下, 请登陆进入MySQL控制台,设置不同的认证模块和用户``root`` 的密码:

root> mysql -u root
root> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NewRootPassword';

对MariaDBM 10.1以上版本,用下面的命令:

root> mysql -u root
root> update mysql.user set authentication_string=password('NewRootPassword') plugin='mysql_native_password' where user='root';

如果此命令不起作用,请尝试以下命令:

root> mysql -u root
root> UPDATE mysql.user SET password = PASSWORD('NewRootPassword') WHERE user = 'root';
root> UPDATE mysql.user SET authentication_string = '' WHERE user = 'root';
root> UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root';

在OTOBO完成安装后,在需要时也可以更改认证模块。

Note

下面的配置设定是MySQL安装的最低要求。请将下面的脚本加入``[mysqld]`` 下面的MySQL服务器配置文件``/etc/my.cnf``,/etc/mysql/my.cnf 或者 /etc/mysql/mysql.conf.d/mysqld.cnf

max_allowed_packet   = 64M
innodb_log_file_size = 256M

对MySQL 8.0之前的版本,查询缓存尺寸需要设定:

query_cache_size     = 32M

下面的配置设定是MySQL安装的最低要求。请将下面的脚本加入``[mysqld]`` 下面的MySQL服务器配置文件``/etc/my.cnf``,/etc/mysql/my.cnf 或者 /etc/mysql/mysql.conf.d/mysqld.cnf

max_allowed_packet   = 64M

出于生产率考虑,我们建议用``mysqltuner`` 工具实现优化。你可以从Github ``https://github.com/major/MySQLTuner-perl``下载脚本,或者通过软件管理在Debian或Ubuntu系统上安装:

root> apt-get install mysqltuner

安装后运行下面的脚本:

root> mysqltuner --user root --pass NewRootPassword

步骤8:安装Elasticsearch弹性搜索

OTOBO建议活性安装Elasticsearch以便快速搜索,最简单的办法就是将Elasticsearch和OTOBO安装在一台主机上,并绑定默认端口。

基于Ubuntu 18.04 LTS的Elasticsearch安装范例

JDK安装

root> apt update
root> apt install openjdk-8-jdk

Elasticsearch安装

root> wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
root> echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list
root> apt update
root> apt -y install elasticsearch

在其他Linux版本中的Elasticsearch安装

请遵照 https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html中的安装教程进行。

Elasticsearch模块安装

另外,OTOBO需要在Elasticsearch上安装插件:

root> /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch ingest-attachment
root> /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch analysis-icu

Elasticsearch配置

Elasticsearch的配置有很多选择和可能。

为了确保无故障运行,你需要调整大型OTOBO系统的jvm堆空间尺寸。这个配置在文件``/etc/elasticsearch/jvm.options``中进行调整。一定要吧JVM堆空间的最大和最小值设置为同一个,例如都设为4GB,设置:

-Xms4g
-Xmx4g

在我们的测试中,对于中型安装,这个值设为4-10GB是最好的。

Note

请遵照 https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html中的安装教程进行。

现在你可以重启你的Elasticsearch服务器,以便新的配置生效。对于大部分系统,可以用下面的命令实现:

root> systemctl restart elasticsearch

Step 9: Basic System Configuration

请用 http://localhost/otobo/installer.pl (请用你的主机名替换“localhost”)中的网络安装软件,设置你的数据库和基本系统配置,例如电子邮件账户。

Step 10: First Login

现在你可以通过http://localhost/otobo/index.pl登陆你的系统了,用户名``root@localhost`` ,密码是上面生成的(请参考之前描述)。

Step 11: Start the OTOBO Daemon

OTOBO守护程序的任务是处理OTOBO系统中的不同步的和重复性的工作。之前在cron文件定义中描述的现在由OTOBO守护程序处理,这是运行OTOBO的需要。守护程序还要处理由用户发起的GenericAgent任务。

otobo> /opt/otobo/bin/otobo.Daemon.pl start

Step 12: Cron jobs for the OTOBO user

在``/opt/otobo/var/cron/*.dist``中有两个默认的cron文件,目的是确保OTOBO Daemon守护程序已经运行起来了。激活这两个文件只需要不带“.dist"扩展名进行拷贝就好。

root> cd /opt/otobo/var/cron/
root> for foo in *.dist; do cp $foo `basename $foo .dist`; done

root> cd /opt/otobo/
root> bin/Cron.sh start

到这一步,基本的系统配置就完成了。

Step 13: Setup Bash Auto-Completion (optional)

所有正常的OTOBO命令行的执行都是通过OTOBO管理接口,管理接口可以实现Linux内核任务的自动完成,从而更方便地找到合适的命令和选项。

你可以通过安装软件包``bash-completion``来激活内核任务自动完成,它将为``otobo`` 用户自动检测并调用``/opt/otobo/.bash_completion``文件。

重启你的shell后,你可以键入这个命令再加上TAB,就会列出所有可用的命令:

otobo> /opt/otobo/bin/otobo.Console.pl

如果你只键入命令名字的几个字母,TAB将会列出所有匹配的命令。键入完整命令,按下TAB键将显示所有的可选项和相应信息。

Note

如果有问题,你可以作为用户``otobo`` 执行下面的命令行,并将它加入你的``~/.bashrc`` ,执行文件中的命令。

source /opt/otobo/.bash_completion

Step 14: Further Information

我们建议你阅读OTOBO文档中的:performance-tuning 章节。