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

docker部署0.4.0使用mysql有问题 #849

Closed
ladeyi opened this Issue Dec 8, 2017 · 5 comments

Comments

Projects
None yet
3 participants
@ladeyi

ladeyi commented Dec 8, 2017

使用版本

0.4.0

问题复现步骤

如果直接docker一键部署的话,老是报sqllite的database is locked,所以尝试修改使用mysql,以下是修改步骤

  1. 修改requirements目录下rpm_requirements.txt和requirements.txt,增加gcc gcc-c++ mysql-devel python-devel mysql,和mysqlclient==1.3.12
  2. 修改config_docker.py的以下内容:
    class DockerConfig(Config):
    #DB_ENGINE = 'sqlite'
    #DB_NAME = os.path.join(BASE_DIR, 'data', 'db.sqlite3')
    DEBUG = False
    DB_ENGINE = 'mysql'
    DB_HOST = 'xxx'
    DB_PORT = 3306
    DB_USER = 'root'
    DB_PASSWORD = 'xxx'
    DB_NAME = 'xxx'

3.重新build jumpserver镜像,然后修改docker-compose.yml的jumpserver为刚刚build的镜像

4.后面就是按照官方步骤操作,但是添加资产之后,点击"测试管理用户"失败,管理用户添加方式为用户名密码,mysql中也看到该用户,报错为{'unreachable': True, 'msg': 'Authentication failed.', 'changed': False},但是我手动ssh过这个管理用户是可以登陆的

@bottlelee

This comment has been minimized.

Show comment
Hide comment
@bottlelee

bottlelee Dec 8, 2017

我也遇到类似的问题了。通过查看 log 可以看到以下输出(部分内容用 ****** 替代):

[2017-12-08 10:05:54,040: DEBUG/MainProcess] TaskPool: Apply <function _fast_trace_task at 0x7f0708548a60> (args:('perms.tasks.push_users', 'ad4f8941-5679-428a-89c4-', {'lang': 'py', 'task': 'perms.tasks.push_users', 'id': 'ad4f8941-5679-428a-89c4-', 'eta': None, 'expires': None, 'group': None, 'retries': 0, 'timelimit': [None, None], 'root_id': 'ad4f8941-5679-428a-89c4-', 'parent_id': None, 'argsrepr': "([{'id': 17, 'hostname': 'node4', 'ip': '10.81..', 'port': 22, 'groups': [...], 'username': '', 'password': {...}, 'private_key': None, 'become': {...}}, {'id': 20, 'hostname': 'node3', 'ip': '10.81.11.', 'port': 22, 'groups': [...], 'username': '', 'password': {...}, 'private_key': None, 'become': {...}}], {'name': '', 'username': '', 'shell': '/bin/bash', 'sudo': '/bin/whoami,/sbin/ifconfig,/usr/bin/vim,/usr/bin/vi', 'password': {}, 'public_key': {}})", 'kwargsrepr': '{}', 'origin': 'gen18@', 'reply_to': 'e6f3cb6b-7d19-33bf-b234-', 'correlation_id': 'ad4f8941-5679-428a-89c4-*****', 'delivery_info': {'exchange': '', 'routing_key':... kwargs:{})

[2017-12-08 10:05:54,041: DEBUG/MainProcess] Task accepted: perms.tasks.push_users[ad4f8941-5679-428a-89c4-***************] pid:35

[2017-12-08 10:05:54,043: ERROR/ForkPoolWorker-10] Task perms.tasks.push_users[ad4f8941-5679-428a-89c4-] raised unexpected: UnicodeEncodeError('ascii', '/opt/jumpserver/apps/[{'id': 17, 'hostname': 'node4', 'ip': '10.81..', 'port': 22, 'groups': ['\u8fd0\u7ef4\u7ba1\u7406'], 'username': '', 'password': {}, 'private_key': None, 'become': {'method': 'sudo', 'user': 'root', 'pass': "b'eyJhbGciOiJIUzI1NiJ9.Im5ld0BUb3VjaCI.*************************************_WJ1yjD4Ug'"}}, {'id': 20, 'hostname': 'node3', 'ip': '10.81..', 'port': 22, 'groups': ['\u8fd0\u7ef4\u7ba1\u7406'], 'username': '', 'password': {}, 'private_key': None, 'become': {'method': 'sudo', 'user': 'root', 'pass': "b'eyJhbGciOiJIUzI1NiJ9.Im5ld0BUb3VjaCI.*****************_WJ1yjD4Ug'"}}]', 100, 104, 'ordinal not in range(128)')
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 374, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 629, in protected_call
return self.run(*args, **kwargs)
File "/opt/jumpserver/apps/perms/tasks.py", line 46, in push_users
task_name=task_name, task_id=self.request.id)
File "/opt/jumpserver/apps/ops/utils.py", line 42, in run_AdHoc
runner = AdHocRunner(assets)
File "/opt/jumpserver/apps/ops/ansible/runner.py", line 178, in init
self.inventory = JMSInventory(hosts)
File "/opt/jumpserver/apps/ops/ansible/inventory.py", line 51, in init
host_list=host_list)
File "/usr/local/lib/python3.6/site-packages/ansible/inventory/init.py", line 76, in init
self._basedir = self.basedir()
File "/usr/local/lib/python3.6/site-packages/ansible/inventory/init.py", line 727, in basedir
if self.is_directory(self.host_list):
File "/usr/local/lib/python3.6/site-packages/ansible/inventory/init.py", line 722, in is_directory
return os.path.isdir(path)
File "/usr/local/lib/python3.6/genericpath.py", line 42, in isdir
st = os.stat(s)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 100-103: ordinal not in range(128)

跟编码有关。

bottlelee commented Dec 8, 2017

我也遇到类似的问题了。通过查看 log 可以看到以下输出(部分内容用 ****** 替代):

[2017-12-08 10:05:54,040: DEBUG/MainProcess] TaskPool: Apply <function _fast_trace_task at 0x7f0708548a60> (args:('perms.tasks.push_users', 'ad4f8941-5679-428a-89c4-', {'lang': 'py', 'task': 'perms.tasks.push_users', 'id': 'ad4f8941-5679-428a-89c4-', 'eta': None, 'expires': None, 'group': None, 'retries': 0, 'timelimit': [None, None], 'root_id': 'ad4f8941-5679-428a-89c4-', 'parent_id': None, 'argsrepr': "([{'id': 17, 'hostname': 'node4', 'ip': '10.81..', 'port': 22, 'groups': [...], 'username': '', 'password': {...}, 'private_key': None, 'become': {...}}, {'id': 20, 'hostname': 'node3', 'ip': '10.81.11.', 'port': 22, 'groups': [...], 'username': '', 'password': {...}, 'private_key': None, 'become': {...}}], {'name': '', 'username': '', 'shell': '/bin/bash', 'sudo': '/bin/whoami,/sbin/ifconfig,/usr/bin/vim,/usr/bin/vi', 'password': {}, 'public_key': {}})", 'kwargsrepr': '{}', 'origin': 'gen18@', 'reply_to': 'e6f3cb6b-7d19-33bf-b234-', 'correlation_id': 'ad4f8941-5679-428a-89c4-*****', 'delivery_info': {'exchange': '', 'routing_key':... kwargs:{})

[2017-12-08 10:05:54,041: DEBUG/MainProcess] Task accepted: perms.tasks.push_users[ad4f8941-5679-428a-89c4-***************] pid:35

[2017-12-08 10:05:54,043: ERROR/ForkPoolWorker-10] Task perms.tasks.push_users[ad4f8941-5679-428a-89c4-] raised unexpected: UnicodeEncodeError('ascii', '/opt/jumpserver/apps/[{'id': 17, 'hostname': 'node4', 'ip': '10.81..', 'port': 22, 'groups': ['\u8fd0\u7ef4\u7ba1\u7406'], 'username': '', 'password': {}, 'private_key': None, 'become': {'method': 'sudo', 'user': 'root', 'pass': "b'eyJhbGciOiJIUzI1NiJ9.Im5ld0BUb3VjaCI.*************************************_WJ1yjD4Ug'"}}, {'id': 20, 'hostname': 'node3', 'ip': '10.81..', 'port': 22, 'groups': ['\u8fd0\u7ef4\u7ba1\u7406'], 'username': '', 'password': {}, 'private_key': None, 'become': {'method': 'sudo', 'user': 'root', 'pass': "b'eyJhbGciOiJIUzI1NiJ9.Im5ld0BUb3VjaCI.*****************_WJ1yjD4Ug'"}}]', 100, 104, 'ordinal not in range(128)')
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 374, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 629, in protected_call
return self.run(*args, **kwargs)
File "/opt/jumpserver/apps/perms/tasks.py", line 46, in push_users
task_name=task_name, task_id=self.request.id)
File "/opt/jumpserver/apps/ops/utils.py", line 42, in run_AdHoc
runner = AdHocRunner(assets)
File "/opt/jumpserver/apps/ops/ansible/runner.py", line 178, in init
self.inventory = JMSInventory(hosts)
File "/opt/jumpserver/apps/ops/ansible/inventory.py", line 51, in init
host_list=host_list)
File "/usr/local/lib/python3.6/site-packages/ansible/inventory/init.py", line 76, in init
self._basedir = self.basedir()
File "/usr/local/lib/python3.6/site-packages/ansible/inventory/init.py", line 727, in basedir
if self.is_directory(self.host_list):
File "/usr/local/lib/python3.6/site-packages/ansible/inventory/init.py", line 722, in is_directory
return os.path.isdir(path)
File "/usr/local/lib/python3.6/genericpath.py", line 42, in isdir
st = os.stat(s)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 100-103: ordinal not in range(128)

跟编码有关。

@ladeyi

This comment has been minimized.

Show comment
Hide comment
@ladeyi

ladeyi Dec 8, 2017

刚才又测试了,如果我是直接在jumpserver容器中安装好依赖,修改config.py为mysql,然后直接commit到新镜像,然后修改compose的jumpserver为刚刚commit的镜像,然后删除所有容器,再docker-compose up,这样是可以使用的, 我怀疑源码中的dockerfile打出的镜像和官网拉下来的镜像不一致

ladeyi commented Dec 8, 2017

刚才又测试了,如果我是直接在jumpserver容器中安装好依赖,修改config.py为mysql,然后直接commit到新镜像,然后修改compose的jumpserver为刚刚commit的镜像,然后删除所有容器,再docker-compose up,这样是可以使用的, 我怀疑源码中的dockerfile打出的镜像和官网拉下来的镜像不一致

@bottlelee

This comment has been minimized.

Show comment
Hide comment
@bottlelee

bottlelee Dec 8, 2017

好,我也试试!

bottlelee commented Dec 8, 2017

好,我也试试!

@ladeyi

This comment has been minimized.

Show comment
Hide comment
@ladeyi

ladeyi Dec 8, 2017

恩恩,目前暂时没发现什么问题,资产添加正常,登录资产正常,其他还有待测试

ladeyi commented Dec 8, 2017

恩恩,目前暂时没发现什么问题,资产添加正常,登录资产正常,其他还有待测试

@ibuler

This comment has been minimized.

Show comment
Hide comment
@ibuler

ibuler Jan 9, 2018

Member

docker运行时没有 tty所以显示中文会报错,docker-compose up -d 应该可以解决

Member

ibuler commented Jan 9, 2018

docker运行时没有 tty所以显示中文会报错,docker-compose up -d 应该可以解决

@ibuler ibuler closed this Jan 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment