Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于部署 #18

Open
lovese opened this issue Jul 31, 2017 · 56 comments
Open

关于部署 #18

lovese opened this issue Jul 31, 2017 · 56 comments
Labels

Comments

@lovese
Copy link

lovese commented Jul 31, 2017

您好,对您这个项目很感兴趣,README里面部署过程中安装了easy_install,但是我看后面部署过程都没用过这个命令,这是为什么?有些软件的版本有要求么?比如pip。谢谢!

@welliamcao
Copy link
Owner

pip需要easy_install

@lovese
Copy link
Author

lovese commented Jul 31, 2017

我的centos7系统,自带python2.7.5,安装epel源的python2-pip代替您的pip可以用吗?

@welliamcao
Copy link
Owner

可以的pip版本无所谓,能安装平台所需模块就可以。

@lovese
Copy link
Author

lovese commented Jul 31, 2017

pip install django==1.8.17这个版本是固定的吗?
pip install ansible==2.2.2这个版本是必须等于我安装的版本么?

@welliamcao
Copy link
Owner

有指定版本的按照要求安装,没有就不用

@liuxiaoxiong
Copy link

TypeError at /login/
render_to_response() got an unexpected keyword argument 'context_instance'
大师好,为啥我部署的时候报错这个?这个是啥意思呢?

@welliamcao
Copy link
Owner

python模块都按要求安装成功了吗?

@liuxiaoxiong
Copy link

恩,模块都安装了,是访问的时候报错的,好像是这段代码有问题
view--->index.py 96行
return render_to_response('login.html',context_instance=RequestContext(request))

@welliamcao
Copy link
Owner

@liuxiaoxiong 提供一下django与python版本?

@liuxiaoxiong
Copy link

Python Version: | 2.7.5
Django Version: | 1.11.2

@welliamcao
Copy link
Owner

@liuxiaoxiong pip install django==1.8.17试一下这个版本,可能你的Django版本太高了,render_to_response不支持context_instance了

@liuxiaoxiong
Copy link

感谢,果然是这个问题!!

@lovese
Copy link
Author

lovese commented Aug 1, 2017

生成数据表时报错
/usr/lib64/python2.7/site-packages/django/db/backends/mysql/base.py:124: Warning: Incorrect string value: '\xE6\x80\xBB\xE8\xB5\x84...' for column 'name' at row 1
return self.cursor.execute(query, args)
还望帮忙看下
不清楚是不是redis设置了密码的缘故

@welliamcao
Copy link
Owner

welliamcao commented Aug 1, 2017

@lovese 能提供一下MySQL版本信息吗?以及这个是在什么操作之后出现的错误。

@lovese
Copy link
Author

lovese commented Aug 1, 2017

Server version: 5.5.52-MariaDB MariaDB Server
配置完OpsManage,在第八步生成数据表时出现的

@welliamcao
Copy link
Owner

@lovese MySQL字符集有没有配置过?(需要重启MySQL)

[mysqld]
default-character-set = utf8
character_set_server = utf8

@lovese
Copy link
Author

lovese commented Aug 1, 2017

/etc/my.cnf.d/client.cnf
[client]
default-character-set=utf8

/etc/my.cnf.d/server.cnf
[mysqld]
character-set-server=utf8

@lovese
Copy link
Author

lovese commented Aug 1, 2017

我把库删了重新建库就可以了,应该是要配置好数据库再建库,前面有重启过的,没起作用

@lovese
Copy link
Author

lovese commented Aug 1, 2017

您好,我的redis本来就装过了还设置了密码,我直接拿来用还要进行哪里配置吗?

@welliamcao welliamcao added the docs label Aug 1, 2017
@welliamcao
Copy link
Owner

@lovese redis暂时不支持认证。

@lovese
Copy link
Author

lovese commented Aug 1, 2017

我配置了使用组,但是不显示,硬盘总容量也读取不到,提示不支持,内存详细信息及硬盘详细信息也没有内容,带宽用的基本都是双线路了,云硬盘也没有raid,这个管理平台好像更适合物理机,对云服务器好像不太完全适配

@welliamcao
Copy link
Owner

基础资产需要自己配置,更新raid与内存,需要模块GitHub上面不提供,如果需要贴合公司环境,可以找我付费定制。

@lovese
Copy link
Author

lovese commented Aug 1, 2017

好的

@slimshadowg
Copy link

Unhandled exception in thread started by <function wrapper at 0x7fc670415de8>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 237, in wrapper
filename = traceback.extract_tb(tb)[-1][0]
TypeError: 'NoneType' object is not callable
按照大师流程做的,期间安装模块出错,更新pip后完成安装,启动runserver时卡住control^c退出显示这个信息

@welliamcao
Copy link
Owner

@slimshadowg 是不是pip install -r requirements.txt这个步骤出现错误或者警告被忽略了?

@slimshadowg
Copy link

安装channels模块不能安装,更新pip后才能安装,安装完成后启动就卡住

@shihuizhen
Copy link

channels 安装问题 Twisted版本不对
wget https://pypi.python.org/packages/a2/37/298f9547606c45d75aa9792369302cc63aa4bbcf7b5f607560180dd099d2/Twisted-17.9.0.tar.bz2#md5=6dbedb918f0c7288a4c670f59393ecf8
tar -xjvf Twisted-17.9.0.tar.bz2
cd Twisted-17.9.0
python setup.py install

@slimshadowg
Copy link

@shihuizhen 十分感谢,问题解决了

@shihuizhen
Copy link

当前代码使用pip install ansible==2.3.2.0,如果装2.2.2.0 的话会出现ansible 执行失败,原因是paramiko 问题。报错
/opt/env/opsmanage/lib/python2.7/site-packages/ansible/executor/task_executor.py\", line 126, in run\n res = self._execute()\n File \"/opt/env/opsmanage/lib/python2.7/site-packages/ansible/executor/task_executor.py\", line 511, in _execute\n result = self._handler.run(task_vars=variables)\n File \"/opt/env/opsmanage/lib/python2.7/site-packages/ansible/plugins/action/normal.py\", line 33, in run\n results = merge_hash(results, self._execute_module(tmp=tmp, task_vars=task_vars))\n File \"/opt/env/opsmanage/lib/python2.7/site-packages/ansible/plugins/action/__init__.py\", line 584, in _execute_module\n tmp = self._make_tmp_path(remote_user)\n File \"/opt/env/opsmanage/lib/python2.7/site-packages/ansible/plugins/action/__init__.py\", line 224, in _make_tmp_path\n tmpdir = self._remote_expand_user(C.DEFAULT_REMOTE_TMP, sudoable=False)\n File \"/opt/env/opsmanage/lib/python2.7/site-packages/ansible/plugins/action/__init__.py\", line 505, in _remote_expand_user\n data = self._low_level_execute_command(cmd, sudoable=False)\n File \"/opt/env/opsmanage/lib/python2.7/site-packages/ansible/plugins/action/__init__.py\", line 777, in _low_level_execute_command\n rc, stdout, stderr = self._connection.exec_command(cmd, in_data=in_data, sudoable=sudoable)\n File \"/opt/env/opsmanage/lib/python2.7/site-packages/ansible/plugins/connection/paramiko_ssh.py\", line 253, in exec_command\n super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)\n File \"/opt/env/opsmanage/lib/python2.7/site-packages/ansible/plugins/connection/__init__.py\", line 52, in wrapped\n self._connect()\n File \"/opt/env/opsmanage/lib/python2.7/site-packages/ansible/plugins/connection/paramiko_ssh.py\", line 141, in _connect\n self.ssh = SSH_CONNECTION_CACHE[cache_key] = self._connect_uncached()\n File \"/opt/env/opsmanage/lib/python2.7/site-packages/ansible/plugins/connection/paramiko_ssh.py\", line 212, in _connect_uncached\n sock_kwarg = self._parse_proxy_command(port)\n File \"/opt/env/opsmanage/lib/python2.7/site-packages/ansible/plugins/connection/paramiko_ssh.py\", line 153, in _parse_proxy_command\n args = self._split_ssh_args(' '.join(ssh_args))\nTypeError: sequence item 0: expected string, NoneType found\n

我的pip freeze
amqp==1.4.9 ansible==2.3.2.0 anyjson==0.3.3 asgi-redis==1.4.3 asgiref==1.1.2 asn1crypto==0.24.0 attrs==17.4.0 autobahn==17.10.1 Automat==0.6.0 bcrypt==3.1.4 billiard==3.3.0.23 celery==3.1.20 celery-with-redis==3.0 cffi==1.11.2 channels==1.1.7 constantly==15.1.0 cryptography==2.1.4 daphne==1.4.2 DBUtils==1.2 Django==1.11.7 django-celery==3.2.2 djangorestframework==3.5.3 enum34==1.1.6 hyperlink==17.3.1 idna==2.6 incremental==17.5.0 ipaddress==1.0.19 Jinja2==2.10 kombu==3.0.37 MarkupSafe==1.0 meld3==1.0.2 msgpack==0.5.0 msgpack-python==0.5.0 MySQL-python==1.2.5 paramiko==2.4.0 pyasn1==0.4.2 pyasn1-modules==0.2.1 pycparser==2.18 pycrypto==2.6.1 PyNaCl==1.2.1 pyOpenSSL==17.5.0 pytz==2017.3 PyYAML==3.12 redis==2.10.6 service-identity==17.0.0 six==1.11.0 supervisor==3.3.3 Twisted==17.9.0 txaio==2.8.2 xlrd==1.1.0 zope.interface==4.4.3

@welliamcao
Copy link
Owner

@shihuizhen 应该跟你用CentOS 7.4有关,如果是CentOS 6使用requirements.txt安装模块是低版本的paramiko,高版本的paramiko应该跟ansible 2.2代码不兼容

@shihuizhen
Copy link

可能跟我用的pip 源有关系。我用的是阿里的pip 源。

@dongwenrong
Copy link

安装python相关包,有谁遇到如下错误吗?请指教!谢谢!
Exception:
Traceback (most recent call last):
File "/opt/OpsManage/ENV/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/opt/OpsManage/ENV/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/opt/OpsManage/ENV/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/req.py", line 1265, in prepare_files
req_to_install.extras):
File "/opt/OpsManage/ENV/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/_vendor/pkg_resources.py", line 2291, in requires
dm = self._dep_map
File "/opt/OpsManage/ENV/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/_vendor/pkg_resources.py", line 2484, in _dep_map
self.__dep_map = self._compute_dependencies()
File "/opt/OpsManage/ENV/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/_vendor/pkg_resources.py", line 2508, in _compute_dependencies
parsed = next(parse_requirements(distvers))
File "/opt/OpsManage/ENV/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/_vendor/pkg_resources.py", line 45, in
next = lambda o: o.next()
File "/opt/OpsManage/ENV/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/_vendor/pkg_resources.py", line 2605, in parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "/opt/OpsManage/ENV/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/_vendor/pkg_resources.py", line 2573, in scan_list
raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', 'asgiref ~=1.1', 'at', ' ~=1.1')

Storing debug log for failure in /root/.pip/pip.log

@welliamcao
Copy link
Owner

@dongwenrong 先升级一下pippip install -U pip,然后再 pip install -r requirements.txt试一下

@dongwenrong
Copy link

@welliamcao 非常感谢快速准确的回复,问题已解决。谢谢~

@dongwenrong
Copy link

dongwenrong commented Jan 23, 2018

记录一下:
执行python manage.py makemigrations OpsManage 遇到错误:
from OpsManage.utils.binlog2sql import Binlog2sql
File "/opt/OpsManage/OpsManage/utils/binlog2sql.py", line 7, in
from pymysqlreplication import BinLogStreamReader
ImportError: No module named pymysqlreplication

需要安装:pip install mysql-replication

@welliamcao
Copy link
Owner

@dongwenrong 非常感谢,因为引入了Binlog2sql,但是requirements.txt文件还未更新,晚点更新requirements.txt文件,加入mysql-replication,pymysql这个两个模块。

@byakkozhang
Copy link

如安装的是mysql5.7+,需要关闭mysql的“ ONLY_FULL_GROUP_BY”

#先查询
select @@global.sql_mode

#再修改
set @@global.sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION’;

@wangr927
Copy link

wangr927 commented Mar 2, 2018

你好,我这用docker安装了redis和mysql,然后启动,已经pip install -r requirements.txt
python manage.py makemirgrations ... 向mysql写入数据时提示错误

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib64/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/lib64/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
    settings.INSTALLED_APPS
  File "/usr/lib64/python2.7/site-packages/django/conf/__init__.py", line 46, in __getattr__
    self._setup(name)
  File "/usr/lib64/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/lib64/python2.7/site-packages/django/conf/__init__.py", line 98, in __init__
    % (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'OpsManage.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named djcelery

我看OpsManage 这个app的目录内,既没有djcelery.py的文件,也没有这样的目录,并且pip 也无法安装。我看了下,这个应该是个插件之类的,djcelery在app有注册过,在setting中,也有加载的动作。
我应该到哪里寻找这些代码

@welliamcao
Copy link
Owner

@wangr927 django-celery是不是没安装成功?

@iamscorpiomm
Copy link

感谢楼主分享~
我已经进行到 九、启动部署平台 这一步了,已经可以通过web访问了。
研究了大概4小时,我的django基础有点忘了,所以安装过程遇到了比较多的问题,列举一下,供参考。

pip install -r requirements.txt
这一步也是出错的,缺少gcc,还需要安装 twisted。

redis安装,报错:Error jemalloc/jemalloc.h: No such file or directory
按照 http://blog.csdn.net/lgh1117/article/details/48270085 的方法解决了。

mysql配置,default-character-set = utf8,character_set_server = utf8
character_set_server,是拼写错误的,我这样配置,mysql出错,根本启动不起来,改成 character-set-server 就可以了。
default-character-set,我进入mysql命令行,执行 show variables like "%default%"; 根本没有这个变量,在/etc/my.cnf里一添加这个变量就无法启动mysql失败。
总之,我只添加了 character-set-server = utf8 就成功的往下进行了。

OpsManage启动
需要关闭防火墙,需要启动nginx(安装nginx又需要先安装epel-release),这些是django项目的基本要求,不能web只能本机curl访问,其他机器无法访问。
我很久没碰django了,这些基础知识忘了,费了会功夫才记得配上这些的。
建议把这些基础要求注明在部署手册里,新手需要。

@iamscorpiomm
Copy link

再补充一个。

七、配置OpsManage
TEMPLATE_DIRS 和 TEMPLATES 的配置好像是冲突的。
我下载下来的代码里, TEMPLATE_DIRS是被注释掉的,我取消注释,项目启动失败,于是我就保留注释了,就正常了。

@iamscorpiomm
Copy link

再补充一个。
我点击 Dashboard 菜单的时候报错:ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'opsmanage.opsmanage_project_order.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
traceback一下,是index函数的 SELECT id,order_user FROM opsmanage_project_order GROUP BY order_user; 这条语句查询失败了。
乍一看这语句没啥毛病,其实跟mysql的设置有关,跟Opsmanage没关系。

我的mysql安装后,默认的sql_mode包含了only_full_group_by这个值,指的是对sql语句的group by语法的一种检查。把这个值去年,

@zhoushao12
Copy link

zhoushao12 commented Mar 28, 2018

Request Method: GET
http://192.168.165.131:8000/assets_list
1.11.7
OperationalError
(1054, "Unknown column 'opsmanage_networkcard_assets.ip' in 'field list'")
/usr/lib/python2.7/site-packages/django/db/models/sql/compiler.py in execute_sql, line 894
/usr/bin/python
2.7.5
['/mnt/OpsManage', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/setuptools-28.0.0-py2.7.egg']
Wed, 28 Mar 2018 15:58:31 +0800

这个是什么问题:

@welliamcao
Copy link
Owner

你是用新版的代码,运行在旧的数据库上面吗?@zhoushao12

@Macroldj
Copy link

用新代码,感觉有些数据库不存在。

@Macroldj
Copy link

image

@lijianqiao
Copy link

大家好,请问我在python manage.py runserver 0.0.0.0:8000时候,下面显示有错误,如下
[INFO] server.py[line:106] HTTP/2 support not enabled (install the http2 and tls Twisted extras),
我安装了TWisted ,但是http2没有,请问是需要安装么?还是我哪里配置的有问题

@Coffe2Cat
Copy link

请问老师 第九步 启动平台部署的 前四行内容具体是什么意思,没太看明白,尤其是第一行和第四行

echo_supervisord_conf > /etc/supervisord.conf

export PYTHONOPTIMIZE=1

vim /etc/supervisord.conf

最后添加,/var/log/celery-*.log这些是日志文件,如果有错误请注意查看,directory的值是代码路径

@welliamcao
Copy link
Owner

请问老师 第九步 启动平台部署的 前四行内容具体是什么意思,没太看明白,尤其是第一行和第四行

echo_supervisord_conf > /etc/supervisord.conf

export PYTHONOPTIMIZE=1

vim /etc/supervisord.conf

最后添加,/var/log/celery-*.log这些是日志文件,如果有错误请注意查看,directory的值是代码路径

1、生成supervisor配置文件
2、让celery支持ansible api
3、通过日志文件平排查celery是否正常

@welliamcao
Copy link
Owner

welliamcao commented Apr 14, 2020 via email

@liuliangliangyyp
Copy link

aceback (most recent call last):
File "/usr/local/python3/lib/python3.6/configparser.py", line 1138, in _unify_values
sectiondict = self._sections[section]
KeyError: 'ldap'

大佬,报这个错

@liuliangliangyyp
Copy link

已解决是opsmanger.ini配置文件的配置问题

@Macroldj
Copy link

Macroldj commented Apr 22, 2020 via email

@cqvienet
Copy link

在执行/usr/local/python3/bin/python3 manage.py migrate时报不能创建外键,我看SQL初始化的时候关闭了外键检测的!_mysql_exceptions.IntegrityError: (1215, 'Cannot add foreign key constraint')

@welliamcao
Copy link
Owner

在执行/usr/local/python3/bin/python3 manage.py migrate时报不能创建外键,我看SQL初始化的时候关闭了外键检测的!_mysql_exceptions.IntegrityError: (1215, 'Cannot add foreign key constraint')

按照文档部署,生成表结构

# /usr/local/python3/bin/python3 manage.py makemigrations wiki
# /usr/local/python3/bin/python3 manage.py makemigrations orders
# /usr/local/python3/bin/python3 manage.py makemigrations navbar
# /usr/local/python3/bin/python3 manage.py makemigrations databases
# /usr/local/python3/bin/python3 manage.py makemigrations asset
# /usr/local/python3/bin/python3 manage.py makemigrations deploy
# /usr/local/python3/bin/python3 manage.py makemigrations cicd
# /usr/local/python3/bin/python3 manage.py makemigrations sched
# /usr/local/python3/bin/python3 manage.py makemigrations apply
# /usr/local/python3/bin/python3 manage.py migrate
# /usr/local/python3/bin/python3 manage.py createsuperuser  #创建管理员账户与密码

@zjyang86
Copy link

image
请问这是什么问题? 刚部署上去就报这错,整个页面会卡死

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests