Unable to restore couchbase bucket using cbrestore - couchbase

I am using Couchbase Server version 4.5.0 and trying to restore a saved backup version onto my local CB server. I am using macOS Sierra
Xcode Development tools are up to date
Python v2.7.10
I First created a backup by using this command
sudo ./cbbackup HOST:PORT ~/Documents/ -u ‘username’ -p ‘password‘ -b BUCKET_NAME
After this I tried restoring this backup onto local Couchbase server using this command
sudo ./cbrestore /path/to/backup/2017-01-24T121528Z/2017-01-24T121528Z-full/ http://localhost:8091 -u ‘USERNAME’ -p ‘PASSWORD’ --bucket-source=SOURCE_BUCKET_NAME --bucket-destination=DESTINATION_BUCKET_NAME
but I am getting following error.
Exception in thread s0:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/Applications/Couchbase Server.app/Contents/Resources/couchbase-core/lib/python/pump_mc.py", line 91, in run
rv, batch, need_backoff = self.scatter_gather(mconns, batch)
File "/Applications/Couchbase Server.app/Contents/Resources/couchbase-core/lib/python/pump_cb.py", line 72, in scatter_gather
rv, conn = self.find_conn(mconns, vbucket_id, msgs)
File "/Applications/Couchbase Server.app/Contents/Resources/couchbase-core/lib/python/pump_cb.py", line 316, in find_conn
host_port = serverList[vBucketMap[vbucket_id][0]]
IndexError: list index out of range

If you took you're backup on a non-osx version of Couchbase and are restoring to an osx version then you need to use "-x rehash=1" with cbrestore. The reason is that the osx version of Couchbase is for development only and has less vbuckets then the standard (non-osx) Couchbase versions. The rehash flag tells cbrestore to deal with the different number of vbuckets.

Related

How to connect superset with mysql database?

I was trying to connect superset with mysql database with this SQLAlchemy URI:mysql://localhost:3306/mysql/database/table1 but not able to connect.
I was getting this error:
ERROR: {"error": "Connection failed!
The error message returned was:
No module named 'MySQLdb'", "stacktrace": "Traceback (most recent call last):
File \"/Users/akay/venv/lib/python3.7/site-packages/superset/views/core.py\", line 1703, in testconn
engine = database.get_sqla_engine(user_name=username)
File \"/Users/akay/venv/lib/python3.7/site-packages/superset/utils/core.py\", line 131, in __call__
value = self.func(*args, **kwargs)
File \"/Users/akay/venv/lib/python3.7/site-packages/superset/models/core.py\", line 923, in get_sqla_engine
return create_engine(url, **params)
File \"/Users/akay/venv/lib/python3.7/site-packages/sqlalchemy/engine/__init__.py\", line 479, in create_engine
return strategy.create(*args, **kwargs)
File \"/Users/akay/venv/lib/python3.7/site-packages/sqlalchemy/engine/strategies.py\", line 87, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File \"/Users/arkay/venv/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/mysqldb.py\", line 118, in dbapi
return __import__(\"MySQLdb\")
ModuleNotFoundError: No module named 'MySQLdb'
"}
Is there any way to connect to a MySQL database?
MySQLdb is not compatible with Python 3, You need to use pymysql.
Install pymysql:
$ pip install pymysql
Connect to mysql data source with below URI string.
mysql+pymysql://user:pass#host/databasename
Configure your database user with hostname=localhost
You need to install mysql-connector-python module:
$ pip install mysql-connector-python
Had similiar issue. I'm sure this will save time for some of you out there:
Use 127.0.0.1 instead of localhost.
Here is the perfect template for MySQL string:
SQLALCHEMY_DATABASE_URI = 'mysql://username:password#127.0.0.1:3306/schema-name'
Install MySQL:
pip3 install mysqlclient
Upgrade SQLAlchemy:
pip install sqlalchemy==1.3.24
Load DB:
superset db upgrade
Create Admin user:
superset fab create-admin
If you are using Docker try using host.docker.internal as host name. It worked for me

I can't start mysql server after modifying data folder - Mac OS

I used the following command on terminal (Mac 10.11.6) to copy database (map) from backup disk (Time Machine) from old mysql folder I had.
sudo cp -R '/Volumes/Time Machine Backups/Backups.backupdb/MacBook Pro/2016-09-26-212804/Macintosh HD/usr/local/mysql/data/map' /usr/local/mysql/data/map
It did copy the database but I couldn't start mysql server again .
I used this command :
sudo /usr/local/mysql/support-files/mysql.server start
I get this error :
ERROR! The server quit without updating PID file (/usr/local/mysql/data/computerName-MBP.pid).

Failed to clone an exist mysql server using mysqlserverclone utilities

I installed mysql server 5.7.12 utilities 1.5.6 using mysql installer for windows. I configed mysql-server through installer wizard. Then, I try to clone this server using mysqlcloneserver utilities:
mysqlserverclone --server=root:mysql#localhost:3306 --new-data="C:/Users/quyet/Documents/DBMS/fabric/store" --mysqld="--server-id=2 --log-bin --log-slave-updates --gtid-mode=ON --enforce-gtid-consistency" --new-port=13000 --delete-data
The command ouput this error after run the command:
WARNING: Using a password on the command line interface can be insecure.
# WARNING: Root password for new instance has not been set.
# Cloning the MySQL server running on localhost.
The console has detected that the utility 'mysqlserverclone' ended with an error code.
You can get more information about the error by running the console command 'show last error'.
I run command:
show last error
and get this output:
Execution of utility: 'mysqlserverclone --server=root:mysql#localhost:3306 --new-data=C:/Users/quyet/Documents/DBMS/fabric/store --mysqld=--server-id=2 --log-bin --log-slave-updates --gtid-mode=ON --enforce-gtid-consistency --new-port=13000 --delete-data' ended with return code '1' and with the following error message:
Traceback (most recent call last):
File "G:\ade\build\sb_0-16486154-1442332453.92\Python-2.7.6-windows-x86-32bit\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
File "scripts\mysqlserverclone.py", line 211, in <module>
File ".\mysql\utilities\command\serverclone.py", line 180, in clone_server
File ".\mysql\utilities\common\tools.py", line 254, in get_mysqld_version
IOError: [Errno 13] Permission denied: 'version_check'
I has searched on google but found any similar problems.
Any help will be much appreciated !
A bit outdated, but it might help.
Run Mysql Utils console as administrator

unoconv return error when running as www-data

When running this from command line as root it works
unoconv -f csv $file
But when running it as www-data this error is returned
Traceback (most recent call last):
File "/usr/bin/unoconv", line 1114, in <module>
office_environ(of)
File "/usr/bin/unoconv", line 203, in office_environ
os.environ['PATH'] = realpath(office.basepath, 'program') + os.pathsep + os.environ['PATH']
File "/usr/lib/python3.4/os.py", line 633, in __getitem__
raise KeyError(key) from None
KeyError: 'PATH'
update
echo shell_exec('echo $PATH');
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
centos 7.3 with php via php-fpm
the env in php is cleaned by php-fpm
u can use putenv to set evn["PATH"] in php code, examples
putenv("PATH=/sbin:/bin:/usr/sbin:/usr/bin");
var_dump(shell_exec('unoconv -vvvv -f pdf -o 123.pdf 123.doc));
or u can set env use one line shell cmd
var_dump(shell_exec('PATH=/sbin:/bin:/usr/sbin:/usr/bin'.' unoconv -vvvv -f pdf -o 123.pdf 123.doc));
or u can change /etc/php-fpm.d/www.conf to pass the env to php, add this line
clean_env = no
and the restart php-fpm
systemctl restart php-fpm.service
The PHP call you used (pasted from chat):
exec("unoconv -f csv $file")
My guess is that exec() is giving you an environment that is too limited. To work around this, you could set up a polled directory. The PHP script would copy files to be converted into the polled directory and wait for the files to be converted.
Then create a bash script (either running as root or a somewhat more secure user) to run in an infinite loop and check the polled directory for any incoming files. See How to keep polling file in a directory till it arrives in Unix for what the bash script might look like.
When the bash script sees incoming files, it runs unoconv.
Found a solution myself by running libreoffice directly
sudo libreoffice --headless --convert-to csv --outdir $tmp_path $file

mysql-workbench on Slackware 13.37 KDE error

After many hours of installing various libraries on my Slackware 13.37 i managed to start mysql-workbench (but I was wrong).
When launched from command line i get this warning:
bash-4.2# mysql-workbench
** Message: Gnome keyring daemon seems to not be available. Stored passwords will be lost once quit
Traceback (most recent call last):
File "/usr/local/lib/mysql-workbench/modules/wb_admin_ssh.py", line 43, in <module>
import paramiko
ImportError: No module named paramiko
Warning! Can't use connect with timeout in paramiko None
Traceback (most recent call last):
File "/usr/local/lib/mysql-workbench/modules/wb_admin_grt.py", line 27, in <module>
import wb_admin_main
File "/usr/local/lib/mysql-workbench/modules/wb_admin_main.py", line 29, in <module>
import wb_admin_monitor
File "/usr/local/lib/mysql-workbench/modules/wb_admin_monitor.py", line 21, in <module>
import wba_monitor_be
File "/usr/local/lib/mysql-workbench/modules/wba_monitor_be.py", line 26, in <module>
import wb_admin_ssh
File "/usr/local/lib/mysql-workbench/modules/wb_admin_ssh.py", line 119, in <module>
log_warning(_this_file, 'Cannot use connect with timeout in paramiko version %s\n' % paramiko.__version__)
AttributeError: 'NoneType' object has no attribute '__version__'
** Message: Failed loading module '/usr/local/lib/mysql-workbench/modules/wb_admin_grt.py' (python)
Ready.
the main program window appear and when i try to make a new connection i get this error :
Traceback (most recent call last):
File "/usr/local/share/mysql-workbench/sshtunnel.py", line 14, in <module>
import paramiko
ImportError: No module named paramiko
** (mysql-workbench-bin:2919): WARNING **: Tunnel manager could not be executed
and a popup appears:
Failed to Connect to MySQL at 127.0.0.1:3306 with user root Cannot
start SSH tunnel manager
mysql and ssh is installed and configured correctly:
bash-4.2# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.24 MySQL Community Server (GPL)
bash-4.2# ssh -v
OpenSSH_6.0p1, OpenSSL 0.9.8x 10 May 2012
can someone help me please !!!
It tells you that the python-paramiko module is missing. It is a python module for SSH connections; apparently that is used by one of the MySQL Workbench features. Get the slackware package here and install it executing
sudo installpkg paramiko-1.7.6-noarch-1gds.txz
Good luck!
Good answer above. On 64 bit systems, you have to install specific 32 bit libraries for workbench to work. E.g I had to install 32 bit python alongside the 64 bit python.
Also common errors include distribution specific errors. "/etc/mysql/my.cnf" not found, I created a soft link from /etc/my.cnf. Also had to create a folder at /root/.mysql/workbench/log for workbench to launch