How Use the Oracle Cloud Infrastructure MYSQL DB and XDev API together? - oracle

So I've created a MYSQL DB on the OCI and can connect to it via SSH, I have all the ingress rules set up, the users, etc.
What do I put in the host: "....": field in the javascript code? (instead of localhost).
mysqlx
.getSession( {
user: 'user',
password: 'password',
host: 'localhost',
port: '33060',
})
Do I have to do anything else in OCI since the connection is set up as SSH or can I set it up on the public subnet settings as a new ingress rule?
Thanks for any help.

The answer in OCI is to use the host name and provider of your instance that houses the MYSQL DB and then set your MYSQL Router in OCI with the following:
Step 1 - Install and Configure MySQL Router
Assuming your OCI Compute is running Enterprise Linux Enterprise Linux Server release 7.
SSH into the OCI Compute where MySQL Router will be installed
Install MySQL Router. Run:
sudo yum -y install https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
sudo yum -y install mysql-router
Configure MySQL Router appending to the file /etc/mysqlrouter/mysqlrouter.conf. For example, assuming the MDS private IP is 10.0.0.6, run:
sudo tee -a /etc/mysqlrouter/mysqlrouter.conf > /dev/null << EOF
[routing:redirect_classic]
bind_address = localhost:3306
destinations = 10.0.0.6:3306
routing_strategy=first-available
[routing:redirect_xprotocol]
bind_address = localhost:33060
destinations = 10.0.0.6:33060
protocol = x
routing_strategy=first-available
EOF
Start MySQL Router and check if the service is active (running). Run:
$ sudo systemctl start mysqlrouter.service
$ sudo systemctl status mysqlrouter.service
Automatically start MySQL Router when the Compute instance reboots
$ sudo systemctl enable mysqlrouter.service
Add the firewalld rules. Run:
$ sudo firewall-cmd --permanent --add-port=3306/tcp
$ sudo firewall-cmd --permanent --add-port=33060/tcp
$ sudo firewall-cmd --reload
Thanks Airton Latori for the assist.

I'm not familiar with OCI specifics, but eventually there should be a hostname or IP address for the MySQL instance (or router) somewhere you can connect to. And, assuming the endpoint "speaks" the X Protocol, that is what you should provide for the host configuration property.
Disclaimer: I'm the lead developer of the MySQL X DevAPI Connector for Node.js

Related

Multipass VM not reachable via specific http ports from host

I'm running an Ubuntu VM with multipass hyperkit do run microk8s. Within the VM all things checkout and available with skaffold/kubectl port forwarding. For instance:
$ multipass list
Name State IPv4 Image
microk8s-vm Running 192.168.64.2 Ubuntu 20.04 LTS
10.0.1.1
172.17.0.1
10.1.254.64
Port forwarding service/my-app in namespace default, remote port 80 -> 127.0.0.1:4503
Within the VM:curl localhost:4503 ✅
From the host: curl 192.168.64.2:4503🛑
I know the VM is reachable on port 80 because curl 192.168.64.2 returns default ngnix not found page. FWIW I never installed ngnix and the service doesn't seem to be running /cannot turn it off.
I've been at this for a day and I'm stumped. I even tried the Vbox driver and manually configured a bridge adapter. I even created my own adapter...
$ multipass exec -- microk8s-vm sudo bash -c "cat > /etc/netplan/60-bridge.yaml" <<EOF
network:
ethernets:
enp0s8: # this is the interface name from above
dhcp4: true
dhcp4-overrides: # this is needed so the default gateway
route-metric: 200 # remains with the first interface
version: 2
EOF
$ multipass exec microk8s-vm sudo netplan apply
How can I reach this VM from the host?
You cant access your pod ip /portlike this.
If you want to access your pods port over the nodes ip address, you need to define a service type NodePort and then use ipaddressOfNode:NodePort.
curl http://ipaddressOfNode:NodePort
With port-forward you must use the localhost of your host system.
kubectl port-forward svc/myservice 8000:yourServicePort
then
curl http://localhost:8000

Connecting PostgreSQL installed in docker inside Hyper-V Ubuntu from Windows 10 PgAdmin

I need help in connecting PostgreSQL which is installed in Docker inside HyperV ubuntu 18.4 from Windows 10 PgAdmin. So far I tried the following
Step 1: Install Postgres in Docker (Ubuntu running on Hyper-V)
sudo docker run -p 5432:5432 --name pg_test -e POSTGRES_PASSWORD=admin -d postgres
Step 2: Create a database
docker exec -it pg_test bash
psql -U postgres
create database mytestdb
Step 3: Get the ip address
sudo docker inspect pg_test | grep IPAddress
//returned with 172.17.0.2
Step 4: pg_hba.conf
host all all 0.0.0.0/0 md5
Step 5: When I try to connect from Windows PgAdmin 4, I get this below error -
Note: I have also tried using UBUNTU VM IP address, but no luck
Your's is a case where you are trying to connect to postgres from another subnet, i.e windows subnet to hyper visor subnet if you are not using bridged protocol.
So case 1:
If this is on NAT\HOST and not on bridge then you need to make sure you are able to ping the ubuntu server from windows server.
next is make sure that port is open from ubuntu's end. How do you check that, do a telnet on the port number from windows cmd prompt.
telnet 192.168.0.10 5432
if you are bridged and you can ping ping the server as well, checked that port is opened which is telnet works. You need to make sure that in the postgres.conf file
"listen address" is to "*". which is all.
Again from OS level in ubuntu run the command systemctl stop firewalld to stop firewall and then try to connect. IF this works then you need to open the port in the firewall using this command:
firewall-cmd --permanent --add-port 5432/tcp
I can see from you docker image that 5432 is already opened. This is more of port mapping and firewalld stuff.
You may want to check that pg_hba.conf is not restricted to local. It should not be the case for docker image but you never know.
See: https://www.postgresql.org/docs/9.1/auth-pg-hba-conf.html
Also, there is a typo: POSTGRES_PASSWOR=admin is missing D, it should be POSTGRES_PASSWORD=admin.
You don't need container IP. Since you have mapped container port to host machine (Ubuntu) anyone outsider just needs the Ubuntu machine IP, and on Ubuntu itself you can use localhost.

Make mysql client use ALL_PROXY socks5 server

I want to connect to an aurora serverless database from my local machine. Because the database is only accessible from within the aws cloud, I have setup an ec2 instance running microsocks:
./microsocks -p 8888
I now want to connect using mysql from my machine:
export ALL_PROXY=socks5h://xx.xx.xx.xx:8888
mysql --user=admin --password=XXXX -h database-XXXX.cluster-XXXX.eu-XXXX.rds.amazonaws.com
ERROR 2003 (HY000): Can't connect to MySQL server on 'database...com' (111)
If I run this command on the ec2 instance it succeeds. So I assume that mysql does not respect my proxy settings. If I run curl on my machine it respects the proxy settings.
Note that this is just for testing purposes and I know that this would not be a solution for production use.
You may use proxychains.
yum install proxychains-ng
edit config file /etc/proxychains.conf, and add this:
[ProxyList]
# add proxy here ...
# meanwile
# defaults set to "tor"
socks5 {your proxy.address} {your.proxy.port}
Lastly, you can run mysql like this:
proxychains mysql --user=admin --password=XXXX -h database-XXXX.cluster-XXXX.eu-XXXX.rds.amazonaws.com

Sesman-Xvnc throws password failed with every user

I have an Ubuntu 16.04 LTS virtual machine that I use for log management. Since I created it, I use Sesman-Xvnc and has always been nice and easy to log in. However, after been on it for the last 3 weeks with on issues whatsoever, today I got to the office and it throws this error:
Connecting to sesman ip 127.0.0.1 port 3350
sesman connect ok
sending login info to session manager, please wait...
xrdp_mm_process_login_response: login successful for display
Started connecting
connecting to 127.0.0.1 5912
tcp connected
security level is 2 (1 = none, 2 = standard)
password failed
error - problem connecting
I didn't changed my password, the machine was on all the time and I am able to log in via ssh with my user and password.
I have tried reinstalling the services with:
sudo apt-get remove xrdp vnc4server tightvncserver
sudo apt-get install tightvncserver
sudo apt-get install xrdp
And then restarted the xrdp service with:
service xrdp restart
I have also created a new user but the results are the same; password failed.
Any ideas of how to sort this out?
Thank you very much familia. ;)
I too have the same issue facing it since today, Have put up the issue here.
XRDP doesnt connect to Azure VM suddenly
I fixed it by allowing the port which it is trying to connect to sesman in the ufw:
The moment u see connecting to "sesman ip 127.0.0.1 port 3350" (or any other port) in the RDP, Take that port number, and allow that port to the ufw using
These are the steps I used :
Downgrade ur xrdp using this :
[sudo apt-get install xrdp=0.6.1-2
and Hold the xrdp instance,
sudo apt-mark hold xrdp
Sudo ufw enable
Sudo ufw allow 3350 and
Sudo ufw allow 3389]
NB:You may use this cmd to see if its open:
sudo netstat -plnt | grep rdp
Perform these in the SSH window.
This worked for me. Hope it fixes this issue.
We had the same issue and it seems to be caused by an automatic update of 'xrdp'. Have a look to this post:
https://askubuntu.com/questions/1108550/xrdp-failed-problem-connecting-when-package-was-auto-updated

How to set up telnet in AWS instance?

I got SSH working fine. But I am facing an issue with connecting via telnet.
sudo yum -y install telnet
This works for me after logging in to the EC2 instance
ssh is recommended over telnet, as telnet is not encrypted and is by default not installed in amazon instance.
However if needed, steps involved for Linux : Amazon Instance or Centos
Install telnet daemon in the instance: Install telnet-server using sudo yum install telnet-server . Package telnet is for the client program in case one want to connect using telnet client from the instance, not needed for the exercise.
Enable the telnet daemon service:
- By default the service is disabled in /etc/xinetd.d/telnet, The disable flag needs to be set to no.
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
disable = yes
}
Post change it should look like below
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
disable = no
}
Verify the configuration in case of any edit related errors.
sudo chkconfig xinetd on
Bring up the telnet service:
Bring up the telnet daemon as root using sudo service xinetd restart command
Enable inbound telnet default port (23) on AWS Console:
In AWS Console EC2/Security Groups/<Your Security Group>/Inbound, set a rule
Type:Custom-TCP Rule
Protocol: TCP Range
Port Range: 23
Source: <As per your business requirement>
Test the telnet connection:
Test the telnet connection from any client enabled in the firewall.
>telnet ec2-XX-XX-XXX-XXX.region.compute.amazonaws.com.
Connected to ec2-XX-XX-XXX-XXX.region.compute.amazonaws.com.
Escape character is '^]'.
Password:
The steps(tools) will vary slightly for other linux variants.
PS: Referred http://aws-certification.blogspot.in/2016/01/install-and-setup-telnet-on-ec2-amazon.html, fixed few issues in the commands.

Resources