如何部署工单系统OTRS?

开源项目

1 OTRS的简介

– OTRS即英文“Open-source Ticket Request System”的简写
– OTRS帮助IT部门,服务台等相关部门跟踪和处理用户方请求(俗称工单系统)
– OTRS是全球范围内最成功和使用寿命最长的开源项目
注:笔者安装过程中发现该项目过度商业化,已经消弱开源的支持(文档支持不够详尽,感觉为利益有所保留)

2 服务端的安装

2.1 环境信息

Server:
IP Address = 10.168.0.70
OS = CentOS 7.4 x86_64
hostname = otrs.cmdschool.org

2.2 基本配置

2.2.1 配置主机名称

hostnamectl set-hostname otrs.cmdschool.org

2.2.2 配置SELinux

setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

2.2.3 配置yum源

yum install -y http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

2.2.4 安装常用的工具

yum install -y vim wget

2.2.5 配置时区和NTP服务

时区配置

timedatectl set-timezone Asia/Shanghai

安装chrony时间同步工具

yum install -y chrony

启动ntp服务

systemctl start chronyd
systemctl enable chronyd

2.2.6 安装编译环境

yum install -y gcc gcc-c++ make expat-devel

2.2.7 防火墙配置

firewall-cmd --permanent --add-service http
firewall-cmd --reload
firewall-cmd --list-all

2.3 安装MariaDB数据库

2.3.1 安装MariaDB相关包

yum install -y mariadb-server mariadb mariadb-devel

2.3.2 修改配置文件

vim /etc/my.cnf

加入如下配置:

[mysqld]
max_allowed_packet   = 64M
query_cache_size     = 32M
innodb_log_file_size = 256M

2.3.3 启动并配置服务自启动

systemctl start mariadb
systemctl enable mariadb

2.3.4 初始化MariaDB服务

mysql_secure_installation

向导如下:

Set root password? [Y/n] y
New password: ******
Re-enter new password: ******
[…]
Remove anonymous users? [Y/n] y
[…]
Disallow root login remotely? [Y/n] y
[…]
Remove test database and access to it? [Y/n] y
[…]
Reload privilege tables now? [Y/n] y

2.4 安装OTRS

2.4.1 基础配置

2.4.1.1 下载安装模块

cd ~
wget http://ftp.otrs.org/pub/otrs/otrs-6.0.6.tar.gz

注:其他版本下载请参看以下链接,

http://ftp.otrs.org/pub/otrs/RPMS/rhel/7/

2.4.1.2 解压安装包

tar -xf otrs-6.0.6.tar.gz

2.4.1.3 部署安装包

mv otrs-6.0.6 /opt/otrs

2.4.1.4 安装依赖的软件包

yum install -y perl-core httpd mod_perl

2.4.1.5 检查依赖关系

perl /opt/otrs/bin/otrs.CheckModules.pl

留意以下提示信息:

  o Apache::DBI......................ok (v1.12)
  o Apache2::Reload..................ok (v0.13)
  o Archive::Tar.....................ok (v1.92)
  o Archive::Zip.....................Not installed! Use: 'yum install "perl(Archive::Zip)"' (required - Required for compressed file generation.)
  o Crypt::Eksblowfish::Bcrypt.......Not installed! Use: 'yum install "perl(Crypt::Eksblowfish::Bcrypt)"' (optional - For strong password hashing.)
  o Crypt::SSLeay....................Not installed! Use: 'yum install "perl(Crypt::SSLeay)"' (optional - Required for Generic Interface REST transport and SOAP SSL connections.)
  o Date::Format.....................Not installed! Use: 'yum install "perl(Date::Format)"' (required)
  o DateTime.........................Not installed! Use: 'yum install "perl(DateTime)"' (required)
  o DBI..............................ok (v1.627)
  o DBD::mysql.......................ok (v4.023)
  o DBD::ODBC........................Not installed! (optional - Required to connect to a MS-SQL database.)
  o DBD::Oracle......................Not installed! (optional - Required to connect to a Oracle database.)
  o DBD::Pg..........................Not installed! Use: 'yum install "perl(DBD::Pg)"' (optional - Required to connect to a PostgreSQL database.)
  o Digest::SHA......................ok (v5.85)
  o Encode::HanExtra.................Not installed! Use: 'yum install "perl(Encode::HanExtra)"' (optional - Required to handle mails with several Chinese character sets.)
  o IO::Socket::SSL..................Not installed! Use: 'yum install "perl(IO::Socket::SSL)"' (optional - Required for SSL connections to web and mail servers.)
  o JSON::XS.........................Not installed! Use: 'yum install "perl(JSON::XS)"' (optional - Recommended for faster AJAX/JavaScript handling.)
  o List::Util::XS...................ok (v1.27)
  o LWP::UserAgent...................FAILED! Not all prerequisites for this module correctly installed.
  o Mail::IMAPClient.................Not installed! Use: 'yum install "perl(Mail::IMAPClient)"' (optional - Required for IMAP TLS connections.)
    o IO::Socket::SSL................Not installed! Use: 'yum install "perl(IO::Socket::SSL)"' (optional - Required for IMAP TLS connections.)
    o Authen::SASL...................Not installed! Use: 'yum install "perl(Authen::SASL)"' (optional - Required for MD5 authentication mechanisms in IMAP connections.)
    o Authen::NTLM...................Not installed! Use: 'yum install "perl(Authen::NTLM)"' (optional - Required for NTLM authentication mechanism in IMAP connections.)
  o ModPerl::Util....................Not installed! Use: 'yum install "perl(ModPerl::Util)"' (optional - Improves Performance on Apache webservers dramatically.)
  o Net::DNS.........................Not installed! Use: 'yum install "perl(Net::DNS)"' (required)
  o Net::LDAP........................Not installed! Use: 'yum install "perl(Net::LDAP)"' (optional - Required for directory authentication.)
  o Template.........................Not installed! Use: 'yum install "perl(Template)"' (required - Template::Toolkit, the rendering engine of OTRS.)
  o Template::Stash::XS..............Not installed! Use: 'yum install "perl(Template::Stash::XS)"' (required - The fast data stash for Template::Toolkit.)
  o Text::CSV_XS.....................Not installed! Use: 'yum install "perl(Text::CSV_XS)"' (optional - Recommended for faster CSV handling.)
  o Time::HiRes......................ok (v1.9725)
  o XML::LibXML......................Not installed! Use: 'yum install "perl(XML::LibXML)"' (required - Required for XML processing.)
  o XML::LibXSLT.....................Not installed! Use: 'yum install "perl(XML::LibXSLT)"' (optional - Required for Generic Interface XSLT mapping module.)
  o XML::Parser......................Not installed! Use: 'yum install "perl(XML::Parser)"' (optional - Recommended for XML processing.)
  o YAML::XS.........................Not installed! Use: 'yum install "perl(YAML::XS)"' (required - Required for fast YAML processing.)

2.4.1.6 安装缺失的软件包

yum install -y "perl(Archive::Zip)" "perl(Crypt::Eksblowfish::Bcrypt)" "perl(Crypt::SSLeay)" "perl(Date::Format)" "perl(DateTime)" "perl(DBD::Pg)" "perl(Encode::HanExtra)" "perl(IO::Socket::SSL)" "perl(JSON::XS)" "perl(Mail::IMAPClient)" "perl(IO::Socket::SSL)" "perl(Authen::SASL)" "perl(Authen::NTLM)" "perl(ModPerl::Util)" "perl(Net::DNS)" "perl(Net::LDAP)" "perl(Template)" "perl(Template::Stash::XS)" "perl(Text::CSV_XS)" "perl(XML::LibXML)" "perl(XML::LibXSLT)" "perl(XML::Parser)" "perl(YAML::XS)"

复查直到显示如下:

  o Apache::DBI......................ok (v1.12)
  o Apache2::Reload..................ok (v0.13)
  o Archive::Tar.....................ok (v1.92)
  o Archive::Zip.....................ok (v1.30)
  o Crypt::Eksblowfish::Bcrypt.......ok (v0.009)
  o Crypt::SSLeay....................ok (v0.64)
  o Date::Format.....................ok (v2.24)
  o DateTime.........................ok (v1.04)
  o DBI..............................ok (v1.627)
  o DBD::mysql.......................ok (v4.023)
  o DBD::ODBC........................Not installed! (optional - Required to connect to a MS-SQL database.)
  o DBD::Oracle......................Not installed! (optional - Required to connect to a Oracle database.)
  o DBD::Pg..........................ok (v2.19.3)
  o Digest::SHA......................ok (v5.85)
  o Encode::HanExtra.................ok (v0.23)
  o IO::Socket::SSL..................ok (v1.94)
  o JSON::XS.........................ok (v3.01)
  o List::Util::XS...................ok (v1.27)
  o LWP::UserAgent...................ok (v6.26)
  o Mail::IMAPClient.................ok (v3.37)
    o IO::Socket::SSL................ok (v1.94)
    o Authen::SASL...................ok (v2.15)
    o Authen::NTLM...................ok (v1.09)
  o ModPerl::Util....................ok (v2.000010)
  o Net::DNS.........................ok (v0.72)
  o Net::LDAP........................ok (v0.56)
  o Template.........................ok (v2.24)
  o Template::Stash::XS..............ok (undef)
  o Text::CSV_XS.....................ok (v1.00)
  o Time::HiRes......................ok (v1.9725)
  o XML::LibXML......................ok (v2.0018)
  o XML::LibXSLT.....................ok (v1.80)
  o XML::Parser......................ok (v2.41)
  o YAML::XS.........................ok (v0.54)

2.4.1.7 准备程序所需的数据库

mysql -uroot -p

向导如下:

create database otrs character set utf8;
grant all privileges on otrs.* to 'otrs'@'localhost' identified by 'otrspwd';
grant all privileges on otrs.* to 'otrs'@'127.0.0.1' identified by 'otrspwd';
flush privileges;

导入数据库结构

mysql -uroot -p otrs < /opt/otrs/scripts/database/otrs-schema.mysql.sql
mysql -uroot -p otrs < /opt/otrs/scripts/database/otrs-initial_insert.mysql.sql
mysql -uroot -p otrs < /opt/otrs/scripts/database/otrs-schema-post.mysql.sql

2.4.2 配置OTRS

2.4.2.1 创建运行用户

useradd -d /opt/otrs -c 'OTRS user' otrs

2.4.2.2 添加运行用户到Apache组

usermod -G apache otrs

2.4.2.3 设置目录权限

/opt/otrs/bin/otrs.SetPermissions.pl

确认文件夹的权限

ls -ld /opt/otrs/

显示如下:

drwxr-xr-x. 9 otrs apache 4096 Mar  6 11:58 /opt/otrs/

2.4.2.4 部署配置文件

cp /opt/otrs/Kernel/Config.pm.dist /opt/otrs/Kernel/Config.pm

修改数据库连接信息:

vim /opt/otrs/Kernel/Config.pm

修改如下信息:

    $Self->{DatabaseHost} = '127.0.0.1';
    $Self->{Database} = 'otrs';
    $Self->{DatabaseUser} = 'otrs';
    $Self->{DatabasePw} = 'otrspwd';
    $Self->{DatabaseDSN} = "DBI:mysql:database=$Self->{Database};host=$Self->{DatabaseHost};";

2.4.2.5 检查模块状态

检查一:

perl -cw /opt/otrs/bin/cgi-bin/index.pl

可见如下状态信息:

/opt/otrs/bin/cgi-bin/index.pl syntax OK

检查二:

perl -cw /opt/otrs/bin/cgi-bin/customer.pl

可见如下状态信息:

/opt/otrs/bin/cgi-bin/customer.pl syntax OK

检查三:

perl -cw /opt/otrs/bin/otrs.Console.pl

可见如下状态信息:

/opt/otrs/bin/otrs.Console.pl syntax OK

2.4.2.6 部署配置文件到Apache

ln -s /opt/otrs/scripts/apache2-httpd.include.conf /etc/httpd/conf.d/otrs.conf

2.4.2.7 配置Apache模块

确认模块存在:

ls /etc/httpd/modules/mod_perl.so
ls /etc/httpd/modules/mod_version.so
ls /etc/httpd/modules/mod_deflate.so
ls /etc/httpd/modules/mod_filter.so
ls /etc/httpd/modules/mod_headers.so

确认perl模块加载:

grep mod_perl.so /etc/httpd/conf.modules.d/*.conf

可见如下显示:

/etc/httpd/conf.modules.d/02-perl.conf:LoadModule perl_module modules/mod_perl.so

确认version模块加载:

grep mod_version.so /etc/httpd/conf.modules.d/*.conf

可见如下显示:

/etc/httpd/conf.modules.d/00-base.conf:LoadModule version_module modules/mod_version.so

确认deflate模块加载:

grep mod_deflate.so /etc/httpd/conf.modules.d/*.conf

可见如下显示:

/etc/httpd/conf.modules.d/00-base.conf:LoadModule deflate_module modules/mod_deflate.so

确认filter模块加载:

grep mod_filter.so /etc/httpd/conf.modules.d/*.conf

可见如下显示:

/etc/httpd/conf.modules.d/00-base.conf:LoadModule filter_module modules/mod_filter.so

2.4.2.8 启动服务并配自启动

systemctl start httpd
systemctl enable httpd

2.4.3 测试与调整OTRS

2.4.3.1 手动控制守护进程

su -s /bin/bash otrs -c "/opt/otrs/bin/otrs.Daemon.pl start"
su -s /bin/bash otrs -c "/opt/otrs/bin/Cron.sh start"
su -s /bin/bash otrs -c "/opt/otrs/bin/otrs.Daemon.pl status"
su -s /bin/bash otrs -c "/opt/otrs/bin/otrs.Daemon.pl stop"
su -s /bin/bash otrs -c "/opt/otrs/bin/Cron.sh stop"

2.4.3.2 配置守护进程

vim /etc/systemd/system/otrs.service

加入如下配置:

[Unit]
Description=OTRS service
After=syslog.target network.target httpd.service

[Service]
Type=forking
ExecStart=/sbin/runuser -l otrs -c '/opt/otrs/bin/otrs.Daemon.pl start; /opt/otrs/bin/Cron.sh start'
PIDFile=/opt/otrs/var/run/Daemon-NodeID-1.pid
ExecStop=/sbin/runuser -l otrs -c '/opt/otrs/bin/otrs.Daemon.pl stop; /opt/otrs/bin/Cron.sh stop'

[Install]
WantedBy=multi-user.target

重载守护进程:

systemctl daemon-reload

测试脚本:

systemctl enable otrs.service
systemctl start otrs.service
systemctl status otrs.service
systemctl stop otrs.service

2.4.3.2 运行安装向导

http://10.168.0.70/otrs/index.pl
user: root@localhost
password: root

参阅文档:
======================================
http://doc.otrs.com/doc/manual/admin/stable/en/html/index.html
http://doc.otrs.com/doc/manual/admin/stable/zh_CN/html/manual-installation-of-otrs.html

没有评论

发表回复

开源项目
如何安装禅道甘特图插件?

1 前言 笔者需要测试禅道的甘特图插件,于是本文应运而生。 2 最佳实践 2.1 实践环境 如果你没 …

开源项目
如何升级禅道?

1 前言 最近收到升级禅道的任务,于是本文应运而生。 2 最佳实践 2.1 实践环境 如果你没有升级 …

开源项目
如何手动部署禅道?

1 基础知识 1.1 软件的介绍 – 禅道是一款专业的研发项目管理软件 – …