Create an EC2 instance and file system. I am trying to mount the file system, for which I use the following command:
sudo mount -t nfs4 fs-0d06d36f390aeXXXX.efs.us-east-2.amazonaws.com:/myDir
And I am getting this error:
mount.nfs4: Failed to resolve server fs-0d06d36f390aeXXXX.efs.us-east-2.amazonaws.com: No address associated with hostname
Could someone guide me to solve this?
You can solve this issue by using following command.
first you need to nslookup nfsdomain from working machine and take the IP address
nslookup fs-7dsqsssscas5e11sefs.eu-central-1.amazonaws.com
Server: 127.0.0.51
Address: 127.0.0.51#51
Non-authoritative answer:
Name: fs-7dsqsssscas5e11sefs.eu-central-1.amazonaws.com
Address: 10.143.27.147
Add the IP address into /etc/hosts with nfsdoamin
vi /etc/hosts
10.143.27.147 fs-7dsqsssscas5e11sefs.eu-central-1.amazonaws.com
and try to mount with following command
sudo mount -t nfs4 fs-7dsqsssscas5e11sefs.eu-central-1.amazonaws.com:/ /mnt
Related
This is how I am trying to retrieve the external IP address of vms:
{{hostvars[inventory_hostname]['ansible_env'].SSH_CONNECTION.split(' ')[2]}}
Here is another way to see all IP addresses associated with a node:
ansible -m setup -i hosts -u
results:
ansible [hostname (or) hostgroup] -m setup -i hosts -u [user name] | grep SSH
"SSH_CLIENT": "<ip a> 57894 22",
"SSH_CONNECTION": "<ip a> 57894 <internal ip> 22",
"SSH_TTY": "/dev/pts/0",
What is getting returned using the first snippet is the 2nd IP i.e VM's internal IP.
How can ansible pull VM's external IP?
Also, what is IP a? It's certainly not the VM's external IP address.
I believe 'ansible_host' variable would do the trick. The playbook below outputs the ip address of the vm.
- name: Show vm's ip
hosts: gcp
tasks:
- debug:
msg: "{{ansible_host}}"
I want to be able to use kubectl commands on my master ec2 instance from my local machine without ssh. I tried copying .kube into my local but the problem is that my kubeconfig is using the private network and so when i try to run kubectl from my local I can not connect.
Here is what I tried:
user#somehost:~/aws$ scp -r -i some-key.pem ubuntu#some.ip.0.0:.kube/ .
user#somehost:~/aws$ cp -r .kube $HOME/
user#somehost:~/aws$ kubectl version
and I got:
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.7", GitCommit:"1dd5338295409edcfff11505e7bb246f0d325d15", GitTreeState:"clean", BuildDate:"2021-01-13T13:23:52Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
Unable to connect to the server: dial tcp some.other.ip.0:6443: i/o timeout
Is there a way to change the kubeconfig in a way that would tell my kubectl when I run commands from local to run them on the master on the ec2 instance?
You have to change clusters.cluster.server key in your kubectl config with externally accessible IP.
For this your VM with master node must have external IP assigned.
Depending on how you provisioned your cluster, you may need to add additional name to Kubernetes API server certificate
With kubeadm you can just reset cluster with
kubeadm reset
on all nodes (including master), and then
kubeadm init --apiserver-cert-extra-sans=<master external IP>
Alternatively you can issue your commands with --insecure-skip-tls-verify flag. E.g.
kubectl --insecure-skip-tls-verify get pods
I am trying to copy local files to my ec2 instance.
When I run this command:
scp -i keypair.pem process.py ubuntu#ip-xx-xxx-xx-xxx.compute-1.amazonaws.com:~/.
I get this error:
ssh: Could not resolve hostname ip-xx-xxx-xx-xxx.compute-1.amazonaws.com: nodename nor servname provided, or not known
lost connection
When I run this code:
scp -i keypair.pem process.py ubuntu#ip-xx-xxx-xx-xxx:~/.
It stalls for ~ 1 minute then I get this error:
ssh: connect to host ip-xx-xxx-xx-xxx port 22: Operation timed out
lost connection
Any ideas how to resolve?
The easiest way to use scp is to start with an SSH command that already works:
ssh -i keypair.pem ec2-user#1.2.3.4
Then, modify it to use scp:
scp -i keypair.pem foo.txt ec2-user#1.2.3.4:/tmp/
The only things changed were:
ssh becomes scp
Insert source filename
Append :/target/
Unable to attach EFS to EC2s. We tried various ways to mount, even it is throwing the same error . logs:
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport fs-c04ksakbe520.efs.us-wsjn-1.amazonaws.com :/ efs mount.nfs4: Connection timed out
we found that the VPC was using a custom DNS in the DHCP option set to resolve Company on premises URLs. In order to mount an EFS using the DNS name, the connecting EC2 instance must be inside a VPC and must be configured to use the DNS server provided by Amazon [1]. Using the IP address of the mount target in the same Availability Zone as the instance (us-east-1a), we were able to mount the EFS [2] using the following command:
mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 83.23.23.4:/ efs-mount-point
Then added the following line to the /etc/fstab file in order to mount the EFS automatically on boot:
83.23.23.4:/ /mnt/efs nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport,_netdev 0 0
tested successfully by running "mount -a"
Mounting on Amazon EC2 with a DNS Name - https://docs.aws.amazon.com/efs/latest/ug/mounting-fs-mount-cmd-dns-name.html
Mounting File Systems Without the EFS Mount Helper - https://docs.aws.amazon.com/efs/latest/ug/mounting-fs-old.html
I have a RDS instance with mysql database and which can only be accessed by an ec2 instance running in AWS. Now i want to access my RDS instance from local machine using SSH tunneling. I searched a lot on the net but none of the solutions worked. Can any one please tell me how to do it step by step with working solution.
Any help will be highly appreciated!
I tried to run -
ssh -i myNewKey.pem -N -L 3306:myredinstance:3306 ec2-user#myec2-instance.
mysql -u dbauser -p -h 127.0.0.1 on mysql-js utility and it gave me error. Please see below :-
You can do it by setting up a ssh tunel
ssh -i /path/to/key -N -L 3306:an_rds_endpoint:3306 user#yourserver.com
Then connect locally
mysql -u myuser -p -h 127.0.0.1