安装包下载地址 https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz
# 检查是否存在mysql用户及用户组
cat /etc/group | grep mysql
cat /etc/passwd |grep mysql
# 若不存在,则创建mysql用户组及用户
groupadd mysql
useradd -r -g mysql mysql
# 设置mysql用户密码
passwd mysql
进入到data目录(可以是其他),并将安装包上传至此目录,并解压
# 进入到data目录
cd /data
# 上传安装包后解压
tar -xvf mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz
# 重命名解压后文件夹名称
mv mysql-5.7.27-linux-glibc2.12-x86_64 mysql
在mysql下创建数据data目录
mkdir /data/mysql/data
更改mysql目录下所有的目录及文件夹所属的用户组和用户,以及权限:
chown -R mysql:mysql /data/mysql
chmod -R 755 /data/mysql
编译安装并初始化mysql,需要关注输出日志末尾的密码(数据库管理员临时密码)
# 进入到bin目录
cd /data/mysql/bin/
# 启动
./mysqld --initialize --user=mysql --datadir=/data/mysql/data --basedir=/data/mysql/
-bash-4.2$ ./mysqld --initialize --user=mysql --datadir=/data/mysql/data --basedir=/data/mysql/
2022-11-14T03:16:19.226053Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-11-14T03:16:19.751812Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-11-14T03:16:19.891364Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-11-14T03:16:19.960788Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: b5991df6-63ca-11ed-bde6-d00da8c12e4f.
2022-11-14T03:16:20.288283Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-11-14T03:16:20.288980Z 1 [Note] A temporary password is generated for root@localhost: 1xqMS(gMh8I3
-bash-4.2$
vim /etc/my.cnf
# 添加以下配置信息
[mysqld]
datadir=/data/mysql/data
socket=/data/mysql/mysql.sock
port=3306
pid-file=/data/mysql/mysqld.pid
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
innodb_file_per_table=1
lower_case_table_names=1
character_set_server=utf8
max_connections = 3000
innodb_buffer_pool_size = 2048M
innodb_thread_concurrency = 8
join_buffer_size = 2M
[mysql]
socket=/data/mysql/mysql.sock
[client]
socket=/data/mysql/mysql.sock
测试启动mysql服务器
/data/mysql/support-files/mysql.server start
启动报错:
$ /data/mysql/support-files/mysql.server start
/data/mysql/support-files/mysql.server:行239: my_print_defaults: 未找到命令
/data/mysql/support-files/mysql.server: 第 259 行:cd: /usr/local/mysql: 没有那个文件或目录
Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)
$
修改Mysql配置文件
vim /data/mysql/support-files/mysql.server
# Set some defaults
mysqld_pid_file_path=
if test -z "$basedir"
then
basedir=/data/mysql // 修改此处,换成目前的目录
bindir=/data/mysql/bin // 修改此处
if test -z "$datadir"
then
datadir=/data/mysql // 修改此处
fi
sbindir=/data/mysql/bin // 修改此处
libexecdir=/data/mysql/bin // 修改此处
else
再次启动遇到下列错误:
$ /data/mysql/support-files/mysql.server start
Starting MySQL.2022-11-14T04:43:50.006213Z mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'mysql'.
ERROR! The server quit without updating PID file (/data/mysql/data/i-A8C12E4F.pid).
$
解决方式就是创建目录并赋予mysql用户权限:
mkdir /var/log/mariadb
touch /var/log/mariadb/mariadb.log
chown -R mysql:mysql /var/log/mariadb/
再次尝试启动,启动成功:
$ /data/mysql/support-files/mysql.server start
Starting MySQL. SUCCESS!
$
创建软连接:
ln -s /data/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /data/mysql/bin/mysql /usr/bin/mysql
重启MySQL:
service mysql restart
$ mysql -u root -p
Enter password: (这个密码是之前初始化启动时,日志末尾显示的)
mysql> set password for root@localhost = password('root');
修改主服务器
sudo vim /etc/my.cnf
[mysqld]
log-bin=mysql-bin #[必须]启用二进制日志
server-id=1 #[必须]服务器唯一ID,默认是1,一般取IP最后一段
修改从服务器
sudo vim /etc/my.cnf
[mysqld]
log-bin=mysql-bin #[必须]启用二进制日志
server-id=2 #[必须]服务器唯一ID,默认是1,一般取IP最后一段
重启两台服务器:
sudo service mysql restart
主服务器上建立帐户并授权slave:
mysql -u root -p
mysql>GRANT REPLICATION SLAVE ON *.* to 'slave'@'%' identified by 'qwer1234';
一般不用root帐号,“%”表示所有客户端都可能连,只要帐号,密码正确,此处可用具体客户端IP代替,如192.168.145.226,加强安全。
登录主服务器的mysql,查询master的状态:
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 438 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql>
登录从服务器,并配置从服务器Slave:
mysql>change master to master_host='mysql主IP', master_user='slave', master_password='qwer1234',master_log_file='mysql-bin.000001', master_log_pos=438;
开启主从同步,并检查从服务器复制功能状态:
mysql> start slave;
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> mysql> show slave status\G
# 主要查看这两个值是否是 Yes状态
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
mysql>
下载地址 https://www.minio.org.cn/download.shtml#/linux
创建安装目录并进入到该目录(/data/minio),上传安装文件:
$ mkdir /data/minio
$ cd /data/minio
查看minio文件权限:
# 当前权限查看
$ ll
-rw-r--r-- 1 root root 102334464 11月 14 10:55 minio
# 添加执行权限
$ chmod +x minio
$ ll
-rwxr-xr-x 1 root root 102334464 11月 14 10:55 minio
创建日志文件路径:
mkdir /data/minio/logs
修改minio控制台密码:
# 进入到根目录
$ cd ~
# 编辑.bash_profile文件
$ vim .bash_profile
# 添加下面的配置信息 (用户密码可自定义设置)
export MINIO_ACCESS_KEY=minio
export MINIO_SECRET_KEY=minio
启动minio:
nohup ./minio server --console-address '127.0.0.1:9002' /data1 > /data/minio/logs/minio.log 2>&1 &