Sunday, September 18, 2016

Install Mysql, MongoDB and JAVA

Install Mysql

1. Extracting the binaries. This is where we are going to extract the binaries. When we extract the binaries, the following steps need to be taken into consideration.

# Default location available in the config files are
/usr/local/mysql.

# If you plan to install these in a different location, you have
to set the installation location in each configuration script.

# It is assumed here that the setup is done at the location
/usr/apps/mysql5.7 and the data files are being installed into
/usr/local/mysql/data

a. Navigate to the location. (your desired installation location)
shell> cd /usr/apps/mysql5.7

b. Extract the tar file.
shell> tar -zxvf /path/to/mysql-VERSION-OS.tar.gz

c. Create a symlink to the installation directory.
shell> ln -s full-path-to-mysql-VERSION-OS mysql

d. Change directory to mysql
shell> cd mysql

e. Create a new directory "mysql-files" and set permissions for that.
shell> mkdir mysql-files
shell> chmod 750 mysql-files


2. Once the directory structure is created and the permissions & ownerships are set, we are ready to configure the databases. Here, before proceeding with command execution, we need to change the scripts that are executed to do the configurations.

a. Open the file /usr/apps/mysql5.7/bin/mysqld_safe in a text editor with elevated privileges.

b. Modify the file as given in the picture below.

c. Open the file /usr/apps/mysql5.7/bin/mysql.server in a text editor with elevated privileges.

d. Modify the file as given in the pictures below.

# What actually happens here is you are pointing out your MySQL installation's data directory and the binaries directory to these scripts for them to properly run.


4. Once you are done with these, you are now ready to roll. This is how the database server daemon should be configured.

a. Initializing the database. Run either one of the following commands based on your version.
In your case it should be the second command.
shell> bin/mysql_install_db --user=mysql    # Before MySQL 5.7.6
shell> bin/mysqld --initialize --user=mysql  # MySQL 5.7.6 and up

b. Run the following and setup ssl for MySQL server with RSA. This is only required is it is MySQL 5.7.6 & up.
shell> bin/mysql_ssl_rsa_setup  # MySQL 5.7.6 and up



5. That's it. If everything is exactly done, the following should launch the mysqld in the safe mode.

shell> bin/mysqld_safe --user=mysql &

# After executing above, if you get no error, that implies your
configuration is successful. This could further be confirmed with the
following command.

ps -A | grep mysql

That should populate some result as follows.

PID  TTY   TIME CMD

1 ?          00:00:01 --CODINGGROUND-
25  pts/0 00:00:00 mysqld_safe
31  pts/0 00:00:00 mysql


6. Add the /usr/apps/mysql5.7/bin to your PATH , so that you could access the daemon and other binaries from any location.


7. After setting the path, restart your PC, open a terminal, type mysql -u root -p and press enter. It should prompt you for a password and once the correct password is given, you should get the
mysql> prompt.


Install MongoDB

1. Download the binaries from https://www.mongodb.org/downloads.

2. Extract the files from the downloaded archive to the installation directory

tar -zxvf mongodb-linux-x86_64-3.2.9.tgz   /home/softwares

3. Ensure the location of the binaries is in the PATH variable.

<mongodb-install-directory>/bin

4. Create the data directory

Before you start MongoDB for the first time, create the directory to which the mongod process will write data. By default, the mongod process uses the /data/db directory. If you create a directory other than this one, you must specify that directory in the dbpath option when starting the mongod process later in this procedure.

The following example command creates the default /data/db directory:

mkdir -p /data/db

5. Set permissions for the data directory

Before running mongod for the first time, ensure that the user account running mongod has read and write permissions for the directory.

6. Run MongoDB

  • Run without specifying paths
If your system PATH variable includes the location of the mongod binary and if you use the default data directory (i.e., /data/db), simply enter mongod at the system prompt:

mongod

  • Specify the path of the mongod
If your PATH does not include the location of the mongod binary, enter the full path to the mongod binary at the system prompt:

<path to binary>/mongod

  • Specify the path of the data directory
If you do not use the default data directory (i.e., /data/db), specify the path to the data directory using the --dbpath option:

mongod --dbpath <path to data directory>

7. Begin using MongoDB.

To help you start using MongoDB, MongoDB provides Getting Started Guides in various driver editions. See Getting Started for the available editions.

Before deploying MongoDB in a production environment, consider the Production Notes document.

Later, to stop MongoDB, press Control+C in the terminal where the mongod instance is running.


Install JAVA 

1. Downloading Oracle Java JDK

go to the oracle java SE website and download tar.gz file. Remember to choose the right tar file(64 or 32 bits)

2. Extract java into the installation directory:

tar -zxf jdk-8u5-linux-x64.tar.gz -C /home/softwares

3. Set path varables

add path of bin directory of jdk in /etc/environment file
eg: /home/softwares/jdk1.8.0_05/bin

also add JAVA_HOME variable
 JAVA_HOME : "/home/softwares/jdk1.8.0_05"

4. Setting Oracle JDK as the default JVM

In our case, the java executable is located under /home/softwares/jdk1.8.0_05/bin/java . To set it as the default JVM in your machine run:

update-alternatives --install /usr/bin/java java /home/softwares/jdk1.8.0_05/bin/java 100

and

update-alternatives --install /usr/bin/javac javac /home/softwares/jdk1.8.0_05/bin/javac 100

5. Verify your installation

java -version

No comments:

Post a Comment