Project

General

Profile

Database Server Installation » History » Version 6

Amber Herold, 03/15/2010 04:25 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 6 Amber Herold
1. Install MySQL-Server
21 1 Amber Herold
22 3 Amber Herold
          * Use your package installer (yum, zypper, YaST) if available.
23
            OR
24
          * Download the latest MySQL-server RPM for Linux from www.mysql.com
25
          * Install the MySQL-server rpm:
26 1 Amber Herold
27 3 Amber Herold
             rpm -Uvh MySQL-server-5.0.xx-y.i386.rpm
28 1 Amber Herold
29 3 Amber Herold
            (substitute correct version numbers)
30
31
   2. Install MySQL-Client
32
33
          * Use your package installer (yum, zypper, YaST) if available.
34
            OR
35
          * Download the latest MySQL-client RPM for Linux from www.mysql.com
36
          *Install the MySQL-client rpm:
37
38
             rpm -Uvh MySQL-client-5.0.xx-y.i386.rpm
39
40
            (substitute correct version numbers)
41
42
   3. MySQL configuration file is usually located in /usr/share/mysql. There are several examples there:
43
44
      > 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
52
   4. Configure my.cnf in /etc using my-huge.cnf as the template
53
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
   5. start MySQL Server
63
64
       >/etc/init.d/mysqld start
65
66
      on some installation,
67
68
       >/etc/init.d/mysql start
69
70
      For future reference: start | stop | restart MySQL Server with similar commands:
71
72
       >/etc/init.d/mysqld start
73
       >/etc/init.d/mysqld stop
74
       >/etc/init.d/mysqld restart
75
76
      If you want to start MySQL automatically at boot on SuSE
77
78
       SuSE >chkconfig mysql on
79
80
   6. For future reference, the database location will be:
81
82
      > cd /var/lib/mysql
83
      Directory: /var/lib/mysql
84
      > ls
85
      yourdbserver.pid
86
      ib_logfile0
87
      mysql
88
      mysql.sock
89
      test
90
      > 
91
92
   7. Create leginon database, here we call dbemdata
93
94
       >mysqladmin create dbemdata
95
96
   8. Create project database, here we call projectdata (optional)
97
98
       >mysqladmin create projectdata
99
100
   9. Connect to mysql db
101
102
      >mysql mysql
103
104
      mysql> select user, password, host from user;
105
      +------+----------+-----------+
106
      | user | password | host      |
107
      +------+----------+-----------+
108
      | root |          | localhost |
109
      | root |          | host1     |
110
      |      |          | host1     |
111
      |      |          | localhost |
112
      +------+----------+-----------+
113
      4 rows in set (0.00 sec)
114
115
  10. 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
      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 1 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
  11. Change Root passworld
128
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
      mysql>^D or exit;
134
135
      From now on, you will need to specify the password to connect to the database as root user like this:
136
137
      >mysql -u root -p mysql
138
139
      ***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
141
      >mysql -u root mysql
142
143
      mysql> flush privileges;
144
      mysql>^D or exit;
145
146
  12. Check MySQL variables
147
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
      | have_query_cache             | YES       |
156
      | 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
      10 rows in set (0.00 sec)
166
167
      mysql> exit;
168
169
  13. Make sure MySQL is running
170
171
      prompt:~> mysqlshow
172
      +--------------+
173
      | Databases    |
174
      +--------------+
175
      | mysql        |
176
      | dbemdata     |
177
      | projectdata  |
178
      +--------------+
179
180
  14. Or check with the following php script (if already installed)
181
182
      <?
183
      mysql_connect('your_host.your_institute.edu', 'usr_object', '','dbemdata');
184
      echo mysql_stat();
185
      ?> 
186
187
      Output
188
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>