Monday, 4 September 2017

INSTALL MYSQL ON CENTOS 6 WITH REMOTE ACCESS:-


rpm -qa | grep mysql
yum remove <ouput mysql label>
yum -y install epel-release; yum clean all
yum -y install mysql-server mysql pwgen supervisor bash-completion psmisc net-tools; yum clean all

#optional steps
mysql_install_db
chown -R mysql:mysql /var/lib/mysql
/usr/bin/mysqld_safe & sleep 10

mysqladmin -u root password jagdeep
#login to mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'jagdeep' WITH GRANT OPTION; FLUSH PRIVILEGES;
>>OR without login
mysql -uroot -pjagdeep -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'jagdeep' WITH GRANT OPTION; FLUSH PRIVILEGES;

#Update password:-
         mysql -u root -p
mysql> use mysql;
mysql> update user set password=PASSWORD("JAGDEEP") where User='root';
mysql> flush privileges;
mysql> quit
/etc/init.d/mysqld restart

#execute mysql db script after login in to mysql
        >> source /home/jagdeep/test.sql;


#HERE ADDING PORT IN FIREWALL
>>vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
# No need to add rule for output because in output accepting all
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

>>/etc/init.d/iptables restart
##IF YOU DON'T WANT TO ADD RULE IN FIREWALL THEN YOU  NEED TO STOP IPTABLES
>>/etc/init.d/iptables stop

[mysqld]
datadir=/var/lib/mysqld
socket=/var/lib/mysql/mysql.sock
user=root
symbolic-links=0
 lower_case_table_names=1
bind-address=0.0.0.0
Note:- lower_case_table_names is used for case insensitive.

#Mysql Admin command:-
    /usr/bin/mysqladmin -u root password 'new-password'
   mysqladmin -uroot -pjagdeep variables
   mysqladmin -uroot -pjagdeep version variables

 Note:-  By using "mysqladmin -uroot -pjagdeep variables" this command we can see default  variable values. If we want to override it, it can be done by my.cnf file.

Thursday, 31 August 2017

Vagrant

1. Need to download virtual machine from  https://www.virtualbox.org/wiki/Downloads
2. Download VM Package according to version https://www.virtualbox.org/wiki/Downloads
3. Download vagrant from  https://www.vagrantup.com/downloads.html

Firstly, install VM
Then install vagrant, which will be help to setup the vagrant environment for setup the VM
After installing vagrant , Run below mentioned command:-

> vagrant init
  - This command will generate the default vagrant file and directory structure
  - Edit the vagrant file and update below mentioned code in vagrant file

    VAGRANTFILE_API_VERSION = "2"


Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :chefMaster do |master|
  master.vm.hostname = "<here enter host i.e. abc.com>"
  master.vm.box      = "<here enter box name i.e. base>"
             master.vm.boot_timeout = <time out in number>
  master.vm.box_url  = "<here enter box image url>"
 master.vm.network :private_network, ip: "<here type ip address>"    
 master.vm.network :forwarded_port, guest: 443, host: 8443

 config.vm.provider :virtualbox do |master|
master.customize ["modifyvm", :id, "--memory", "1024"]
 end

end

end


> vagrant up
   - This command will download the vm at local and access it with mentioned ip in vagrant file.
   - Default credential is root/vagrant

Monday, 10 April 2017