腾飞基因项目 安装配置文档-CentOS版

腾飞基因项目 安装配置文档-CentOS版

一、buildout Plone 生产环境

1、创建用户组,用户,并为该用户账号授权sudo
以root身份登陆系统

#>groupadd plone
#>useradd plone -g plone

运行命令:visudo

注释掉下面这行:

# %wheel        ALL=(ALL)       ALL

添加用户demo到wheel组

#>usermod –aG wheel plone


2、用plone用户登陆系统,安装Plone依存的系统库

[plone@localhost ~]$ sudo yum install gcc-c++ patch openssl-devel libjpeg-devel libxslt-devel readline-devel make which python-devel wv poppler-utils python-docutils  -y

 

3、在用户主目录下,创建程序目录workspace,下载并编译安装python2.7.x最新版,本文是python 2.7.15

[plone@localhost downloads]$ mkdir ~/workspace

去到python.org官方网站下载:

[plone@localhost downloads]$ cd ~/downloads

 

[plone@localhost downloads]$ wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz

解压缩,编译安装python2.7.15

[plone@localhost downloads]$ tar -zxvf Python-2.7.15.tgz
[plone@localhost downloads]$ cd Python-2.7.15
[plone@localhost Python-2.7.15]$ ./configure --prefix=/home/plone/workspace/python2715 --enable-unicode=ucs4 --enable-optimizations
[plone@localhost Python-2.7.15]$ make
[plone@localhost Python-2.7.15]$ make install

4、下载get-pip.py,用python2.7.15 安装pip

[plone@localhost downloads]$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
[plone@localhost downloads]$ cd workspace/python2715/

给python2715安装pip

[plone@localhost python2715]$ bin/python2 ~/downloads/get-pip.py


5、克隆gene.buildout生产站点配置项目到用户主目录workspace

[plone@localhost python2715]$ cd ~/workspace
[plone@localhost workspace]$ git clone -b master --single-branch  https://github.com/Ascendasgenomics/gene.buildout.git gene


6、用pip2 安装virtualenv,并创建python虚拟环境

[plone@localhost workspace]$ cd ~/workspace/python2715/
[plone@localhost python2715]$ bin/pip2 install virtualenv
[plone@localhost python2715]$ bin/virtualenv /home/plone/workspace/gene

7、激活虚拟环境

[plone@localhost python2715]$ cd ~/workspace/gene
[plone@localhost gene]$ source bin/activate

8、编译安装部分三方模块到虚拟环境python路径,包括但不限于zc.buildout、setuptools等

(gene)[plone@localhost gene]$ cd ~/workspace/gene
(gene)[plone@localhost gene]$ pip2 install --trusted-host mirrors.aliyun.com -i http://mirrors.aliyun.com/pypi/simple -r requirements-5-1.txt


9、建立buildout默认配置文件及缓存目录,运行buildout配置命令:

(gene)[plone@localhost gene]$ mkdir ~/.buildout

 

(gene)[plone@localhost gene]$ mkdir ~/.buildout/eggs
(gene)[plone@localhost gene]$ mkdir ~/.buildout/downloads
(gene)[plone@localhost gene]$ mkdir ~/.buildout/extends
(gene)[plone@localhost gene]$ touch ~/.buildout/default.cfg
(gene)[plone@localhost gene]$ vi ~/.buildout/default.cfg

填充如下内容:

[buildout]
eggs-directory = /home/plone/.buildout/eggs
download-cache = /home/plone/.buildout/downloads
extends-cache = /home/plone/.buildout/extends

运行buildout

(gene)[plone@localhost gene]$ bin/buildout -Nvvv -c deploy_haproxy.cfg

10、通过supervisor启动各服务进程

(gene)[plone@localhost gene]$ sudo bin/supervisord

检测各服务进程

(gene)[plone@localhost gene]$ bin/supervisorctl status

二、安装libreoffice

1、下载指定版本libreoffice

详细安装文档参考:https://wiki.documentfoundation.org/Documentation/Install/Linux#Installing_via_Terminal

去到libreoffice官方网站下载:

打开网址:https://downloadarchive.documentfoundation.org/libreoffice/old/5.1.3.2/rpm/x86_64/

LibreOffice_5.1.6.2_Linux_x86-64_rpm.tar.gz

解压缩下载文件:

$ tar zxvf LibreOffice_$version_Linux_x86-rpm.tar.gz

$ cd LibreOffice_$version_Linux_x86-rpm/

$ cd RPMS/

对于Fedora / CentOS系统
$ su -c 'yum install *.rpm'

默认安装在 /opt/libreoffice5.1

为了方便deamon方式启动libreoffice,作如下修改:

sudo ln -s /opt/libreoffice5.1/program/soffice /usr/bin/soffice

创建report默认保存目录,并设置权限:

sudo mkdir -p /srv/report_files

sudo chown -R plone:plone  /srv/report_files

安装字体:

unzip fonts.zip
sudo mv  fonts/truetype  /usr/share/fonts/
sudo mv  fonts/opentype  /usr/share/fonts/

如果不能自动识别新安装的字体,可以调节matplotlib/font_manager.py 的参数,强制识别新安装的字体:

编辑  /home/plone/workspace/gene/lib/python2.7/site-packages/matplotlib/font_manager.py,修改USE_FONTCONFIG :

USE_FONTCONFIG = True

三、安装python3 及uno,unohelper

sudo yum install python3 python3-devel

安装完后,默认安装在/usr/lib64/python3.x

cd /usr/lib64/python3.x/site-packages

拷贝libreoffice 的 uno.py unohelper.py 到python3.x的site-packages

sudo cp -a /opt/libreoffice5.1/program/uno.py .
sudo cp -a /opt/libreoffice5.1/program/unohelper.py .

修改uno.py,便python3正确加载这两个模块

uno.py 在文件起始位置添加四行:

import sys, os
sys.path.append('/opt/libreoffice5.1/program')
os.putenv('URE_BOOTSTRAP', 'vnd.sun.star.pathname:/opt/libreoffice5.1/program/fundamentalrc')
os.putenv('UNO_PATH', '/opt/libreoffice5.1/program')

验证下修改是否正确:

/usr/bin/python3

尝试导入uno 和 unohelper,应不报错,如下:

Python 3.6.8 (default, Apr  2 2020, 13:34:55) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import uno
>>> import unohelper
>>>

 

四、添加并配置Plone站点,完成gene项目初始化

  1. 添加站点:打开浏览器,访问http://localhost:8080/,输入管理员账户admin及密码,按照提示添加站点,站点id默认为Plone。
  2. 安装策略包,完成gene项目初始化

打开浏览器访问http://localhost:8080/Plone,输入管理员账户admin及密码,登录后,点击左下角菜单中的“网站设置”。

在 “常规”组里面点击“附加组件”,在“可启用附加组件”中寻找gene.policy,找到后,点击其后的 “安装”按钮即可。

 

五、设置相关服务自启动

添加systemd管理的自启动服务

1、自启动supervisord

sudo touch /etc/systemd/system/supervisord.service
sudo vi /etc/systemd/system/supervisord.service

填充如下内容:

[Unit]
Description=Supervisor Monitor
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=root
Group=root
PIDFile=/home/plone/workspace/gene/var/supervisord.pid
# Disable service start and stop timeout logic of systemd for supervisor service.
TimeoutSec=0
Type=forking
# Start main service
ExecStart=/home/plone/workspace/gene/bin/supervisord
ExecStop=/home/plone/workspace/gene/bin/supervisorctl shutdown
StartLimitBurst=2
StartLimitInterval=30

允许supervisord 作为deamon自动启动:

sudo systemctl enable supervisord.service

2、自启动libreoffice 

sudo touch /etc/systemd/system/libreoffice.service
sudo vi /etc/systemd/system/libreoffice.service

填充如下内容:

 [Unit]
 Description=Control headless soffice instance
 After=network.target
 
 [Service]
 Type=simple
 ExecStart=/opt/libreoffice5.1/program/soffice --invisible --headless \
 --accept=socket,host=127.0.0.1,port=2002;urp;
 --pidfile=/var/run/soffice.pid
 RestartSec=5 
 PIDFile=/var/run/soffice.pid

 [Install]
 WantedBy=multi-user.target

允许libreoffice 作为deamon自动启动:

sudo systemctl enable libreoffice.service
设置