I am trying to deploy Adonisjs 5 API using on Digital Ocean. I encountered an error relating to .env. Below is the code bbase of the error.
gmh#ubuntu-gmh:~/www/gmh-api$ cd build
gmh#ubuntu-gmh:~/www/gmh-api/build$ node ace migration:run --force
Exception
E_MISSING_ENV_VALUE: Missing environment variable "DB_CONNECTION"
gmh#ubuntu-gmh:~/www/gmh-api/build$
I have DB_CONNECTION declared in .env file
PORT=3333
HOST=127.0.0.1
NODE_ENV=production
DRIVE_DISK=local
DB_CONNECTION=mysql
Below is the database configuration code:
connection: Env.get('DB_CONNECTION'),
connections: {
/*
|--------------------------------------------------------------------------
| MySQL config
|--------------------------------------------------------------------------
|
| Configuration for MySQL database. Make sure to install the driver
| from npm when using this connection
|
| npm i mysql2
|
*/
mysql: {
client: 'mysql2',
connection: {
host: Env.get('MYSQL_HOST'),
port: Env.get('MYSQL_PORT'),
user: Env.get('MYSQL_USER'),
password: Env.get('MYSQL_PASSWORD', ''),
database: Env.get('MYSQL_DB_NAME'),
},
n/b: mysql is installed on the nginx server on Digital Ocean
Pls guys, an helpfull insight is welcome.
I tried running:
node ace migration:run --force
inside the build folder root, afterwhich i got:
Exception
E_MISSING_ENV_VALUE: Missing environment variable "DB_CONNECTION"
Move to the root directory of your project and run your migration command:
node ace migration:run --force
If you encounter this error:
create table `adonis_schema_versions` (`version` int not null) - Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set.
Visit this answer in this link.
Related
I'm trying to install FIWARE Orion on AKS using your Helm chart. I installed MongoDB using
helm repo add azure-marketplace https://marketplace.azurecr.io/helm/v1/repo
helm install my-release azure-marketplace/mongodb
Consequently I configured the MongoDB in values.yaml as follows:
## database configuration
db:
# -- configuration of the mongo-db hosts. if multiple hosts are inserted, its assumed that mongo is running as a replica set
hosts: [my-release-mongodb]
# - my-release-mongodb
# -- the db to use. if running in multiservice mode, its used as a prefix.
name: orion
# -- Database authentication (not needed if MongoDB doesn't use --auth)
auth:
# --user for connecting mongo
user: root
# -- password to be used on mongo
password: mypasswd
# -- the MongoDB authentication mechanism to use in the case user and password is set
#mech: SCRAM-SHA-1
I use the command : helm install test orion
As I see this error in the pod logging I suppose something is wrong;
kubectl logs test-orion-7dfcc9c7fb-8vbgw
time=2021-05-28T19:50:29.737Z | lvl=ERROR | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=mongocContextCachePersist.cpp[59]:mongocContextCachePersist | msg=Database Error (persisting context: command insert requires authentication)
Can you help me with this please?
Kind regards,
Johan,
you should assure that mongo-db is actually available at "my-release-mongodb:27017", you can use "kubectl get services" for that. Beside that, assure that "root:mypasswd" are actually the credentials setup at mongodb.
I'm learning how to work with Docker and Minikube on a Windows 10 Home computer. I've installed the needed software OK. I've installed Docker, minikube, kubectl, and a recent version of MySQL, properly pathed so its CLI can be used. I'm using either the Bash console provided by GIT, and/or the Bash console provided by Cygwin. Both seem to provide the same (bad) results.
I start Docker, and install the MySQL service. The kubectl get all shows everything running OK.
Per the programming book I'm working through, I want to try accessing MySQL through this command:
mysql -h $(minikube service mysql-svc --format "{{.IP}}") -P $(minikube service mysql-svc --format "{{.Port}}") -u root -p
The result should be the MySQL CLI prompt, like mysql> . Instead I get this behavior:
A popup window stating "Windows cannot find '192.168.99.101'. Make sure you typed the name correctly, and then try again."
The console text:
The system cannot find the file 192.168.99.101.
*
X open url failed: 192.168.99.101: exit status 1
*
* minikube is exiting due to an error. If the above message is not useful, open an issue:
- (URL for sending an error message)
A popup window stating "Windows cannot find '31067'. Make sure you typed the name correctly, and then try again."
The console text:
mysql: [ERROR] Unknown suffix '|' used for variable 'port' (value (gives the border fence that surrounds the output from minikube service mysql-svc .)
mysql: [ERROR] (path to mysql.exe): Error while setting value '|-----|--- (etc)' to 'port'
The expected behavior is to insert an IP and Port into the mysql command line, then firing a command like mysql -h http://192.168.99.101 -P 31067 -u root -p .
I think that the problem is with the using the Bash console in a Windows environment. Any explanation is appreciated.
Thanks,
Jerome.
UPDATE ON 8/7/2020:
I'm asked to more thoroughly document my issue. Here we go.
Here is what Docker knows:
$ docker images
REPOSITORY TAG
IMAGE ID CREATED SIZE
logicaltiger/cloudnative-statelessness-posts latest
3a3c66daf7f3 5 days ago 139MB
logicaltiger/cloudnative-statelessness-connections latest
d060e9857f49 5 days ago 139MB
logicaltiger/cloudnative-statelessness-connectionposts-stateful latest
ce33f0966380 5 days ago 123MB
openjdk 8-jdk-alpine
a3562aa0b991 15 months ago 105MB
mysql 8.0.12
ee1e8adfcefb 22 months ago 484MB
Here is my reconfiguring of minikube. Other posters suggested that minikube runs iffy unless given a lot of resources.
$ minikube delete
* Deleting "minikube" in virtualbox ...
* Removed all traces of the "minikube" cluster.
$ minikube start --cpus=4 --memory=4096
* minikube v1.12.1 on Microsoft Windows 10 Home 10.0.18363 Build 18363
* Automatically selected the virtualbox driver
* Starting control plane node minikube in cluster minikube
* Creating virtualbox VM (CPUs=4, Memory=4096MB, Disk=20000MB) ...
* Found network options:
- NO_PROXY=192.168.99.100
- no_proxy=192.168.99.100
* Preparing Kubernetes v1.18.3 on Docker 19.03.12 ...
- env NO_PROXY=192.168.99.100
* Verifying Kubernetes components...
* Enabled addons: default-storageclass, storage-provisioner
* Done! kubectl is now configured to use "minikube"
After starting mysql from its yaml file I have it running:
$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/mysql-7dbfd4dbc4-b2tmm 1/1 Running 0 2m55s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) A
GE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 6
m43s
service/mysql-svc NodePort 10.102.7.119 <none> 3306:32235/TCP 2
m55s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/mysql 1/1 1 1 2m55s
NAME DESIRED CURRENT READY AGE
replicaset.apps/mysql-7dbfd4dbc4 1 1 1 2m55s
Now get the mysql-svc URL:
$ minikube service mysql-svc --url
http://192.168.99.102:32235
Try to run the book example. Again I get the two popup windows and what is shown below in the terminal. I omit the popup window text here...
$ mysql -h $(minikube service mysql-svc --format "{{.IP}}") -P $(minikube service mysql-svc --format "{{.Port}}") -u root -p
The system cannot find the file 192.168.99.102.
*
X open url failed: 192.168.99.102: exit status 1
*
* minikube is exiting due to an error. If the above message is not useful, open
an issue:
- https://github.com/kubernetes/minikube/issues/new/choose
The system cannot find the file 32235.
*
X open url failed: 32235: exit status 1
*
* minikube is exiting due to an error. If the above message is not useful, open
an issue:
- https://github.com/kubernetes/minikube/issues/new/choose
mysql: [ERROR] Unknown suffix '|' used for variable 'port' (value '|-----------|
-----------|-------------|-------|')
mysql: [ERROR] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe: Error whil
e setting value '|-----------|-----------|-------------|-------|' to 'port'
I'm asked what happens if I put in the IP directly. From above, that IP was http://192.168.99.102:32235
$ mysql -h http://192.168.99.102 -P 32235 -u root -p
Enter password: **********
ERROR 2005 (HY000): Unknown MySQL server host 'http://192.168.99.102' (0)
When directly entering the IP and Port, the MySQL server IS reached (see the "Enter password:" prompt) but the request is refused. I'm thinking that I don't know how to make MySQL use the HTTP request.
But is the MySQL not knowing what to do with the IP, and the way that the indirect method (minikube service mysql -svc ...), related?
Continuing, I edit my cookbook-deployment-posts.yaml file with the MySQL address:
kind: Service
apiVersion: v1
metadata:
name: posts-svc
spec:
selector:
app: posts
ports:
- protocol: "TCP"
port: 80
targetPort: 8080
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: posts
labels:
app: posts
spec:
replicas: 1
selector:
matchLabels:
app: posts
template:
metadata:
labels:
app: posts
spec:
containers:
- name: posts
image: cdavisafc/cloudnative-statelessness-posts
env:
- name: INSTANCE_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: PORT
value: "8080"
- name: SPRING_APPLICATION_JSON
value: '{"spring":{"datasource":{"url":"jdbc:mysql://192.168.99.102:32235/cookbook"}}}'
Going to kubectl get all, the posts-svc continually starts, errors out and reboots. Don't know what is wrong...
Jerome.
I now see a number of things going wrong.
First, I keep thinking that the mysql call is somehow related to the MySQL installed on my PC. It never is. Just because I manually create a cookbook database on my PC instance doesn't mean that the textbook example thru Docker / Minikube ever references it.
Second, the textbook is missing the --url from its minikube requests. Here is what is happening.
> kubectl create -f mysql-deployment.yaml
> minikube service mysql-svc --url
http://192.168.99.102:31030
> minikube service mysql-svc
This opens the web browser to show the service at 192.168.99.102:31030. The mysql service doesn't render a web page, but that doesn't matter to this example. The console then shows the details of the service (namespace, name, target port, url) in an ASCII box.
minikube service mysql-svc --format "{{.IP}}"
This wants to open the web browser to show the service at http://192.168.99.102, with an implied port of 80. But there is nothing there, and Windows complains at a popup box. The console then complains about not opening that url.
minikube service mysql-svc --format "{{.Port}}"
This wants to open the web browser to show the service at 31030, which isn't a valid URL. Complaints, complaints.
What I really wanted all along is to add the --url to the minikube bits:
mysql -h $(minikube service mysql-svc --format "{{.IP}}" --url) -P $(minikube service mysql-svc --format "{{.Port}}" --url) -u root -p
This connects to the managed mysql in the console, yielding the mysql> prompt. Now I can run 'create database cookbook;'.
Solved!
I am running a compose file which is installing mysql in the container and initialized the db. I can enter into the container and see the tables which are created.
But when I try to login to MySQL DB using SQLyog, can't connect this time. I was using the public IP of my ec2 instance. In the failed case I was using port 3308 of the host machine. If I use the default port(3306) then it gets connected !!! But in port 3306, I need to run another MySQL server. So to run in port 3308 of the host machine, what to do from my side?
This is my compose file:
cat docker-compose.yml
version: '3'
volumes:
failed_db_data: {}
services:
faileddb:
build:
context: .
dockerfile: ./faileddb/Dockerfile
args:
- database=${FAILED_DB}
- password=${FAILED_DB_PASSWORD}
image: failed_db_image
volumes:
- failed_db_data:/var/lib/mysql
ports:
- "3308:3308"
This is the Dockerfile:
cat faileddb/Dockerfile
FROM mysql:5.7.15
ARG database
ARG password
MAINTAINER me
ENV MYSQL_DATABASE=${database} \
MYSQL_ROOT_PASSWORD=${password}
ADD ./faileddb/failed100.sql /docker-entrypoint-initdb.d
EXPOSE 3308
This is .env file
cat .env
#FAILED_DB
FAILED_DB_PORT=3308
FAILED_DB=failed
FAILED_DB_USER=root
FAILED_DB_PASSWORD=123
This is my tree command, from where the compose file exists:
tree -a
.
├── .env
├── docker-compose.yml
└── faileddb
├── Dockerfile
└── failed100.sql
1 directory, 4 files
Now, I am building it:
docker-compose up -d
Creating network "reve_default" with the default driver
Creating volume "reve_failed_db_data" with default driver
Building faileddb
Step 1/7 : FROM mysql:5.7.15
5.7.15: Pulling from library/mysql
6a5a5368e0c2: Pull complete
0689904e86f0: Pull complete
486087a8071d: Pull complete
3eff318f6785: Pull complete
3df41d8a4cfb: Pull complete
1b4a00485931: Pull complete
0bab0b2c2630: Pull complete
264fc9ce512d: Pull complete
e0181dcdbbe8: Pull complete
53b082fa47c7: Pull complete
e5cf4fe00c4c: Pull complete
Digest: sha256:966490bda4576655dc940923c4883db68cca0b3607920be5efff7514e0379aa7
Status: Downloaded newer image for mysql:5.7.15
---> 18f13d72f7f0
Step 2/7 : ARG database
---> Running in 3d0dedd7e51f
Removing intermediate container 3d0dedd7e51f
---> bf054f294f4b
Step 3/7 : ARG password
---> Running in 0f09ff73a201
Removing intermediate container 0f09ff73a201
---> 9948007a0fc0
Step 4/7 : MAINTAINER me
---> Running in 4b11b4bba056
Removing intermediate container 4b11b4bba056
---> be09d8a1ad2a
Step 5/7 : ENV MYSQL_DATABASE=${database} MYSQL_ROOT_PASSWORD=${password}
---> Running in 0ad7701bc7d4
Removing intermediate container 0ad7701bc7d4
---> 9c28be0c1367
Step 6/7 : ADD ./faileddb/failed100.sql /docker-entrypoint-initdb.d
---> d8ab45637fca
Step 7/7 : EXPOSE 3308
---> Running in f3eda2d36bbe
Removing intermediate container f3eda2d36bbe
---> 4b16e6a06593
Successfully built 4b16e6a06593
Successfully tagged failed_db_image:latest
WARNING: Image for service faileddb was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating reve_faileddb_1 ... done
Checking if it is running fine:
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
217acd44a1df failed_db_image "docker-entrypoint.s…" 8 seconds ago Up 7 seconds 3306/tcp, 0.0.0.0:3308->3308/tcp reve_faileddb_1
entered into the container now:
docker exec -it 217acd44a1df bash
entered in MySQL and checked if tables are ok, found those okay as well.
mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.15 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| failed |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> use failed;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
Now I am trying to login using SQLyog(from my windows machine using public IP of ec2 instance):
What am I missing here? Thanks in advance.
Port forwarding was wrong. It should be
3308:3306
instead of
3308:3308
I am trying to configure the CircleCi setup.
When I try to run the tests in my own environment then everything works out, but when I try to run it in Circle CI, then I haave got this error.
PHPUnit 5.6.0 by Sebastian Bergmann and contributors.
IIIII.IIIIIIIIIIIIIIIIIIIIIIIIIIIIIFFFFFFFFFFFFIIII..IIIIIIIIIIII 65 / 89 ( 73%)
IIIIIIIIIIIIIIIIIIIIIII. 89 / 89 (100%)
Time: 1.27 seconds, Memory: 56.00MB
There were 12 failures:
1) App\Test\TestCase\Controller\TagsControllerTest::testStages
exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in /home/ubuntu/cemcloud2/vendor/cakephp/cakephp/src/Database/Driver/PDODriverTrait.php:48
This is the first part of the error.
I am getting that I have an error with my database configuration.
We are using Vagrant with the script (not sure if this is viable).
Also we are using mariaDB 10.1.19 and I have built up a test database for PHPUnit to run the tests against.
I don't know how to add this database with the configuration of mariadb and specific database.
I know that I have to add the
database.yml.ci
to my config file so I have added it in there and it looks like this.
test:
adapter: mysql
database: cemcloudTest
username: root
password: ''
Also I have added the circle.yml to our project root and it looks like this.
machine:
php:
version: 7.0
mysql:
version: 10.1.19
database:
override:
- cp config/database.yml.ci config/database.yml
- bundle exec rake db:create db:schema:load
Could someone help me out ?
in your cicle.yml database have to be created with name you use in your test config.
database:
override:
- mysql -u ubuntu -e "create database circle_ruby_test"
So that, this is the db conf:
test: # connection name
adapter: mysql2
encoding: utf8
reconnect: false
host: localhost
database: circle_ruby_test #your created DB
username: ubuntu #default circle user
pool: 25
socket: /var/run/mysqld/mysqld.sock # default sock location for circle
HTH:)
I have been trying Windows Containers on windows server 2016 TP5. Suddenly I started getting error while running a container with port maping option -p 80:80
c:\>docker run -it -p 80:80 microsoft/iis cmd
docker: Error response from daemon: failed to create endpoint sharp_brahmagupta on network nat: HNS failed with error : Failed to create endpoint.
I made sure that no other container is running and port 80 on host machine is not being used by any other service.
Did anyone face same issue?
After searching around I stunbled upon this issue on github. This seemed to be a known issue with Windows containers on Windows server TP5.
Then thanks to this forum, I found the solution
You can check active static port mapping with below command
C:\>powershell
PS C:\>Get-NetNatStaticMapping
StaticMappingID : 3
NatName : Hda6caca4-06ec-4251-8a98-1fe0b4c5af88
Protocol : TCP
RemoteExternalIPAddressPrefix : 0.0.0.0/0
ExternalIPAddress : 0.0.0.0
ExternalPort : 80
InternalIPAddress : 172.31.181.4
InternalPort : 80
InternalRoutingDomainId : {00000000-0000-0000-0000-000000000000}
Active : True
From above output it seemed that even though container was removed the static port mapping was not removed and was still active.
But I removed it with below command.
PS C:\> Get-NetNatStaticMapping | ? ExternalPort -eq 80 | Remove-NetNatStaticMapping
Then simply rebooted the system and the error was gone.
For me these steps solved the problem:
Stop-Service docker
Get-ContainerNetwork | Remove-ContainerNetwork
Get-NetNat | Remove-NetNat
Get-VMSwitch | Remove-VMSwitch
Start-Service docker
(suggested by JMesser81 at:https://github.com/Microsoft/Virtualization-Documentation/issues/273)
I had similar error.
$ docker --version
Docker version 1.13.0-rc3, build 4d92237
$ docker-compose -f .\docker-compose.windows.yml up
Starting musicstore_db_1
ERROR: for db Cannot start service db: {"message":"failed to create endpoint musicstore_db_1 on network nat: HNS failed with error : Unspecified error"}
ERROR: Encountered errors while bringing up the project.
Static mapping removal did not work, only network removal helped:
Get-ContainerNetwork -Name nat | Remove-ContainerNetwork
Execute the command in PowerShell as administrator, then restart Docker.
Update:
Use CleanupContainerHostNetworking.ps1 script to resolve Docker 17 networking issues.
.\CleanupContainerHostNetworking.ps1 -Cleanup -ForceDeleteAllSwitches
I had a docker and docker-compose which were already working on Centos.
I did the following changes to make it work on windows server 2016:
Stop the docker service, remove nat, start the docker service.
ps>stop-service docker
ps>Get-ContainerNetwork | Remove-ContainerNetwork -Force -ea SilentlyContinue
ps>start-service docker
Configure network in your docker-compose.yml
version: '3.7'
networks:
default:
external:
name: nat
That's It!