This is my configuration for the database:
config :hello, Hello.Repo,
username: "postgres",
password: "admin",
hostname: "localhost",
database: "hello_dev_postgres",
show_sensitive_data_on_connection_error: true,
pool_size: 10
config :hello, Hello.MRepo,
adapter: Tds.Ecto,
username: "sa",
password: "server",
hostname: "localhost",
instance: "SERVER",
port: 1433,
database: "hello_dev_mssql",
show_sensitive_data_on_connection_error: true,
pool_size: 10
And this is my two repo:
defmodule Hello.MRepo do
use Ecto.Repo,
otp_app: :hello,
adapter: Ecto.Adapters.Tds
end
defmodule Hello.Repo do
use Ecto.Repo,
otp_app: :hello,
adapter: Ecto.Adapters.Postgres
end
When I run mix ecto.create, I get this error:
16:37:43.867 [error] GenServer #PID<0.309.0> terminating
** (Tds.Error) tcp connect: econnrefused
(db_connection 2.4.2) lib/db_connection/connection.ex:100: DBConnection.Connection.connect/2
(connection 1.1.0) lib/connection.ex:622: Connection.enter_connect/5
(stdlib 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
State: Tds.Protocol
(Mix) The database for Hello.MRepo couldn't be created: killed
Have you enabled TCP in your database configuration file?
There is a similar post on the elixirforum where someone had the same problem as you and enabling TCP in one of the configuration file helped them.
Related
I'd like to use CockroachDB Serverless for my Ecto application. How do I specify the connection string?
I get an error like this when trying to connect.
[error] GenServer #PID<0.295.0> terminating
** (Postgrex.Error) FATAL 08004 (sqlserver_rejected_establishment_of_sqlconnection) codeParamsRoutingFailed: missing cluster name in connection string
(db_connection 2.4.1) lib/db_connection/connection.ex:100: DBConnection.Connection.connect/2
CockroachDB Serverless says to connect by including the cluster name in the connection string, like this:
postgresql://username:<ENTER-PASSWORD>#free-tier.gcp-us-central1.cockroachlabs.cloud:26257/defaultdb?sslmode=verify-full&sslrootcert=$HOME/.postgresql/root.crt&options=--cluster%3Dcluster-name-1234
but I'm not sure how to get Ecto to create this connection string via its configuration.
The problem is that Postgrex is not able to parse all of the information from the connection URL - notable the SSL configuration. The solution is to specify the connection parameters explicitly, including the cacertfile SSL option. Assuming that you have downloaded your cluster's CA certificate to priv/certs/ca-cert.crt, you can use the following config as a template:
config :my_app, MyApp.Repo,
username: "my_user",
password: "my_password",
database: "defaultdb",
hostname: "free-tier.gcp-us-central1.cockroachlabs.cloud",
port: "26257",
ssl: true,
ssl_opts: [
cacertfile: Path.expand("priv/certs/ca-cert.crt"),
],
parameters: [options: "--cluster=my-cluster-123"]
Possible Other Issues
Table Locking
Since that CockroachDB also does not support the locking that Ecto/Postgrex attempts on the migration table, the :migration_lock config needs to be disabled as well:
config :my_app, MyApp.Repo,
# ...
migration_lock: false
Auth generator
Finally, the new phx.gen.auth generator defaults to using the citext extension for storing a user's email address in a case-insensitive manner. The line in the generated migration that executes CREATE EXTENSION IF NOT EXISTS citext should be removed, and the column type for the :email field should be changed from :citext to :string.
This configuration allows Ecto to connect to CockroachDB Serverless correctly:
config :myapp, MyApp.repo,
username: "username",
password: "xxxx",
database: "defaultdb",
hostname: "free-tier.gcp-us-central1.cockroachlabs.cloud",
port: 26257,
ssl: true,
ssl_opts: [
cert_pem: "foo.pem",
key_pem: "bar.pem"
],
show_sensitive_data_on_connection_error: true,
pool_size: 10,
parameters: [
options: "--cluster=cluster-name-1234"
]
By following the documentation steps, I wasn't able to activate Zipkin Receiver in apache-skywalking-apm-bin-es7-8.7.0
my application.yml is
cluster:
selector: ${SW_CLUSTER:standalone}
...
storage:
selector: ${SW_STORAGE:zipkin-elasticsearch7}
...
zipkin-elasticsearch7:
nameSpace: ${SW_NAMESPACE:""}
clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200}
protocol: ${SW_STORAGE_ES_HTTP_PROTOCOL:"http"}
trustStorePath: ${SW_STORAGE_ES_SSL_JKS_PATH:""}
trustStorePass: ${SW_STORAGE_ES_SSL_JKS_PASS:""}
dayStep: ${SW_STORAGE_DAY_STEP:1}
indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:1}
indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:1}
superDatasetDayStep: ${SW_SUPERDATASET_STORAGE_DAY_STEP:-1}
superDatasetIndexShardsFactor: ${SW_STORAGE_ES_SUPER_DATASET_INDEX_SHARDS_FACTOR:5}
superDatasetIndexReplicasNumber: ${SW_STORAGE_ES_SUPER_DATASET_INDEX_REPLICAS_NUMBER:0}
user: ${SW_ES_USER:""}
password: ${SW_ES_PASSWORD:""}
secretsManagementFile: ${SW_ES_SECRETS_MANAGEMENT_FILE:""}
bulkActions: ${SW_STORAGE_ES_BULK_ACTIONS:5000}
flushInterval: ${SW_STORAGE_ES_FLUSH_INTERVAL:15}
concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2}
resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000}
metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
profileTaskQueryMaxSize: ${SW_STORAGE_ES_QUERY_PROFILE_TASK_SIZE:200}
oapAnalyzer: ${SW_STORAGE_ES_OAP_ANALYZER:"{\"analyzer\":{\"oap_analyzer\":{\"type\":\"stop\"}}}"}
oapLogAnalyzer: ${SW_STORAGE_ES_OAP_LOG_ANALYZER:"{\"analyzer\":{\"oap_log_analyzer\":{\"type\":\"standard\"}}}"}
advanced: ${SW_STORAGE_ES_ADVANCED:""}
...
receiver_zipkin:
selector: ${SW_RECEIVER_ZIPKIN:-}
default:
host: ${SW_RECEIVER_ZIPKIN_HOST:0.0.0.0}
port: ${SW_RECEIVER_ZIPKIN_PORT:9411}
contextPath: ${SW_RECEIVER_ZIPKIN_CONTEXT_PATH:/}
jettyMinThreads: ${SW_RECEIVER_ZIPKIN_JETTY_MIN_THREADS:1}
jettyMaxThreads: ${SW_RECEIVER_ZIPKIN_JETTY_MAX_THREADS:200}
jettyIdleTimeOut: ${SW_RECEIVER_ZIPKIN_JETTY_IDLE_TIMEOUT:30000}
jettyAcceptorPriorityDelta: ${SW_RECEIVER_ZIPKIN_JETTY_DELTA:0}
jettyAcceptQueueSize: ${SW_RECEIVER_ZIPKIN_QUEUE_SIZE:0}
instanceNameRule: ${SW_RECEIVER_ZIPKIN_INSTANCE_NAME_RULE:[spring.instance_id,node_id]}
Started with
./bin/startup.sh
ports 11800 12900 are listed as listening
ui is working
port 9411 is not listed as listening
You should set SW_RECEIVER_ZIPKIN= default through the system environment, or change the application.yml about selector: ${SW_RECEIVER_ZIPKIN:default}
You should follow the Level 2 instruction in the backend set up doc, https://skywalking.apache.org/docs/main/v8.7.0/en/setup/backend/backend-setup/#applicationyml
i tried to connect a postgresdatabase in my grails 3.3.9 project;
My posgrest server is working, since I can connect and operate on the posgres database from Intelli J 2021 databse, but I can't connect to grails 3.3.9.
The password and user are correct but it always throws me this error:
Running application...
2021-07-05 19:06:25.298 ERROR --- [ main] org.postgresql.Driver : Connection error:
org.postgresql.util.PSQLException: El servidor requiere autenticación basada en contraseña, pero no se ha provisto ninguna contraseña.
And this mi Application.yml
hibernate:
cache:
queries: false
use_second_level_cache: false
use_query_cache: false
dataSource:
IkebanaUsuarios:
pooled: true
jmxExport: true
driverClassName: "org.postgresql.Driver"
username: "postgres"
password: "postgres"
environments:
development:
dataSource:
dbCreate: update
url: jdbc:postgresql://localhost:5432/IkebanaERP
test:
dataSource:
dbCreate: update
url: jdbc:postgresql://localhost:5432/IkebanaERP
production:
dataSource:
dbCreate: update
url: jdbc:postgresql://localhost:5432/IkebanaERP
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
and my build.graddle is this
.......
compile "org.grails.plugins:cache"
compile "org.grails.plugins:async"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:events"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.1.16.Final"
compile "org.grails.plugins:gsp"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "org.glassfish.web:el-impl:2.1.2-b03"
runtime "com.h2database:h2"
runtime "org.apache.tomcat:tomcat-jdbc"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.15.1"
runtime 'org.xerial:sqlite-jdbc:3.6.17'
runtime 'org.postgresql:postgresql:9.4.1208.jre1.8'
runtime 'mysql:mysql-connector-java:5.1.29'
runtime 'org.postgresql:postgresql:42.2.1.jre7'
testCompile "org.grails:grails-gorm-testing-support"
testCompile "org.grails.plugins:geb"
testCompile "org.grails:grails-web-testing-support"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}
Help pleases; thanks a lot
You are defining properties for your IkebanaUsuarios dataSource, but not for the default one used by Grails.
You may remove the IkebanaUsuarios block, leaving this:
dataSource:
pooled: true
jmxExport: true
driverClassName: "org.postgresql.Driver"
username: "postgres"
password: "postgres"
Or, if you needed that secondary datasource as well, you may define properties for both. I'm guessing you did not need it, since you did not mention intentionally having two.
I have users in active directory LDAP (each have a username and email set).
I configured LDAP authentication in gitlab.rb and ran "gitlab-ctl reconfigure".
I user Gitlab Community Edition.
The following command returns the users so configuration seems ok "sudo gitlab-rake gitlab:ldap:check".
Returns :
LDAP: ... Server: ldapmain
LDAP authentication... Success
LDAP users with access to your GitLab server (only showing the first 100 results)
DN: cn=Mike Gordon,cn=users,dc=ad,dc=mydomain,dc=com sAMAccountName: mike.gordon
... here other users
I'm trying to login with LDAP username mike.gordon and corresponding password on "Sign in" gitlab pane but i get "invalid username or password".
Some screenshots show that there is an LDAP pane but it's not displayed even with :
gitlab_rails['prevent_ldap_sign_in'] = false
this is my configuration :
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'LDAP'
host: 'myAdUrl'
port: 3268
uid: 'sAMAccountName'
bind_dn: 'CN=serveur-ovh,CN=Users,dc=ad,dc=mydomain,dc=com'
password: 'adpassword'
encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
active_directory: true
allow_username_or_email_login: false
base: 'dc=ad,dc=mydomain,dc=com'
user_filter: ''
#lowercase_usernames: false
#block_auto_created_users: false
#verify_certificates: true
#smartcard_auth: false
### EE only
Thank you very much in advance for you help.
Comparing your configuration to mine, I have a user_filter value
###! **remember to close this block with 'EOS' below**
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'LDAP'
host: 'ADHostname.example.com'
port: 636
uid: 'sAMAccountName'
method: 'ssl' # "tls" or "ssl" or "plain"
bind_dn: 'cn=UserID,ou=SystemAccounts,dc=example,dc=com'
password: 'AccountPasswordGoesHere'
active_directory: true
allow_username_or_email_login: false
block_auto_created_users: false
base: 'ou=ResourceUsers,dc=example,dc=com'
user_filter: '(&(sAMAccountName=*))' # Can add attribute value to restrict authorized users to GitLab access, we leave open to all valid user accounts in the OU. Should be able to authorize based on group membership using linked attribute value like (&(memberOf=cn=group,ou=groupOU,dc=example,dc=com))
attributes:
username: ['uid', 'userid', 'sAMAccountName']
email: ['mail', 'email', 'userPrincipalName']
name: 'cn'
first_name: 'givenName'
last_name: 'sn'
EOS
I've written an elixir application that connects to two different databases, and I have it working nicely in my remote database dev environment -- connecting with the same exact setup to a different database that is across my vpn. When I run it against a different remote SQL Server database, I get a strange error:
** (DBConnection.ConnectionError) bad return value: {:error, %Tds.Protocol{env: %{trans: <<0>>}, itcp: nil, opts: [password:
:REDACTED, idle_timeout: 5000, name: EventBridge.C3poRepo.Pool,
otp_app: :event_bridge, repo: EventBridge.C3poRepo, timeout: 15000,
pool_timeout: 5000, adapter: Tds.Ecto, username: :ALSO_REDACTED,
database: :REDACTED, hostname: :REDACTED, pool:
DBConnection.Poolboy], pak_data: "", pak_header: "", query:
%Tds.Query{handle: 1, statement: nil}, result: %Tds.Result{columns:
[], command: nil, num_rows: 0, rows: []}, sock: {:gen_tcp,
#Port<0.6472>}, state: :ready, tail: "", transaction: nil, usock: nil}}
The credentials I've got in my configuration for this database are correct--I verified them manually with DBeaver. I believe I'm capable of debugging this but I've run into a bit of that error message that I don't understand. Specifically:
{:error, %Tds.Protocol{env: %{trans: <<0>>}
For the sake of completeness, here the deps section in mix.exs:
defp deps do
[
{:tds_ecto, "~> 2.0.3"},
{:postgrex, ">= 0.0.0"},
{:gen_stage, "~> 0.12"},
{:timex, "~> 3.1"},
{:timex_ecto, "~> 3.0"},
{:poison, "~> 3.1"},
{:ecto, "~> 2.1"}
]
end
What I'm asking is for some insight into what that part of the error message means, or perhaps even some more general feedback on the entire error output.
Here are the two instances of configuration for the Repo in question. First the one that works:
config :event_bridge, EventBridge.FirstRepo,
adapter: Tds.Ecto,
database: "first_repo_development",
username: "testuser",
password: "password_redacted",
hostname: "server_one"
And here is the configuration for the one that doesn't work:
config :event_bridge, EventBridge.FirstRepo,
adapter: Tds.Ecto,
database: "first_repo_staging",
username: "staging_username",
password: "password_redacted",
hostname: "server_twelve"
Both work in DBeaver.
Add
pool_size:
in the db config and try again