summaryrefslogtreecommitdiff
path: root/doc/README.mysql
blob: e123c43acf9b885e40ecab7b59617856fddf545d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
How to setup the MySQL database for GNUnet.

NOTE: This db module does NOT work with mysql before 4.1 since we need
prepared statements.  We are generally testing the code against MySQL
5.0 at this point.
 
HIGHLIGHTS

Pros
 + On up-to-date hardware where mysql can be used comfortably, this
   module will have better performance than the other db choices
   (according to our tests). 
 + Its often possible to recover the mysql database from internal 
   inconsistencies. The other db choices do not support repair 
   (gnunet-check cannot fix problems internal to the dbmgr!). 
   For example, we have seen several cases where power failure 
   has ruined a gdbm database beyond repair. 
 + much faster (for one of the key benchmarks -- content migration
   -- we have measure mysql taking 2s for an operation where
   sqlite takes 150s).
Cons 
 - Memory usage (Comment: "I have 1G and it never caused me trouble")
 - Manual setup

MANUAL SETUP INSTRUCTIONS

 1) in /etc/gnunet.conf, set
    sqstore = "sqstore_mysql"

 2) Then access mysql as root,
    $ mysql -u root -p 
    and do the following. [You should replace $USER with the username 
    that will be running the gnunetd process].

      CREATE DATABASE gnunet;
      GRANT select,insert,update,delete,create,alter,drop,create temporary tables
         ON gnunet.* TO $USER@localhost;
      SET PASSWORD FOR $USER@localhost=PASSWORD('$the_password_you_like');
      FLUSH PRIVILEGES;

 3) In the $HOME directory of $USER, create a ".my.cnf" file 
    with the following lines
 
      [client]
      user=$USER
      password=$the_password_you_like
    
 Thats it. Note that .my.cnf file is a security risk unless its on
 a safe partition etc. The $HOME/.my.cnf can of course be a symbolic
 link. Even greater security risk can be achieved by setting no 
 password for $USER.  Luckily $USER has only priviledges to mess 
 up GNUnet's tables, nothing else (unless you give him more, 
 of course).

 4) Still, perhaps you should briefly try if the DB connection 
    works. First, login as $USER. Then use,

    $ mysql -u $USER
    mysql> use gnunet;
    
    If you get the message "Database changed" it probably works.
 
    [If you get "ERROR 2002: Can't connect to local MySQL server 
     through socket '/tmp/mysql.sock' (2)" it may be resolvable by
     "ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock"
     so there may be some additional trouble depending on your mysql setup.]

 5) If you want to run the testcases, you must create a second
    database "gnunetcheck" with the same username and password.
    This database will then be used for testing ("make check").


REPAIRING TABLES 

- Its probably healthy to check your tables for inconsistencies
  every now and then, especially after system crashes.
- If you get odd SEGVs on gnunetd startup, it might be that the mysql
  databases have been corrupted. 
- The tables can be verified/fixed in two ways;
  1) by shutting down mysqld (mandatory!) and running 
  # myisamchk -r *.MYI 
  in /var/lib/mysql/gnunet/ (or wherever the tables are stored).
  Another repair command is "mysqlcheck". The usable command
  may depend on your mysql build/version. Or,
  2) by executing 
  mysql> REPAIR TABLE gn090;


PROBLEMS?

If you have problems related to the mysql module, your best friend is
probably the mysql manual. The first thing to check is that mysql is
basically operational, that you can connect to it, create tables,
issue queries etc.