Setting up lwm2m-node-lib to FIWARE platform - fiware

Having reached a stumbling block with my wakaama LWM2M implementation for couple of weeks, as I reported in #154 I have no option than to try using telefonica lwm2m-node-lib instead.
To make my point clear again, I have already IOTA, Orion, MongoDB, Cygnus all working fine. It is my client implementation that isn't sending measure to IOTA despite being able to connect. The scenario I want is LWM2M -> IOTA -> Orion -> Cygnus -> MongoDB.
My issue now: I want have a precise explanation of configuration I need to do to have lwm2m-node-lib implementation work here, for instance where to input the server IP to connect to (where my FIWARE is running), which file to edit etc. I already picked a new device to use, keeping aside the other.
My docker-compose file below:
version: "3.1"
services:
mongo:
image: mongo:3.4
hostname: mongo
container_name: fiware-mongo
ports:
- "27017:27017"
networks:
- default
command: --nojournal
orion:
image: fiware/orion
hostname: orion
container_name: fiware-orion
depends_on:
- mongo
networks:
- default
ports:
- "1026:1026"
expose:
- "1026"
command: -dbhost mongo -logLevel DEBUG
lightweightm2m-iotagent:
image: telefonicaiot/lightweightm2m-iotagent
hostname: idas
container_name: fiware-iotagent
depends_on:
- mongo
networks:
- default
expose:
- "4041"
- "5684"
ports:
- "4041:4041"
- "5684:5684/udp"
environment:
- "IOTA_CB_HOST=orion"
- "IOTA_CB_PORT=1026"
- "IOTA_NORTH_PORT=4041"
- "IOTA_REGISTRY_TYPE=mongodb"
- "IOTA_LOG_LEVEL=DEBUG"
- "IOTA_TIMESTAMP=true"
- "IOTA_MONGO_HOST=mongo"
- "IOTA_MONGO_PORT=27017"
- "IOTA_MONGO_DB=lwm2miotagent"
- "IOTA_HTTP_PORT=5684"
- "IOTA_PROVIDER_URL=http://lightweightm2m-iotagent:4041"
cygnus:
image: fiware/cygnus-ngsi:latest
hostname: cygnus
container_name: fiware-cygnus
depends_on:
- mongo
networks:
- default
expose:
- "5080"
ports:
- "5050:5050"
- "5080:5080"
environment:
- "CYGNUS_MONGO_HOSTS=mongo:27017"
- "CGYNUS_LOG_LEVEL_=DEBUG"
- "CYGNUS_SERVICE_PORT=5050"
- "CYGNUS_API_PORT=5080"

You can have a look to:
https://hub.docker.com/r/fiware/lightweightm2m-iotagent/
There you have a very good explanation in how to use the IOTA-LWM2M docker, along with configuration examples to run it with Orion.

Related

ERROR 2002 (HY000): Can't connect to MySQL server on 'db' (115)

I am trying to move existing project to Docker. I followed this tutorial at M.Academy and followed the setup instructions from Docker on Existing Project
While executing trying to connect with MySQL I am getting this error ERROR 2002 (HY000): Can't connect to MySQL server on 'db' (115)
I also tried to execute: telnet db 3306
Response:
Trying 172.17.0.1...
telnet: Unable to connect to remote host: Connection timed out
I tried everything but couldn't figure out the problem. I am new to Docker. I am using Ubuntu 18.04 LTE. Haven't changed db.env and got no error on any other step before importing the database.
I further checked and found out that the container is not able to establish connection with MySQL.
P.S. I am successfully able to connect with same MySQL service outside Docker container by using (external MySQL port) mysql -h 127.0.01 -u root -p -P 3306
Steps To Reproduce
Install Docker & Docker Compose on Ubuntu 18.04
Download the Docker Compose template: curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/template | bash
Replace with existing source code of your existing Magento instance: cp -R ~/Sites/existing src
Execute: docker-compose -f docker-compose.yml up -d
Copy files to container: bin/copytocontainer --all
Import existing database: bin/mysql < /var/www/magento243.sql
Expected Result
Database should have been successfully imported
Actual Result
ERROR 2002 (HY000): Can't connect to MySQL server on 'db' (115)
P.S. Issue has already been raised here: https://github.com/markshust/docker-magento/issues/589
docker-compose.yml
version: "3"
services:
app:
image: markoshust/magento-nginx:1.18-5
ports:
- "80:8000"
- "443:8443"
depends_on:
- "db"
volumes: &appvolumes
- ~/.composer:/var/www/.composer:cached
- ~/.ssh/id_rsa:/var/www/.ssh/id_rsa:cached
- ~/.ssh/known_hosts:/var/www/.ssh/known_hosts:cached
- appdata:/var/www/html
- sockdata:/sock
- ssldata:/etc/nginx/certs
extra_hosts: &appextrahosts
## M1 Mac support to fix Docker delay, see #566
- "app:172.17.0.1"
- "phpfpm:172.17.0.1"
- "db:172.17.0.1"
- "redis:172.17.0.1"
- "elasticsearch:172.17.0.1"
- "rabbitmq:172.17.0.1"
## Selenium support, replace "magento.test" with URL of your site
- "magento.test:172.17.0.1"
phpfpm:
image: markoshust/magento-php:7.4-fpm-11
volumes: *appvolumes
extra_hosts: *appextrahosts
env_file: env/phpfpm.env
db:
image: mariadb:10.4
command: --max_allowed_packet=256M
ports:
- "3306:3306"
env_file: env/db.env
volumes:
- dbdata:/var/lib/mysql
extra_hosts: *appextrahosts
redis:
image: redis:5.0-alpine
ports:
- "6379:6379"
extra_hosts: *appextrahosts
elasticsearch:
image: markoshust/magento-elasticsearch:7.9.3-1
ports:
- "9200:9200"
- "9300:9300"
environment:
- "discovery.type=single-node"
## Set custom heap size to avoid memory errors
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
## Avoid test failures due to small disks
## More info at https://github.com/markshust/docker-magento/issues/488
- "cluster.routing.allocation.disk.threshold_enabled=false"
- "index.blocks.read_only_allow_delete"
extra_hosts: *appextrahosts
rabbitmq:
image: rabbitmq:3.8.22-management-alpine
ports:
- "15672:15672"
- "5672:5672"
volumes:
- rabbitmqdata:/var/lib/rabbitmq
environment:
- RABBITMQ_VM_MEMORY_HIGH_WATERMARK=1GB
extra_hosts: *appextrahosts
mailcatcher:
image: sj26/mailcatcher
ports:
- "1080:1080"
extra_hosts: *appextrahosts
## Selenium support, uncomment to enable
#selenium:
# image: selenium/standalone-chrome-debug:3.8.1
# ports:
# - "5900:5900"
# extra_hosts: *appextrahosts
volumes:
appdata:
dbdata:
rabbitmqdata:
sockdata:
ssldata:
This issue was finally resolved by
Removing extra_hosts entries from the YML file
Adding networks in YML
Final docker-compose.yml
version: "3"
services:
app:
image: markoshust/magento-nginx:1.18-5
ports:
- "81:8000"
- "444:8443"
depends_on:
- "db"
volumes: &appvolumes
- ~/.composer:/var/www/.composer:cached
- ~/.ssh/id_rsa:/var/www/.ssh/id_rsa:cached
- ~/.ssh/known_hosts:/var/www/.ssh/known_hosts:cached
- appdata:/var/www/html
- sockdata:/sock
- ssldata:/etc/nginx/certs
networks:
- customNetwork
phpfpm:
image: markoshust/magento-php:7.4-fpm-11
volumes: *appvolumes
env_file: env/phpfpm.env
networks:
- customNetwork
db:
image: mariadb:10.4
command: --max_allowed_packet=256M
ports:
- "3307:3306"
env_file: env/db.env
volumes:
- dbdata:/var/lib/mysql
networks:
- customNetwork
redis:
image: redis:5.0-alpine
ports:
- "6379:6379"
networks:
- customNetwork
elasticsearch:
image: markoshust/magento-elasticsearch:7.9.3-1
ports:
- "9201:9200"
- "9301:9300"
environment:
- "discovery.type=single-node"
## Set custom heap size to avoid memory errors
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
## Avoid test failures due to small disks
## More info at https://github.com/markshust/docker-magento/issues/488
- "cluster.routing.allocation.disk.threshold_enabled=false"
- "index.blocks.read_only_allow_delete"
networks:
- customNetwork
rabbitmq:
image: rabbitmq:3.8.22-management-alpine
ports:
- "15672:15672"
- "5672:5672"
volumes:
- rabbitmqdata:/var/lib/rabbitmq
environment:
- RABBITMQ_VM_MEMORY_HIGH_WATERMARK=1GB
networks:
- customNetwork
mailcatcher:
image: sj26/mailcatcher
ports:
- "1080:1080"
networks:
- customNetwork
volumes:
appdata:
dbdata:
rabbitmqdata:
sockdata:
ssldata:
networks:
customNetwork:

Docker Compose - Can't access Database

My Docker Wordpress Container some how cannot connect to my database container. I tried to pass the credentials through the environment key.
I'm using external volumes that stores the Data from my previous Wordpress build as well as the data from the Database.
docker-compose.yml
version: '3'
services:
db:
image: mysql:5.7
container_name: db
restart: unless-stopped
env_file: .env
environment:
- MYSQL_DATABASE=wordpress_oxygen
volumes:
- wordpress_db-data:/var/lib/mysql
networks:
- conturas-network
wordpress:
depends_on:
- db
image: wordpress:5.6.0-fpm-alpine
container_name: wordpress
restart: unless-stopped
env_file: .env
environment:
- WORDPRESS_DB_HOST=db:3306
- WORDPRESS_DB_USER=$MYSQL_USER
- WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD
- WORDPRESS_DB_NAME=wordpress_oxygen
volumes:
- wordpress_data:/var/www/html
networks:
- conturas-network
webserver:
depends_on:
- wordpress
image: nginx:1.19.6-alpine
container_name: webserver
restart: unless-stopped
ports:
- "80:80"
volumes:
- wordpress_data:/var/www/html
- ./nginx-conf:/etc/nginx/conf.d
- certbot-etc:/etc/letsencrypt
networks:
- conturas-network
certbot:
depends_on:
- webserver
image: certbot/certbot
container_name: certbot
volumes:
- certbot-etc:/etc/letsencrypt
- wordpress_data:/var/www/html
command: certonly --webroot --webroot-path=/var/www/html --email username#xyz.io --agree-tos --no-eff-email --force-renewal -d xyz.io -d www.xyz.io
volumes:
certbot-etc:
wordpress_data:
external: true
wordpress_db-data:
external: true
networks:
conturas-network:
driver: bridge
Error Logs from the db-container
...
2020-12-27T15:53:26.593191Z 2 [Note] Access denied for user 'wordpress_oxygen'#'172.30.0.3' (using password: YES)
Thanks for helping!
The very last line of the logs give the important hint on the underlying issue:
[Note] Access denied for user 'wordpress_oxygen'#'172.30.0.3' (using password: YES)
It means that the database credentials used to connect to the database are incorrect - i.e. the username/password combination.
But since this is logged by the database it means WordPress is actually able to connect to the database - i.e. your docker networks are setup correctly.
You should verify now that the values of configured credentials (WORDPRESS_DB_USER, WORDPRESS_DB_PASSWORD etc.) are actually correct - which is the same as MYSQL_USER and MYSQL_PASSWORD used at the time of initializing the database - that is, the environment variables MYSQL_USER, MYSQL_PASSWORD etc. are only used when the database volume is empty and needs to be initialized, see Environment Variables in the image description:
Do note that none of the variables below will have any effect if you start the container with a data directory that already contains a database: any pre-existing database will always be left untouched on container startup.
You may also try to re-initialize the database by deleting the volume and starting a fresh instance of the service.
Also note that environment and env_file two different ways of specifying environment variables for the service, but mixing those two is bad practice since it can lead to unexpected behavior.
If you want to import values from your .env file to use for variable substitution you don't need to "import" it with env_file since it is loaded automatically for docker-compose! I.e. your current configuration does not do what you probably think it does.
What I did to fix the issue
I removed the the environment keys from the whole compose file.
Why did I do this?
I realized with the help of #acran answers, that the volume that I passed into the docker-compose file, was already a ready to use copy of my Initial Wordpress build/installation the same goes for the MySQL Database. (This means all credentials was already stored inside of each volume) Because of that I was not able to pass environment-variables to the composition, to be more precise, you can pass environment-variables to a build but they would simple have no effect on the finished container build.
You can only set environment-variables at the initial build.
Result
version: '3.3'
services:
db:
image: mysql:5.7
container_name: db
restart: unless-stopped
volumes:
- wordpress_db-data:/var/lib/mysql
networks:
- my-network
wordpress:
depends_on:
- db
image: wordpress:5.6.0-fpm-alpine
container_name: wordpress
restart: unless-stopped
volumes:
- wordpress_data:/var/www/html
networks:
- my-network
webserver:
depends_on:
- wordpress
image: nginx:1.19.6-alpine
container_name: webserver
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- wordpress_data:/var/www/html
- ./nginx-conf:/etc/nginx/conf.d
- certbot-etc:/etc/letsencrypt
networks:
- my-network
certbot:
depends_on:
- webserver
image: certbot/certbot
container_name: certbot
volumes:
- certbot-etc:/etc/letsencrypt
- wordpress_data:/var/www/html
command: certonly --webroot --webroot-path=/var/www/html --email my.name#xyz.io --agree-tos --no-eff-email --expand --noninteractive -d xyz.io -d www.xyz.io -d dev.xyz.io
volumes:
certbot-etc:
wordpress_data:
external: true
wordpress_db-data:
external: true
networks:
my-network:
driver: bridge

How to create docker-compose for JIRA and MySQL

I'm trying to create a docker-compose.yml file that will bring up JIRA and MySQL. Here's my file:
version: '3'
services:
jira:
depends_on:
- mysql
container_name: jira
restart: always
networks:
- jiranet
build:
context: .
dockerfile: Dockerfile.jira
environment:
- ATL_DB_TYPE=mysql
- ATL_DB_DRIVER=com.mysql.cj.jdbc.Driver
- ATL_JDBC_URL=jdbc:mysql://mysql:3306/jiradb
- ATL_JDBC_USER=jira
- ATL_JDBC_PASSWORD=jellyfish
ports:
- 8080:8080
volumes:
- jira-data:/var/atlassian-data/jira
mysql:
container_name: mysql
restart: always
image: mysql:5.7
networks:
- jiranet
environment:
- MYSQL_ROOT_PASSWORD=ChangeMe!
- MYSQL_DATABASE=jiradb
- MYSQL_USER=jira
- MYSQL_PASSWORD=jellyfish
command: [mysqld, --character-set-server=utf8, --collation-server=utf8_bin, --default-storage-engine=INNODB, --max_allowed_packet=256M, --innodb_log_file_size=2GB, --transaction-isolation=READ-COMMITTED, --binlog_format=row]
volumes:
- mysql-data:/var/lib/mysql
networks:
jiranet: {}
volumes:
jira-data:
mysql-data:
Unfortunately, I'm getting JIRA startup errors when it tried to initialize the database, of the form:
CREATE command denied to user 'jira'#'172.22.0.3' for table 'jiraaction'
I'm guessing it's because the mysql container is creating user jira, but only allowing it to connect from localhost. But, the JIRA container is being seen as coming from an an external IP.
Any ideas on how I can get the jiradb database in mysql to be accessible by the JIRA container by user jira?
I figured out the problem -- I was missing an environment variable in the jira container:
ATL_DB_SCHEMA_NAME=jiradb
After that, things worked fine!

Docker-Compose Unable to connect to any of the specified MySQL hosts

i have an existing Project ( API - portal - Mysql )
i have used Docker-compose without dockerfile
i publish the API - Portal and put them all in folder and then Docker-compose up
i can reach the api by getting the local values in it
but if i tried to reach mysql trough the API using postman its not working even when i open the frontend website
ConnectionString:
"ConnectionString": "server=xmysql;port=4406;Database=sbs_hani;User ID=hani;Password=123456; persistsecurityinfo=True;Charset=utf8; TreatTinyAsBoolean=false;"
This is my docker-compose file :
version: '3'
services:
xmysql:
container_name: xmysql
hostname: xmysql
image: mysql:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: "123456"
MYSQL_DATABASE: "sbs_hani"
MYSQL_USER: "hani"
MYSQL_PASSWORD: "123456"
ports:
- "3306:4406"
networks:
- xnetwork
volumes:
- data-volume:/var/lib/mysql
- ./hanimysql/sbs_hani.sql:/docker-entrypoint-initdb.d/sbs_hani.sql
xapi:
container_name: xapi
hostname: xapi
image: microsoft/dotnet:latest
# restart: always
tty: true
command: ["dotnet", "/var/lib/volhaniapi/hani.APIs.dll"]
ports:
- "8081:80"
- "8444:443"
networks:
- xnetwork
links:
- xmysql:xmysql
depends_on:
- xmysql
volumes:
- ./haniapi/:/var/lib/volhaniapi/
xportal:
container_name: xportal
hostname: xportal
image: microsoft/dotnet:latest
# restart: always
tty: true
command: ["dotnet", "/var/lib/volhaniportal/hani.Portal.dll"]
ports:
- "8083:80"
- "8446:443"
networks:
- xnetwork
links:
- xmysql:xmysql
depends_on:
- xmysql
volumes:
- ./haniportal/:/var/lib/volhaniportal/
xfront:
container_name: xfront
hostname: xfront
image: nginx:stable-alpine
# restart: always
ports:
- "8082:80"
- "4445:443"
networks:
- xnetwork
links:
- xapi:xapi
depends_on:
- xapi
volumes:
- ./hanifront/:/usr/share/nginx/html
volumes:
data-volume: {}
# xvolmysql:
# driver: "local"
# xvolmongo:
# driver: "local"
# xvolrabbitmq:
# driver: "local"
# xvolstarapi:
# driver: "local"
networks:
xnetwork:
driver: bridge
When you make a connection from one Docker container to another, you always connect to the port the service inside the container is actually listening on. Any ports: mappings are ignored (and in fact you don't need ports: if you don't want the service to be accessible from outside Docker container space).
In your example, you need to change the port number in the connection string to the default MySQL port 3306.
(Consider removing all of the container_name:, hostname:, networks:, and links: blocks in the file. You should have an equivalent container stack with the same functionality; the two most observable differences are that if you directly use docker commands then the container names will be prefixed with the directory names, and the Docker-internal network will be named default. You can still use the service block names like xmysql as host names.)

can I Use mysql,oracle database as well as sql server on Same system

I have installed SQL-Server 2008 r2 on my system,but now i need to install MYSQL too. Is it possible to install MYSQL and SQL-Server side-by-side. Does installing both SQL-Server and MYSQL on same system affect each other?
Yes this is possible. However you have to make sure the ports they listen to are different.By default mysql uses port 3306 and SQL-server uses port 1433.They are both applications like any other application. With different processes, so they should run on the same machine without any conflicts. On setup just make sure you configure the ports well so that they do not use the same port, of which the system too should detect that the port is being used by another application.
The simple and clean answer to your question is Docker, i have created tutorial where MySQL, MSSQL, Oracle, PostgreSQL and MongoDB are setup and running simultaneously in single CentOS system with 3GB of RAM without affecting each other:
https://adhoctuts.com/run-mulitple-databases-in-single-machine-using-docker-vagrant/
https://www.youtube.com/watch?v=LeqkCoX28qg
below is the content of docker-compose.yml file from the tutorial, but you need the other files as well (all files are in following git repository: https://github.com/mamedshahmaliyev/adhoctuts/tree/master/docker/multiple_databases). If you need MySQL and MSSQL only just delete other services from docker-compose.yml and run docker-compose up:
# link to tutorial: https://adhoctuts.com/run-mulitple-databases-in-single-machine-using-docker-vagrant/
version: "3.1"
networks:
docker-network:
services:
# https://hub.docker.com/_/mysql
mysql_persistance: # service name
image: mysql:8
container_name: mysql_p # container_name
command: --default-authentication-plugin=mysql_native_password
volumes:
- /docker/mysql/data:/var/lib/mysql # for data persistance
- /docker/mysql/conf:/etc/mysql/conf.d # put all the custom configuration files from host to container
environment:
- MYSQL_ROOT_PASSWORD=AdHocTuts2019#
ports:
- "3309:3306" # map host port to container port
networks:
- docker-network
#restart: on-failure
mysql_no_persistance:
image: mysql:5.7
container_name: mysql_np
environment:
- MYSQL_ROOT_PASSWORD=AdHocTuts2019#
ports:
- "3308:3306"
networks:
- docker-network
# https://hub.docker.com/_/microsoft-mssql-server
mssql:
image: mcr.microsoft.com/mssql/server:2017-CU8-ubuntu
container_name: mssql
volumes:
- /docker/mssql/data:/var/opt/mssql
environment:
- SA_PASSWORD=AdHocTuts2019#
- ACCEPT_EULA=Y
- TZ=Asia/Baku
- MSSQL_PID=Express
ports:
- "1433:1433"
networks:
- docker-network
# https://hub.docker.com/_/oracle-database-enterprise-edition
# Accept Terms of Service for Oracle Database Enterprise Edition (Proceed to Checkout).
# Then in command line: docker login
# sqlplus sys/Oradoc_db1#ORCLDB as sysdba
oracle:
image: store/oracle/database-enterprise:12.2.0.1-slim
container_name: oracle
volumes:
- /docker/oracle/data:/ORCL # host path must have 777 permission or writable by docker oracle user
environment:
- DB_SID=ORCLDB
- DB_MEMORY=1GB
ports:
- "1521:1521"
networks:
- docker-network
# https://hub.docker.com/_/postgres
postgres:
image: postgres:12
container_name: postgres
volumes:
- /docker/postgre/data:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=AdHocTuts2019#
- POSTGRES_USER=postgres
- POSTGRES_DB=docker_db
ports:
- "5432:5432"
networks:
- docker-network
# https://hub.docker.com/_/mongo
mongo:
image: mongo:3.4.21-xenial
container_name: mongo
volumes:
- /docker/mongo/data:/data/db
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=AdHocTuts2019#
ports:
- "27017:27017"
networks:
- docker-network