Project

General

Profile

Database Server Installation » History » Version 8

Amber Herold, 03/15/2010 04:33 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 8 Amber Herold
h3. 7. Create leginon database, here we call dbemdata
92 3 Amber Herold
93
       >mysqladmin create dbemdata
94
95 8 Amber Herold
h3. 8. Create project database, here we call projectdata (optional)
96 1 Amber Herold
97 3 Amber Herold
       >mysqladmin create projectdata
98
99 8 Amber Herold
h3. 9. Connect to mysql db
100 3 Amber Herold
101
      >mysql mysql
102
103 1 Amber Herold
      mysql> select user, password, host from user;
104 3 Amber Herold
      +------+----------+-----------+
105
      | user | password | host      |
106 1 Amber Herold
      +------+----------+-----------+
107
      | root |          | localhost |
108
      | root |          | host1     |
109 3 Amber Herold
      |      |          | host1     |
110
      |      |          | localhost |
111 1 Amber Herold
      +------+----------+-----------+
112 3 Amber Herold
      4 rows in set (0.00 sec)
113
114 8 Amber Herold
h3. 10. Create user
115 7 Amber Herold
116 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
117
118 3 Amber Herold
      mysql> create user usr_object@'localhost';
119
      mysql> grant all privileges on dbemdata.* to usr_object@'localhost';
120
      mysql> grant all privileges on projectdata.* to usr_object@'localhost';
121
122 8 Amber Herold
Similarly,
123 3 Amber Herold
124 4 Amber Herold
      mysql> create user usr_object@'%';
125 3 Amber Herold
      mysql> grant all privileges on dbemdata.* to usr_object@'%';
126
      mysql> grant all privileges on projectdata.* to usr_object@'%';
127
128 8 Amber Herold
h3. 11. Change Root passworld
129 3 Amber Herold
130
      mysql> update user set password=password('a passwd') where user="root";
131
      Query OK, 2 rows affected (0.01 sec)
132
      Rows matched: 2  Changed: 2  Warnings: 0
133
134 1 Amber Herold
      mysql>^D or exit;
135 3 Amber Herold
136 7 Amber Herold
From now on, you will need to specify the password to connect to the database as root user like this:
137 3 Amber Herold
138
      >mysql -u root -p mysql
139
140 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):
141 3 Amber Herold
142
      >mysql -u root mysql
143
144
      mysql> flush privileges;
145
      mysql>^D or exit;
146 1 Amber Herold
147 8 Amber Herold
h3. 12. Check MySQL variables
148 3 Amber Herold
149
      >mysql -u usr_object dbemdata
150
151
      mysql> SHOW VARIABLES LIKE 'query%';
152
      +------------------------------+-----------+
153
      | Variable_name                | Value     |
154
      +------------------------------+-----------+
155
      | ft_query_expansion_limit     | 20        |
156 1 Amber Herold
      | have_query_cache             | YES       |
157 3 Amber Herold
      | long_query_time              | 10        |
158
      | query_alloc_block_size       | 8192      |
159
      | query_cache_limit            | 104857600 | <<---This should correspond to your change
160
      | query_cache_min_res_unit     | 4096      |
161
      | query_cache_size             | 104857600 | <<---This should correspond to your change
162
      | query_cache_type             | ON        | <<---This should correspond to your change
163
      | query_cache_wlock_invalidate | OFF       |
164
      | query_prealloc_size          | 8192      |
165
      +------------------------------+-----------+
166 1 Amber Herold
      10 rows in set (0.00 sec)
167 3 Amber Herold
168
      mysql> exit;
169
170 8 Amber Herold
h3. 13. Make sure MySQL is running
171 3 Amber Herold
172 1 Amber Herold
      prompt:~> mysqlshow
173 3 Amber Herold
      +--------------+
174
      | Databases    |
175
      +--------------+
176
      | mysql        |
177
      | dbemdata     |
178
      | projectdata  |
179
      +--------------+
180
181 8 Amber Herold
h3. 14. Or check with the following php script (if already installed)
182 3 Amber Herold
183
      <?
184
      mysql_connect('your_host.your_institute.edu', 'usr_object', '','dbemdata');
185
      echo mysql_stat();
186
      ?> 
187
188 8 Amber Herold
Output
189 3 Amber Herold
190
       Uptime: 1452562 Threads: 1 Questions: 618 Slow queries: 0 Opens: 117 Flush tables: 1 Open tables: 106 Queries per second avg: 0.000
191
192 1 Amber Herold
193
h2. Configure phpMyAdmin 
194
195
Edit the phpMyAdmin config file:
196
197
<pre>
198
$ sudo nano /etc/phpMyAdmin/config.inc.php
199
</pre> 
200
201
and change the following lines:
202
203
<pre>
204
$cfg['Servers'][$i]['AllowRoot']     = FALSE;
205
</pre>
206
207
Edit the phpMyAdmin apache config file:
208
209
<pre>
210
$ sudo nano /etc/httpd/conf.d/phpMyAdmin.conf
211
</pre>
212
213
and change the following lines:
214
215
<pre>
216
<Directory /usr/share/phpMyAdmin/>
217
   order deny,allow
218
   deny from all
219
   allow from 127.0.0.1
220
   allow from YOUR_IP_ADDRESS
221
</Directory>
222
</pre>