Today I spent some time studying Neo4j Administration course and I got an error on the 5th exercise ( Copying databases). It is a very simple exercise executed from within a docker instance of Neo4j Enterprise 4.1.3.
After I executed the command to copy a database sudo docker exec --interactive neo4j bin/neo4j-admin copy --from-database=movies --to-database=movies2 a new folder movies2 is created in ~/docker-neo4j/neo4j/data/databases, which is a mounted volume of the container. Then I updated the ownership of the folder from user root to 7474 (don't know why the owner is 7474, but it is what it is) using sudo chown --reference=movies movies2
drwxr-xr-x 6 7474 7474 4.0K Nov 23 16:55 .
drwxr-xr-x 5 7474 7474 4.0K Nov 23 14:44 ..
drwxr-xr-x 3 7474 7474 4.0K Nov 23 16:24 movies
drwxr-xr-x 2 7474 7474 4.0K Nov 23 16:56 movies2
drwxr-xr-x 3 7474 7474 4.0K Nov 23 14:44 neo4j
-rw-r--r-- 1 7474 7474 0 Nov 23 14:44 store_lock
drwxr-xr-x 4 7474 7474 4.0K Nov 23 14:44 system
renatospaka@dell-w10home:~/docker-neo4j/neo4j/data/databases$
In cypher-shell I executed the command to create a new database movies2 and it returned OK. Only when I listed the databases of my instance I noticed the error:
Hi @elaine_rosenber, I don't know either. I only followed the instructions of the course and when I noticed the error, the folder & files were already set up this way.
As my first impression was I screwed up, I deleted everything (movies & movies2) and started over. The result was the same: error.
@elaine_rosenber, I repeated the tests, now from a 4.0,2 Enterprise image, and the same issue occurred.
These are the databases of the instance:
neo4j@system> CREATE DATABASE movies2;
0 rows available after 16 ms, consumed after another 0 ms
neo4j@system> show databases;
+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| name | address | role | requestedStatus | currentStatus | error | default |
+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| "movies" | "0.0.0.0:7687" | "standalone" | "offline" | "offline" | "" | FALSE |
| "movies2" | "0.0.0.0:7687" | "standalone" | "online" | "offline" | "An error occurred! Unable to start database with name `movies2`." | FALSE |
| "neo4j" | "0.0.0.0:7687" | "standalone" | "online" | "online" | "" | TRUE |
| "system" | "0.0.0.0:7687" | "standalone" | "online" | "online" | "" | FALSE |
+------------------------------------------------------------------------------------------------------------------------------------------------------------+
4 rows available after 18 ms, consumed after another 3 ms
neo4j@system>
neo4j@system> START DATABASE movies2;
0 rows available after 198 ms, consumed after another 0 ms
neo4j@system> :use movies2
Unable to get a routing table for database 'movies2' because this database is unavailable
neo4j@movies2[UNAVAILABLE]>
And if I use movies, it is alright, all set:
neo4j@system> START DATABASE movies;
0 rows available after 33 ms, consumed after another 0 ms
neo4j@system> :use movies;
neo4j@movies> match(m) return count(m);
+----------+
| count(m) |
+----------+
| 171 |
+----------+
1 row available after 41 ms, consumed after another 10 ms
neo4j@movies>
This is the log:
renatospaka@dell-w10home:~/docker-neo4j/neo4j/data/databases$ docker logs neo4j
Warning: Folder mounted to "/logs" is not writable from inside container. Changing folder owner to neo4j.
Warning: Folder mounted to "/data" is not writable from inside container. Changing folder owner to neo4j.
Directories in use:
home: /var/lib/neo4j
config: /var/lib/neo4j/conf
logs: /logs
plugins: /plugins
import: /import
data: /var/lib/neo4j/data
certificates: /var/lib/neo4j/certificates
run: /var/lib/neo4j/run
Starting Neo4j.
2020-11-24 22:30:46.538+0000 INFO ======== Neo4j 4.0.2 ========
2020-11-24 22:30:46.548+0000 INFO Starting...
2020-11-24 22:30:55.997+0000 INFO Sending metrics to CSV file at /var/lib/neo4j/metrics
2020-11-24 22:30:56.046+0000 INFO Bolt enabled on 0.0.0.0:7687.
2020-11-24 22:30:56.046+0000 INFO Started.
2020-11-24 22:30:56.495+0000 INFO Server thread metrics have been registered successfully
2020-11-24 22:30:58.270+0000 INFO Remote interface available at http://0.0.0.0:7474/
2020-11-24 23:04:49.542+0000 WARN The client is unauthorized due to authentication failure.
@elaine_rosenber, let me understand one thing. When you say the ownership of files and folders are wrong/odd and it should be neo4j, you are referring to Linux OS or to the container OS?
All prints and info I sent in my last post are from Linux OS - in my case a WSL2 running Ubuntu. And there is no user neo4 created there. I suppose the chown command would fail.
Today I made a fresh execution of everything but the container creation. And this time I executed every single step from within the container via bash.
Nevertheless, I ran the command to copy movies database to movies2 database, it executes OK, but the owner of the movies2 folder is root. Then I changed the owner to neo4j and proceeded to create the movies2 database.
root@b6811e4f16e4:/var/lib/neo4j# ls -lah data/databases/
total 28K
drwxr-xr-x 7 neo4j neo4j 4.0K Dec 9 22:32 .
drwxr-xr-x 4 neo4j neo4j 4.0K Nov 24 22:30 ..
drwxr-xr-x 2 root root 4.0K Nov 25 14:25 foo
drwxr-xr-x 3 neo4j neo4j 4.0K Nov 25 14:22 movies
drwxr-xr-x 2 neo4j neo4j 4.0K Dec 9 22:33 movies2
drwxr-xr-x 3 neo4j neo4j 4.0K Nov 24 22:30 neo4j
-rw-r--r-- 1 neo4j neo4j 0 Nov 24 22:30 store_lock
drwxr-xr-x 4 neo4j neo4j 4.0K Nov 24 22:30 system
This is the output:
neo4j@system> create database movies2;
0 rows available after 350 ms, consumed after another 0 ms
neo4j@system> show databases;
+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| name | address | role | requestedStatus | currentStatus | error | default |
+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| "movies" | "0.0.0.0:7687" | "standalone" | "offline" | "offline" | "" | FALSE |
| "movies2" | "0.0.0.0:7687" | "standalone" | "online" | "offline" | "An error occurred! Unable to start database with name `movies2`." | FALSE |
| "neo4j" | "0.0.0.0:7687" | "standalone" | "online" | "online" | "" | TRUE |
| "system" | "0.0.0.0:7687" | "standalone" | "online" | "online" | "" | FALSE |
+------------------------------------------------------------------------------------------------------------------------------------------------------------+
4 rows available after 9 ms, consumed after another 6 ms