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