Centos commands from websites

How do I update Centos?

update

How do I install Apache in Centos?

yum install httpd

How do I set Apache to start on boot in Centos?

chkconfig –-levels 235 httpd on

How do I install MySQL in Centos?

yum install mysql mysql-server

How do I get MySQL to start at boot in Centos?

chkconfig –-levels 235 mysqld on

How do I Secure my MySQL install in Centos?

mysql_secure_installation

Then run through the basic configuration accepting the defaults such as removing the guest accounts and passwords.

How do I restart MySQL in Centos?

 service restart mysqld

How do I install PHP in Centos?

yum install php

How do I restart the Apache service in Centos?

 Service httpd restart

How do I list a directory in Centos?

find

How do I locate a specific file in a directory in Centos?

find . -name FILENAME

How do I locate a file with a certain word in it in Centos?

Lets say you wanted to find a file that had the word log in it.

locate log

How do I restart IPTables in Centos?

 service iptables restart

How do I flush the cache of my IPTables in Centos?

 iptables -f

How do I see what services are running and their status under Centos?

top

and to exit CTRL+X. This service will give you information on what CPU usage and memory usage is being used for a given service.

How do I list in order what service is using the most memory in Centos?

ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10

How do I change the name of my server in Centos?

 hostname yourchosenservername

How do I create a new user in Centos?

adduser thentheusername

How do I change the password for the user I am logged in as in Centos?

passwd

How do I edit files in Centos? I presonally use Nano, so lets first install it.

yum install nano


original from :http://www.techieshelp.com/basic-centos-commands-and-information/

Deployment on Amazon cloud with load balancer

What Is Elastic Load Balancing?

Elastic Load Balancing automatically distributes incoming traffic across multiple EC2 instances. we can create a load balancer and register instances with the load balancer in one or more Availability Zones. The load balancer serves as a single point of contact for clients. This enables you to increase the availability of your application. we can add and remove EC2 instances from your load balancer as our needs change, without disrupting the overall flow of information. If an EC2 instance fails, Elastic Load Balancing automatically reroutes the traffic to the remaining running EC2 instances(Ref-From AWS).

 

Architecture:

 

lb-archi

 

 

Please do the following setups to create  load balancer and then  add at least two EC2 instances .

createloadbalcner

 

lb-02

 

lb-03

 

lb-04

 

lb-05

 

Commands(connect to one of the ec2 instances):

  • ssh -i /path/my-key-pair.pem ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com
  • /path/my-key-pair.pem - is where key is located
  • ec2-user - user name
  • Hostname -ec2-198-51-100-1.compute-1.amazonaws.com
Then go into htdocs or your root directory and do the deployment .
after finish that do r-sync to other EC2 instance .
ex: rsync -i /path/my-key-pair2.pem -avz –exclude app/config/database.php –exclude app/routes.php –exclude app/storage /mnt/www/mybitbucket_bkp/ ec2-user@ec2-197-51-101-1.compute-2.amazonaws.com:/mnt/www/my_dev_store/

then please change the configuration to the newly updated server

Mongo setup with replication

MongoDB handles replication through an implementation called “replication sets”. Replication sets in their basic form are somewhat similar to nodes in a master-slave configuration. A single primary member is used as the base for applying changes to secondary members.

  • Primary member: The primary member is the default access point for transactions with the replication set. It is the only member that can accept write operations.
  • Secondary members: A replication set can contain multiple secondary members. Secondary members reproduce changes from the oplog on their own data.
  • Arbiter: An arbiter is an optional member of a replication set that does not take part in the actual replication process. It is added to the replication set to participate in only a single, limited function: to act as a tie-breaker in elections.

 

Please read the fololwoing link to for more information :

https://www.digitalocean.com/community/tutorials/how-to-implement-replication-sets-in-mongodb-on-an-ubuntu-vps