我正在尝试在 this link 的帮助下安装 Sentry
运行此命令后在运行迁移标题下
createdb -E utf-8 sentry
它要求我安装postgresql-client-common
我通过这个命令安装了它
sudo apt install postgresql-client-common
此后,当我尝试运行createdb -E utf-8 Sentry
时,我收到了此消息
Warning: No existing local cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one.
Error: You must install at least one postgresql-client-<version> package
运行命令后出现异常
sentry upgrade
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/sentry/options/store.py", line 165, in get_store
value = self.model.objects.get(key=key.name).value
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 151, in get
return self.get_queryset().get(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 304, in get
num = len(clone)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 77, in __len__
self._fetch_all()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 857, in _fetch_all
self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 220, in iterator
for row in compiler.results_iter():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 713, in results_iter
for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 785, in execute_sql
cursor = self.connection.cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 162, in cursor
cursor = util.CursorWrapper(self._cursor(), self)
File "/usr/local/lib/python2.7/dist-packages/sentry/db/postgres/decorators.py", line 44, in inner
return func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/sentry/db/postgres/base.py", line 84, in _cursor
cursor = super(DatabaseWrapper, self)._cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 132, in _cursor
self.ensure_connection()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 115, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py", line 115, in get_new_connection
return Database.connect(**conn_params)
File "/usr/local/lib/python2.7/dist-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
12:21:31 [ERROR] sentry: option.failed-lookup (key=u'system.url-prefix')
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/sentry/options/store.py", line 165, in get_store
value = self.model.objects.get(key=key.name).value
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 151, in get
return self.get_queryset().get(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 304, in get
num = len(clone)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 77, in __len__
self._fetch_all()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 857, in _fetch_all
self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 220, in iterator
for row in compiler.results_iter():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 713, in results_iter
for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 785, in execute_sql
cursor = self.connection.cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 162, in cursor
cursor = util.CursorWrapper(self._cursor(), self)
File "/usr/local/lib/python2.7/dist-packages/sentry/db/postgres/decorators.py", line 44, in inner
return func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/sentry/db/postgres/base.py", line 84, in _cursor
cursor = super(DatabaseWrapper, self)._cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 132, in _cursor
self.ensure_connection()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 115, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py", line 115, in get_new_connection
return Database.connect(**conn_params)
File "/usr/local/lib/python2.7/dist-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
12:21:31 [INFO] sentry.utils.raven.SentryInternalClient: Not capturing exception due to filters: <class 'django.db.utils.OperationalError'>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/sentry/options/store.py", line 165, in get_store
value = self.model.objects.get(key=key.name).value
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 151, in get
return self.get_queryset().get(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 304, in get
num = len(clone)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 77, in __len__
self._fetch_all()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 857, in _fetch_all
self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 220, in iterator
for row in compiler.results_iter():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 713, in results_iter
for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 785, in execute_sql
cursor = self.connection.cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 162, in cursor
cursor = util.CursorWrapper(self._cursor(), self)
File "/usr/local/lib/python2.7/dist-packages/sentry/db/postgres/decorators.py", line 44, in inner
return func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/sentry/db/postgres/base.py", line 84, in _cursor
cursor = super(DatabaseWrapper, self)._cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 132, in _cursor
self.ensure_connection()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 115, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py", line 115, in get_new_connection
return Database.connect(**conn_params)
File "/usr/local/lib/python2.7/dist-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
12:21:31 [ERROR] sentry: option.failed-lookup (key=u'system.url-prefix')
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/sentry/options/store.py", line 165, in get_store
value = self.model.objects.get(key=key.name).value
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 151, in get
return self.get_queryset().get(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 304, in get
num = len(clone)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 77, in __len__
self._fetch_all()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 857, in _fetch_all
self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 220, in iterator
for row in compiler.results_iter():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 713, in results_iter
for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 785, in execute_sql
cursor = self.connection.cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 162, in cursor
cursor = util.CursorWrapper(self._cursor(), self)
File "/usr/local/lib/python2.7/dist-packages/sentry/db/postgres/decorators.py", line 44, in inner
return func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/sentry/db/postgres/base.py", line 84, in _cursor
cursor = super(DatabaseWrapper, self)._cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 132, in _cursor
self.ensure_connection()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 115, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py", line 115, in get_new_connection
return Database.connect(**conn_params)
File "/usr/local/lib/python2.7/dist-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
12:21:31 [INFO] sentry.utils.raven.SentryInternalClient: Not capturing exception due to filters: <class 'django.db.utils.OperationalError'>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/sentry/utils/metrics.py", line 64, in worker
tsdb.incr(tsdb.models.internal, full_key, count=amount)
File "/usr/local/lib/python2.7/dist-packages/sentry/utils/services.py", line 91, in <lambda>
context[key] = (lambda f: lambda *a, **k: getattr(self, f)(*a, **k))(key)
File "/usr/local/lib/python2.7/dist-packages/sentry/tsdb/redis.py", line 214, in incr
self.incr_multi([(model, key)], timestamp, count, environment_id)
File "/usr/local/lib/python2.7/dist-packages/sentry/tsdb/redis.py", line 239, in incr_multi
client.hincrby(hash_key, hash_field, count)
File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 1865, in hincrby
return self.execute_command('HINCRBY', name, key, amount)
File "/usr/local/lib/python2.7/dist-packages/rb/clients.py", line 333, in execute_command
buf = self._get_command_buffer(host_id, args[0])
File "/usr/local/lib/python2.7/dist-packages/rb/clients.py", line 351, in _get_command_buffer
buf = CommandBuffer(host_id, connect, self.auto_batch)
File "/usr/local/lib/python2.7/dist-packages/rb/clients.py", line 90, in __init__
self.connect()
File "/usr/local/lib/python2.7/dist-packages/rb/clients.py", line 109, in connect
self.connection.connect()
File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 442, in connect
raise ConnectionError(self._error_message(e))
ConnectionError: Error 111 connecting to 127.0.0.1:6379. Connection refused.
12:21:31 [ERROR] sentry.errors: Unable to incr internal metric
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/sentry/utils/metrics.py", line 64, in worker
tsdb.incr(tsdb.models.internal, full_key, count=amount)
File "/usr/local/lib/python2.7/dist-packages/sentry/utils/services.py", line 91, in <lambda>
context[key] = (lambda f: lambda *a, **k: getattr(self, f)(*a, **k))(key)
File "/usr/local/lib/python2.7/dist-packages/sentry/tsdb/redis.py", line 214, in incr
self.incr_multi([(model, key)], timestamp, count, environment_id)
File "/usr/local/lib/python2.7/dist-packages/sentry/tsdb/redis.py", line 239, in incr_multi
client.hincrby(hash_key, hash_field, count)
File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 1865, in hincrby
return self.execute_command('HINCRBY', name, key, amount)
File "/usr/local/lib/python2.7/dist-packages/rb/clients.py", line 333, in execute_command
buf = self._get_command_buffer(host_id, args[0])
File "/usr/local/lib/python2.7/dist-packages/rb/clients.py", line 351, in _get_command_buffer
buf = CommandBuffer(host_id, connect, self.auto_batch)
File "/usr/local/lib/python2.7/dist-packages/rb/clients.py", line 90, in __init__
self.connect()
File "/usr/local/lib/python2.7/dist-packages/rb/clients.py", line 109, in connect
self.connection.connect()
File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 442, in connect
raise ConnectionError(self._error_message(e))
ConnectionError: Error 111 connecting to 127.0.0.1:6379. Connection refused.
12:21:31 [ERROR] sentry.errors: Unable to incr internal metric
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/raven/base.py", line 274, in handle_exception
self.captureException(exc_info=exc_info, level='fatal')
File "/usr/local/lib/python2.7/dist-packages/raven/base.py", line 814, in captureException
'raven.events.Exception', exc_info=exc_info, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/sentry/utils/raven.py", line 46, in capture
return super(SentryInternalClient, self).capture(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/raven/contrib/django/client.py", line 297, in capture
result = super(DjangoClient, self).capture(event_type, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/raven/base.py", line 641, in capture
self.send(**data)
File "/usr/local/lib/python2.7/dist-packages/sentry/utils/raven.py", line 75, in send
key = ProjectKey.get_default(settings.SENTRY_PROJECT)
File "/usr/local/lib/python2.7/dist-packages/sentry/models/projectkey.py", line 121, in get_default
)[0]
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 132, in __getitem__
return list(qs)[0]
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 96, in __iter__
self._fetch_all()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 857, in _fetch_all
self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 220, in iterator
for row in compiler.results_iter():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 713, in results_iter
for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 785, in execute_sql
cursor = self.connection.cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 162, in cursor
cursor = util.CursorWrapper(self._cursor(), self)
File "/usr/local/lib/python2.7/dist-packages/sentry/db/postgres/decorators.py", line 44, in inner
return func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/sentry/db/postgres/base.py", line 84, in _cursor
cursor = super(DatabaseWrapper, self)._cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 132, in _cursor
self.ensure_connection()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 115, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py", line 115, in get_new_connection
return Database.connect(**conn_params)
File "/usr/local/lib/python2.7/dist-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Original exception was:
Traceback (most recent call last):
File "/usr/local/bin/sentry", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/sentry/runner/__init__.py", line 162, in main
cli(prog_name=get_prog(), obj={}, max_content_width=100)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/sentry/runner/decorators.py", line 35, in inner
configure()
File "/usr/local/lib/python2.7/dist-packages/sentry/runner/__init__.py", line 125, in configure
configure(ctx, py, yaml, skip_service_validation)
File "/usr/local/lib/python2.7/dist-packages/sentry/runner/settings.py", line 152, in configure
skip_service_validation=skip_service_validation
File "/usr/local/lib/python2.7/dist-packages/sentry/runner/initializer.py", line 321, in initialize_app
setup_services(validate=not skip_service_validation)
File "/usr/local/lib/python2.7/dist-packages/sentry/runner/initializer.py", line 344, in setup_services
service.validate()
File "/usr/local/lib/python2.7/dist-packages/sentry/utils/services.py", line 91, in <lambda>
context[key] = (lambda f: lambda *a, **k: getattr(self, f)(*a, **k))(key)
File "/usr/local/lib/python2.7/dist-packages/sentry/buffer/redis.py", line 71, in validate
raise InvalidConfiguration(six.text_type(e))
sentry.exceptions.InvalidConfiguration: Error 111 connecting to 127.0.0.1:6379. Connection refused.
我没有更改这些文件config.yml
和sentry.conf.py
的内容,除了config.yml中的mail.backend: 'dummy'
这是sentry.conf.py的内容
import os.path
CONF_ROOT = os.path.dirname(__file__)
DATABASES = {
'default': {
'ENGINE': 'sentry.db.postgres',
'NAME': 'sentry',
'USER': 'postgres',
'PASSWORD': '',
'HOST': '',
'PORT': '',
'AUTOCOMMIT': True,
'ATOMIC_REQUESTS': False,
}
}
SENTRY_USE_BIG_INTS = True
SENTRY_SINGLE_ORGANIZATION = True
DEBUG = False
SENTRY_CACHE = 'sentry.cache.redis.RedisCache'
BROKER_URL = 'redis://localhost:6379'
SENTRY_RATELIMITER = 'sentry.ratelimits.redis.RedisRateLimiter'
SENTRY_BUFFER = 'sentry.buffer.redis.RedisBuffer'
SENTRY_QUOTAS = 'sentry.quotas.redis.RedisQuota'
SENTRY_TSDB = 'sentry.tsdb.redis.RedisTSDB'
SENTRY_DIGESTS = 'sentry.digests.backends.redis.RedisBackend'
SENTRY_WEB_HOST = '0.0.0.0'
SENTRY_WEB_PORT = 9000
SENTRY_WEB_OPTIONS = {
}
配置.yml
mail.backend: 'dummy' # Use dummy if you want to disable email entirely
system.secret-key: 'iur********************'
redis.clusters:
default:
hosts:
0:
host: 127.0.0.1
port: 6379
filestore.backend: 'filesystem'
filestore.options:
location: '/tmp/sentry-files'
为了简化起见,我从两个文件中删除了注释部分。导致此异常的原因可能是什么?
我是 Sentry 的初学者,我也不熟悉 postgresql
最佳答案
我曾经遇到过这个问题。原因是您的Redis 服务器未在后台运行。默认情况下,Redis 不作为守护进程运行。 从 Redis 2.6 开始,可以直接使用命令行传递 Redis 配置参数。这对于测试目的非常有用。
- 如果您想要快速选择,请运行:
redis-server --daemonize yes
检查进程是否启动:
ps aux | grep redis-server
- 还有一些其他方法可以更改 Redis 服务器的配置。在 Redis conf 文件中将 daemonize 设置为 yes。在
/path/to/redis.conf
的 Redis conf 文件中设置 daemonize yes 通常应该位于/etc/
然后以conf文件作为参数触发redis-server:
./redis-server/etc/redis.conf
关于java - Sentry:sentry.exceptions.InvalidConfiguration:连接到 127.0.0.1:6379 时出现错误 111。连接被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54314320/