Install ODOO under centos

yum install zlib-devel

yum install bzip2-devel

yum install openssl-devel

yum install ncurses-devel

yum install sqlite-devel

 

yum -y groupinstall Development tools

 

cd / opt

wget --no-check-certificate https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz

 

tar xf Python-2.7.9.tar.xz

cd Python-2.7.14

 

./configure --prefix=/usr/local

make && make install

 

ln -s /usr/local/bin/python2.7 /usr/local/bin/python

 

Establish a soft connection so that the default python of the system points to python2.7

Under normal circumstances, even if python2.7 is successfully installed, the default python that the system points to is still version 2.6, and yum is based on python2.6 to work properly. So point the system default python to version 2.7.

# /usr/local/bin/python2.7 -V    

# mv /usr/bin/python  /usr/bin/python266 

# ln -s /usr/local/bin/python2.7 /usr/bin/python

 

when the upgrade is complete. There will be garbled characters after entering the arrow keys.

This problem is mainly caused by the missing readline Module problem. By default, CentOS only has the readline module instead of the readline-devel development module. So just install it.

# yum -y install readline-devel

then reinstall python

cd Python-2.7.14

 

./configure --prefix=/usr/local

make && make install

 

Install pip and the setuptools wheel

curl https://bootstrap.pypa.io/get-pip.py | python2.7 - 

 

 

安装postgresql

wget https://ftp.postgresql.org/pub/source/v9.4.16/postgresql-9.4.16.tar.gz --no-check-certificate

tar xf postgresql-9.4.16.tar.gz

adduser postgres

passwd postgres

编译postgresql 安装在home目录下

./configure --prefix=/home/pgsql

 

make && make install

 

cd /home/postgres

 vi .bash_profile

把 PATH=$PATH:$HOME/bin

改成 PATH=$PATH:$HOME/bin:/home/pgsql/bin

保存退出。

让环境变量生效:

 

source .bash_profile

 

 

然后回到root目录

 

cd /root

 vi .bash_profile

把 PATH=$PATH:$HOME/bin

改成 PATH=$PATH:$HOME/bin:/home/pgsql/bin

保存退出。

让环境变量生效:

 

source .bash_profile

 

 

8.初始化数据库

8.1新建数据目录

[root@postgresql ~]# mkdir /home/pgsql/data

8.2更改权限

[root@postgresql ~]# chown postgres:postgres /home/pgsql/data

8.3切换到postgres用户

[root@postgresql ~]# su - postgres

8.4 init db

[postgres@postgresql ~]$ /home/pgsql/bin/initdb -D /home/pgsql/data

到这里数据的初始化就完成

 

9.1回到root用户

[postgres@postgresql ~]$ exit

9.2复制安装目录下的linux文件到/etc/init.d/

进入postgresql 的安装目录(即刚刚使用tar命令解压的目录)

[root@postgresql ~]# cd postgresql-9.4.3

[root@postgresql postgresql-9.4.3]# cp contrib/start-scripts/linux /etc/init.d/postgresql

9.3修改/etc/init.d/postgresql  

[root@postgresql postgresql-9.4.3]# vi /etc/init.d/postgresql

修改如下prefix和PGDATA到安装的目录

# Installation prefix

#prefix=/usr/local/pgsql

prefix=/home/pgsql

 

# Data directory

#PGDATA="/usr/local/pgsql/data"

PGDATA="/home/pgsql/data"

 

9.4添加执行权限

[root@postgresql postgresql-9.4.3]# chmod +x /etc/init.d/postgresql

 

9.5启动数据库

[root@postgresql postgresql-9.4.3]# /etc/init.d/postgresql start

Starting PostgreSQL: ok

9.6让数据库开机启动

[root@postgresql postgresql-9.4.3]# chkconfig --add postgresql

[root@postgresql postgresql-9.4.3]# chkconfig postgresql on

 

这样就可以通过 service postgresql restart方式重新启动服务了。

 

9.7创建数据库操作历史记录文件 

[root@postgresql postgresql-9.4.3]# touch /home/pgsql/.pgsql_history

[root@postgresql postgresql-9.4.3]# chown postgres:postgres /home/pgsql/.pgsql_history

10.测试使用

[root@postgresql postgresql-9.4.3]# su - postgres

[postgres@postgresql ~]$ createdb test

[postgres@postgresql ~]$ psql test

psql (9.4.3)

Type "help" for help.

test=#

 

源码编译安装成功。

 设置posgresql的远程连接

 

cd /home/pgsql/data

 

修改pg_hba.conf

添加一条host    all             all             0.0.0.0/24              trust

 

# IPv4 local connections:

host    all             all             127.0.0.1/32            trust

host    all             all             0.0.0.0/0              trust

 

另一个要改的就是postgresql.conf文件.

将listen_address =”localhost” 引号里面改为*,即对所有地址监听.

 

 

安装subversion

# yum install subversion*

cd  /usr/src/

#svn co http:/xxxxxxxx(svn代码路径)

 

cd /usr/src/tse_3.0

然后安装python的类库

pip install -r requirement.txt

通过requirements.txt安装psycopg2失败,尝试下载psycopg2,手动安装。

pip install psycopg2 失败。报错说没有pg_config的PATH。

(也可以通过source方式:http://initd.org/psycopg/download/下载psycopg2-2.6.2.tar.gz

解压后,python setup.py build)

是因为没有安装postgres9.4-devel

The pg_config program: it is usually installed by the libpq-dev package but sometimes it is not in a PATH directory. Having it in thePATH greatly streamlines the installation, so try running pg_config --version: if it returns an error or an unexpected version number then locate the directory containing the pg_config shipped with the right libpq version (usually/usr/lib/postgresql/X.Y/bin/) and add it to the PATH:

 

pg_config在/usr/pgsql-9.4/bin下

#vim /etc/profile

添加

export PATH="$PATH:/usr/pgsql-9.4/bin"

#source /etc/profile

#pip install psycopg2成功

 

注意,要把requirement.txt的 

psycopg2==2.5.3注释掉。

 

 

supervisor的配置

odoo的源代码放在usr/odoo下

[program:odoo]

command=/usr/local/python278/bin/python2.7 /opt/odoo/openerp-server -c /opt/odoo/openerp-server.conf

directory=/opt/odoo

autostart=true

autorestart=true

startsecs=3

user=openerp

stdout_logfile=/opt/odoo/openerp-server.log

stdout_logfile_maxbytes=500MB

stdout_logfile_backups=50

stdout_capture_maxbytes=1MB

stdout_events_enabled=false

 

 

2017-2-13comment

安装完成之后,配置openerp-server.conf。因为自己的模块放在另外一个目录下,所以addons_path=/home/radzhang/workspace/tse2.0/openerp/addons,/home/radzhang/workspace/tse2.0/openerp/addons_self。设置了两个路径。但是#./openerp-server开启odoo服务端的时候,一直无法识别后面那个新加的addons_self目录。

然后把我自己的模块放到openerp/addons目录下的话,程序是能正常运行的。

后来通过openerp-server命令,直接指定addons路径,然后用-s参数,保存了一下,之后,就能正常识别第二个

 

2017-12-31comment

#pip install -r requirement.txt的时候,报错

  1. src/lxml/lxml.etree.c:157929: error: ‘xsltLibxsltVersion’ undeclared (first use in this function)  
  2. src/lxml/lxml.etree.c:157941: error: ‘__pyx_v_4lxml_5etree_XSLT_DOC_DEFAULT_LOADER’ undeclared (first use in this function)  
  3. src/lxml/lxml.etree.c:157941: error: ‘xsltDocDefaultLoader’ undeclared (first use in this function)  
  4. src/lxml/lxml.etree.c:157950: error: ‘__pyx_f_4lxml_5etree__xslt_doc_loader’ undeclared (first use in this function)  
  5. error: command 'gcc' failed with exit status 1  

pip list查看有lxml4.1.1安装过了,但是还是报lxml的错误。

 

查看了一下#rpm -qa|grep libxlm2*,

[root@tse4-odoo tse_4.0]# rpm -qa|grep libxml2*

libxml2-python-2.7.6-21.el6_8.1.x86_64

libxml2-2.7.6-21.el6_8.1.x86_64

libxml2-devel-2.7.6-21.el6_8.1.x86_64

libxml2-static-2.7.6-21.el6_8.1.x86_64

已经安装了,但是没有libxslt。

#yum install libxslt*

[root@tse4-odoo tse_4.0]# rpm -qa|grep libxslt*

libxslt-1.1.26-2.el6_3.1.x86_64

libxslt-devel-1.1.26-2.el6_3.1.x86_64

 

然后就正常了。requirement.txt的lxml是3.3.5版本的,pip install -r requirement.txt自动会删除lxml4.1.1。然后安装lxml3.3.5

 

2018-2-11comment

openerp-server.conf多核配置

db_user = odoo

dbfilter = .*

limit_memory_hard = 2147483648

limit_memory_soft = 1744830464

limit_request = 81920

limit_time_cpu = 6000

limit_time_real = 7200

log_handler = [':INFO']

log_level = info

syslog=true

#logfile = /usr/src/tse_3.0/log/log.log

login_message = False

logrotate = True

longpolling_port = 8072

max_cron_threads = 2

netrpc = False

netrpc_interface =

netrpc_port = 8070

osv_memory_age_limit = 1.0

osv_memory_count_limit = False

pg_path = /home/pgsql/bin

smtp_password = False

smtp_port = 25

smtp_server = localhost

smtp_ssl = False

smtp_user = False

workers = 13

xmlrpc = True

xmlrpc_interface =

xmlrpc_port = 8169

xmlrpcs = True

xmlrpcs_interface =

xmlrpcs_port = 8071

pre_code=$

 

然后Postgresql.conf优化

 

数据库恢复问题

odoo正常启动之后,还原数据库一直出错。上传到一半就跳出来了。

后来发现是因为多核设定之后,用Nginx做了转发,odoo的端口是8069,直接用nginx转发的80端口访问database/manager后

上传会受到nginx的上传文件的限制,

解决办法。1.更改nginx设置。2.直接访问odoo的8069端口。

 

上传问题解决了之后,还是不行。后来在centos上直接还原也还是不行。

尝试通过pg_restore命令手动恢复数据库看看,果然执行pg_restore的时候报错

undefined symbol: PQconnectdbParams

网上有人说是因为ld_library_path没有设定对的原因

It's probably finding the wrong library. Which binaries are you using?
If you do "ldd /path/to/binary", what does it show? Maybe you need to
set LD_LIBRARY_PATH to the "lib" directory of your new postgres install?

在centos查看

rpm -qa | grep postgresql 发行有另外一个版本的lib存在,是否这个产生了冲突?

# rpm -qa |grep postgres

postgresql-libs-8.4.20-8.el6_9.x86_64

回想到前面postgres用户的.bashrc里是添加了ld_library_path.不知道为什么不能识别

LD_LIBRARY_PATH: 动态库的查找路径

设置:

方法一: export  LD_LIBRARY_PATH=LD_LIBRARY_PATH:/XXX 但是登出后就失效

方法二:  修改~/.bashrc或~/.bash_profile或系统级别的/etc/profile

                  1. 在其中添加例如export PATH=/opt/ActiveP/lib:$LD_LIBRARY_PATH

                  2. source .bashrc  (Source命令也称为“点命令”,也就是一个点符号(.)。source命令通常用于重新执行刚修改的初始化文件,使之立即生效,而不必注销并重新登录)

方法三:这个没有修改LD_LIBRARY_PATH但是效果是一样的实现动态库的查找, 

                1. /etc/ld.so.conf下面加一行/home/pgsql/lib

于是按照第三种方法再设置了一下LD_library_path。

然后执行pg_restore就正常了。

回到odoo的database/manager页面,也能正常还原数据了。

 

#2018-02-12comment

今天恢复一个300M的备份文件,上传也成功了,上传过程中也在/tmp/目录下出现了

临时上传文件,但是总是报错不能恢复数据库。

然后把那个备份文件直接ftp上传到服务器,通过pg_restore命令,能正常还原数据库。

怀疑是300M的文件上传不完全???导致/tmp/下的临时备份文件缺失?导致还原数据库失败?有待验证。下次可以把/tmp/下的那个文件复制出来试试能不能手动pg_restore还原。

 

 

#2018-02-13comment

因为使用了多核处理,网上评论说用循环日志的话,有时候会出错。原因是跨天文件日志备份的时候,正好把日志文件备份后删除的时候,其他进程还有可能在使用原来的

日志文件。

方案一,改用rsyslog

openerp-server.conf里的设置syslog=true

然后 vi /etc/rsyslog.conf

在最后添加如下规则

 

:msg,contains,"werkzeug" /var/log/odoo/odoo-server.log

:msg,contains,"werkzeug" ~

:msg,contains,"openerp\." /var/log/odoo/odoo-server.log

:msg,contains,"openerp\." ~

 

然后 service rsyslog restart

这样odoo的日志就保存在/var/log/odoo/odoo-server.log日志文件里了。

缺点是这个文件会一直变大。网上也有通过安装logrotate来分割日志的文章。可以尝试一下。

 

方案二

依旧使用原来的odoo的log日志

#syslog=true

logfile = /usr/src/tse_3.0/log/log.log

login_message = False

 

logrotate = True

因为logging用的是python自带的库类。

修改/usr/local/lib/python2.7/logging/handlers.py

有一个class TimedRotatingFileHandler(BaseRotatingHandler):类是处理循环日志的

在349行左右

        #if os.path.exists(dfn):

        #    os.remove(dfn)

        # Issue 18940: A file may not have been created if delay is True.

        #if os.path.exists(self.baseFilename):

        #    os.rename(self.baseFilename, dfn)

        #if self.backupCount > 0:

        #    for s in self.getFilesToDelete():

        #        os.remove(s)

        #if not self.delay:

        #    self.stream = self._open()

 

        #20180208 modify by rad change logging file for multiprocess

        if not os.path.exists(dfn) and os.path.exists(self.baseFilename):

            os.rename(self.baseFilename, dfn)

        if self.backupCount > 0:

            for s in self.getFilesToDelete():

                os.remove(s)

        if not self.delay:

            self.mode = "a"

 

            self.stream = self._open()

把删除文件变成改名。

这个方法有待验证。

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326094999&siteId=291194637