User Tools

Site Tools


ec2_config

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ec2_config [2015/07/07 13:41]
wbeckett
ec2_config [2021/06/04 02:16] (current)
Line 1: Line 1:
-====== EC2 Config ======+====== EC2 MYSQL Config ======
  
  
-<​pre>​ +[[http://​comsci.liu.edu/​~murali/​cvs/​pserver.htm]]
-Installing MySQL with APT+
  
-Install MySQL by the following command: 
  
-shell> sudo apt-get install mysql-server ​+[[http://​docs.aws.amazon.com/​AWSEC2/​latest/​UserGuide/​ebs-using-volumes.html| EBS Volumes Doc]]
  
-This installs the package for the MySQL server, as well as the packages for the client and for the database common files. 
  
-During the installation,​ there are two requests by the dialogue boxes:+[[https://​www.howtoforge.com/​install_nfs_server_and_client_on_debian_wheezy|NFS Mount]]
  
-    Supply ​password ​for the root user for your MySQL installation+[[https://​theredblacktree.wordpress.com/​2013/​05/​23/​how-to-setup-a-amazon-aws-ec2-nfs-share/​|Setting up NFS]] 
-    ​Important+ 
 +[[http://​docs.aws.amazon.com/​AWSEC2/​latest/​UserGuide/​storage_expand_partition.html#​return-expanded-root-partition|Expand Root ]] 
 + 
 +<​code>​ 
 +EBS Volume 
 +leave the device file blank on console it will tell you what are valid devices 
 + 
 +lsblk 
 +NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT 
 +xvda    202:0    0    8G  0 disk  
 +└─xvda1 202:1    0    8G  0 part / 
 +xvdf    202:​80 ​  ​0 ​ 100G  0 disk  
 +# mkfs -t ext4 /dev/xvdf 
 +mke2fs 1.42.12 (29-Aug-2014) 
 +Creating filesystem with 26214400 4k blocks and 6553600 inodes 
 +Filesystem UUID: be67a30f-e553-4d86-ab41-e183d1e93a5b 
 +Superblock backups stored on blocks:  
 + 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,  
 + 4096000, 7962624, 11239424, 20480000, 23887872 
 + 
 +Allocating group tables: done                             
 +Writing inode tables: done                             
 +Creating journal (32768 blocks): done 
 +Writing superblocks and filesystem accounting information:​ done    
 + 
 +# mount /dev/xvdf /assets 
 +# df -h 
 +Filesystem ​     Size  Used Avail Use% Mounted on 
 +/​dev/​xvda1 ​     7.8G  1.5G  6.0G  20% / 
 +udev             ​10M ​    ​0 ​  ​10M ​  0% /dev 
 +tmpfs           ​3.0G ​ 8.2M  3.0G   1% /run 
 +tmpfs           ​7.4G ​    ​0 ​ 7.4G   0% /dev/shm 
 +tmpfs           ​5.0M ​    ​0 ​ 5.0M   0% /run/lock 
 +tmpfs           ​7.4G ​    ​0 ​ 7.4G   0% /​sys/​fs/​cgroup 
 +/​dev/​xvdf ​       99G   ​60M ​  ​94G ​  1% /assets 
 +</​code>​ 
 + 
 +<​code>​ 
 +A. Adding the CVSROOT environment variable 
 + 
 +    Add the following two lines to your .cshrc (or equivalent) file: 
 +    umask 007     (this will replace any existing umask) 
 +    setenv CVSROOT $HOME/​.cvsroot ​    ​(.cvsroot is the main CVS repository) 
 +    This sets up the CVSROOT environment variable, which is needed by CVS (for example, $HOME = /​u2/​rmflatt/​ ). 
 +    Logout and log back in for these changes to take affect  
 + 
 +B. Setting up the CVS repository so that other group members and yourself can checkout/in files. 
 + 
 +    Go to your root directory 
 +    type: groups ​    (this determines which groups you are a part of. Remember the group name you wish to use CVS with) 
 +    type: umask 007     (all new files will be locked to outsiders but readable and writable by the owner and group of the file) 
 +    type: mkdir .cvsroot ​    (this is the CVS repository) 
 +    type: chgrp group_name .cvsroot ​    ​(allows the group '​group_name'​ access to the .cvsroot repository - substitute group_name with a group name from step 2 [i.e. cs354_31] ) 
 +    type: chmod 2770 .cvsroot ​    ​(makes the repository owner and group readable and writable) 
 +    type: mkdir .cvsroot/​CVSROOT ​    (all the files that CVS needs are stored within this directory) 
 +    type: mkdir .cvsroot/​project ​    ​(where project is the name of the project you're working on. Make as many '​project'​s as desired. A module with the name '​project'​ will be used [this name goes in the file modules, as described on step 12]) 
 +    type: cvs init     (this populates the .cvsroot/​CVSROOT directory with the files that CVS needs. This step assumes the CVSROOT environment variable has been set) 
 +    Go to your root directory 
 +    type: cvs checkout CVSROOT/​modules ​    (this creates a CVSROOT directory tree in your root) 
 +    Edit the file (~/​CVSROOT/​modules) and insert a line that defines the module(s) you're working on (i.e. '​project'​)
 +    ​Add the following line at the end of the file (you can add as many modules as needed): 
 +    project_name ​    ​project ​    ​(where project_name is the name of the module you want defined, and project is the name of the directory containing the files [as created on step 8]) 
 +    Save ~/​CVSROOT/​modules 
 +    type: cvs commit -m "The message to log with this change"​ CVSROOT/​modules ​    (this commits this changed file into the repository) 
 +    type: cvs release -d CVSROOT ​    (this releases (and deletes) the CVSROOT working directory, which you just checked out/in)  
 + 
 +To import an existing directory (with files) into the repository:​ 
 + 
 +    Go to the directory that contains any directories/​files that you want to import into CVS 
 +    type: cvs import -m '​Initial checkin'​ project_name VENDER_TAG RELEASE_TAG ​    (This imports (recursively) any directories/​files in the current directory into the project_name repository. VENDER_TAG and RELEASE_TAG can be anything)  
 +    </​code>​ 
 + 
 +<​code>​ 
 +Installing MySQL with APT 
 + 
 +Install MySQL by the following command: 
 + 
 +shell> sudo apt-get install mysql-server ​
  
-    Make sure you remember the root password you set. Users who want to set a password later can leave the password field blank in the dialogue box and just press OK. However, it is very important that you set the password soon using the program mysql_secure_installation,​ as people can gain anonymous access to your MySQL server until you have secured the database'​s root account with a password. 
  
-    Indicate if you want to install the test database with “Yes” or “No”. Installation of the test database is not recommended for production environments. ​ 
  
 Starting and Stopping the MySQL Server Starting and Stopping the MySQL Server
Line 33: Line 105:
  
 shell> sudo service mysql start shell> sudo service mysql start
-</pre>+</code>
  
 [[https://​console.aws.amazon.com/​ec2/​v2/​home?​region=us-east-1#​Instances:​sort=instanceType | Console]] [[https://​console.aws.amazon.com/​ec2/​v2/​home?​region=us-east-1#​Instances:​sort=instanceType | Console]]
 +
 +<​code>​
 +mysql> CREATE USER '​monty'​@'​localhost'​ IDENTIFIED BY '​some_pass';​
 +mysql> GRANT ALL PRIVILEGES ON *.* TO '​monty'​@'​localhost'​
 +    ->     WITH GRANT OPTION;
 +mysql> CREATE USER '​monty'​@'​%'​ IDENTIFIED BY '​some_pass';​
 +mysql> GRANT ALL PRIVILEGES ON *.* TO '​monty'​@'​%'​
 +    ->     WITH GRANT OPTION;
 +mysql> CREATE USER '​admin'​@'​localhost'​ IDENTIFIED BY '​admin_pass';​
 +mysql> GRANT RELOAD,​PROCESS ON *.* TO '​admin'​@'​localhost';​
 +mysql> CREATE USER '​dummy'​@'​localhost';​
 +
 +</​code>​
 +
 +<​code>​
 +#! /bin/bash
 +
 +mysql --user=root --password= --host=162.209.124.42
 +wrb@media-labs-server-2:​~/​queue/​sql$ cat c
 +#! /bin/bash
 +
 +mysql --user=wrb --password= --host=162.209.124.42 ​ parks
 +
 +create database parks;
 +</​code>​
 +
 +<​code>​
 + ​netstat -tln
 +Active Internet connections (only servers)
 +Proto Recv-Q Send-Q Local Address ​          ​Foreign Address ​        ​State ​     ​
 +tcp        0      0 0.0.0.0:​22 ​             0.0.0.0:​* ​              ​LISTEN ​    
 +tcp        0      0 127.0.0.1:​3306 ​         0.0.0.0:​* ​              ​LISTEN ​    
 +tcp6       ​0 ​     0 :::​8080 ​                :::​* ​                   LISTEN ​    
 +tcp6       ​0 ​     0 :::80                   :::​* ​                   LISTEN ​    
 +tcp6       ​0 ​     0 :::22                   :::​* ​                   LISTEN ​    
 +tcp6       ​0 ​     0 127.0.0.1:​8005 ​         :::*                    LISTEN ​    
 +tcp6       ​0 ​     0 :::​8009 ​      
 +
 +</​code>​
 +
 +<​code>​
 +
 +# vi /etc/my.cnf
 +Step # 3: Once file opened, locate line that read as follows
 +
 +[mysqld] ​
 +
 +Make sure line skip-networking is commented (or remove line) and add following line
 +
 +bind-address=YOUR-SERVER-IP
 +
 +For example, if your MySQL server IP is 65.55.55.2 then entire block should be look like as follows:
 +
 +[mysqld]
 +user            = mysql
 +pid-file ​       = /​var/​run/​mysqld/​mysqld.pid
 +socket ​         = /​var/​run/​mysqld/​mysqld.sock
 +port            = 3306
 +basedir ​        = /usr
 +datadir ​        = /​var/​lib/​mysql
 +tmpdir ​         = /tmp
 +language ​       = /​usr/​share/​mysql/​English
 +bind-address ​   = 65.55.55.2
 +# skip-networking
 +....
 +..
 +</​code>​
 +
 +<​code>​
 +nc -z -w1 54.87.112.192 3306
 +Connection to 54.87.112.192 port 3306 [tcp/mysql] succeeded!
 +</​code>​
 +
 +<​code>​
 +show tables;
 +
 +show grants;
 +
 +use mysql;
 +
 +describe user;
 +</​code>​
 +
 +<​code>​
 +
 +mysql> show tables;
 ++---------------------------+
 +| Tables_in_mysql ​          |
 ++---------------------------+
 +| columns_priv ​             |
 +| db                        |
 +| event                     |
 +| func                      |
 +| general_log ​              |
 +| help_category ​            |
 +| help_keyword ​             |
 +| help_relation ​            |
 +| help_topic ​               |
 +| host                      |
 +| ndb_binlog_index ​         |
 +| plugin ​                   |
 +| proc                      |
 +| procs_priv ​               |
 +| proxies_priv ​             |
 +| servers ​                  |
 +| slow_log ​                 |
 +| tables_priv ​              |
 +| time_zone ​                |
 +| time_zone_leap_second ​    |
 +| time_zone_name ​           |
 +| time_zone_transition ​     |
 +| time_zone_transition_type |
 +| user                      |
 ++---------------------------+
 +24 rows in set (0.00 sec)
 +
 +mysql> ​
 +
 +</​code>​
 +<​code>​
 +
 +1. Configure Exim4
 +
 +Exim4 is installed by default, but it needs to be reconfigured to setup a Gmail server configuration :
 +
 +# dpkg-reconfigure exim4-config
 +
 +You will ge thru a setup procedure. Make sure to set it up as follow :
 +Option Choice ​
 + ​Configuration type mail sent by smarthost; received via SMTP or fetchmail
 + ​System mail name localhost
 + ​IP-addresses to listen on for incoming SMTP connections 127.0.0.1 (to refuse external connections)
 +Other destinations for which mail is accepted leave empty
 +Machines to relay mail for leave empty
 +IP address or host name of the outgoing smarthost smtp.gmail.com:​587
 +Hide local mail name in outgoing mail ? no
 +Keep number of DNS-queries minimal (Dial-on-Demand) ? no
 +Delivery method for local mail mbox format in /var/mail/
 +Split configuration into small files ? yes
 +
 + 
 +2. Declare your Gmail account
 +
 +As Gmail is using authentification on its smtp servers, you need to declare your account:​password for the gmail servers.
 +
 +This is done in the file /​etc/​exim4/​passwd.client where you have to declare any server gmail can use.
 +
 +/​etc/​exim4/​passwd.client
 +
 +# password file used when the local exim is authenticating to a remote
 +# host as a client.
 +#
 +# see exim4_passwd_client(5) for more documentation
 +#
 +# Example:
 +### target.mail.server.example:​login:​password
 +gmail-smtp.l.google.com:​your.account@gmail.com:​yourpassword
 +*.google.com:​your.account@gmail.com:​yourpassword
 +smtp.gmail.com:​your.account@gmail.com:​yourpassword
 +
 +As Exim is quite touchy about the rights of its password files, it's better to explicitly setup proper ownership and permissions.
 +
 +# chown Debian-exim:​root /​etc/​exim4/​passwd.client
 +# chmod 640 /​etc/​exim4/​passwd.client
 +
 +Finally, we need to reload exim4 for the setup to be used.
 +
 +We will also configure it to do a delivery attempt for every message, whether frozen or not (-qff option).
 +
 +# update-exim4.conf
 +# invoke-rc.d exim4 restart
 +# exim4 -qff
 +
 +3. Send your first mail
 +
 +Everything is now ready to send your first command line email.
 +
 +To send your first mail, you now need to prepare the email body in a text file.
 +
 +This email body should respect a specific structure that will provide :
 +
 +    the Recipient (to:)
 +    the Sender (from:)
 +    the Subject (subject:)
 +    the mail text
 +
 +/​root/​mail-body.txt
 +
 +to : your.account@gmail.com
 +from : Your server name
 +subject : Test mail
 +
 +This is the first mail sent by my server'​s sendmail !
 +
 +Now that the mail body is ready, you just need to pass it to sendmail with the -t option for it to send the mail :
 +
 +# cat /​root/​mail-body.txt | sendmail -t
 +
 +You should receive a mail like this one :
 +
 +debian-sendmail-message
 +
 + 
 +
 +Hope it helps.
 +</​code>​
 +
 +<​code>​
 +# exportfs -v
 +/​assets ​      ​ <​world>​(rw,​wdelay,​root_squash,​no_subtree_check,​sec=sys,​rw,​root_squash,​no_all_squash)
 +/​asset2 ​      ​ <​world>​(rw,​wdelay,​root_squash,​no_subtree_check,​sec=sys,​rw,​root_squash,​no_all_squash)
 +# cat /​etc/​exports
 +# /​etc/​exports:​ the access control list for filesystems which may be exported
 +# to NFS clients. ​ See exports(5).
 +#
 +# Example for NFSv2 and NFSv3:
 +# /​srv/​homes ​      ​hostname1(rw,​sync,​no_subtree_check) hostname2(ro,​sync,​no_subtree_check)
 +#
 +# Example for NFSv4:
 +# /​srv/​nfs4 ​       gss/​krb5i(rw,​sync,​fsid=0,​crossmnt,​no_subtree_check)
 +# /​srv/​nfs4/​homes ​ gss/​krb5i(rw,​sync,​no_subtree_check)
 +#
 +/assets *(rw,​no_subtree_check)
 +/asset2 *(rw,​no_subtree_check)
 +
 +</​code>​
 +
 +[[http://​docs.datastax.com/​en/​cassandra/​2.0/​cassandra/​install/​installDeb_t.html | Cassandra Install]]
  
ec2_config.1436276479.txt.gz · Last modified: 2021/06/04 02:16 (external edit)