Unable to create directory in hadoop - hadoop2

I have tried to create a directory by using below command
hadoop fs -mkdir /home/myuser/data1
its showing "/home/myuser/data1" no such file or directory.
But, where below command is working fine.
hadoop fs -mkdir /tmp/data1
(Using hadoop 2.7.0)
I could not get, why its not creating inside my user directory, but allowing to create in tmp directory (/tmp/).

you can try
hadoop fs -mkdir -p '/home/myuser/data1'
this should create entire path.

I think you are trying to execute this command being in home directory which does not work. If you want to create any folder in your home directory you can just type mkdir your_dir_name and it will create directory for you. The second command works as this will create a directory in root folder not under your home directory.. Hope it helps

As per Abhiieor comment, hadoop fs -mkdir not allowing to create directory more than 2 level. Below command works fine.
pwd # /home/
hadoop fs -mkdir myuser/data1
hadoop fs -ls myuser/ #showing data1 directory
Thnaks Abhiieor.
http://hortonworks.com/hadoop-tutorial/using-commandline-manage-files-hdfs/

Related

Can't write to .bash_profile file even when I am admin

I am trying to fix the problem with MySQL Server. When I type in terminal MySQL I get command not found.
I know I have to edit .bash_profile file and add to it this line:
export PATH=${PATH}:/usr/local/mysql/bin
The problem is I can't write to it. I tried these commands:
brackets ~/.bask_profile
sudo brackets ~/.bash_profile
touch ~/.bash_profile; open ~/.bash_profile
sudo touch ~/.bash_profile; open ~/.bash_profile
All the time I get a message that I am not allowed to write to this file because it is protected.
My question is, how can I write to this file and start MySQL Server?
Thank you for your help.
Cheers
EDIT:
Output in terminal of command:
ls -l ~/.bash_profile
is
-rw-r--r-- 1 root staff 447 13 paź 17:33 /Users/macos/.bash_profile
EDIT2:
Could you write to me about how to find the path to the .bash_profile file? I think changing the privileges of this file will be the solution to the problem.
The solution was using vi/vim editor:
vi ~/.bash_profile
Then in vi/vim I pasted this line:
export PATH=${PATH}:/usr/local/mysql/bin
And saved it with this commands:
:wq!

How can I create a docker image with a initialized database

I want to use the official mysql docker image to create an new image with an initialized database and imported dump file. The default command is mysqld, so I wonder how I can achieve this.
Is there a way to only initialize the database and import a dump, without starting the mysql daemon?
The MySQL docker images automatically parse .sh .sql and .sql.gz from the /docker-entrypoint-initdb.d directory on first start up. Files will be executed in alphabetical order.
Dump your existing database to a file, then edit your Dockerfile to add:
ADD mysqldump.sql /docker-entrypoint-initdb.d/mysqldump.sql
On first start, mysqldump.sql will be imported.
An option would be to access the bash shell of the docker container (please see "Container shell access and viewing MySQL logs" section in https://hub.docker.com/_/mysql/ ), import your dump file (you can use docker cp to copy the dump file from your host system to the docker container) and once you are done, you can use docker commit command to create a new docker image from your current running container. And you can use the newly created image afterwards.
Hope this helps.
I just found a solution for mysql:5.7. I execute the slightly modified entrypoint.sh during the build process:
COPY ./docker-entrypoint.sh /
RUN /docker-entrypoint.sh mysqld
In the docker-entrypoint.sh I deleted the last line:
exec "$#
It looks ugly, but it works so far.

OwnCloud: How to synchronyze the FileSystem with the DB

I have to "insert" a lot of files into an owncloud server (8.2).
A user give me a USB key with the files and tell me to copy of all them into his owncloud data files repository.
Do you know if is it possible ?
Is it possible to synchronyze the ownCloud data fileSystem with the ownCloud database?
My environment is Linux CentOS7 (Apache 2.4, mySQL 5.6, php 5.6)
Thanks,
owncloud brings a command line utility that allows to manually trigger some tasks. Among those is the files:scan function which re-scans a users file system.
So you can import those files by following these steps:
1. you copy the files into the physical file system of the user(s) inside ownclouds data folder
2. you fire the command line utility to re-scan the files. That takes care to update the database according to the files found.
This is an example for the manual trigger:
sudo -u www-data php occ files:scan <user name>
Here <user name> obviously has to be replaced. Also the account name the sudo command switches to depends on the linux distribution and its setup. The command has to be started inside ownclouds base folder. THe command can be called in a loop with different user names, that can be done by means of standard scripting.
Here is a documentation of the utility: https://doc.owncloud.org/server/8.0/admin_manual/configuration_server/occ_command.html
I just made a try myself using an owncloud-8.2 installation and succeeded.
Before I could sucessfully scan my files again as arkascha explained, I needed to change the ownder and the group of the new folder to www-data (for Debian OS - others see OC-Docu 1) and set rights of the new directory to 755
Change ownder:
sudo chown -R www-data:www-data <path>
Change rights:
sudo chmod 755 <path>
whwere is the path to the newly added directory and could for example look like this example: /media/hdd/owncloud/data/<username>/files/<newFolderName>
OC-Docu:
https://doc.owncloud.org/server/9.0/admin_manual/configuration_server/occ_command.html

Copy my.cnf file to Mysql Directory with Command Line

I am trying to copy a new my.cnf to my mysql5 directory in the command line. I have used:
cp my.cnf /opt/local/etc/mysql5
However when I execute the command, I get Permission Denied.
I am the directory where my.cnf resides.
Thanks for your help.
You are trying to copy the file to root user's directory. You'll need to use sudo.
Try
$ sudo cp my.cnf /opt/local/etc/mysql5

Using MySQL in the command line in OS X - command not found?

I'm trying to get MySQL up and running on my Mac OS X 10.9.5.
I've installed the latest version 5.6.21 of MySQL Community Server. I've gone to system preferences and started the mysql server, then launched terminal and typed this:
/usr/local/mysql/bin/mysql --version
which should return the version. But when I type any of the mysql commands I get command not found.
I've also tried:
sudo mysql_secure_installation
mysql -u root --password=password`
I do have web hosting with MySQL etc installed, but I want to be able to get to grips with it in the command line first.
So there are few places where terminal looks for commands. This places are stored in your $PATH variable. Think of it as a global variable where terminal iterates over to look up for any command. This are usually binaries look how /bin folder is usually referenced.
/bin folder has lots of executable files inside it. Turns out this are command. This different folder locations are stored inside one Global variable i.e. $PATH separated by :
Now usually programs upon installation takes care of updating PATH & telling your terminal that hey i can be all commands inside my bin folder.
Turns out MySql doesn't do it upon install so we manually have to do it.
We do it by following command,
export PATH=$PATH:/usr/local/mysql/bin
If you break it down, export is self explanatory. Think of it as an assignment. So export a variable PATH with value old $PATH concat with new bin i.e. /usr/local/mysql/bin
This way after executing it all the commands inside /usr/local/mysql/bin are available to us.
There is a small catch here. Think of one terminal window as one instance of program and maybe something like $PATH is class variable ( maybe ). Note this is pure assumption. So upon close we lose the new assignment. And if we reopen terminal we won't have access to our command again because last when we exported, it was stored in primary memory which is volatile.
Now we need to have our mysql binaries exported every-time we use terminal. So we have to persist concat in our path.
You might be aware that our terminal using something called dotfiles to load configuration on terminal initialisation. I like to think of it's as sets of thing passed to constructer every-time a new instance of terminal is created ( Again an assumption but close to what it might be doing ). So yes by now you get the point what we are going todo.
.bash_profile is one of the primary known dotfile.
So in following command,
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> ~/.bash_profile
What we are doing is saving result of echo i.e. output string to ~/.bash_profile
So now as we noted above every-time we open terminal or instance of terminal our dotfiles are loaded. So .bash_profile is loaded respectively and export that we appended above is run & thus a our global $PATH gets updated and we get all the commands inside /usr/local/mysql/bin.
P.s.
if you are not running first command export directly but just running second in order to persist it? Than for current running instance of terminal you have to,
source ~/.bash_profile
This tells our terminal to reload that particular file.
That means /usr/local/mysql/bin/mysql is not in the PATH variable..
Either execute /usr/local/mysql/bin/mysql to get your mysql shell,
or type this in your terminal:
PATH=$PATH:/usr/local/mysql/bin
to add that to your PATH variable so you can just run mysql without specifying the path
for me the following commands worked:
$ brew install mysql
$ brew services start mysql
You can just modified the .bash_profile by adding the MySQL $PATH as the following:
export PATH=$PATH:/usr/local/mysql/bin.
I did the following:
1- Open Terminal then $ nano .bash_profile or $ vim .bash_profile
2- Add the following PATH code to the .bash_profile
# Set architecture flags
export ARCHFLAGS="-arch x86_64"
# Ensure user-installed binaries take precedence
export PATH=/usr/local/mysql/bin:$PATH
# Load .bashrc if it exists
test -f ~/.bashrc && source ~/.bashrc
3- Save the file.
4- Refresh Terminal using $ source ~/.bash_profile
5- To verify, type in Terminal $ mysql --version
6- It should print the output something like this:
$ mysql Ver 14.14 Distrib 5.7.17, for macos10.12 (x86_64)
The Terminal is now configured to read the MySQL commands from $PATH which is placed in the .bash_profile .
modify your bash profile as follows
<>$vim ~/.bash_profile
export PATH=/usr/local/mysql/bin:$PATH
Once its saved you can type in mysql to bring mysql prompt in your terminal.
You have to create a symlink to your mysql installation if it is not the most recent version of mysql.
$ brew link --force mysql#5.6
see this post by Alex Todd