Project

General

Profile

Database Server Installation » History » Version 9

Amber Herold, 03/15/2010 04:34 PM

1 3 Amber Herold
h1. Database Server-side Installation
2 1 Amber Herold
3
Refer to [[Start_with_existing_ANY_Linux_flavor_OS#2-Setup-MySQL-databases|Setup MySQL databases]]
4 2 Amber Herold
Note: the above link includes unnessary steps....
5
Start Here: http://emg.nysbc.org/documentation/leginon/bk02ch04s07.php
6 1 Amber Herold
7 3 Amber Herold
h2. Install MySQL 
8 1 Amber Herold
9 3 Amber Herold
The following is for the computer that hosts the databases. This involves installing MySQL server and creation/configuration of the leginondb and projectdb databases.
10 1 Amber Herold
11 4 Amber Herold
Table 4.3. Leginon Database Supporting Packages
12 3 Amber Herold
Name:	Download site:
13
MySQL-Server 5.0 or higher	http://www.mysql.com
14
MySQL-Client 5.0 or higher	http://www.mysql.com
15
MySQL
16 1 Amber Herold
17 4 Amber Herold
Note: you may already have MySQL Server and Client installed. Check by typing mysql at the command line. 
18
If you see a MySQL prompt (mysql>), skip steps 1 and 2.
19
 
20 8 Amber Herold
h3. 1. Install MySQL-Server
21 1 Amber Herold
22 7 Amber Herold
* Use your package installer (yum, zypper, YaST) if available.
23 3 Amber Herold
            OR
24 7 Amber Herold
* Download the latest MySQL-server RPM for Linux from www.mysql.com
25
* Install the MySQL-server rpm:
26 1 Amber Herold
27 7 Amber Herold
    rpm -Uvh MySQL-server-5.0.xx-y.i386.rpm
28 1 Amber Herold
29 7 Amber Herold
(substitute correct version numbers)
30 3 Amber Herold
31 8 Amber Herold
h3. 2. Install MySQL-Client
32 3 Amber Herold
33 7 Amber Herold
* Use your package installer (yum, zypper, YaST) if available.
34 3 Amber Herold
            OR
35 7 Amber Herold
* Download the latest MySQL-client RPM for Linux from www.mysql.com
36
*Install the MySQL-client rpm:
37 3 Amber Herold
38 7 Amber Herold
    rpm -Uvh MySQL-client-5.0.xx-y.i386.rpm
39 3 Amber Herold
40 7 Amber Herold
(substitute correct version numbers)
41 3 Amber Herold
42 8 Amber Herold
h3. 3. MySQL configuration file is usually located in /usr/share/mysql. There are several examples there:
43 3 Amber Herold
44 7 Amber Herold
  > ls /usr/share/mysql/my*
45
    /usr/share/mysql/my-huge.cnf
46
    /usr/share/mysql/my-innodb-heavy-4G.cnf
47
    /usr/share/mysql/my-large.cnf
48
    /usr/share/mysql/my-medium.cnf
49
    /usr/share/mysql/my-small.cnf
50
  > 
51 3 Amber Herold
52 8 Amber Herold
h3. 4. Configure my.cnf in /etc using my-huge.cnf as the template
53 3 Amber Herold
54
         1. > cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
55
56
         2. Edit /etc/my.cnf to add or change query cache variables like these:
57
58
            query_cache_type= 1
59
            query_cache_size = 100M
60
            query_cache_limit= 100M
61
62 8 Amber Herold
h3. 5. start MySQL Server
63 3 Amber Herold
64
       >/etc/init.d/mysqld start
65
66 7 Amber Herold
on some installation,
67 3 Amber Herold
68 1 Amber Herold
       >/etc/init.d/mysql start
69 3 Amber Herold
70 7 Amber Herold
For future reference: start | stop | restart MySQL Server with similar commands:
71 1 Amber Herold
72 3 Amber Herold
       >/etc/init.d/mysqld start
73
       >/etc/init.d/mysqld stop
74
       >/etc/init.d/mysqld restart
75
76 7 Amber Herold
If you want to start MySQL automatically at boot on SuSE
77 3 Amber Herold
78
       SuSE >chkconfig mysql on
79
80 8 Amber Herold
h3. 6. For future reference, the database location will be:
81 3 Amber Herold
82
      > cd /var/lib/mysql
83
      Directory: /var/lib/mysql
84
      > ls
85 1 Amber Herold
      yourdbserver.pid
86 3 Amber Herold
      ib_logfile0
87
      mysql
88
      mysql.sock
89
      test
90
      > 
91 9 Amber Herold
92 8 Amber Herold
h3. 7. Create leginon database, here we call dbemdata
93 3 Amber Herold
94
       >mysqladmin create dbemdata
95
96 8 Amber Herold
h3. 8. Create project database, here we call projectdata (optional)
97 1 Amber Herold
98 3 Amber Herold
       >mysqladmin create projectdata
99
100 8 Amber Herold
h3. 9. Connect to mysql db
101 3 Amber Herold
102
      >mysql mysql
103
104 1 Amber Herold
      mysql> select user, password, host from user;
105 3 Amber Herold
      +------+----------+-----------+
106
      | user | password | host      |
107 1 Amber Herold
      +------+----------+-----------+
108
      | root |          | localhost |
109
      | root |          | host1     |
110 3 Amber Herold
      |      |          | host1     |
111
      |      |          | localhost |
112 1 Amber Herold
      +------+----------+-----------+
113 3 Amber Herold
      4 rows in set (0.00 sec)
114
115 8 Amber Herold
h3. 10. Create user
116 7 Amber Herold
117 8 Amber Herold
Create and grant privileges to a user called usr_object for the databases on both the localhost and other hosts involved. For example, use wild card '%' for all hosts. You may also set specific privilege to the user. See MySQL Reference Manual for details
118
119 3 Amber Herold
      mysql> create user usr_object@'localhost';
120
      mysql> grant all privileges on dbemdata.* to usr_object@'localhost';
121
      mysql> grant all privileges on projectdata.* to usr_object@'localhost';
122
123 8 Amber Herold
Similarly,
124 3 Amber Herold
125 4 Amber Herold
      mysql> create user usr_object@'%';
126 3 Amber Herold
      mysql> grant all privileges on dbemdata.* to usr_object@'%';
127
      mysql> grant all privileges on projectdata.* to usr_object@'%';
128
129 8 Amber Herold
h3. 11. Change Root passworld
130 3 Amber Herold
131
      mysql> update user set password=password('a passwd') where user="root";
132
      Query OK, 2 rows affected (0.01 sec)
133
      Rows matched: 2  Changed: 2  Warnings: 0
134
135 1 Amber Herold
      mysql>^D or exit;
136 3 Amber Herold
137 7 Amber Herold
From now on, you will need to specify the password to connect to the database as root user like this:
138 3 Amber Herold
139
      >mysql -u root -p mysql
140
141 7 Amber Herold
***If your password change does not take effect in your next database connection, you will need to flush the mysql pivileges cache as mysql root and connecting with you old password (or no password in the above case):
142 3 Amber Herold
143
      >mysql -u root mysql
144
145
      mysql> flush privileges;
146
      mysql>^D or exit;
147 1 Amber Herold
148 8 Amber Herold
h3. 12. Check MySQL variables
149 3 Amber Herold
150
      >mysql -u usr_object dbemdata
151
152
      mysql> SHOW VARIABLES LIKE 'query%';
153
      +------------------------------+-----------+
154
      | Variable_name                | Value     |
155
      +------------------------------+-----------+
156
      | ft_query_expansion_limit     | 20        |
157 1 Amber Herold
      | have_query_cache             | YES       |
158 3 Amber Herold
      | long_query_time              | 10        |
159
      | query_alloc_block_size       | 8192      |
160
      | query_cache_limit            | 104857600 | <<---This should correspond to your change
161
      | query_cache_min_res_unit     | 4096      |
162
      | query_cache_size             | 104857600 | <<---This should correspond to your change
163
      | query_cache_type             | ON        | <<---This should correspond to your change
164
      | query_cache_wlock_invalidate | OFF       |
165
      | query_prealloc_size          | 8192      |
166
      +------------------------------+-----------+
167 1 Amber Herold
      10 rows in set (0.00 sec)
168 3 Amber Herold
169
      mysql> exit;
170
171 8 Amber Herold
h3. 13. Make sure MySQL is running
172 3 Amber Herold
173 1 Amber Herold
      prompt:~> mysqlshow
174 3 Amber Herold
      +--------------+
175
      | Databases    |
176
      +--------------+
177
      | mysql        |
178
      | dbemdata     |
179
      | projectdata  |
180
      +--------------+
181
182 8 Amber Herold
h3. 14. Or check with the following php script (if already installed)
183 3 Amber Herold
184
      <?
185
      mysql_connect('your_host.your_institute.edu', 'usr_object', '','dbemdata');
186
      echo mysql_stat();
187
      ?> 
188
189 8 Amber Herold
Output
190 3 Amber Herold
191
       Uptime: 1452562 Threads: 1 Questions: 618 Slow queries: 0 Opens: 117 Flush tables: 1 Open tables: 106 Queries per second avg: 0.000
192
193 1 Amber Herold
194
h2. Configure phpMyAdmin 
195
196
Edit the phpMyAdmin config file:
197
198
<pre>
199
$ sudo nano /etc/phpMyAdmin/config.inc.php
200
</pre> 
201
202
and change the following lines:
203
204
<pre>
205
$cfg['Servers'][$i]['AllowRoot']     = FALSE;
206
</pre>
207
208
Edit the phpMyAdmin apache config file:
209
210
<pre>
211
$ sudo nano /etc/httpd/conf.d/phpMyAdmin.conf
212
</pre>
213
214
and change the following lines:
215
216
<pre>
217
<Directory /usr/share/phpMyAdmin/>
218
   order deny,allow
219
   deny from all
220
   allow from 127.0.0.1
221
   allow from YOUR_IP_ADDRESS
222
</Directory>
223
</pre>