Project

General

Profile

Database Server Installation » History » Version 10

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