cbrestore/cbbackup from Couchbase 5.5 to Couchbase 6.5 - couchbase

I have backed up data from an Couchbase 5.5 cluster, using the following command:
$ cbbackup http://couchbase:8091 ~/cbbackup -u *** -p ***
Then, I copied the ~/cbbackup files out of the cluster and onto my local machine.
I have a new Couchbase 6.5 cluster that I want to migrate the data to.
So then I copied ~/cbbackup in to the new cluster.
However, when I try to restore it in the Couchbase 6.5 cluster this happens:
$ cbrestore ~/cbbackup http://couchbase:8091 -u *** -p ***
2020-05-23 14:11:47,209: s0 error: async operation: error: conn.sendall() exception: [Errno 104] Connection reset by peer on sink: http://couchbase:8091(b'default'#b'couchbase-0001.couchbase.couchbase.svc:8091')
2020-05-23 14:11:47,221: s2 error: async operation: error: conn.sendall() exception: [Errno 104] Connection reset by peer on sink: http://couchbase:8091(b'default'#b'couchbase-0003.couchbase.couchbase.svc:8091')
2020-05-23 14:11:47,226: s1 error: async operation: error: conn.sendall() exception: [Errno 104] Connection reset by peer on sink: http://couchbase:8091(b'default'#b'couchbase-0002.couchbase.couchbase.svc:8091')
error: conn.sendall() exception: [Errno 104] Connection reset by peer
How can I restore the backup from Couchbase 5.5 to my Couchbase 6.5 cluster?

Luckily, I know exactly what you need!
According to this chart of version compatibility, it should be possible for Couchbase 6.5 to restore backups from all the way back to Couchbase 5.0.
The reason it's failing though, I'm not sure. According to this thread at the Couchbase forums, it could be because of some problem handling xattrs [MB-31224] made by Sync Gateway; but again, I'm not sure.
However, after much trial and error, what worked for me once was to use cbbackup from 6.5 to make a backup of the 5.5 cluster. Then it's not cbbackup from 5.5 and cbrestore from 6.5, but rather both from 6.5. And it worked!
My setup was running in Kubernetes, so I did something like this:
$ kubectl run -i -t couchbase-migrate --image=couchbase/server:6.5.1 --restart=Never --rm=true --command -- /bin/bash
root#couchbase-migrate:/# cbbackup http://couchbase:8091 ~/cbbackup -u *** -p ***
...
Then I copied the backup out of the couchbase-migrate pod and onto my local machine.
After that, I did the restore similarly:
$ kubectl run -i -t couchbase-migrate --image=couchbase/server:6.5.1 --restart=Never --rm=true --command -- /bin/bash
...
root#couchbase-migrate:/# cbrestore ~/cbbackup http://couchbase:8091 -u *** -p ***
...

There are compatibility issues with the backup and restore process among the various Couchbase versions.
From the problem statement, it seems like it's one time data migration.
If nothing works and actually I too had the similar use cases, where I simply exported all the records from older version of Couchbase to a external file by running the simple SELECT query and ingested the same using the simple java based application to later version of Couchbase.
The difference between this approach and standard backup/restore process is, backup/restore would take care of building the indexes also and will be faster too.

Related

Install MySQL v8 in Google Colab. Service is not starting. Not recognised

I have been successfully installing and using MySQL V5.7 in Google Colab (with Ubuntu 18.04) for quite some time. However trying to install MySQL V8 has repeated failed. I have used the following sequence of commands ..
!apt update
!apt upgrade
#!wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.11-1_all.deb
!wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb
!dpkg -i mysql-apt-config_0.8.*
!sudo apt update
!sudo apt install mysql-server
During the install, I provide the root password and have used both the strong password option as well as the legacy authentication. Everything goes fine upto this point and even the following command
!mysqld --version
returns the correct version
/usr/sbin/mysqld Ver 8.0.28 for Linux on x86_64 (MySQL Community Server - GPL)
After this things go wrong! The MySQL service should have started but it hasn't
!mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
and when I try to start it, it is not recognised ( neither mysql nor mysqld)
!sudo service mysqld start
mysqld: unrecognized service
in fact, even this fails
!systemctl status mysql
System has not been booted with systemd as init system (PID 1). Can't operate.
What am I doing wrong? or what else should I do? or is it that for some reason, Google Colab with Ubuntu 18.04 does not support MySQL V8
No action required ... just this will do
!apt update > null
!apt -y install mysql-server -V
!/etc/init.d/mysql restart
then check
!mysql --version
mysql Ver 8.0.31-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu))
earlier this used to show Ver 5.7!
Now, with this we can now use CTE, recursion and Windows functions of v8
Check with sudo service mysql start or sudo start mysql once.
Another thing is that google colab instance might not use the system init system at all. That's why it's resulting in System has not been booted with systemd as init system. Check with the sys-v init system once. Its commands look like service service_name start. The same thing happens when trying to start services in WSL.

mysqld service won't start

After Fedora 28 decided to upgrade mysql-community packages to 8.0 (latest) ,I realized my application was failing and had to downgrade to mysql 5.27.2
Of course my db files (.idb) were the same (altered by mysql 8.0).
When starting mysql 5.27 service, it fails. I have read the log file /var/log/mysqld.log and found this:
InnoDB: Table flags are 0 in the data dictionary but the flags in
file ./ibdata1 are 0x4000!
This problem was solved removing all database files:
sudo rm -rf /var/lib/mysql/*
Please be aware you will lose every database in the server by doing this!!!
In my case I had a dump and i could restore.
Ensure you are using the MySQL version 8.0 client specifically to avoid this error
RCA
1.You attempted to start a newer version of mysql server with mysqld_safe(ver5) instead of the version 8.0
Solution
export MYSQL_8_HOME=/path/to/mysql-8.0.17-macos10.14-x86_64 #e.g /usr/local/mysql-8.0.17-macos10.14-x86_64
cd $MYSQL_8_HOME # where is the dorectory mysql v8.0 was installed.
bin/mysqld_safe --user=mysql --datadir=/path/to/data/mysql
Just for added measure, you might consider updating your PATH variable to prefix it with the newer version of MySQL programs like this
export PATH=$MYSQL_HOME/bin:$PATH
before starting mysqld_safe

Hadoop - No route to host while configuring HUE

I have installed hue on my local ubuntu system and installed hadoop muti cluster system on two system.
Hadoop Version : 2.7.3
Hue Version : 3.12.0
Ozzie Version : 4.3.0
I am facing issue when I am running sqoop job process from mysql to import data from HDFS. I am getting following error.
Caused by: java.net.NoRouteToHostException: No Route to Host from Developer4/127.0.0.1 to cm:10020 failed on socket timeout exception: java.net.NoRouteToHostException: No route to host; For more details see: http://wiki.apache.org/hadoop/NoRouteToHost
HDFS url hdfs://master:9000
My /etc/hosts file like
192.168.1.149 master
127.0.0.1 developer4
192.168.1.161 slave
Please suggest me where I am doing wrong. Even ozzie command for start and stop command work properly on command line.
You have set Hadoop in your localhost system then you need to remove or modified below things in core-site.xml file.
mapreduce.jobhistory.address 0.0.0.0:10020 Host and port for Job History Server (default 0.0.0.0:10020)
After that you need to run jobhistoryservice with below command.
sbin/mr-jobhistory-daemon.sh --config /home/developer4/hadoop-2.7.3/etc start historyserver
After this command port is enable on your localhost and hope this will help you.

Intermittent MySQL connection on Vagrant VirtualBox when Jenkins runs PHPUnit

We have a Jenkins CI server that runs our suite of tests on every commit, triggered by a GitHub hook.
We recently moved the suite of tests from running locally on the Jenkins server to running inside a VirtualBox/Vagrant VM. This is to ensure that the test configuration matches the dev environment. This is an Ubuntu 14.04 guest running on Ubuntu 14.04 host.
After moving to the VM model, PHPUnit occasionally fails with no connection to MySQL. The error is Can't connect to MySQL server on '127.0.0.1'.
This error is intermittent, not easily reproducible. That is, if I trigger a new build on Jenkins, it usually succeeds. However, when the new build is triggered by the GitHub hook, it fails more often than manually triggered builds, and sometimes succeeds.
Here's what I tried:
sudo service mysql restart before running phpunit
sleep 5 between the mysql restart and phpunit
Connecting to localhost and 127.0.0.1 -- When I tried connecting to localhost, I received intermittent errors Can't connect to MySQL server on '/var/run/mysqld/mysqld.sock'.
Here's the full output of the failed build:
sudo service mysql restart
* Stopping MySQL (Percona Server) mysqld
...done.
* Starting MySQL (Percona Server) database server mysqld
...done.
* Checking for corrupt, not cleanly closed and upgrade needing tables.
sleep 5
sudo service mysql status
* /usr/bin/mysqladmin Ver 8.42 Distrib 5.6.23-72.1, for debian-linux-gnu on x86_64
Server version 5.6.23-72.1-log
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 6 sec
Threads: 1 Questions: 111 Slow queries: 0 Opens: 761 Flush tables: 1 Open tables: 754 Queries per second avg: 18.500
phpunit
PHPUnit 4.6.2 by Sebastian Bergmann and contributors.
Configuration read from /vagrant/phpunit.xml
...........EEE.E.............E............................EEEEE.
Time: 8.51 seconds, Memory: 135.25Mb
1) ProcessDatasetsTest::test_process_on_census_fraction
PDOException: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111)
I've had intermittent connectivity issues with Mysql on Vagrant, but not precisely related to PHPUnit. Connections were dropping just out of the blue, until I found out there were many boxes running at the same time in virtualbox for the same app. I killed them all, then ran vagrant global-status --purge and I had perfect connections again.
We saw a similar issue on a different Vagrant VM -- Can't connect to MySQL server -- and it turned out to be a memory issue. The VM was out of RAM. This was fixed by adding or increasing a swapfile on the VM:
sudo fallocate -l 1G /swapfile.img
sudo chmod 0600 /swapfile.img
sudo mkswap /swapfile.img
sudo swapon /swapfile.img

how to setup and configure mysql-proxy on ubuntu on amazon ec2

i am trying to setup mysql-proxy on ubuntu on amazon ec2
i have done following:
sudo apt-get install mysql-proxy --yes
vi /etc/default/mysql-proxy
i put following content on "/etc/default/mysql-proxy"
ENABLED="true"
OPTIONS="--proxy-lua-script=/usr/share/mysql-proxy/rw-splitting.lua
--proxy-address=127.0.0.1:3306
--proxy-backend-addresses=private_ip_of_another_ec2_db_server:3306,private_ip_of_another_ec2_db_server:3306"
also tied with "--proxy-address=private_ip_or_public_ip_of_proxy-server:3306 or 4040"
and "--proxy-backend-addresses=public_ip_of_another_ec2_db_server:3306,public_ip_of_another_ec2_db_server:3306"
after that i tried to connect proxy server from another pc using mysql like:
mysql -u some_user -pxxxxx -h proxy_server_ip
or
mysql -u some_user -pxxxxx -h proxy_server_ip -P 4040
but its not working
its showing error:
ERROR 2003 (HY000): Can't connect to MySQL server on 'ip' (10061)
i want to tell you can connect the db server remotely where i allowed remote connection to any host
i also tried /etc/init.d/mysql-proxy start or /etc/init.d/mysql-proxy restart but no result
just to inform you that /etc/init.d/mysql-proxy stop is showing failed
can anyone please help me to setup and configure mysql-proxy on ubuntu
===
Edit
i found some help from other question of stackoverflow and also according to a suggestion in the comments, have done following procedure. and it seems its working now.
i installed mysql-client and mysql-server locally(on proxy server)
then i tried to run mysql-proxy using following command:
mysql-proxy --proxy-backend-addresses=10.73.151.244:3306 --proxy-backend-addresses=10.73.198.7:3306 --proxy-address=:4040 --admin-username=root --admin-password=root --admin-lua-script=>/usr/lib/mysql-proxy/lua/admin.lua
then i tried to connect remotely to the proxy server and its working.
but it seems i need to run this command under screen because when i close the terminal proxy stops working.
Can you please tell me that do i need to run this command under screen or is there any other way to make it alive all time?
There is no need to install Mysql client or Mysql Server on your mysql-proxy.
Installing mysql-proxy does have "full daemon capabilities" compiled into it.
If your are running Ubuntu Server, you may wish to use an UPSTART service script.
This script can be copied into /etc/init/mysql-proxy.conf
# mysql-proxy.conf (Ubuntu 14.04.1) Upstart proxy configuration file for AWS RDS
# mysql-proxy - mysql-proxy job file
description "mysql-proxy upstart script"
author "shadowbq <shadowbq#gmail.com>"
# Stanzas
#
# Stanzas control when and how a process is started and stopped
# See a list of stanzas here: http://upstart.ubuntu.com/wiki/Stanzas#respawn
# When to start the service
start on runlevel [2345]
# When to stop the service
stop on runlevel [016]
# Automatically restart process if crashed
respawn
# Essentially lets upstart know the process will detach itself to the background
expect daemon
# Run before process
pre-start script
[ -d /var/run/mysql-proxy ] || mkdir -p /var/run/mysql-proxy
echo "starting mysql-proxy"
end script
# Start the process
exec /usr/bin/mysql-proxy --plugins=proxy --proxy-lua-script=/usr/share/mysql-proxy/rw-splitting.lua --log-level=debug --proxy-backend-addresses=private_ip_of_another_ec2_db_server:3306,private_ip_of_another_ec2_db_server:3306 --daemon --log-use-syslog --pid-file=/var/run/mysql-proxy/mysql-proxy.pid
In the above example I hard coded the AWS RDS server into script, instead of fiddling with defaults and config file
Install Upgraded version 0.8.5
Note:
apt repo does not have 0.8.5 so we need to download tar from mysql official site
Prerequisite :-
Create file /etc/default/mysql-proxy with following content
ENABLED="true"
OPTIONS="--defaults-file=/etc/mysql/mysql-proxy.cnf"
Installation Procedure :-
Download mysql-proxy 0.8.x
Untar in /usr/local
Update PATH environment with /usr/local/mysql-proxy-0.8.5-linux-debian6.0-x86-64bit/bin
vim /etc/environment (to update environment path)
cd /usr/local/mysql-proxy-0.8.5-linux-debian6.0-x86-64bit/bin
Run command sudo ./mysql-proxy --defaults-file=/etc/mysql/mysql-proxy.cnf
Sample mysql-proxy.cnf file
[mysql-proxy]
log-level=debug
log-file=/var/log/mysql-proxy.log
pid-file = /var/run/mysql-proxy.pid
daemon = true
--no-proxy = false
admin-username=ADMIN
admin-password=ADMIN
proxy-backend-addresses=RDS-ENDPOINT:RDS-PORT
admin-lua-script=/usr/lib/mysql-proxy/lua/admin.lua
proxy-address=0.0.0.0:4040
admin-address=localhost:4041
change host ip and port of RDS or mysql
connect to Mysql server via proxy with
mysql -h{proxy-host-ip} -P 4040 -u{mysql_username} -p