Kamis, 27 September 2018

How to start and stop IBM MQ broker service

  Tidak ada komentar
Login as mqsi user
login as: mquser
[email protected]'s password:
Last login: Thu Sep 20 16:36:14 2018 from 192.168.72.234

MQSI 9.0.0.2
/opt/ibm/mqsi/9.0.0.2

Check MQ list status
[mquser@devsoa ~]$ mqsilist
BIP1285I: Broker 'TES_DEV' on queue manager 'TESQ_DEV' is stopped.
BIP8071I: Successful command completion.
[mquser@devsoa ~]$ uptime
 17:58:30 up 10 days,  1:54,  2 users,  load average: 0.27, 0.16, 0.06
[mquser@devsoa ~]$ mqsistart TEST_DEV
WebSphere MQ queue manager 'TESTQ_DEV' starting.
The queue manager is associated with installation 'Installation1'.
9 log records accessed on queue manager 'TESQ_DEV' during the log replay phase.
Log replay for queue manager 'TESQ_DEV' complete.
Transaction manager state recovered for queue manager 'TESQ_DEV'.
WebSphere MQ queue manager 'TESQ_DEV' started using V8.0.0.2.
BIP8096I: Successful command initiation, check the system log to ensure that the component started without problem and that it continues to run without problem.
[mquser@devsoa ~]$
Running the mq service with following commad and check the listen port
[mquser@devsoa ~]$ runmqlsr -t tcp -p 1551 -m TESTQ_DEV&
[1] 29499
[mquser@devsoa ~]$ 5724-H72 (C) Copyright IBM Corp. 1994, 2014.

[mquser@devsoa ~]$ netstat -atn | grep 6969
tcp        0      0 :::6969                    :::*                        LISTEN
[mquser@devsoa ~]$
If you are preparing to stop a broker, you can stop the broker's WebSphere® MQ queue manager at the same time.

You can specify a -q parameter on the mqsistop command to initiate a controlled shutdown of the queue manager for a broker.

To stop a WebSphere MQ queue manager enter the following command on the command line:
mqsistop IB9NODE  -qCopy
where:

IB9NODE is the name of the broker.

-q stops the WebSphere MQ queue manager associated with the component.

The command cannot complete until shutdown of the queue manager has completed.
[mquser@devsoa ~]$ mqsistop TES_DEV -q
[mquser@devsoa ~]$ 

[mquser@devsoa ~]$ endmqlsr -m TESTQ_DEV
[mquser@devsoa ~]$ endmqm TESTQ_DEV

Rabu, 26 September 2018

How to upgrade check mk agent version

  Tidak ada komentar
Running check mk
[root@traveler ~]# check_mk_agent
<<<check_mk>>>
Version: 1.2.4p3
AgentOS: linux
PluginsDirectory: /usr/lib/check_mk_agent/plugins
LocalDirectory: /usr/lib/check_mk_agent/local
SpoolDirectory: /etc/check_mk/spool
AgentDirectory: /etc/check_mk
<<<df>>>
/dev/mapper/vg_traveler5-LogVol01 ext4   100791728 12224496  83447232      13% /
/dev/sda2                         ext4      198337    35356    152741      19% /boot
/dev/sda1                         vfat      204580      260    204320       1% /boot/efi
/dev/mapper/vg_traveler5-LogVol03 ext4   132711808  5338044 120632364       5% /local
/dev/mapper/vg_traveler5-LogVol02 ext4    50395844  2567632  45268212       6% /opt
<<<nfsmounts>>>
<<<mounts>>>
/dev/mapper/vg_traveler5-LogVol01 / ext4 rw,relatime,barrier=1,stripe=64,data=ordered 0 0
/dev/sda2 /boot ext4 rw,relatime,barrier=1,stripe=256,data=ordered 0 0
/dev/sda1 /boot/efi vfat rw,relatime,fmask=0077,dmask=0077,codepage=cp437,iocharset=ascii,shortname=winnt,errors=remount-ro 0 0
/dev/mapper/vg_traveler5-LogVol03 /local ext4 rw,relatime,barrier=1,stripe=64,data=ordered 0 0
/dev/mapper/vg_traveler5-LogVol02 /opt ext4 rw,relatime,barrier=1,stripe=64,data=ordered 0 0
<<<ps>>>
From the result above indicate that check mk agent version is 1.2.43

Install newer check mk agent by running yum as shown on following figure
[root@traveler ~]# yum install http://192.168.70.250/monitoring/check_mk/agents/check-mk-agent-1.5.0p4-1.noarch.rpm
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
file:///media/rhel6/repodata/repomd.xml: [Errno 14] Could not open/read file:///media/rhel6/repodata/repomd.xml
Trying other mirror.
Setting up Install Process
check-mk-agent-1.5.0p4-1.noarch.rpm                                                                            |  33 kB     00:00
Examining /var/tmp/yum-root-i97A6y/check-mk-agent-1.5.0p4-1.noarch.rpm: check-mk-agent-1.5.0p4-1.noarch
Marking /var/tmp/yum-root-i97A6y/check-mk-agent-1.5.0p4-1.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package check-mk-agent.noarch 0:1.5.0p4-1 will be obsoleting
---> Package check_mk-agent.noarch 0:1.2.4p3-1 will be obsoleted
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================
 Package                       Arch                  Version                    Repository                                       Size
======================================================================================================================================
Installing:
 check-mk-agent                noarch                1.5.0p4-1                  /check-mk-agent-1.5.0p4-1.noarch                 63 k
     replacing  check_mk-agent.noarch 1.2.4p3-1

Transaction Summary
======================================================================================================================================
Install       1 Package(s)

Total size: 63 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : check-mk-agent-1.5.0p4-1.noarch                                                                                    1/2
warning: /etc/xinetd.d/check_mk created as /etc/xinetd.d/check_mk.rpmnew
Activating startscript of xinetd
Reloading xinetd...
Reloading configuration: [  OK  ]
  Erasing    : check_mk-agent-1.2.4p3-1.noarch                                                                                    2/2
  Verifying  : check-mk-agent-1.5.0p4-1.noarch                                                                                    1/2
  Verifying  : check_mk-agent-1.2.4p3-1.noarch                                                                                    2/2

Installed:
  check-mk-agent.noarch 0:1.5.0p4-1

Replaced:
  check_mk-agent.noarch 0:1.2.4p3-1

Complete!
[root@traveler ~]#
Check mk version was updated to 1.5.0.4, and xinetd service was restarted during installation process

Running  check mk agent 
[root@traveler5 ~]# check_mk_agent
<<<check_mk>>>
Version: 1.5.0p4
AgentOS: linux
Hostname: traveler5.dephub.go.id
AgentDirectory: /etc/check_mk
DataDirectory: /var/lib/check_mk_agent
SpoolDirectory: /var/lib/check_mk_agent/spool
PluginsDirectory: /usr/lib/check_mk_agent/plugins
LocalDirectory: /usr/lib/check_mk_agent/local
<<<df>>>
/dev/mapper/vg_traveler5-LogVol01 ext4    100791728 12224428  83447300      13% /
tmpfs                             tmpfs    66019332      152  66019180       1% /dev/shm
/dev/sda2                         ext4       198337    35356    152741      19% /boot
/dev/sda1                         vfat       204580      260    204320       1% /boot/efi
/dev/mapper/vg_traveler5-LogVol03 ext4    132711808  5338032 120632376       5% /local
/dev/mapper/vg_traveler5-LogVol02 ext4     50395844  2567632  45268212       6% /opt
The check mk agent result shown the version was updated to 1.5.0.p4

Senin, 24 September 2018

How to reset mysql 5.7 root password from command line

  Tidak ada komentar
MySQL version
[msteam@dbbackup ~]$ mysql -V
mysql  Ver 14.14 Distrib 5.7.15, for Linux (x86_64) using  EditLine wrapper
[msteam@dbbackup ~]$
Check status and stop mysql service
[msteam@dbbackup ~]$ sudo service mysqld status
mysqld (pid  29946) is running...
[msteam@dbbackup ~]$
[msteam@dbbackup ~]$ sudo service mysqld stop
Stopping mysqld:                                           [  OK  ]
[msteam@dbbackup ~]$
[msteam@dbbackup ~]$ sudo service mysqld status
mysqld is stopped
Start mysql service with skipping grant table
[msteam@dbbackup ~]$ sudo mysqld_safe --skip-grant-tables &
[1] 27503
[msteam@dbbackup ~]$ 2018-09-24T10:22:18.602519Z mysqld_safe Logging to '/var/log/mysqld.log'.
2018-09-24T10:22:18.641748Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

[msteam@dbbackup ~]$
Enter to mysql and change the root password
[msteam@dbbackup ~]$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.7.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> update mysql.user set authentication_string=password('NewPassword') where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> quit;
Bye
[msteam@dbbackup ~]$
Restart mysql service
[msteam@dbbackup ~]$ sudo service mysqld restart
[sudo] password for msteam:
2018-09-24T10:29:47.899437Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[1]+  Done                    sudo mysqld_safe --skip-grant-tables
[msteam@dbbackup ~]$

Trying login to mysql without password to make sure our grant table not skipping
[msteam@dbbackup ~]$ mysql
ERROR 1045 (28000): Access denied for user 'msteam'@'localhost' (using password: NO)
[msteam@dbbackup ~]$
Enter to mysql using new root password that we set before
[msteam@dbbackup ~]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

How to run open vpn client load configuration from command line

  Tidak ada komentar
Here i share how to run open vpn client load configuration from command line
maswachid@Lenovo-G470:~$ sudo openvpn --config '/home/jglerner/Desktop/vpnbook-us1-tcp443.ovpn'
After open vpn success fully connected, there will be a new interface tunnel as shown on following figure
maswachid@Lenovo-G470:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether dc:0e:a1:f8:c4:4a brd ff:ff:ff:ff:ff:ff
3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 74:e5:43:19:e1:8f brd ff:ff:ff:ff:ff:ff
    inet 172.16.221.186/24 brd 172.16.221.255 scope global dynamic wlp2s0
       valid_lft 518sec preferred_lft 518sec
    inet6 fe80::2f98:b071:f643:5663/64 scope link 
       valid_lft forever preferred_lft forever
4: dummy0: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether ca:72:75:4e:90:fd brd ff:ff:ff:ff:ff:ff
    inet6 fe80::c872:75ff:fe4e:90fd/64 scope link 
       valid_lft forever preferred_lft forever
6: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
    link/none 
    inet 172.16.212.60/24 brd 172.16.212.255 scope global tun0
       valid_lft forever preferred_lft forever
maswachid@Lenovo-G470:~$ 

How to add static route on Ubuntu via command line

  Tidak ada komentar
To add static route
maswachid@Lenovo-G470:~$ 
maswachid@Lenovo-G470:~$ sudo route add -net 10.252.242.0 netmask 255.255.255.0 gw 172.16.221.1
maswachid@Lenovo-G470:~$ 
maswachid@Lenovo-G470:~$ ping 10.252.242.163PING 10.252.242.163 (10.252.242.163) 56(84) bytes of data.
64 bytes from 10.252.242.163: icmp_seq=1 ttl=63 time=1.58 ms
64 bytes from 10.252.242.163: icmp_seq=2 ttl=63 time=1.70 ms
To add static route based on interface
maswachid@Lenovo-G470:~$ 
maswachid@Lenovo-G470:~$ sudo route add -net 10.252.242.0 netmask 255.255.255.0 dev tun0
maswachid@Lenovo-G470:~$ 
maswachid@Lenovo-G470:~$ ping 10.252.242.163PING 10.252.242.163 (10.252.242.163) 56(84) bytes of data.
64 bytes from 10.252.242.163: icmp_seq=1 ttl=63 time=1.58 ms
64 bytes from 10.252.242.163: icmp_seq=2 ttl=63 time=1.70 ms

To delete static route
maswachid@Lenovo-G470:~$ sudo route delete -net 10.252.242.0 netmask 255.255.255.0 gw 172.16.221.1
maswachid@Lenovo-G470:~$ 

To delete static route based on dev
maswachid@Lenovo-G470:~$ sudo route delete -net 10.252.242.0 netmask 255.255.255.0 dev wlp2s0
maswachid@Lenovo-G470:~$ 


Minggu, 23 September 2018

How to Setup MySQL (Master-Slave) Replication in RHEL, CentOS, Fedora

  Tidak ada komentar
The following tutorial aims to provide you a simple step-by-step guide for setting up MySQL (Master-Slave) Replication in RHEL 6.3/6.2/6.1/6/5.8, CentOS 6.3/6.2/6.1/6/5.8 and Fedora 17,16,15,14,13,12 using latest MySQL version. This guide is specially written for Redhat 6.6 Operating System, but also work with older version of Linux distributions with MySQL 5.x.

The MySQL Replication is very useful in terms of Data Security, Fail-over Solution, Database Backup from Slave, Analytics etc. We use the following things to carry the replication process. In your scenario it would be different.
  • Working Linux OS like CentOS 6.3, RedHat 6.3 or Fedora 17
  • Master and Slave are Redhat 6.6 Linux Servers.
  • Master IP Address is: 192.168.1.1.
  • Slave IP Address is: 192.168.1.2.
  • Master and Slave are on the same LAN network.
  • Master and Slave has MySQL version installed.
  • Master allow remote MySQL connections on port 3306.
[root@wachid ~]# mysql -V
mysql  Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
[root@wachid ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.6 (Santiago)
[root@wachid ~]#
We have two servers, one is Master with IP (192.168.1.1) and other is Slave as (192.168.1.2). We have divided the setup process in two phases to make things easier for you, In Phase I we will configure Master server and in Phase II with Slave server. Let’s start the replication setup process.
Phase I: Configure Master Server (192.168.1.1) for Replication
In Phase I, we will see the installation of MySQL, setting up Replication and then verifying replication.
Install a MySQL on Master Server
First, proceed with MySQL installation using YUM command. If you already have MySQL installation, you can skip this step.
[root@wachid ~]# yum install yum install mysql mysql-server
If you need detail about mysql 5.1 installation on Redhat 6 you can find in here
Configure a MySQL on Master Server
Open  my.cnf with vi editor
[root@wachid ~]# vi /etc/my.cnf
Configuration before edit shown on following figure
[root@wachid ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@wachid ~]#
Add the following entries under [mysqld] section and don’t forget to replacedb_wachid with database name that you would like to replicate on Slave.
server-id = 1
binlog-do-db=db_wachid
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/mysql-relay-bin.index
log-error = /var/lib/mysql/mysql.err
master-info-file = /var/lib/mysql/mysql-master.info
relay-log-info-file = /var/lib/mysql/mysql-relay-log.info
log-bin = /var/lib/mysql/mysql-bin
Save  my.cnf and the configuration will be like following figure 
[root@wachid ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

server-id = 1
binlog-do-db=db_wachid
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/mysql-relay-bin.index
log-error = /var/lib/mysql/mysql.err
master-info-file = /var/lib/mysql/mysql-master.info
relay-log-info-file = /var/lib/mysql/mysql-relay-log.info
log-bin = /var/lib/mysql/mysql-bin

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@wachid ~]#
Restart MySQL service
[root@wachid ~]# service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[root@wachid ~]#
Login into MySQL as root user and create the slave user and grant privileges for replication. Replace slave_user with user and   p4ssw0rd with your password.
[root@wachid ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY 'p4ssw0rd';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH TABLES WITH READ LOCK;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |      331 | db_wachid    |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

mysql>
mysql> quit
Please write down the File (mysql-bin.000001) and Position (331) numbers, we required these numbers later on Slave server. Next apply READ LOCK to databases to export all the database and master database information with mysqldump command.
[root@wachid ~]# mysqldump -u root -p --all-databases --master-data > /root/dbdump.db
Enter password:
-- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly.
[root@wachid ~]#
Once you’ve dump all the databases, now again connect to mysql as root user and unlcok tables.Once you’ve dump all the databases, now again connect to mysql as root user and unlcok tables.
[root@wachid ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.73-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> UNLOCK TABLES;
Query OK, 0 rows affected (0.00 sec)

mysql> quit;
Bye
[root@wachid ~]#
Transfer the database dump file on Slave Server (192.168.1.2) using SCP command.
[root@wachid yum.repos.d]# scp /root/dbdump.db [email protected]:/root/
[email protected]'s password:
dbdump.db                                     100%  514KB 514.4KB/s   00:00
[root@wachid yum.repos.d]#
That’s it we have successfully configured Master server, let’s proceed to Phase II section..
Phase II: Configure Slave Server (192.168.1.2) for Replication
In Phase II, we do the installation of MySQL, setting up Replication and then verifying replication.
Install a MySQL on Master Server
Install MySQL server, if you don't have then perform installation with following command
[root@wachid ~]# yum install yum install mysql mysql-server
Configure a MySQL on Slave Server

Restart MySQL service
[root@wachid ~]# service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[root@wachid ~]#
Now import the dump file to slave server with following command
[root@wachid ~]# mysql -u root -p < /root/dbdump.db
Enter password:
[root@wachid ~]#
You cannot import the dump file while mysql server running as slave, you will get this error
[root@wachid ~]# mysql -u root -p < /root/dbdump.db
Enter password:
ERROR 1198 (HY000) at line 22: This operation cannot be performed with a running slave; run STOP SLAVE first
[root@wachid ~]#
Open  my.cnf with vi editor
[root@wachid ~]# vi /etc/my.cnf
Configuration before edit shown on following figure
[root@wachid ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@wachid ~]#
Add the following entries under [mysqld] section and don’t forget to replacedb_wachid with database name that you would like to replicate with master.
server-id = 2
master-host=192.168.1.2
master-connect-retry=60
master-user=slave_user
master-password=p4ssw0rd
replicate-do-db=db_wachid
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/mysql-relay-bin.index
log-error = /var/lib/mysql/mysql.err
master-info-file = /var/lib/mysql/mysql-master.info
relay-log-info-file = /var/lib/mysql/mysql-relay-log.info
log-bin = /var/lib/mysql/mysql-bin
Save  my.cnf and the configuration will be like following figure 
[root@wachid ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

server-id = 2
master-host=192.168.1.2
master-connect-retry=60
master-user=slave_user
master-password=p4ssw0rd
replicate-do-db=db_wachid
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/mysql-relay-bin.index
log-error = /var/lib/mysql/mysql.err
master-info-file = /var/lib/mysql/mysql-master.info
relay-log-info-file = /var/lib/mysql/mysql-relay-log.info
log-bin = /var/lib/mysql/mysql-bin

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@wachid ~]#
Restart MySQL service again to reload new configuration
[root@wachid ~]# service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[root@wachid ~]#
Login into MySQL as root user and stop the slave. Then tell the slave to where to look for Master log file, that we have write down on master with SHOW MASTER STATUS; command as File (mysql-bin.000001) and Position (331) numbers. You must change 192.168.1.1 to the IP address of the Master Server, and change the user and password accordingly.
[root@wachid ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.73-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> slave stop;
Query OK, 0 rows affected (0.00 sec)

mysql> CHANGE MASTER TO MASTER_HOST='192.168.1.3', MASTER_USER='slave_user', MASTER_PASSWORD='p4ssw0rd', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=331;
Query OK, 0 rows affected (0.03 sec)

mysql> slave start;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.1.2
                  Master_User: slave_user
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000001
          Read_Master_Log_Pos: 331
               Relay_Log_File: mysql-relay-bin.000002
                Relay_Log_Pos: 251
        Relay_Master_Log_File: mysql-bin.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: db_wachid
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 331
              Relay_Log_Space: 406
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
1 row in set (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

mysql>
mysql> exit
Bye
Verifying MySQL Replication on Master and Slave Server

It’s really very important to know that the replication is working perfectly. On Master server create table and insert some values in it.

On Master
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

mysql>
mysql> create database db_wachid;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| db_wachid         |
+--------------------+
3 rows in set (0.00 sec)

mysql>
mysql> use db_wachid;
Database changed
mysql>
mysql> create table test_tab (col1 int);
Query OK, 0 rows affected (0.02 sec)

mysql> insert into test_tab (col1) values (10);
Query OK, 1 row affected (0.00 sec)

mysql> select * from test_tab;
+------+
| col1 |
+------+
|   10 |
+------+
1 row in set (0.00 sec)

mysql>
mysql> exit
Bye
On Slave
mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.1.2
                  Master_User: slave_user
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000001
          Read_Master_Log_Pos: 631
               Relay_Log_File: mysql-relay-bin.000004
                Relay_Log_Pos: 551
        Relay_Master_Log_File: mysql-bin.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: db_wachid
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 631
              Relay_Log_Space: 706
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
1 row in set (0.00 sec)

mysql>
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| db_wachid          |
| mysql              |
+--------------------+
3 rows in set (0.00 sec)

mysql>
mysql> use db_wachid;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql>
mysql> show tables;
+---------------------+
| Tables_in_db_wachid |
+---------------------+
| test_tab            |
+---------------------+
1 row in set (0.00 sec)

mysql>
mysql> select * from test_tab;
+------+
| col1 |
+------+
|   10 |
+------+
1 row in set (0.00 sec)

mysql>
That’s it, finally you’ve configured MySQL Replication in a few simple steps. More information can be found at MySQL Replication Guide.

How to install scp ssh client on redhat 6 minimal installation

  Tidak ada komentar
Some day i get an issue, i cannot find scp command on my redhat machine with minimal installation, after check the trouble is there is no ssh client installed on redhat 6 machine with minimal installation, here i share what i do to install ssh client on my redhat machine

[root@wachid ~]# scp /root/dbdump.db [email protected]:/root/
-bash: scp: command not found
[root@wachid ~]#
We have install the centos package repo first you can find how to install the centos package here, because the open ssh client are served by centos repo except your redhat subscribed to redhat repository
[root@wachid yum.repos.d]# yum list openssh-clients
Loaded plugins: product-id
Installed Packages
openssh-clients.x86_64                  5.3p1-123.el6_9                  @centos
[root@wachid yum.repos.d]#
[root@wachid yum.repos.d]#
Install the open-ssh client with enable centos repo as shown on following figure
[root@wachid yum.repos.d]#
[root@wachid yum.repos.d]# yum --enablerepo=centos install openssh-clients
Loaded plugins: product-id
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package openssh-clients.x86_64 0:5.3p1-123.el6_9 will be installed
--> Processing Dependency: openssh = 5.3p1-123.el6_9 for package: openssh-clients-5.3p1-123.el6_9.x86_64
--> Processing Dependency: libedit.so.0()(64bit) for package: openssh-clients-5.3p1-123.el6_9.x86_64
--> Running transaction check
---> Package libedit.x86_64 0:2.11-4.20080712cvs.1.el6 will be installed
---> Package openssh.x86_64 0:5.3p1-104.el6 will be updated
--> Processing Dependency: openssh = 5.3p1-104.el6 for package: openssh-server-5.3p1-104.el6.x86_64
---> Package openssh.x86_64 0:5.3p1-123.el6_9 will be an update
--> Running transaction check
---> Package openssh-server.x86_64 0:5.3p1-104.el6 will be updated
---> Package openssh-server.x86_64 0:5.3p1-123.el6_9 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch       Version                        Repository  Size
================================================================================
Installing:
 openssh-clients     x86_64     5.3p1-123.el6_9                centos     444 k
Installing for dependencies:
 libedit             x86_64     2.11-4.20080712cvs.1.el6       centos      74 k
Updating for dependencies:
 openssh             x86_64     5.3p1-123.el6_9                centos     277 k
 openssh-server      x86_64     5.3p1-123.el6_9                centos     329 k

Transaction Summary
================================================================================
Install       2 Package(s)
Upgrade       2 Package(s)

Total download size: 1.1 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): libedit-2.11-4.20080712cvs.1.el6.x86_64.rpm       |  74 kB     00:00
(2/4): openssh-5.3p1-123.el6_9.x86_64.rpm                | 277 kB     00:00
(3/4): openssh-clients-5.3p1-123.el6_9.x86_64.rpm        | 444 kB     00:00
(4/4): openssh-server-5.3p1-123.el6_9.x86_64.rpm         | 329 kB     00:00
--------------------------------------------------------------------------------
Total                                           1.7 MB/s | 1.1 MB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : openssh-5.3p1-123.el6_9.x86_64                               1/6
  Installing : libedit-2.11-4.20080712cvs.1.el6.x86_64                      2/6
  Installing : openssh-clients-5.3p1-123.el6_9.x86_64                       3/6
  Updating   : openssh-server-5.3p1-123.el6_9.x86_64                        4/6
  Cleanup    : openssh-server-5.3p1-104.el6.x86_64                          5/6
  Cleanup    : openssh-5.3p1-104.el6.x86_64                                 6/6
  Verifying  : openssh-clients-5.3p1-123.el6_9.x86_64                       1/6
  Verifying  : libedit-2.11-4.20080712cvs.1.el6.x86_64                      2/6
  Verifying  : openssh-5.3p1-123.el6_9.x86_64                               3/6
  Verifying  : openssh-server-5.3p1-123.el6_9.x86_64                        4/6
  Verifying  : openssh-server-5.3p1-104.el6.x86_64                          5/6
  Verifying  : openssh-5.3p1-104.el6.x86_64                                 6/6

Installed:
  openssh-clients.x86_64 0:5.3p1-123.el6_9

Dependency Installed:
  libedit.x86_64 0:2.11-4.20080712cvs.1.el6

Dependency Updated:
  openssh.x86_64 0:5.3p1-123.el6_9    openssh-server.x86_64 0:5.3p1-123.el6_9

Complete!
[root@wachid yum.repos.d]#
The ssh client successfully installed

How have to install ssh-client on both of server, instead you will get following error


[root@wachid yum.repos.d]# scp /root/dbdump.db [email protected]:/root/
The authenticity of host '192.168.1.6 (192.168.1.6)' can't be established.
RSA key fingerprint is 48:fc:6a:4d:cf:30:90:76:85:6d:94:03:59:74:1f:6e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.6' (RSA) to the list of known hosts.
[email protected]'s password:
bash: scp: command not found
lost connection
[root@wachid yum.repos.d]#
After we install ssh-client on both side, we can perform scp successfully

[root@wachid yum.repos.d]# yum list openssh-clients
Loaded plugins: product-id
Installed Packages
openssh-clients.x86_64                  5.3p1-123.el6_9                  @centos
[root@wachid yum.repos.d]#
[root@wachid yum.repos.d]#

How to fix Cannot retrieve repository metadata (repomd.xml) for repository: epel. redhat 6

  Tidak ada komentar
Some day i get an issue when install the openssh-client on my redhat 6 machine
[root@wachid ~]# yum install openssh-clients
Loaded plugins: product-id
Setting up Install Process
centos                                                   | 3.7 kB     00:00
centos/primary_db                                        | 4.7 MB     00:01
Error: Cannot retrieve repository metadata (repomd.xml) for repository: epel. Please verify its path and try again
[root@wachid ~]#
I got the sollution from website that we have to update nss package with ignoring epel repo, we update because the nss package is too old to can communicate with fedora repositories, update the nss package with following command line
[root@wachid yum.repos.d]# sudo yum --disablerepo="epel" update nss
Loaded plugins: product-id
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package nss.x86_64 0:3.16.1-14.el6 will be updated
--> Processing Dependency: nss = 3.16.1-14.el6 for package: nss-sysinit-3.16.1-14.el6.x86_64
--> Processing Dependency: nss(x86-64) = 3.16.1-14.el6 for package: nss-tools-3.16.1-14.el6.x86_64
---> Package nss.x86_64 0:3.36.0-8.el6 will be an update
--> Processing Dependency: nss-util >= 3.36.0 for package: nss-3.36.0-8.el6.x86_64
--> Processing Dependency: nss-softokn(x86-64) >= 3.14.3-22 for package: nss-3.36.0-8.el6.x86_64
--> Processing Dependency: nspr >= 4.19.0 for package: nss-3.36.0-8.el6.x86_64
--> Processing Dependency: libnssutil3.so(NSSUTIL_3.33)(64bit) for package: nss-3.36.0-8.el6.x86_64
--> Processing Dependency: libnssutil3.so(NSSUTIL_3.31)(64bit) for package: nss-3.36.0-8.el6.x86_64
--> Processing Dependency: libnssutil3.so(NSSUTIL_3.24)(64bit) for package: nss-3.36.0-8.el6.x86_64
--> Processing Dependency: libnssutil3.so(NSSUTIL_3.21)(64bit) for package: nss-3.36.0-8.el6.x86_64
--> Running transaction check
---> Package nspr.x86_64 0:4.10.6-1.el6_5 will be updated
---> Package nspr.x86_64 0:4.19.0-1.el6 will be an update
---> Package nss-softokn.x86_64 0:3.14.3-17.el6 will be updated
---> Package nss-softokn.x86_64 0:3.14.3-23.3.el6_8 will be an update
--> Processing Dependency: nss-softokn-freebl(x86-64) >= 3.14.3-23.3.el6_8 for package: nss-softokn-3.14.3-23.3.el6_8.x86_64
---> Package nss-sysinit.x86_64 0:3.16.1-14.el6 will be updated
---> Package nss-sysinit.x86_64 0:3.36.0-8.el6 will be an update
---> Package nss-tools.x86_64 0:3.16.1-14.el6 will be updated
---> Package nss-tools.x86_64 0:3.36.0-8.el6 will be an update
---> Package nss-util.x86_64 0:3.16.1-3.el6 will be updated
---> Package nss-util.x86_64 0:3.36.0-1.el6 will be an update
--> Running transaction check
---> Package nss-softokn-freebl.x86_64 0:3.14.3-17.el6 will be updated
---> Package nss-softokn-freebl.x86_64 0:3.14.3-23.3.el6_8 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                 Arch        Version                  Repository   Size
================================================================================
Updating:
 nss                     x86_64      3.36.0-8.el6             centos      865 k
Updating for dependencies:
 nspr                    x86_64      4.19.0-1.el6             centos      114 k
 nss-softokn             x86_64      3.14.3-23.3.el6_8        centos      262 k
 nss-softokn-freebl      x86_64      3.14.3-23.3.el6_8        centos      168 k
 nss-sysinit             x86_64      3.36.0-8.el6             centos       52 k
 nss-tools               x86_64      3.36.0-8.el6             centos      460 k
 nss-util                x86_64      3.36.0-1.el6             centos       72 k

Transaction Summary
================================================================================
Upgrade       7 Package(s)

Total download size: 1.9 M
Is this ok [y/N]: y
Downloading Packages:
(1/7): nspr-4.19.0-1.el6.x86_64.rpm                      | 114 kB     00:00
(2/7): nss-3.36.0-8.el6.x86_64.rpm                       | 865 kB     00:02
(3/7): nss-softokn-3.14.3-23.3.el6_8.x86_64.rpm          | 262 kB     00:01
(4/7): nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64.rpm   | 168 kB     00:01
(5/7): nss-sysinit-3.36.0-8.el6.x86_64.rpm               |  52 kB     00:00
(6/7): nss-tools-3.36.0-8.el6.x86_64.rpm                 | 460 kB     00:01
(7/7): nss-util-3.36.0-1.el6.x86_64.rpm                  |  72 kB     00:00
--------------------------------------------------------------------------------
Total                                           112 kB/s | 1.9 MB     00:17
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : nspr-4.19.0-1.el6.x86_64                                    1/14
  Updating   : nss-util-3.36.0-1.el6.x86_64                                2/14
  Updating   : nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64                 3/14
  Updating   : nss-softokn-3.14.3-23.3.el6_8.x86_64                        4/14
  Updating   : nss-sysinit-3.36.0-8.el6.x86_64                             5/14
  Updating   : nss-3.36.0-8.el6.x86_64                                     6/14
  Updating   : nss-tools-3.36.0-8.el6.x86_64                               7/14
  Cleanup    : nss-tools-3.16.1-14.el6.x86_64                              8/14
  Cleanup    : nss-sysinit-3.16.1-14.el6.x86_64                            9/14
  Cleanup    : nss-3.16.1-14.el6.x86_64                                   10/14
  Cleanup    : nss-softokn-3.14.3-17.el6.x86_64                           11/14
  Cleanup    : nss-util-3.16.1-3.el6.x86_64                               12/14
  Cleanup    : nspr-4.10.6-1.el6_5.x86_64                                 13/14
  Cleanup    : nss-softokn-freebl-3.14.3-17.el6.x86_64                    14/14
  Verifying  : nss-3.36.0-8.el6.x86_64                                     1/14
  Verifying  : nss-util-3.36.0-1.el6.x86_64                                2/14
  Verifying  : nss-softokn-3.14.3-23.3.el6_8.x86_64                        3/14
  Verifying  : nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64                 4/14
  Verifying  : nspr-4.19.0-1.el6.x86_64                                    5/14
  Verifying  : nss-sysinit-3.36.0-8.el6.x86_64                             6/14
  Verifying  : nss-tools-3.36.0-8.el6.x86_64                               7/14
  Verifying  : nss-sysinit-3.16.1-14.el6.x86_64                            8/14
  Verifying  : nspr-4.10.6-1.el6_5.x86_64                                  9/14
  Verifying  : nss-softokn-3.14.3-17.el6.x86_64                           10/14
  Verifying  : nss-util-3.16.1-3.el6.x86_64                               11/14
  Verifying  : nss-3.16.1-14.el6.x86_64                                   12/14
  Verifying  : nss-tools-3.16.1-14.el6.x86_64                             13/14
  Verifying  : nss-softokn-freebl-3.14.3-17.el6.x86_64                    14/14

Updated:
  nss.x86_64 0:3.36.0-8.el6

Dependency Updated:
  nspr.x86_64 0:4.19.0-1.el6
  nss-softokn.x86_64 0:3.14.3-23.3.el6_8
  nss-softokn-freebl.x86_64 0:3.14.3-23.3.el6_8
  nss-sysinit.x86_64 0:3.36.0-8.el6
  nss-tools.x86_64 0:3.36.0-8.el6
  nss-util.x86_64 0:3.36.0-1.el6

Complete!
[root@wachid yum.repos.d]#

Install the open-ssh client with enable centos repo as shown on following figure
[root@wachid yum.repos.d]#
[root@wachid yum.repos.d]# yum --enablerepo=centos install openssh-clients
Loaded plugins: product-id
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package openssh-clients.x86_64 0:5.3p1-123.el6_9 will be installed
--> Processing Dependency: openssh = 5.3p1-123.el6_9 for package: openssh-clients-5.3p1-123.el6_9.x86_64
--> Processing Dependency: libedit.so.0()(64bit) for package: openssh-clients-5.3p1-123.el6_9.x86_64
--> Running transaction check
---> Package libedit.x86_64 0:2.11-4.20080712cvs.1.el6 will be installed
---> Package openssh.x86_64 0:5.3p1-104.el6 will be updated
--> Processing Dependency: openssh = 5.3p1-104.el6 for package: openssh-server-5.3p1-104.el6.x86_64
---> Package openssh.x86_64 0:5.3p1-123.el6_9 will be an update
--> Running transaction check
---> Package openssh-server.x86_64 0:5.3p1-104.el6 will be updated
---> Package openssh-server.x86_64 0:5.3p1-123.el6_9 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch       Version                        Repository  Size
================================================================================
Installing:
 openssh-clients     x86_64     5.3p1-123.el6_9                centos     444 k
Installing for dependencies:
 libedit             x86_64     2.11-4.20080712cvs.1.el6       centos      74 k
Updating for dependencies:
 openssh             x86_64     5.3p1-123.el6_9                centos     277 k
 openssh-server      x86_64     5.3p1-123.el6_9                centos     329 k

Transaction Summary
================================================================================
Install       2 Package(s)
Upgrade       2 Package(s)

Total download size: 1.1 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): libedit-2.11-4.20080712cvs.1.el6.x86_64.rpm       |  74 kB     00:00
(2/4): openssh-5.3p1-123.el6_9.x86_64.rpm                | 277 kB     00:00
(3/4): openssh-clients-5.3p1-123.el6_9.x86_64.rpm        | 444 kB     00:00
(4/4): openssh-server-5.3p1-123.el6_9.x86_64.rpm         | 329 kB     00:00
--------------------------------------------------------------------------------
Total                                           1.7 MB/s | 1.1 MB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : openssh-5.3p1-123.el6_9.x86_64                               1/6
  Installing : libedit-2.11-4.20080712cvs.1.el6.x86_64                      2/6
  Installing : openssh-clients-5.3p1-123.el6_9.x86_64                       3/6
  Updating   : openssh-server-5.3p1-123.el6_9.x86_64                        4/6
  Cleanup    : openssh-server-5.3p1-104.el6.x86_64                          5/6
  Cleanup    : openssh-5.3p1-104.el6.x86_64                                 6/6
  Verifying  : openssh-clients-5.3p1-123.el6_9.x86_64                       1/6
  Verifying  : libedit-2.11-4.20080712cvs.1.el6.x86_64                      2/6
  Verifying  : openssh-5.3p1-123.el6_9.x86_64                               3/6
  Verifying  : openssh-server-5.3p1-123.el6_9.x86_64                        4/6
  Verifying  : openssh-server-5.3p1-104.el6.x86_64                          5/6
  Verifying  : openssh-5.3p1-104.el6.x86_64                                 6/6

Installed:
  openssh-clients.x86_64 0:5.3p1-123.el6_9

Dependency Installed:
  libedit.x86_64 0:2.11-4.20080712cvs.1.el6

Dependency Updated:
  openssh.x86_64 0:5.3p1-123.el6_9    openssh-server.x86_64 0:5.3p1-123.el6_9

Complete!
[root@wachid yum.repos.d]#
The ssh client successfully installed

Source : 

https://unix.stackexchange.com/questions/148144/unable-to-pull-epel-repository-metadata

How to install vnc server ubuntu with same session with dekstop x session

  Tidak ada komentar
Some day i need to install vnc server on my ubuntu dekstop that connected on public IP, here i share the tutorial how to install VNC server on Gnome Ubuntu desktop

Install the vnc server by following command
maswachid@Lenovo-G470:~$ sudo apt-get install x11vnc
[sudo] password for msteam:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  x11vnc-data
The following NEW packages will be installed:
  x11vnc x11vnc-data
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 1.148 kB of archives.
After this operation, 2.739 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://id.archive.ubuntu.com/ubuntu xenial/universe amd64 x11vnc-data all 0.9.13-1.2build1 [203 kB]
Get:2 http://id.archive.ubuntu.com/ubuntu xenial/universe amd64 x11vnc amd64 0.9.13-1.2build1 [944 kB]
Fetched 1.148 kB in 6s (167 kB/s)
Selecting previously unselected package x11vnc-data.
(Reading database ... 280157 files and directories currently installed.)
Preparing to unpack .../x11vnc-data_0.9.13-1.2build1_all.deb ...
Unpacking x11vnc-data (0.9.13-1.2build1) ...
Selecting previously unselected package x11vnc.
Preparing to unpack .../x11vnc_0.9.13-1.2build1_amd64.deb ...
Unpacking x11vnc (0.9.13-1.2build1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20180209-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for desktop-file-utils (0.22-1ubuntu5.2) ...
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Setting up x11vnc-data (0.9.13-1.2build1) ...
Setting up x11vnc (0.9.13-1.2build1) ...
maswachid@Lenovo-G470:~$

Start the vnc server with following command
msteam@Lenovo-G470:~$ x11vnc -display :0 -auth .Xauthority
##################################################################
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
#@                                                                                                                         @#
#@  **  WARNING  **  WARNING  **  WARNING  **  WARNING  **       @#
#@                                                                                                                         @#
#@        YOU ARE RUNNING X11VNC WITHOUT A PASSWORD!!           @#
#@                                                                                                                         @#
#@  This means anyone with network access to this computer                           @#
#@  may be able to view and control your desktop.                                            @#
#@                                                                                                                        @#
#@ >>> If you did not mean to do this Press CTRL-C now!! <<<                     @#
#@                                                                                                                        @#
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
#@                                                                                                                        @#
#@  You can create an x11vnc password file by running:                                   @#
#@                                                                                                                        @#
#@       x11vnc -storepasswd password /path/to/passfile                                     @#
#@  or   x11vnc -storepasswd /path/to/passfile                                                    @#
#@  or   x11vnc -storepasswd                                                                              @#
#@                                                                                                                        @#
#@  (the last one will use ~/.vnc/passwd)                                                            @#
#@                                                                                                                        @#
#@  and then starting x11vnc via:                                                                        @#
#@                                                                                                                        @#
#@      x11vnc -rfbauth /path/to/passfile                                                              @#
#@                                                                                                                        @#
#@  an existing ~/.vnc/passwd file from another VNC                                       @#
#@  application will work fine too.                                                                      @#
#@                                                                                                                        @#
#@  You can also use the -passwdfile or -passwd options.                                  @#
#@  (note -passwd is unsafe if local users are not trusted)                                  @#
#@                                                                                                                        @#
#@  Make sure any -rfbauth and -passwdfile password files                               @#
#@  cannot be read by untrusted users.                       @#
#@                                                           @#
#@  Use x11vnc -usepw to automatically use your              @#
#@  ~/.vnc/passwd or ~/.vnc/passwdfile password files.       @#
#@  (and prompt you to create ~/.vnc/passwd if neither       @#
#@  file exists.)  Under -usepw, x11vnc will exit if it      @#
#@  cannot find a password to use.                           @#
#@                                                           @#
#@                                                           @#
#@  Even with a password, the subsequent VNC traffic is      @#
#@  sent in the clear.  Consider tunnelling via ssh(1):      @#
#@                                                           @#
#@    http://www.karlrunge.com/x11vnc/#tunnelling            @#
#@                                                           @#
#@  Or using the x11vnc SSL options: -ssl and -stunnel       @#
#@                                                           @#
#@  Please Read the documention for more info about          @#
#@  passwords, security, and encryption.                     @#
#@                                                           @#
#@    http://www.karlrunge.com/x11vnc/faq.html#faq-passwd    @#
#@                                                           @#
#@  To disable this warning use the -nopw option, or put     @#
#@  'nopw' on a line in your ~/.x11vncrc file.               @#
#@                                                                                                                       @#
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
###############################################################
23/09/2018 15:38:23 x11vnc version: 0.9.13 lastmod: 2011-08-10  pid: 14899
23/09/2018 15:38:23 Using X display :0
23/09/2018 15:38:23 rootwin: 0xc0 reswin: 0xe00001 dpy: 0x1b42c40
23/09/2018 15:38:23 ...
You can set the password by typing following command
maswachid@Lenovo-G470:~$
maswachid@Lenovo-G470:~$ x11vnc -storepasswd
Enter VNC password:
Verify password:
Write password to /home/msteam/.vnc/passwd?  [y]/n y
Password written to: /home/msteam/.vnc/passwd
maswachid@Lenovo-G470:~$
To start the vnc server using password, type the following command
msteam@Lenovo-G470:~$ x11vnc -usepw -display :0 -auth .Xauthority
23/09/2018 16:34:11 -usepw: found /home/msteam/.vnc/passwd
23/09/2018 16:34:11 x11vnc version: 0.9.13 lastmod: 2011-08-10  pid: 21815
23/09/2018 16:34:11 Using X display :0
23/09/2018 16:34:11 rootwin: 0xc0 reswin: 0xe00001 dpy: 0xfaf050
23/09/2018 16:34:11
23/09/2018 16:34:11 ------------------ USEFUL INFORMATION ------------------
23/09/2018 16:34:11 X DAMAGE available on display, using it for polling hints.
23/09/2018 16:34:11   To disable this behavior use: '-noxdamage'
23/09/2018 16:34:11
23/09/2018 16:34:11   Most compositing window managers like 'compiz' or 'beryl'
23/09/2018 16:34:11   cause X DAMAGE to fail, and so you may not see any screen
23/09/2018 16:34:11   updates via VNC.  Either disable 'compiz' (recommended) or
23/09/2018 16:34:11   supply the x11vnc '-noxdamage' command line option.
23/09/2018 16:34:11
23/09/2018 16:34:11 Wireframing: -wireframe mode is in effect for window moves.
23/09/2018 16:34:11   If this yields undesired behavior (poor response, painting

You can start the vnc session on default port 5900 and use your password to login