Misaliperver: Create New AWS Instance And Setting Default



You can decide to create ec2 instance for your job. m6i.large type is enough for this time. I think that you have set vpc and subnet configs. And you can use public subnet settings. Or you can use elastic ip for speedy.

Then you choose OS, you preffer to use most popular default os as me.

Then connect with your key on terminal;

ssh -i ~/.ssh/aws-key.pem ec2-user@ec2-publicdns.aws.com

enter your secret and connect.

If you don't access to machine, please check it;

  • Is pem file or secret correct?
  • Is your machine security group allow internet?
  • Is your user name correct?
  • Is your writed public dns name correct?
If everything is correct so far;

Run the command;

yum upgrade
yum install tmux
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
. ~/.nvm/nvm.sh
nvm install --lts

if you get error, please try to nvm install 16. Node18 is wrong for me 26.07.2022


if you want to run batch and you need to big memory, fisrt of all you need to swap space, i think to alloc 2 2gb for 8 gb storage.

sudo dd if=/dev/zero of=/swapfile bs=128M count=16
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon -s
sudo vi /etc/fstab

open with vi and press i and paste below string;

/swapfile swap swap defaults 0 0

press esc and write :wq  and  enter (for exit from vi editor)

Nodejs by default alloc for process 512 MB. You need to increase that maybe 5 GB. Below code very exactly i think.

export NODE_OPTIONS="--max-old-space-size=5120"

Finally you ready for start your process. Be greedy for be happy

Resources:
https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Scenario1.html
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html
https://aws.amazon.com/premiumsupport/knowledge-center/ec2-memory-swap-file/


Yorumlar