Project

General

Profile

Database Server Setup to allow connection from the instruments » History » Version 16

Anchi Cheng, 04/15/2019 07:18 PM

1 9 Anchi Cheng
h1. Setup to allow connection from the instruments
2 1 Anchi Cheng
3 16 Anchi Cheng
h2. Allow remote access to database server (default in CentOS 6 and CentOS 7).
4 2 Anchi Cheng
5
h3. Edit /etc/my.cnf search for *skip-networking* and make sure it is commented out like this:
6
7
<pre>
8
#skip-networking
9 1 Anchi Cheng
</pre>
10 7 Anchi Cheng
11
Also look for bind-address in the same file and if it says 127.0.0.1, it will only listen to local connection.
12
You should comment that out as well.
13 3 Anchi Cheng
<pre>
14 7 Anchi Cheng
#bind-address=127.0.0.1
15 5 Anchi Cheng
</pre>
16 2 Anchi Cheng
17 7 Anchi Cheng
h3. Restart mysqld if you have made changes.
18 2 Anchi Cheng
19 15 Anchi Cheng
For CentOS7 that runs mariadb,
20
<pre>
21 16 Anchi Cheng
sudo systemctl restart mariadb
22 15 Anchi Cheng
</pre>
23
24
For CentOS6, Fedora that runs mysql
25
<pre>
26 2 Anchi Cheng
sudo /etc/init.d/mysqld restart
27
</pre>
28
or
29
<pre>
30
sudo /sbin/service mysqld restart
31 1 Anchi Cheng
</pre>
32
33 8 Anchi Cheng
h2. Create remote user if autoinstaller was used
34 2 Anchi Cheng
35 9 Anchi Cheng
Autoinstaller creates only root user and only allow its access to database from the localhost.
36 1 Anchi Cheng
37 8 Anchi Cheng
The following assumes that you want to use usr_object user for remote access as referenced in most of this document.
38
39
h3. Create and grant privileges to the usr_object for the databases on the hosts involved.  See MySQL Reference Manual for details.
40
41 1 Anchi Cheng
You can set hosts on a particular subnet by only specify the network number portion such as '192.168' and use wild card for the host number portion to give '192.168.%.%' as the global host allowing connection.
42 14 Morgan Beeby
If appropriate, you can also use domain name with wild card, i.e., '%.mydomain.edu'
43 2 Anchi Cheng
44 12 Anchi Cheng
Start mysql command line interface in a terminal as root and access the database named mysql which manages users and permission. We assume that you have used autoinstaller here and hence the password for root using in mysql is not yet set.
45 1 Anchi Cheng
46
For CentOS7 running mariadb
47 15 Anchi Cheng
<pre>
48 16 Anchi Cheng
mysql -u root -p mysql
49 15 Anchi Cheng
</pre>
50 16 Anchi Cheng
The mysql root user password is set during autoinstallation and is the same as your host root password you gave.
51 15 Anchi Cheng
52
For CentOS6 running mysql
53 12 Anchi Cheng
<pre>
54
mysql mysql
55
</pre>
56
57 2 Anchi Cheng
At the mysql prompt execute the following commands:
58
<pre>
59 9 Anchi Cheng
CREATE USER usr_object@'192.168.%.%' IDENTIFIED BY 'YOUR_PASSWORD';
60 2 Anchi Cheng
GRANT ALTER, CREATE, INSERT, SELECT, UPDATE ON leginondb.* TO usr_object@'192.168.%.%';
61 1 Anchi Cheng
GRANT ALTER, CREATE, INSERT, SELECT, UPDATE ON projectdb.* TO usr_object@'192.168.%.%';
62
</pre>
63
64
<pre>
65 9 Anchi Cheng
CREATE USER usr_object@'localhost' IDENTIFIED BY 'YOUR_PASSWORD';
66 1 Anchi Cheng
GRANT ALTER, CREATE, INSERT, SELECT, UPDATE ON leginondb.* TO usr_object@'localhost';
67
GRANT ALTER, CREATE, INSERT, SELECT, UPDATE ON projectdb.* TO usr_object@'localhost';
68
</pre>
69 8 Anchi Cheng
70 11 Anchi Cheng
<pre>
71
flush privileges;
72
exit;
73
</pre>
74
75 10 Anchi Cheng
h3. Other changes if usr_object will be used all the time from now on in autoinstalled Leginon:
76 8 Anchi Cheng
77 1 Anchi Cheng
*webserver* myamiweb/config.php
78 8 Anchi Cheng
<pre>
79
define('DB_USER', 'usr_object');
80 13 Anchi Cheng
define('DB_USER','YOUR_PASSWORD');
81 8 Anchi Cheng
</pre> 
82
83 9 Anchi Cheng
*processing server* /etc/myami/sinedon.cfg or ,if it does not exist, see [[Configure_sinedoncfg]] for other possibilities
84 8 Anchi Cheng
<pre>
85
user: usr_object
86 9 Anchi Cheng
passwd: YOUR_PASSWORD
87 2 Anchi Cheng
</pre>
88
89
______
90
91
[[Web Server Installation|< Web Server Installation]] | [[Additional Database Server Setup after Web Server Installation| Additional Database Server Setup >]] 
92
93
94 1 Anchi Cheng
______