Kodi Community Forum
2 XBMC PCs and 1 Database on the shared NAS - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: Windows (https://forum.kodi.tv/forumdisplay.php?fid=59)
+---- Thread: 2 XBMC PCs and 1 Database on the shared NAS (/showthread.php?tid=70603)



- colbert - 2011-01-10

charrua Wrote:There is a new feature already implemented in XBMC(since svn r28142) that lets you use a central MySQL database for all your clients.
The basic steps you need to do in order to use it are:

1. Setup a MySQL server (a database server) accesible from all the machines running XBMC. Even some NAS support running MySQL server, so an option is to run the database server directly on your NAS (if you have one that supports it) or run it on any machine that you want (MySQL server is freeware and supports lots of OSs).

2. Modify your advancedsettings.xml located in the userdata folder of XBMC adding this lines:
Code:
<videodatabase>
  <type>mysql</type>
  <host>localhost</host>
  <port>3306</port>
  <user>xbmc</user>
  <pass>xbmc</pass>
  <name>xbmc_video</name>
</videodatabase>
where:
host is the network address of the server running MySQL
port is the port used by the MySQL server (default is 3306)
user and pass are the credentials used to connect to the MySQL server
name is the name of the MySQL database you want XBMC to use (it must be all lowercased)
(you don't need to create the database, XBMC will create it for you the first time you run it after modifying the advancedsettings.xml).

You can also setup a central database for music albums, you need to add these additional lines to your advancedsettings.xml:
Code:
<musicdatabase>
  <type>mysql</type>
  <host>localhost</host>
  <port>3306</port>
  <user>xbmc</user>
  <pass>xbmc</pass>
  <name>xbmc_music</name>
</musicdatabase>
The same explanation given for videodatabase applys here, just one more thing: you can't share the same database for music and video, so just pick a different name for each database (also all lowercased)
Remember to modify the advancedsettings.xml of each XBMC you intend to share the MySQL database with.

Some advantages of this setup:
Every PC or MAC running XBMC can access that central database even simultaneously (instead of using a local database for each instance of XBMC), avoiding the need to scrape movie info once per each XBMC. Also sharing the info of watched/unwatched movies/tvshows/musicvideos and any other info that XBMC stores in the media library database (like stop/resume bookmarks).

For more info, trobleshooting and details you can check this thread (readers beware: it may be a bit technical (it's in the developers area of the forum)).

Hi there, linux user here (Arch distro) and I did not have an advancedsettings.xml file in my ~/.xbmc/userdata folder, so I created one and pasted the first part you displayed for video database. I changed the localhost to 192.168.1.101 which has MySQL all set and running xbmc 24/7.

Now that file is there, what else needs to be done or is that all? I am looking to keep my laptop and desktop in sync, so now with it setup on the desktop, I just pop the advancedsettings.xml on my laptop as well, referencing 192.168.1.101 where the MySQL is running?


- zosky - 2011-01-10

colbert Wrote:Hi there, linux user here (Arch distro) and I did not have an advancedsettings.xml file in my ~/.xbmc/userdata folder, so I created one and pasted the first part you displayed for video database. I changed the localhost to 192.168.1.101 which has MySQL all set and running xbmc 24/7.

Now that file is there, what else needs to be done or is that all? I am looking to keep my laptop and desktop in sync, so now with it setup on the desktop, I just pop the advancedsettings.xml on my laptop as well, referencing 192.168.1.101 where the MySQL is running?

your advancedsettings.xml needs start with <advancedsettings> and end with </advancedsettings> (sorry, that may be too obvious)

the other thing you need to do is deal with tumbnail cache (fanArt/movie cover/TV banners...) found in ~/.xbmc/userdata/Thumnails. i use rSync in both directions w/ cronTab
Code:
## local to livingRoom
rsync -avr ~/.xbmc/userdata/Thumbnails xbmc@xbmc:~/.xbmc/userdata/
## livingRoom to local
rsync -avr xbmc@xbmc:~/.xbmc/userdata/Thumbnails ~/.xbmc/userdata/
i've read you can mount a centralized cache, but i imagine your laptop's xbmc would browse the library slow(er) as its fetching thumbs over the network


- colbert - 2011-01-10

zosky Wrote:your advancedsettings.xml needs start with <advancedsettings> and end with </advancedsettings> (sorry, that may be too obvious)

Haha, indeed it is not! I forgot to do that :o

zosky Wrote:the other thing you need to do is deal with tumbnail cache (fanArt/movie cover/TV banners...) found in ~/.xbmc/userdata/Thumnails. i use rSync in both directions w/ cronTab
Code:
## local to livingRoom
rsync -avr ~/.xbmc/userdata/Thumbnails xbmc@xbmc:~/.xbmc/userdata/
## livingRoom to local
rsync -avr xbmc@xbmc:~/.xbmc/userdata/Thumbnails ~/.xbmc/userdata/
i've read you can mount a centralized cache, but i imagine your laptop's xbmc would browse the library slow(er) as its fetching thumbs over the network

Hmm, before visiting this thread to start the MySQL going, I had added the movie+tv sources on my laptop and completed the content scan, all art/thumbs are there. Do I still need to do this? I'm wondering if when I update the library on the laptop, it will download the necessary art as normal and I just continue to do that?


- zosky - 2011-01-10

colbert Wrote:Haha, indeed it is not! I forgot to do that :o



Hmm, before visiting this thread to start the MySQL going, I had added the movie+tv sources on my laptop and completed the content scan, all art/thumbs are there. Do I still need to do this? I'm wondering if when I update the library on the laptop, it will download the necessary art as normal and I just continue to do that?

you're laptop now has a local.db (~/.xbmc/userdata/Database/MyVideos34.db) which contains all the MetaData (title/air-date/actors...)

the cache is based on each entries $PATH/$File.name ... so *IF* the (sources &) paths are the same in your laptop's local DB & your localhost (mySQL.db), then yes, its fine. otherwise you will need to blow away the laptop's cache & copy over from localhost.

thats the 1st part (setup), then comes maintenance... if you scan for new content on 1 box, the meta-data will be added to the (mySQL) db, but the thumbnails will only exist on that box... hence my rSync solution.

hope that clarifies


- colbert - 2011-01-10

zosky Wrote:you're laptop now has a local.db (~/.xbmc/userdata/Database/MyVideos34.db) which contains all the MetaData (title/air-date/actors...)

the cache is based on each entries $PATH/$File.name ... so *IF* the (sources &) paths are the same in your laptop's local DB & your localhost (mySQL.db), then yes, its fine. otherwise you will need to blow away the laptop's cache & copy over from localhost.

thats the 1st part (setup), then comes maintenance... if you scan for new content on 1 box, the meta-data will be added to the (mySQL) db, but the thumbnails will only exist on that box... hence my rSync solution.

hope that clarifies

Gotcha, that makes sense. I have oodles of rsync scripts as it is so that *should* be okay when I get there hehe...

So I'm having some errors here just running XBMC (from xbmc.log):

Code:
16:40:15 T:3022292864 M:2263351296   ERROR: Unable to open database at host: 192.168.1.101 db: xbmc_video (old version?)
16:40:15 T:3022292864 M:2263351296   ERROR: Unable to open database: xbmc_video [2003](Can't connect to MySQL server on '192.168.1.101' (111))
16:40:15 T:3022292864 M:2263351296   ERROR: Unable to open database at host: 192.168.1.101 db: xbmc_video (old version?)
16:40:15 T:3022292864 M:2263351296   ERROR: Unable to open database: xbmc_video [2003](Can't connect to MySQL server on '192.168.1.101' (111))
16:40:15 T:3022292864 M:2263351296   ERROR: Unable to open database at host: 192.168.1.101 db: xbmc_video (old version?)

Here is my ~/.xbmc/userdata/advancedsettings.xml:

Code:
<advancedsettings>
<videodatabase>
  <type>mysql</type>
  <host>192.168.1.101</host>
  <port>3306</port>
  <user>xbmc</user>
  <pass>xbmc</pass>
  <name>xbmc_video</name>
</videodatabase>
</advancedsettings>

I have the MySQL daemon running fine, but am such a noob to MySQL that I must be missing something obvious lol.


- zosky - 2011-01-11

colbert Wrote:So I'm having some errors here just running XBMC (from xbmc.log):

Code:
16:40:15 T:3022292864 M:2263351296   ERROR: Unable to open database at host: 192.168.1.101 db: xbmc_video (old version?)

I have the MySQL daemon running fine, but am such a noob to MySQL that I must be missing something obvious lol.

im convinced being proficient at mySQL needs black-magic or selling your fist born to the devil. luckly, im not half bad with google & its all still fresh in my mind as i only set this up a week ago... i hope this helps. YMMV.
  1. first you need to create the mySQL.db
    Code:
    $mysql -u root -p $PASSWORD$
    > create database xbmc_video;
  2. by default (for security) it does not broadcast over the network ... so that needs to be changed
    in /etc/mysql/my.cnf change bind-address=127.0.0.1 to $mySQL-server-LAN-IP$ & restart mySQL
  3. at this point i could see port 3306 was finally open, but it still woudn't accept connection from any other machine (only localhost). turns out thats another default that needs to be changed ...
    Code:
    $mysql -u root -p $PASSWORD$
    > grant all privileges on xbmc_video.* to xbmc@[*your-laptop.IP*] ;
    (you can grant privees to *.* ... but that seems a little dangerous to me)

cheers
~z


- colbert - 2011-01-11

Thanks a bunch! After quite some fudging and googling myself I was able to get it working alas by commenting out "skip-networking" and I didn't have a bind-address line to begin with, and read that it needed to be commented out so I added it and then commented it out, and followed this: http://www.debuntu.org/how-to-create-a-mysql-database-and-set-privileges-to-a-user getting the database and user setup.

So no more errors in the xbmc.log about being able to access the database, it's clearly seeing and using it, but now when running XBMC I'm getting this when trying to Scan for New content:

Code:
18:35:17 T:2848979824 M:2400669696   ERROR: AddLinkToActor failed
18:35:17 T:2848979824 M:2400669696   ERROR: SQL: The table does not exist
                                            Query: select * from actorlinktvshow where idActor=8 and idShow=-1
18:35:17 T:2848979824 M:2400669696   ERROR: AddLinkToActor failed
18:35:17 T:2848979824 M:2400669696   ERROR: SQL: The table does not exist
                                            Query: select * from actorlinktvshow where idActor=9 and idShow=-1
18:35:17 T:2848979824 M:2400669696   ERROR: AddLinkToActor failed
18:35:17 T:2848979824 M:2400669696   ERROR: SQL: The table does not exist
                                            Query: select * from actorlinktvshow where idActor=10 and idShow=-1
18:35:17 T:2848979824 M:2400669696   ERROR: AddLinkToActor failed
18:35:17 T:2848979824 M:2400669696   ERROR: SQL: The table does not exist
                                            Query: select * from genrelinktvshow where idGenre=1 and idShow=-1
18:35:17 T:2848979824 M:2400669696   ERROR: AddToLinkTable failed
18:35:17 T:2848979824 M:2400669696   ERROR: SQL: The table does not exist
                                            Query: select * from genrelinktvshow where idGenre=2 and idShow=-1
18:35:17 T:2848979824 M:2400669696   ERROR: AddToLinkTable failed
18:35:17 T:2848979824 M:2400669696   ERROR: SQL: The table does not exist
                                            Query: select * from studiolinktvshow where idStudio=-1 and idShow=-1
18:35:17 T:2848979824 M:2400669696   ERROR: AddToLinkTable failed
18:35:17 T:2848979824 M:2400669696   DEBUG: Mysql execute: update tvshow set c00='The Vampire Diaries',c01='As the school

In MySQL, the tables for the xbmc_video database show:

Code:
mysql> show tables;
+----------------------+
| Tables_in_xbmc_video |
+----------------------+
| actorlinkmovie       |
| actors               |
| bookmark             |
| country              |
| countrylinkmovie     |
| directorlinkmovie    |
| genre                |
| genrelinkmovie       |
| movie                |
| path                 |
| settings             |
| stacktimes           |
| version              |
| writerlinkmovie      |
+----------------------+
14 rows in set (0.00 sec)

So something is up here, it appears the necessary tables aren't all there, and I'm quite weary of doing it myself lol. Oo


zosky Wrote:im convinced being proficient at mySQL needs black-magic or selling your fist born to the devil.

Giddy up to that lol Big Grin


- zosky - 2011-01-11

yeah, that definitely doesn't look right.

here's what mine looks like
Code:
mysql> show tables in xbmcvid ;
+------------------------+
| Tables_in_xbmcvid      |
+------------------------+
| actorlinkepisode       |
| actorlinkmovie         |
| actorlinktvshow        |
| actors                 |
| artistlinkmusicvideo   |
| bookmark               |
| country                |
| countrylinkmovie       |
| directorlinkepisode    |
| directorlinkmovie      |
| directorlinkmusicvideo |
| directorlinktvshow     |
| episode                |
| episodeview            |
| files                  |
| genre                  |
| genrelinkmovie         |
| genrelinkmusicvideo    |
| genrelinktvshow        |
| movie                  |
| movielinktvshow        |
| movieview              |
| musicvideo             |
| musicvideoview         |
| path                   |
| setlinkmovie           |
| sets                   |
| settings               |
| stacktimes             |
| streamdetails          |
| studio                 |
| studiolinkmovie        |
| studiolinkmusicvideo   |
| studiolinktvshow       |
| tvshow                 |
| tvshowlinkepisode      |
| tvshowlinkpath         |
| version                |
| writerlinkepisode      |
| writerlinkmovie        |
+------------------------+
40 rows in set (0.00 sec)
blow it away and create it again ? (my best guess)


- ti_gusus - 2011-01-11

zosky Wrote:
  1. backUP (move) the cache folder as noted previously
  2. make a new mount point ... sudo mkdir /media/samba
  3. open /etc/fstab ... sudo nano /etc/fstab
  4. add a new line (at the end of the file) & edit to match your setup...here's the ex from ubuntu's wiki

  5. close nano... cntrl+x ... save = y
  6. mount all (mount -a) or restart (sudo shutdown -R now)
  7. simLink your cache folder ... ln -s /media/samba/[path/to/cache] /home/htpc/.xbmc/userdata/Thumbnails



Accessing the QNAP from Ubuntu is fairly easy.
http://mytekstuff.blogspot.com/2008/12/accessing-qnap-from-ubuntu-is-fairly.html

First install "smbfs": -

sudo apt-get install smbfs

Then it's just a matter of creating the relevant directories in /mnt

sudo mkdir /mnt/Thumbnails


...and then editing /etc/fstab

sudo nano /etc/fstab

//192.168.1.108/Public/Video/Thumbnails /mnt/Thumbnails cifs directio,iocharset=utf8,noacl,noperm,nosetuids,rw


To mount:
sudo mount -a

simLink your cache folder ...

ln -s /mnt/Thumbnails /home/htpc/.xbmc/userdata/Thumbnails


Now my problem , Each time I need to reboot, the shortcut is not created. Have to "Mount -a" each time
What wrong ??
This is the last item on my list to get it work at 100%

Please help.
Thank


- ti_gusus - 2011-01-11

Anyone Huh?

Now my problem , Each time I need to reboot, the shortcut is not created. Have to "Mount -a" each time
What wrong ??
This is the last item on my list to get it work at 100%

Please help.
Thank


- RockDawg - 2011-01-11

ti_gusus Wrote:Anyone Huh?

Now my problem , Each time I need to reboot, the shortcut is not created. Have to "Mount -a" each time
What wrong ??
This is the last item on my list to get it work at 100%

Please help.
Thank

I'm no expert on things Linux but I did something similar to what you did. Make sure smbfs is installed and then I just added the following line to /etc/fstab (obviously adjust the paths to what yours are):

Code:
//192.168.1.20/disk7/xbmc_thumbs/Thumbnails  /home/kevin/.xbmc/userdata/Thumbnails   cifs  credentials=/home/kevin/.credentials,_netdev,file_mode=0777,dir_mode=0777 0 0

/home/kevin/.credentials is a file I created with the username and password for the network share where my thumbs are. You can probably eliminate that if yours doesn't require a username or password. The file contents goes like:

Code:
username=yourusername
password=yourpassword

I don't remember exactly what they do, but I remember that the "file_mode=0777,dir_mode=0777" portion was critical to getting it to work for me.

That entry in /etc/fstab is what recreates the mount on each boot. Like I said, just make sure you already have smbfs installed. After that it worked great for me. Good luck!


- zosky - 2011-01-11

You are missing 2numbers at the end of the line. Something like 0 0. One tells the system to mount it on boot, the other is to indicate if it should be checked for errors. Don't just put 0 0 at the end. Google fstab and find the proper description.


- RockDawg - 2011-01-11

Yah, I missed that in his post. You can see the two zeroes at the end on the line I posted. Although according to wikipedia it doesn't have anything to do with mount on boot. It says the first number is "dump-freq" and the second is "pass-num" and here is what it says about them:

Quote:dump-freq adjusts the archiving schedule for the partition (used by dump).

pass-num Controls the order in which fsck checks the device/partition for errors at boot time. The root device should be 1. Other partitions should be either 2 (to check after root) or 0 (to disable checking for that partition altogether).



- zosky - 2011-01-11

oi, ooops. sorry. its not the 2 numbers.
its the options string before that...
it needs to include auto (ie auto-mount)

directio,iocharset=utf8,noacl,noperm,nosetuids,rw,auto


- RockDawg - 2011-01-11

zosky - Please don't take me the wrong way. I'm not setting out to correct you. I don't know much about Linux and it was quite a while ago when I was going through this myself and haven't had to touch it since so I forgot most of it. This post just seemed like a good reason to refresh myself on it while trying to help out ti_gusus.

Anyway, according to what I read, auto is the default mount option so it doesn't need to be specified. As you can see in the fstab entry I posted earlier, it doesn't include the auto option and it auto mounts on every boot.