Friday 10 February 2017

How to install MemSQL Manually on ubuntu 14.04 using

Steps for a Fresh Installation of MEMSQL

  • Run below command to check current running MEMSQL processes. The following command should now show nothing:
ps aux | grep memsql
a = show processes for all users | u = display the process's user/owner | x = also show processes not attached to a terminal
  • Configure the Linux virtual machine settings.
sysctl -w vm.max_map_count=1000000000
sysctl -w vm.min_free_kbytes=164330
Or, optionally, at root, edit the /etc/sysctl.conf file at root as the superuser. Add or edit the virtual machine settings.
sudo su
sudo vi /etc/sysctl.conf
vm.max_map_count=1000000000
vm.min_free_kbytes=500000
i = Insert Mode | Esc = Normal Mode | :w! = force save changes | :q = quits and closes | :wq! = force save and quits
  • Configure the Linux ulimit settings.
sudo su
ulimit -n 1000000
ulimit -u 128000
Or, optionally, at root, edit the /etc/security/limits.conf file.
sudo su
sudo vi /etc/security/limits.conf
ulimit -n 1000000
ulimit -u 128000
i = Insert Mode | Esc = Normal Mode | :w! = force saves changes | :q = quits and closes | :wq! = force saves and closes
  • Install the MySQL client
You will need a client to connect to our MemSQL database. You will install the MySQL client.
From root, get the MySQL client.
sudo su
whoami
sudo apt-get update --fix-missing
sudo apt-get install mysql-client

At the prompt, type Y to install the client.
Y
  • Add the memsql user
Add a memsql user to the machine.
If there is no memsql user, let’s create one.
sudo useradd memsql
Create a password for the memsql user. For the password, enter memsql.
sudo passwd memsql
memsql
memsql

Add the memsql user to the admin group.
sudo usermod -a -G admin memsql
Switch to the memsql user in a new shell.
sudo -u memsql -s /bin/bash
Verify that you are memsql.
whoami
  • Download and untar MemSQL
Download to the tmp directory.
cd /tmp
wget http://download.memsql.com/734707c866e44856989fef2942e9141b/memsqlbin_amd64.tar.gz

Create a local directory and change the ownership.
cd ..
sudo mkdir /var/lib/memsql/
cd /var/lib/
sudo chown -R memsql:memsql memsql

Verify the directory ownership.
ls -l
The memsql user should own the memsql directory.
drwxr-xr-x 2 memsql memsql 4096 Sep 20 22:08 memsql
Untar MemSQL as the memsql user and copy to /var/lib/memsql/.
whoami
cd /tmp
tar -xvzf memsqlbin_amd64.tar.gz -C /var/lib/memsql/

Confirm the successful installation.
cd /var/lib/memsql/
ls
You should see the memsqlbin folder.
  • Create leaf-3307, leaf-3308, and master-3306
Next, you will copy and rename the memsqlbin directory.

Copy the memsqlbin directory as leaf-3307
cp -r memsqlbin leaf-3307
ls

Copy the memsqlbin directory as leaf-3308
cp -r memsqlbin leaf-3308
ls

Rename the memsqlbin directory to master-3306
mv memsqlbin/ master-3306
ls

You should now see three directories in /var/lib/memsql:
leaf-3307 leaf-3308 master-3306
  • On port 3307, start leaf-3307
You will start the leaf after making some configuration file changes.

For leaf-3307, edit the memsql.cnf file.
sudo -u memsql -s /bin/bash
cd /var/lib/memsql/leaf-3307/
sudo vi memsql.cnf
Bind the leaf to port 3307.
; ---------------------------------
; MySQL-style configuration options
; ---------------------------------
basedir = .
tmpdir = .
lc-messages-dir = ./share
socket = memsql.sock
port = 3307
lock_wait_timeout = 60
bind-address = 0.0.0.0
max-connections = 100000
core-file
i = Insert Mode | Esc = Normal Mode | :w! = force save changes | :q = quits and closes | :wq! = force save and quits

Start MemSQL with the ./service scripts (not generic service).
./service start
In the console, you should now see:
* Starting memsqld [ OK ]
* Waiting up to 60 seconds for a clean start [ OK ]
The following command should now show various user processes:
ps aux | grep memsql
Connect to MemSQL.
Connect to the leaf on port 3307.
mysql -h <your-host-ip> –u root –P 3307
At the mysql prompt, enter:
show databases;
Verify the two databases, information_schema and memsql, and exit.
exit;
  • On port 3308, start leaf-3308
You will start the leaf after making some configuration file changes. These are the same steps for leaf-3307 except that you are binding the leaf to port 3308.

For leaf-3308, edit the memsql.cnf file.
sudo -u memsql -s /bin/bash
cd /var/lib/memsql/leaf-3308/
sudo vi memsql.cnf

Bind the leaf to port 3308.
; ---------------------------------
; MySQL-style configuration options
; ---------------------------------
basedir = .
tmpdir = .
lc-messages-dir = ./share
socket = memsql.sock
port = 3308
lock_wait_timeout = 60
bind-address = 0.0.0.0
max-connections = 100000
core-file
i = Insert Mode | Esc = Normal Mode | :w! = force save changes | :q = quits and closes | :wq! = force save and quits

Start MemSQL with the ./service scripts (not generic service).
./service start
In the console, you should now see:
* Starting memsqld [ OK ]
* Waiting up to 60 seconds for a clean start [ OK ]

The following command should now show various user processes:
ps aux | grep memsql
Connect to MemSQL.
Connect to the leaf on port 3308.
mysql -h 127.0.0.1 –u root –P 3308
At the mysql prompt, enter:
show databases;
Verify the two databases and exit.
exit;
  • On port 3306, start master-3306
You will start the master aggregator after making some configuration file changes. The steps are similar to configuring and starting a leaf.

For master-3306, edit the memsql.cnf file to declare the master aggregator.
sudo -u memsql -s /bin/bash
cd /var/lib/memsql/master-3306/
sudo vi memsql.cnf
Declare the master-aggregator.
; ---------------------------------
; MySQL-style configuration options
; ---------------------------------
basedir = .
tmpdir = .
lc-messages-dir = ./share
socket = memsql.sock
port = 3306
lock_wait_timeout = 60
bind-address = 0.0.0.0
max-connections = 100000
core-file
master-aggregator
i = Insert Mode | Esc = Normal Mode | :w! = force save changes | :q = quits and closes | :wq! = force save and quits

Start MemSQL with the ./service scripts (not generic service).
./service start
In the console, you should now see:
* Starting memsqld [ OK ]
* Waiting up to 60 seconds for a clean start [ OK ]

View the tracelogs.
cd tracelogs
ls
Verify the command.log, memsql.log, and query.log files.

The following command should now show various user processes:
ps aux | grep memsql
Verify that you see processes for leaf-3307, leaf-3308, and master-3306.

  • Add a leaf for 3307
Connect to the master aggregator with the MySQL client.
mysql -h <your-host-ip> –u root -P 3306

The host IP can be a public IP or public host name. In most cases, it is the internal IP or host name. It is also possible to use the machine IP or host name.

At the mysql prompt, enter:
show databases;
Verify the three database:
information_schema
memsql
sharding


Set Redundancy Level to 2.
set global redundancy_level=2;
show variables like '%redun%';

At the mysql prompt, enter:
show leaves;

Verify that the command returns an empty set.
Add a Leaf for port 3307 into Group 1.
ADD LEAF root@'<your-host-ip>':3307 into group 1;

The host IP can be a public IP or public host name. In most cases, it is the internal IP or host name. It is also possible to use the machine IP or host name.

Verify the Leaf.
show leaves;

The console output should look like:
+-----------+------+--------------------+-----------+-----------+--------+--------------------+------------------------------+
| Host | Port | Availability_Group | Pair_Host | Pair_Port | State | Opened_Connections | Average_Roundtrip_Latency_ms |
+-----------+------+--------------------+-----------+-----------+--------+--------------------+------------------------------+
| 127.0.0.1 | 3307 | 1 | NULL | NULL | online | 1 | 0.487 |
+-----------+------+--------------------+-----------+-----------+--------+--------------------+------------------------------+

  • Add a leaf for 3308
Add a Leaf for port 3308 into Group 2.
ADD LEAF root@'<your-host-name':3308 INTO group 2;

Verify the leaves.
show leaves;

The console output should look like:
+-----------+------+--------------------+-----------+-----------+--------+--------------------+------------------------------+
| Host | Port | Availability_Group | Pair_Host | Pair_Port | State | Opened_Connections | Average_Roundtrip_Latency_ms |
+-----------+------+--------------------+-----------+-----------+--------+--------------------+------------------------------+
| 127.0.0.1 | 3307 | 1 | 127.0.0.1 | 3308 | online | 1 | 0.345 |
| 127.0.0.1 | 3308 | 2 | 127.0.0.1 | 3307 | online | 1 | 0.281 |
+-----------+------+--------------------+-----------+-----------+--------+--------------------+------------------------------+

FINAL: Create a database and table on the master aggregator and insert some data. 
             Verify the databases. using show databases extended ; on leaf nodes.


No comments:

Post a Comment