Samba do use shared memory of mariadb

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_42298432/article/details/97921464

Prepare the environment:

First need two centos7,

samba-service 192.168.10.10 centos7
Mariadb 192.168.10.20 centos7

Case Requirements:
Create a file in the samba-service Mariadb do mount a shared directory, and then specify the samba-service shared directory to the local directory on top of the database server in Mariad above.

Install Service Pack
Centos7.3 ------------------> yum -y install Samba
Centos7.3 ---------------- -> yum -y install mariadb cifs- utils

Deployment Services:

In the above configuration server samba-server:

mkdir mariadb // Create the mount shared folders
useradd mysql// Create mysql user must specify Mariadb above MySQL database user uid and gid
usermod -u uid mysql user name groupmod -g gid mysql user name
chown mysql: mysql / mariadb / // Owner and an array of shared files changed mysql user, or mysql user does not have write access to the data can not be stored for mariad
smbpasswd -a mysql // set the samba shared users (needs to have the same name as the local system users)

Configuration samba configuration file

[mariadb]   //共享目录名称
        comment = zhe shi yi ge gongxiang dir //描述
        path = /mariadb_1/ //挂载目录的路径
        public = no //是否所有人可见
        writeable = yes  //是否可以写入
        valid users = mysql  //那些用户可以查看
        write list = mysql  //那些用户可以写入,组加上"@组名或者+组名

Check whether to write configuration syntax error, restart the samba service

testparm // check whether the syntax errors
systemctl restart smb // restart the samba service

In the above Mariadb-server configuration:
First: Mounting create mount folder, the owner and group configuration directory, then mount the shared directory to the local mount.cifs. Modify data storage path of samba. Restart mysql service. Insert table, insert the contents of view, is completed.

mkdir mariadb // create mount folder
chown mysql: mysql / mariadb / // set the owner and an array of directory
smbclient -L 192.168.10.10 -U mysql // view the shared directory of mysql

Use mount to mount samba-server above the shared directory to the local directory Mariadb

mount -t cifs //192.168.10.10/mariadb /mariadb/ -o username=mysql,password=hello


Use ls -d to view the local directory property

Attribute ll -d / mariadb // View directory

Note: No permission to mount a local directory when the directory is the local authority, after the samba server is mounted above the authority

Mariadb edit the configuration file, modify the MySQL default storage location:

vim /etc/my.conf
[mysqld]
datadir=/mariadb //修改数据库的默认储存路径为/mariadb  
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

~                            

systemctl restart mariadb // restart mariadb service
1. Go to mysql database

mysql -u root -p password

2. Create a database, named mdb_ceshi

create database mdb_ceshi;

3. Check whether the shared directory to store data successfully

Here Insert Picture Description

connection succeeded-

Guess you like

Origin blog.csdn.net/qq_42298432/article/details/97921464