Linux中运行多个MySQL实例

这里将介绍使用mysqld_safe来启动多个MySQL实例。对于使用一个RPM发布版本安装的MySQL来说,在多数Linux平台中MySQL服务的启动和关闭是由systemd来管理的。在这些平台上没有安装msyqld_safe因为不需要。

一种在Linux上运行多个MySQL实例的方法是用不同的默认TCP/IP端口和Unix套接字文件编译不同的服务器,以便每个服务器都监听不同的网络接口。为了在每个不同的基本目录中进行编译,还会自动生成一个单独的、编译后的数据目录、日志文件和每个服务器的PID文件位置。

假设一个现有的5.6服务器被配置成TCP/IP端口为3306并且Unix socket文件为/tmp/mysql.sock。为了配置一个新的5.7.21服务器使用不同的操作参数,使用CMake命令进行编译:
shell> cmake . -DMYSQL_TCP_PORT=port_number \
-DMYSQL_UNIX_ADDR=file_name \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.7.21

这里,port_number和file_name必须与缺省的TCP/CP端口号和Unix socket文件路径名不同,并且CMAKE_INSTALL_PREFIX值指定的安装目录不能是现有MySQL安装目录相同的目录。

如果有一个MySQL服务器正在监听一个指定的端口号,你可以使用下面的命令来找出多个重要配置变量所使用的操作参数,包括base目录和Unix socket文件名:
shell> mysqladmin –host=host_name –port=port_number variables

通过命令所显示的信息,你也可以知道当配置另一个服务器时什么选项值将不能使用。

如果指定localhost作为主机名,mysqladmin缺省会使用一个Unix socket文件来进行连接而不是使用TCP/IP。为了显性指定连接协议,使用–protocol={TCP|SOCKET|PIPE|MEMORY}选项。

如果只是使用不同的Unix socket文件和TCP/IP端口来启动一个MySQL实例那么不需要编译一个新的MySQL服务器。可以使用相同的服务器二进制文件并且在运行时为每个MySQL实例使用不同的参数。一种方式是使用命令行选项:
shell>mysqld_safe –socket=file_name –port=port_number

为了启动第二个MySQL实例,给mysqld_safe提供不同的–socket和–port选项值并传一个–datadir=dir_name选项因此这个实例将使用不同的数据目录。

另一种方法是将每个MySQL实例的选项放入不同的选项文件,然后启动每个实例时使用–defaults-file选项来指定合适选项文件的路径。

shell> mysqld_safe --defaults-file=/usr/local/mysql/my.cnf
shell> mysqld_safe --defaults-file=/usr/local/mysql/my.cnf2

另一种方法来完成相同的功能是使用环境变量来设置Unix socket文件名和TCP/IP端口号:

shell> MYSQL_UNIX_PORT=/tmp/mysqld-new.sock
shell> MYSQL_TCP_PORT=3307
shell> export MYSQL_UNIX_PORT MYSQL_TCP_PORT
shell> mysql_install_db --user=mysql
shell> mysqld_safe --datadir=/path/to/datadir &

这是一种快速启动第二个实例进行测试的方法。它的好处是设置的环境变量可以应用到从相同shell执行调用的任何客户端程序。因此对于这些客户端连接会自动指向第二实例。

另一种方法是在Linux中使用mysqld_multi脚本来管理多个MySQL实例。
下面来创建三个实例(实例的端口号为3307,3308,3309)
创建存储这三个实例的数据库文件目录

-bash-4.2$ mkdir mysql3307
-bash-4.2$ mkdir mysql3308
-bash-4.2$ mkdir mysql3309
-bash-4.2$ ls -lrt
总用量 4
drwxrwxrwx. 5 mysql mysql 4096 8月  22 21:46 mysql
drwxr-xr-x. 2 mysql mysql    6 9月   4 10:26 mysql3307
drwxr-xr-x. 2 mysql mysql    6 9月   4 10:26 mysql3308
drwxr-xr-x. 2 mysql mysql    6 9月   4 10:26 mysql3309

为每个实例创建一个选项文件(my3307.cnf,my3308.cnf,my3309.cnf)
my3307.cnf文件内容如下:

-bash-4.2$ cat my3307.cnf
[mysqld]
basedir=/mysqlsoft/mysql
datadir=/mysqldata/mysql3307
bind-address=0.0.0.0
user=mysql
port=3307
log-error=/mysqldata/mysql3307/mysql.err
pid-file=/mysqldata/mysql3307/mysqld.pid
socket = /mysqldata/mysql3307/mysql.sock
character-set-server=utf8mb4
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true

my3308.cnf文件内容如下:

-bash-4.2$ cat my3308.cnf
[mysqld]
basedir=/mysqlsoft/mysql
datadir=/mysqldata/mysql3308
bind-address=0.0.0.0
user=mysql
port=3308
log-error=/mysqldata/mysql3308/mysql.err
pid-file=/mysqldata/mysql3308/mysqld.pid
socket = /mysqldata/mysql3308/mysql.sock
character-set-server=utf8mb4
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true

my3309.cnf文件内容如下:

-bash-4.2$ cat my3309.cnf
[mysqld]
basedir=/mysqlsoft/mysql
datadir=/mysqldata/mysql3309
bind-address=0.0.0.0
user=mysql
port=3309
log-error=/mysqldata/mysql3309/mysql.err
pid-file=/mysqldata/mysql3309/mysqld.pid
socket = /mysqldata/mysql3309/mysql.sock
character-set-server=utf8mb4
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true

初始化数据库

-bash-4.2$ mysqld  --defaults-file=/mysqlsoft/mysql/my3307.cnf --initialize --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql3307 --user=mysql
-bash-4.2$ mysqld  --defaults-file=/mysqlsoft/mysql/my3308.cnf --initialize --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql3308 --user=mysql
-bash-4.2$ mysqld  --defaults-file=/mysqlsoft/mysql/my3309.cnf --initialize --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql3309 --user=mysql

启动数据库

-bash-4.2$ mysqld_safe --defaults-file=/mysqlsoft/mysql/my3307.cnf &
[1] 10359
-bash-4.2$ 2019-09-05T09:39:35.467416Z mysqld_safe Logging to '/mysqldata/mysql3307/mysql.err'.
2019-09-05T09:39:35.545107Z mysqld_safe Starting mysqld daemon with databases from /mysqldata/mysql3307


-bash-4.2$ mysqld_safe --defaults-file=/mysqlsoft/mysql/my3308.cnf &
[1] 10624
-bash-4.2$ 2019-09-05T09:42:28.457387Z mysqld_safe Logging to '/mysqldata/mysql3308/mysql.err'.
2019-09-05T09:42:28.532350Z mysqld_safe Starting mysqld daemon with databases from /mysqldata/mysql3308


-bash-4.2$ mysqld_safe --defaults-file=/mysqlsoft/mysql/my3309.cnf &
[1] 10889
-bash-4.2$ 2019-09-05T09:45:03.772185Z mysqld_safe Logging to '/mysqldata/mysql3309/mysql.err'.
2019-09-05T09:45:03.847584Z mysqld_safe Starting mysqld daemon with databases from /mysqldata/mysql3309

修改每个MySQL实例的用户密码并关闭实例

-bash-4.2$ mysql --port=3307 --host=127.0.0.1 --user=root --password=nCohVRg-=7LP 
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.26

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
-bash-4.2$ mysqladmin --port=3307 --host=127.0.0.1 --user=root --password=123456 shutdown
mysqladmin: [Warning] Using a password on the command line interface can be insecure.


-bash-4.2$ mysql --port=3308 --host=127.0.0.1 --user=root --password=g*tV/I%#s6j#
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
-bash-4.2$ mysqladmin --port=3308 --host=127.0.0.1 --user=root --password=123456 shutdown
mysqladmin: [Warning] Using a password on the command line interface can be insecure.

-bash-4.2$ mysql --port=3309 --host=127.0.0.1 --user=root --password=eIsXkThGK5*4
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
-bash-4.2$ mysqladmin --port=3309 --host=127.0.0.1 --user=root --password=123456 shutdown
mysqladmin: [Warning] Using a password on the command line interface can be insecure.

使用mysqld_multi来管理多个MySQL实例
修改配置文件my.cnf增加以下内容(增加三个实例的选项参数)

[mysqld_multi]
mysqld=/mysqlsoft/mysql/bin/mysqld_safe
mysqladmin =/mysqlsoft/mysql/bin/mysqladmin
log =/mysqlsoft/mysql/mysqld_multi.log

[mysqld1]
basedir=/mysqlsoft/mysql
datadir=/mysqldata/mysql3307
bind-address=0.0.0.0
user=mysql
port=3307
log-error=/mysqldata/mysql3307/mysql.err
pid-file=/mysqldata/mysql3307/mysqld.pid
socket = /mysqldata/mysql3307/mysql.sock
character-set-server=utf8mb4
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true


[mysqld2]
basedir=/mysqlsoft/mysql
datadir=/mysqldata/mysql3308
bind-address=0.0.0.0
user=mysql
port=3308
log-error=/mysqldata/mysql3308/mysql.err
pid-file=/mysqldata/mysql3308/mysqld.pid
socket = /mysqldata/mysql3308/mysql.sock
character-set-server=utf8mb4
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true


[mysqld3]
basedir=/mysqlsoft/mysql
datadir=/mysqldata/mysql3309
bind-address=0.0.0.0
user=mysql
port=3309
log-error=/mysqldata/mysql3309/mysql.err
pid-file=/mysqldata/mysql3309/mysqld.pid
socket = /mysqldata/mysql3309/mysql.sock
character-set-server=utf8mb4
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true

使用mysqld_multi来启动实例

[mysql@localhost ~]$ mysqld_multi start 1

报错了,从日志可以看到启动实例时调用了两次,我这里的测试环境在创建多个实例之前创建了一个mysqld实例(也许存在影响)

[mysql@localhost mysql]$ tail -f mysqld_multi.log 
Starting MySQL servers

2019-09-06T05:40:07.558168Z mysqld_safe Logging to '/mysqldata/mysql3307/mysql.err'.
2019-09-06T05:40:07.563783Z mysqld_safe Logging to '/mysqldata/mysql3307/mysql.err'.
2019-09-06T05:40:07.618543Z mysqld_safe Starting mysqld daemon with databases from /mysqldata/mysql3307
2019-09-06T05:40:07.623821Z mysqld_safe Starting mysqld daemon with databases from /mysqldata/mysql3307

root@localhost mysql3307]# tail -f mysql.err
2019-09-06T06:24:30.964335Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2019-09-06T06:24:31.964485Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2019-09-06T06:24:31.964573Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2019-09-06T06:24:32.964723Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2019-09-06T06:24:32.964812Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2019-09-06T06:24:33.964935Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2019-09-06T06:24:33.964987Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2019-09-06T06:24:34.965105Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2019-09-06T06:24:34.965178Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2019-09-06T06:24:35.965292Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2019-09-06T06:24:35.965340Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2019-09-06T06:24:36.965460Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2019-09-06T06:24:36.965509Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2019-09-06T06:24:37.965632Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11

所以这里在使用mysqld_multi来启动实例时使用–defaults-file

[mysql@localhost bin]$ mysqld_multi --defaults-file=/mysqlsoft/mysql/my.cnf start 1
[mysql@localhost bin]$ mysqld_multi --defaults-file=/mysqlsoft/mysql/my.cnf start 2,3

[mysql@localhost mysql]$ tail -f mysqld_multi.log 
Starting MySQL servers

2019-09-06T06:49:50.003877Z mysqld_safe Logging to '/mysqldata/mysql3307/mysql.err'.
2019-09-06T06:49:50.096954Z mysqld_safe Starting mysqld daemon with databases from /mysqldata/mysql3307
mysqld_multi log file version 2.16; run: 五 9月  6 14:59:33 2019

Starting MySQL servers

2019-09-06T06:59:33.644263Z mysqld_safe Logging to '/mysqldata/mysql3308/mysql.err'.
2019-09-06T06:59:33.650226Z mysqld_safe Logging to '/mysqldata/mysql3309/mysql.err'.
2019-09-06T06:59:33.704593Z mysqld_safe Starting mysqld daemon with databases from /mysqldata/mysql3308
2019-09-06T06:59:33.710937Z mysqld_safe Starting mysqld daemon with databases from /mysqldata/mysql3309

到此使用mysqld_multi来管理多个实例的操作就完成了。

MySQL Server Startup Script

MySQL Server Startup Script
在Unix和类似于Unix的系统中的MySQL发布版本包含一个名叫mysql.server的脚本,它将调用mysqld_safe来启动MySQL服务器。它也可以用于像Linux和Solaris系统上使用System V-style来运行指令来启动和停止系统服务。也可以被macOS启动项目来启动MySQL。

mysql.server是MySQL源码树中的脚本名称。其安装后的名称可能不一样,例如,mysqld或mysql。下面将会介绍将mysql.server脚本调整成适合于你系统的名称。注意对于某些Linux平台,使用RPM或Debian包安装的MySQL包含用来管理MySQL服务器启动和关闭的systemd的支持。在这些平台上,mysql.server和mysqld_safe不需要安装因为不需要它们。

为了使用mysql.server来手动启动或停止MySQL服务,可以从命令调用它并使用start或stop参数:

[root@localhost support-files]# ./mysql.server stop
Shutting down MySQL.. SUCCESS!
[root@localhost support-files]# ./mysql.server start
Starting MySQL.. SUCCESS!

相关日志信息如下:

2019-08-22T13:29:13.429419Z 0 [Note] Giving 0 client threads a chance to die gracefully
2019-08-22T13:29:13.429508Z 0 [Note] Shutting down slave threads
2019-08-22T13:29:13.429535Z 0 [Note] Forcefully disconnecting 0 remaining clients
2019-08-22T13:29:13.429553Z 0 [Note] Event Scheduler: Purging the queue. 0 events
2019-08-22T13:29:13.429630Z 0 [Note] Binlog end
2019-08-22T13:29:13.460102Z 0 [Note] Shutting down plugin 'ngram'
2019-08-22T13:29:13.460187Z 0 [Note] Shutting down plugin 'partition'
2019-08-22T13:29:13.460214Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2019-08-22T13:29:13.460235Z 0 [Note] Shutting down plugin 'ARCHIVE'
2019-08-22T13:29:13.460277Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2019-08-22T13:29:13.460405Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2019-08-22T13:29:13.460446Z 0 [Note] Shutting down plugin 'MyISAM'
2019-08-22T13:29:13.460553Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2019-08-22T13:29:13.460599Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2019-08-22T13:29:13.460619Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2019-08-22T13:29:13.460637Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2019-08-22T13:29:13.460681Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2019-08-22T13:29:13.460736Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2019-08-22T13:29:13.460776Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2019-08-22T13:29:13.460898Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2019-08-22T13:29:13.460920Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2019-08-22T13:29:13.460938Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2019-08-22T13:29:13.460956Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2019-08-22T13:29:13.460973Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2019-08-22T13:29:13.460991Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2019-08-22T13:29:13.461008Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2019-08-22T13:29:13.461026Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2019-08-22T13:29:13.461044Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2019-08-22T13:29:13.461089Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2019-08-22T13:29:13.461140Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2019-08-22T13:29:13.461161Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2019-08-22T13:29:13.461180Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2019-08-22T13:29:13.461220Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2019-08-22T13:29:13.461286Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2019-08-22T13:29:13.461306Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2019-08-22T13:29:13.461325Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2019-08-22T13:29:13.461343Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2019-08-22T13:29:13.461361Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2019-08-22T13:29:13.461378Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2019-08-22T13:29:13.461396Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2019-08-22T13:29:13.461414Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2019-08-22T13:29:13.461431Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2019-08-22T13:29:13.461450Z 0 [Note] Shutting down plugin 'InnoDB'
2019-08-22T13:29:13.461776Z 0 [Note] InnoDB: FTS optimize thread exiting.
2019-08-22T13:29:13.462092Z 0 [Note] InnoDB: Starting shutdown...
2019-08-22T13:29:13.562479Z 0 [Note] InnoDB: Dumping buffer pool(s) to /mysqldata/mysql/ib_buffer_pool
2019-08-22T13:29:13.563934Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 190822 21:29:13
2019-08-22T13:29:14.807857Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2530229
2019-08-22T13:29:14.810644Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2019-08-22T13:29:14.810690Z 0 [Note] Shutting down plugin 'MEMORY'
2019-08-22T13:29:14.810707Z 0 [Note] Shutting down plugin 'CSV'
2019-08-22T13:29:14.810721Z 0 [Note] Shutting down plugin 'sha256_password'
2019-08-22T13:29:14.810731Z 0 [Note] Shutting down plugin 'mysql_native_password'
2019-08-22T13:29:14.810961Z 0 [Note] Shutting down plugin 'binlog'
2019-08-22T13:29:14.811432Z 0 [Note] /mysqlsoft/mysql/bin/mysqld: Shutdown complete

2019-08-22T13:30:24.969246Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2019-08-22T13:30:24.969441Z 0 [Note] /mysqlsoft/mysql/bin/mysqld (mysqld 5.7.26) starting as process 32558 ...
2019-08-22T13:30:24.980591Z 0 [Note] InnoDB: PUNCH HOLE support available
2019-08-22T13:30:24.980678Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-08-22T13:30:24.980740Z 0 [Note] InnoDB: Uses event mutexes
2019-08-22T13:30:24.980758Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-08-22T13:30:24.980779Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-08-22T13:30:24.981460Z 0 [Note] InnoDB: Number of pools: 1
2019-08-22T13:30:24.981799Z 0 [Note] InnoDB: Using CPU crc32 instructions
2019-08-22T13:30:24.985591Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-08-22T13:30:25.002296Z 0 [Note] InnoDB: Completed initialization of buffer pool
2019-08-22T13:30:25.007382Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-08-22T13:30:25.021394Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2019-08-22T13:30:25.063462Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-08-22T13:30:25.063830Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-08-22T13:30:25.758116Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-08-22T13:30:25.760396Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2019-08-22T13:30:25.760448Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2019-08-22T13:30:25.761681Z 0 [Note] InnoDB: Waiting for purge to start
2019-08-22T13:30:25.811963Z 0 [Note] InnoDB: 5.7.26 started; log sequence number 2530229
2019-08-22T13:30:25.812330Z 0 [Note] InnoDB: Loading buffer pool(s) from /mysqldata/mysql/ib_buffer_pool
2019-08-22T13:30:25.813642Z 0 [Note] Plugin 'FEDERATED' is disabled.
2019-08-22T13:30:25.819058Z 0 [Note] InnoDB: Buffer pool(s) load completed at 190822 21:30:25
2019-08-22T13:30:25.824582Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2019-08-22T13:30:25.825236Z 0 [Warning] CA certificate ca.pem is self signed.
2019-08-22T13:30:25.827375Z 0 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
2019-08-22T13:30:25.827463Z 0 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
2019-08-22T13:30:25.829361Z 0 [Note] Server socket created on IP: '0.0.0.0'.
2019-08-22T13:30:25.859593Z 0 [Note] Event Scheduler: Loaded 0 events
2019-08-22T13:30:25.859938Z 0 [Note] /mysqlsoft/mysql/bin/mysqld: ready for connections.
Version: '5.7.26'  socket: '/mysqlsoft/mysql/mysql.sock'  port: 3306  Source distribution

mysql.server进入到MySQL安装目录,然后调用mysqld_safe。为了让某些特定的用户能够运行服务,在全局/etc/my.cnf选项文件中为[mysqld]组增加一个合适的user选项,后面将会介绍(如果你将二进制版本的MySQL安装在非标准位置,那么可能必须要修改mysql.server脚本。修改它是为了在运行mysqld_safe之前进入到合适的目录中。如果这样做,当将来升级MySQL时你修改的mysql.server版本可能会被覆盖,创建一个你修改版本的副本可以进行重新安装)。

mysql.server stop通过发送一个信号给它来停止MySQL服务。也可以通过执行mysqladmin shutdown来手动关闭服务。

[root@localhost bin]# ./mysqladmin -uroot -p123456 shutdown
mysqladmin: [Warning] Using a password on the command line interface can be insecure.

日志信息如下:

2019-08-22T13:44:57.170282Z 0 [Note] Giving 0 client threads a chance to die gracefully
2019-08-22T13:44:57.170357Z 0 [Note] Shutting down slave threads
2019-08-22T13:44:57.170919Z 0 [Note] Forcefully disconnecting 0 remaining clients
2019-08-22T13:44:57.171016Z 0 [Note] Event Scheduler: Purging the queue. 0 events
2019-08-22T13:44:57.171140Z 0 [Note] Binlog end
2019-08-22T13:44:57.172096Z 0 [Note] Shutting down plugin 'ngram'
2019-08-22T13:44:57.172142Z 0 [Note] Shutting down plugin 'partition'
2019-08-22T13:44:57.172203Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2019-08-22T13:44:57.172225Z 0 [Note] Shutting down plugin 'ARCHIVE'
2019-08-22T13:44:57.172259Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2019-08-22T13:44:57.172317Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2019-08-22T13:44:57.172348Z 0 [Note] Shutting down plugin 'MyISAM'
2019-08-22T13:44:57.172398Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2019-08-22T13:44:57.172428Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2019-08-22T13:44:57.172441Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2019-08-22T13:44:57.172452Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2019-08-22T13:44:57.172476Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2019-08-22T13:44:57.172506Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2019-08-22T13:44:57.172564Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2019-08-22T13:44:57.172579Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2019-08-22T13:44:57.172590Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2019-08-22T13:44:57.172601Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2019-08-22T13:44:57.172612Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2019-08-22T13:44:57.172623Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2019-08-22T13:44:57.172634Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2019-08-22T13:44:57.172644Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2019-08-22T13:44:57.172655Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2019-08-22T13:44:57.172666Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2019-08-22T13:44:57.172676Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2019-08-22T13:44:57.172687Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2019-08-22T13:44:57.172698Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2019-08-22T13:44:57.172708Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2019-08-22T13:44:57.172734Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2019-08-22T13:44:57.172746Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2019-08-22T13:44:57.172769Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2019-08-22T13:44:57.172802Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2019-08-22T13:44:57.172814Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2019-08-22T13:44:57.172838Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2019-08-22T13:44:57.172849Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2019-08-22T13:44:57.172872Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2019-08-22T13:44:57.172884Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2019-08-22T13:44:57.172895Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2019-08-22T13:44:57.172906Z 0 [Note] Shutting down plugin 'InnoDB'
2019-08-22T13:44:57.173010Z 0 [Note] InnoDB: FTS optimize thread exiting.
2019-08-22T13:44:57.173195Z 0 [Note] InnoDB: Starting shutdown...
2019-08-22T13:44:57.274546Z 0 [Note] InnoDB: Dumping buffer pool(s) to /mysqldata/mysql/ib_buffer_pool
2019-08-22T13:44:57.275296Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 190822 21:44:57
2019-08-22T13:44:58.528547Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2530257
2019-08-22T13:44:58.531650Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2019-08-22T13:44:58.531698Z 0 [Note] Shutting down plugin 'MEMORY'
2019-08-22T13:44:58.531736Z 0 [Note] Shutting down plugin 'CSV'
2019-08-22T13:44:58.531752Z 0 [Note] Shutting down plugin 'sha256_password'
2019-08-22T13:44:58.531764Z 0 [Note] Shutting down plugin 'mysql_native_password'
2019-08-22T13:44:58.531967Z 0 [Note] Shutting down plugin 'binlog'
2019-08-22T13:44:58.532460Z 0 [Note] /mysqlsoft/mysql/bin/mysqld: Shutdown complete

为了在服务器上自动启动和停止MySQL服务,你必须在你的/etc/rc*文件中合适的地方添加启动和停止命令:
.如果使用Linux服务RPM包(MySQL-server-VERSION.rpm)或一个原生的Linux包安装,那么mysql.server脚本可能以mysqld或mysql的名称安装到/etc/init.d目录中。

.如果使用源码或二进制版本来安装MySQL时不能自动安装mysql.server,可以手动安装这个脚本。它可以在MySQL安装目录或MySQL源码树下的support-files目录中找到。将这个脚本复制到/etc/init.d目录中并命名为mysql并且修改权限让其它可以执行:

[root@cs2 ~]# cp /mysqlsoft/mysql/support-files/mysql.server  /etc/init.d/mysqld
[root@cs2 ~]# chmod 755 /etc/init.d/mysqld

在安装脚本后,依赖于操作系统命令需要在系统启动时来激活它。在Linux上,你可以使用chkconfig:

[root@localhost init.d]# chkconfig --add mysqld

在有一些Linux系统中,也需要执行以下命令来完全启用mysqld脚本:

[root@localhost init.d]# chkconfig --level 345 mysqld on

在FreeBSD系统中,启动脚本通常应该在/usr/local/etc/rc.d/目录中,安装的mysql.server脚本就是/usr/local/etc/rc.d/mysql.server.sh来启用自动启动。rc(8)手册页指出,只有当脚本的基本名称与*.sh shell文件名模式匹配时,才会执行该目录中的脚本。该目录中存在的任何其他文件或目录都将被默认忽略。

作为上述设置的一种替代方案,有些操作系统也会使用/etc/rc.local或/etc/init.d/boot.local来在操作系统启动时启动额外的服务。为了使用这种方法来启动MySQL。需要在合适的启动文件中增加类似下面的命令:

/bin/sh -c 'cd /usr/local/mysql; ./bin/mysqld_safe --user=mysql &'

对于其它系统,咨询你操作系统文档来查看如何安装启动脚本。

mysql.server会读取选项文件中的[mysql.server]和[mysqld]部分的选项。为了向后兼容,它也会读取[mysql_server]部分的选项,但是现在你应该将它重命名为[mysql.server]。

可以在全局/etc/my.cnf文件中为mysql.server增加选项。一个常见的my.cnf文件可能看到类似于以下所示:

[mysqld]
basedir=/mysqlsoft/mysql
datadir=/mysqldata/mysql
user=mysql
port=3306
socket = /mysqlsoft/mysql/mysql.sock

[mysql.server]
basedir=/usr/local/mysql

mysql.server脚本支持下表中所列出的选项。如果指定,他们必须被存储在一个选项文件中,而不是在命令行中设置。mysql.server只支持start和stop作为命令行参数

表4.4 mysql.server选项文件选项
Option Name Description Type
basedir MySQL安装目录路径 目录名
datadir MySQL数据目录路径 目录名
pid-file 服务器将它的进程ID需要写入的文件 文件名
service-startup-timeout 服务器在启动时所等待的时间长度 整数

basedir=dir_name
MySQL安装目录路径

datadir=dir_name
MySQL数据目录路径

pid-file=file_name
服务器将它的进程ID需要写入的文件的路径名。如果这个选项没有指定,mysql.server将使用缺省值host_name.pid这种PID文件值传送给mysql_safe会覆盖在[mysqld_safe]选项文件组中所指定的任何值。因为mysql.server会读取[mysqld]选项文件组但不会读取[mysqld_safe]组,你也可以确保通过在[mysqld_safe]和[mysqld]组中设置相同的pid-file值使用在手动从mysql.server脚本中调用mysqld_safe时可以得到相同的值。

service-startup-timeout=seconds
确认服务器启动时可以等待的时间长度。如果服务器在这个时间内没有启动成功,mysql.server会抛出错误并退出。缺省时间为900秒。0意味着在启动时不会执行等待。负数意味着将会永久等待(不会超时)。

PostgreSQL 行安全策略

行安全策略除可以通过GRANT使用 SQL 标准的 特权系统之外,表还可以具有 行安全性策略,它针对每一个用户限制哪些行可以 被普通的查询返回或者可以被数据修改命令插入、更新或删除。这种 特性也被称为行级安全性。默认情况下,表不具有 任何策略,这样用户根据 SQL 特权系统具有对表的访问特权,对于 查询或更新来说其中所有的行都是平等的。

当在一个表上启用行安全性时(使用 ALTER TABLE … ENABLE ROW LEVEL SECURITY),所有对该表选择行或者修改行的普通访问都必须被一条 行安全性策略所允许(不过,表的拥有者通常不服从行安全性策略)。如果 表上不存在策略,将使用一条默认的否定策略,即所有的行都不可见或者不能 被修改。应用在整个表上的操作不服从行安全性,例如TRUNCATE和 REFERENCES。

行安全性策略可以针对特定的命令、角色或者两者。一条策略可以被指定为 适用于ALL命令,或者SELECT、 INSERT、UPDATE或者DELETE。 可以为一条给定策略分配多个角色,并且通常的角色成员关系和继承规则也适用。

要指定哪些行根据一条策略是可见的或者是可修改的,需要一个返回布尔结果 的表达式。对于每一行,在计算任何来自用户查询的条件或函数之前,先会计 算这个表达式(这条规则的唯一例外是leakproof函数, 它们被保证不会泄露信息,优化器可能会选择在行安全性检查之前应用这类 函数)。使该表达式不返回true的行将不会被处理。可以指定独立的表达式来单独控制哪些行可见以及哪些行被允许修改。策略表达式会作为查询的一部分运行并且带有运行该查询的用户的特权,但是安全性定义者函数可以被用来访问对调用用户不可用的数据。

具有BYPASSRLS属性的超级用户和角色在访问一个表时总是 可以绕过行安全性系统。表拥有者通常也能绕过行安全性,不过表拥有者 可以选择用ALTER TABLE … FORCE ROW LEVEL SECURITY来服从行安全性。

用和禁用行安全性以及向表增加策略是只有表拥有者具有的特权。

策略的创建可以使用CREATE POLICY命令,策略的修改 可以使用ALTER POLICY命令,而策略的删除可以使用 DROP POLICY命令。要为一个给定表启用或者禁用行 安全性,可以使用ALTER TABLE命令。

每一条策略都有名称并且可以为一个表定义多条策略。由于策略是表相 关的,一个表的每一条策略都必须有一个唯一的名称。不同的表可以拥有 相同名称的策略。

当多条策略适用于一个给定查询时,它们会被用OR 组合起来,这样只要任一策略允许,行就是可访问的。这类似于一个给定 角色具有它所属的所有角色的特权的规则。

作为一个简单的例子,这里是如何在account关系上 创建一条策略以允许只有managers角色的成员能访问行, 并且只能访问它们账户的行:
CREATE TABLE accounts (manager text, company text, contact_email text);

ALTER TABLE accounts ENABLE ROW LEVEL SECURITY;

CREATE POLICY account_managers ON accounts TO managers USING (manager = current_user);

上述政策隐式地提供了一个with check子句来标识它的using子句,因此这个约束应用于通过命令来选所择的行(因此一个管理者不能select,update或delete现有属于不同管理都的行)和通过命令来修改的行(因此属于不同管理者的行不能通过insert或update来创建)。

如果没有指定角色或者指定的用户名为public,那么这个熏将应用给系统中的所有用户。 为了允许所有用户只访问在一个user表中的行记录,可以使用如下一个简单和策略:
CREATE POLICY user_policy ON users USING (user_name = current_user);

这与前面的示例类似

要对添加到表中的行与可见行使用不同的策略,可以组合多个策略。这对策略将允许所有的用户来查看users表中的所有行,但只能修改属于他们自己的行记录:
CREATE POLICY user_sel_policy ON users FOR SELECT USING (true);

CREATE POLICY user_mod_policy ON users USING (user_name = current_user);

在SELECT命令中,使用OR组合来使用这两个策略,最终的效果是可以选择所有行。在其他命令类型中,只应用第二个策略,因此效果与前面相同。

行安全策略也可以使用alter table命令来禁用。禁用行安全策略不会删除在表上所定义的任何策略,它们只是被忽略。然后表中的所有行都可见并且能被修改,服从于标准的SQL特权系统。

下面是一个较大的例子,它展示了这种特性如何被用于生产环境。表 passwd模拟了一个 Unix 口令文件:
— 简单的口令文件例子

jydb=# CREATE TABLE passwd (
jydb(# user_name text UNIQUE NOT NULL,
jydb(# pwhash text,
jydb(# uid int PRIMARY KEY,
jydb(# gid int NOT NULL,
jydb(# real_name text NOT NULL,
jydb(# home_phone text,
jydb(# extra_info text,
jydb(# home_dir text NOT NULL,
jydb(# shell text NOT NULL
jydb(# );
CREATE TABLE

–创建用户:

jydb=# CREATE ROLE admin;
CREATE ROLE
jydb=# CREATE ROLE bob;
CREATE ROLE
jydb=# CREATE ROLE alice;
CREATE ROLE

— 向表中插入数据

jydb=# INSERT INTO passwd VALUES('admin','xxx',0,0,'Admin','111-222-3333',null,'/root','/bin/dash');
INSERT 0 1
jydb=# INSERT INTO passwd VALUES('bob','xxx',1,1,'Bob','123-456-7890',null,'/home/bob','/bin/zsh');
INSERT 0 1
jydb=# INSERT INTO passwd VALUES('alice','xxx',2,1,'Alice','098-765-4321',null,'/home/alice','/bin/zsh');
INSERT 0 1

–确保在表上启用行级安全性

jydb=# ALTER TABLE passwd ENABLE ROW LEVEL SECURITY;
ALTER TABLE

创建策略
— 管理员能看见所有行并且增加任意行

jydb=# CREATE POLICY admin_all ON passwd TO admin USING (true) WITH CHECK (true);
CREATE POLICY

–普通用户可以看见所有行

jydb=# CREATE POLICY all_view ON passwd FOR SELECT USING (true);
CREATE POLICY

–普通用户可以更新它们自己的记录,但是限制普通用户可用的 shell

jydb=# CREATE POLICY user_mod ON passwd FOR UPDATE
jydb-#   USING (current_user = user_name)
jydb-#   WITH CHECK (
jydb(#     current_user = user_name AND
jydb(#     shell IN ('/bin/bash','/bin/sh','/bin/dash','/bin/zsh','/bin/tcsh')
jydb(#   );
CREATE POLICY

–允许admin有所有普通权限

jydb=# GRANT SELECT, INSERT, UPDATE, DELETE ON passwd TO admin;
GRANT

–普通用户只在公共列上得到选择访问权限

jydb=# GRANT SELECT
jydb-# (user_name, uid, gid, real_name, home_phone, extra_info, home_dir, shell)
jydb-# ON passwd TO public;
GRANT

— 允许普通用户更新特定行

jydb=# GRANT UPDATE
jydb-# (pwhash, real_name, home_phone, extra_info, shell)
jydb-# ON passwd TO public;
GRANT

对于任意安全性设置来说,重要的是测试并确保系统的行为符合预期。 使用上述的例子,下面展示了权限系统工作正确:

–admin 可以看到所有的行和字段

jydb=# set role admin;
SET
jydb=> table passwd;
 user_name | pwhash | uid | gid | real_name |  home_phone  | extra_info |  home_dir   |   shell   
-----------+--------+-----+-----+-----------+--------------+------------+-------------+-----------
 admin     | xxx    |   0 |   0 | Admin     | 111-222-3333 |            | /root       | /bin/dash
 bob       | xxx    |   1 |   1 | Bob       | 123-456-7890 |            | /home/bob   | /bin/zsh
 alice     | xxx    |   2 |   1 | Alice     | 098-765-4321 |            | /home/alice | /bin/zsh
(3 rows)

jydb=> select * from passwd;
 user_name | pwhash | uid | gid | real_name |  home_phone  | extra_info |  home_dir   |   shell   
-----------+--------+-----+-----+-----------+--------------+------------+-------------+-----------
 admin     | xxx    |   0 |   0 | Admin     | 111-222-3333 |            | /root       | /bin/dash
 bob       | xxx    |   1 |   1 | Bob       | 123-456-7890 |            | /home/bob   | /bin/zsh
 alice     | xxx    |   2 |   1 | Alice     | 098-765-4321 |            | /home/alice | /bin/zsh
(3 rows)

— 测试 Alice 能做什么

jydb=> set role alice;
SET
jydb=>  table passwd;
ERROR:  permission denied for relation passwd
jydb=> select * from passwd;
ERROR:  permission denied for relation passwd
jydb=> select user_name,real_name,home_phone,extra_info,home_dir,shell from passwd;
 user_name | real_name |  home_phone  | extra_info |  home_dir   |   shell   
-----------+-----------+--------------+------------+-------------+-----------
 admin     | Admin     | 111-222-3333 |            | /root       | /bin/dash
 bob       | Bob       | 123-456-7890 |            | /home/bob   | /bin/zsh
 alice     | Alice     | 098-765-4321 |            | /home/alice | /bin/zsh
(3 rows)


jydb=> update passwd set user_name = 'joe';
ERROR:  permission denied for relation passwd

–Alice 被允许更改她自己的 real_name,但不能改其他的

jydb=> update passwd set real_name = 'Alice Doe';
UPDATE 1
jydb=> update passwd set real_name = 'John Doe' where user_name = 'admin';
UPDATE 0
jydb=> update passwd set shell = '/bin/xx';
ERROR:  new row violates row-level security policy for table "passwd"
jydb=> delete from passwd;
ERROR:  permission denied for relation passwd
jydb=> insert into passwd (user_name) values ('xxx');
ERROR:  permission denied for relation passwd

— Alice 可以更改她自己的口令;行级安全性会悄悄地阻止更新其他行

jydb=> update passwd set pwhash = 'abc';
UPDATE 1

引用完整性检查(例如唯一或主键约束和外键引用)总是会绕过行级安全策略以保证数据完整性得到维护。在开发模式和行级安全策略时必须小心避免 “隐蔽通道”通过这类引用完整性检查泄露信息。

在某些环境中确保不应用行级安全策略是很重要的。例如,当执行备份时,如果行级安全策略默默地造成备份操作忽略了一些行数据这将是灾难性的。在这种情部钙,你可以将row_security配置参数设置为off。这本身不会绕过行级安全策略,如果任何查询结果因为行级安全策略而被过滤掉记录时就是抛出一个错误,然后就可以找到错误原因并修复它。

在上面的例子中,策略表达式只考虑了要被访问或被更新行中的当前值。这是最简单并且表现最好的情况。如果可能,最好设计行级安全策略应用来以这种方式工作。 如果需要参考其他行或者其他表来做出策略的决定,可以在策略表达式中通过使用子-SELECTs或者包含SELECT的函数来实现。不过要注意这类访问可能会导致竞争条件,在不小心的情况下这可能会导致信息泄露。作为一个例子,考虑下面的表设计:
–定义权限组

jydb=> CREATE TABLE groups (group_id int PRIMARY KEY,group_name text NOT NULL);
CREATE TABLE
jydb=> INSERT INTO groups VALUES
jydb->   (1, 'low'),
jydb->   (2, 'medium'),
jydb->   (5, 'high');
INSERT 0 3
jydb=> GRANT ALL ON groups TO alice;
GRANT
jydb=> GRANT SELECT ON groups TO public;
GRANT
jydb=> select * from groups;
 group_id | group_name 
----------+------------
        1 | low
        2 | medium
        5 | high
(3 rows)

–定义用户的权限级别

jydb=# CREATE TABLE users (user_name text PRIMARY KEY,
jydb(#                     group_id int NOT NULL REFERENCES groups);
CREATE TABLE
jydb=# INSERT INTO users VALUES
jydb-#   ('alice', 5),
jydb-#   ('bob', 2),
jydb-#   ('mallory', 2);
INSERT 0 3
jydb=# GRANT ALL ON users TO alice;
GRANT
jydb=# GRANT SELECT ON users TO public;
GRANT

jydb=# CREATE ROLE mallory;
CREATE ROLE

jydb=# select * from users;
 user_name | group_id 
-----------+----------
 alice     |        5
 bob       |        2
 mallory   |        2
(3 rows)

–保存的信息的表将被保护

jydb=# CREATE TABLE information (info text,
jydb(#                           group_id int NOT NULL REFERENCES groups);
CREATE TABLE
jydb=# INSERT INTO information VALUES
jydb-#   ('barely secret', 1),
jydb-#   ('slightly secret', 2),
jydb-#   ('very secret', 5);
INSERT 0 3
jydb=# ALTER TABLE information ENABLE ROW LEVEL SECURITY;
ALTER TABLE

–对于用户的安全策略group_id大于等于行的group_id的,这行记录应该是可见的或可被更新的

jydb=# CREATE POLICY fp_s ON information FOR SELECT
jydb-#   USING (group_id < = (SELECT group_id FROM users WHERE user_name = current_user));
CREATE POLICY
jydb=# CREATE POLICY fp_u ON information FOR UPDATE
jydb-#   USING (group_id <= (SELECT group_id FROM users WHERE user_name = current_user));
CREATE POLICY

--我们只依赖于行级安全性来保护信息表

jydb=# GRANT ALL ON information TO public;
GRANT

现在假设alice希望更改information表中的”slightly secret”的信息,但是觉得用户mallory不应该看到该行中的新内容,因此她这样做:

jydb=# BEGIN;
BEGIN
jydb=# UPDATE users SET group_id = 1 WHERE user_name = 'mallory';
UPDATE 1
jydb=# UPDATE information SET info = 'secret from mallory' WHERE group_id = 2;
UPDATE 1
jydb=# COMMIT;
COMMIT

jydb=> select * from users;
 user_name | group_id 
-----------+----------
 alice     |        5
 bob       |        2
 mallory   |        1
(3 rows)

jydb=> select * from information;
        info         | group_id 
---------------------+----------
 barely secret       |        1
 very secret         |        5
 secret from mallory |        2
(3 rows)

–检查用户mallory是否可以查看information表中的group_id=2的记录

jydb=> set role mallory ;
SET
jydb=> SELECT * FROM information WHERE group_id = 2;
 info | group_id 
------+----------
(0 rows)


jydb=> SELECT * FROM information;
     info      | group_id 
---------------+----------
 barely secret |        1
(1 row)

可以看到现有用户mallory因为users表中的group_id被修改为1了,所以不能查看表information中的group_id为2的记录了。

这看起来是安全的,没有窗口可供用户mallory看到”secret from mallory”字符串。不过,这里有一种竞争条件。如果mallory正在并行地做:
SELECT * FROM information WHERE group_id = 2 FOR UPDATE;

并且她的事务处于READ COMMITTED模式,她就可能看到”secret from mallory”字符串。如果她的事务在alice做完之后就到达information表的行记录,这就会发生。它会阻塞等待alice的事务提交,然后拜FOR UPDATE子句所赐取得更新后的行内容。不过,对于来自users的隐式SELECT,它不会取得一个已更新的行, 因为子-SELECT没有FOR UPDATE,相反会使用查询开始时取得的快照读取users行。因此策略表达式会测试mallory的权限级别的旧值并且允许她看到被更新的行。

有多种方法能解决这个问题。一种简单的答案是在行安全性策略中的 子-SELECT里使用SELECT … FOR SHARE。 不过,这要求在被引用表(这里是users)上授予 UPDATE特权给受影响的用户,这可能不是我们想要的(但是另一条行安全性策略可能被应用来阻止它们实际使用这个特权,或者子-SELECT可能被嵌入到一个安全性定义者函数中)。 还有,在被引用的表上过多并发地使用行共享锁可能会导致性能问题, 特别是表更新比较频繁时。另一种解决方案(如果被引用表上的更新 不频繁就可行)是在更新被引用表时对它取一个排他锁,这样就没有 并发事务能够检查旧的行值了。或者我们可以在提交对被引用表的更新 之后、在做依赖于新安全性情况的更改之前等待所有并发事务结束。

oracle rac 单个实例不能生成awr报告的问题

同事对rac集群生成性能报告时发现rac集群有一个实例没有生成awr快照,另一个实例快照正常。下面是具体处理步骤。
1号实例没有生成awr快照

SQL> select SNAP_ID,END_INTERVAL_TIME,instance_number from dba_hist_snapshot where instance_number=1;

no rows selected

2号实快照正常

SQL> set long 200   
SQL> set linesize 200
SQL> select * from ( select SNAP_ID,END_INTERVAL_TIME,instance_number from dba_hist_snapshot where instance_number=2 order by SNAP_ID desc) where rownum < =10;

   SNAP_ID END_INTERVAL_TIME                                                           INSTANCE_NUMBER
---------- --------------------------------------------------------------------------- ---------------
     24405 17-AUG-19 07.00.47.595 PM                                                                 2
     24404 17-AUG-19 06.00.42.150 PM                                                                 2
     24403 17-AUG-19 05.00.37.041 PM                                                                 2
     24402 17-AUG-19 04.00.31.774 PM                                                                 2
     24401 17-AUG-19 03.00.26.414 PM                                                                 2
     24400 17-AUG-19 02.00.21.176 PM                                                                 2
     24399 17-AUG-19 01.00.16.316 PM                                                                 2
     24398 17-AUG-19 12.00.10.997 PM                                                                 2
     24397 17-AUG-19 11.00.05.446 AM                                                                 2
     24396 17-AUG-19 10.00.59.801 AM                                                                 2

10 rows selected.

mmon进程与awr快照相关,mmnl与ash相关,如是查看两个实例的mmon与mmnl进程
2号实例

[root@db2 ~]# ps -ef | grep mmon
root     128329 127956  0 18:11 pts/2    00:00:00 grep mmon
oracle   201527      1  0  2018 ?        17:17:11 ora_mmon_RLZY2
[root@db2 ~]# ps -ef | grep mmnl
root     131772 127956  0 18:17 pts/2    00:00:00 grep mmnl
oracle   201531      1  0  2018 ?        1-06:06:24 ora_mmnl_RLZY2

1号实例

[root@db1 ~]# ps -ef | grep mmon
root     239020 238963  0 18:52 pts/2    00:00:00 grep mmon
[root@db1 ~]# ps -ef | grep mmnl
root     239052 238963  0 18:52 pts/2    00:00:00 grep mmnl

可以看到1号实例没有mmon与mmnl进程了。

如是查看1号实例的mmon进程的跟踪文件

[root@db1 trace]# ls -lrt *mmon*.trc
-rw-r----- 1 oracle asmadmin 1351052 Jan 19  2018 RLZY1_mmon_20073.trc
-rw-r----- 1 oracle asmadmin  173031 Jan 22  2018 RLZY1_mmon_49119.trc
[root@db1 trace]# more RLZY1_mmon_49119.trc
Trace file /u01/app/oracle/diag/rdbms/rlzy/RLZY1/trace/RLZY1_mmon_49119.trc
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1
System name:    Linux
Node name:      db1
Release:        3.8.13-68.3.4.el6uek.x86_64
Version:        #2 SMP Tue Jul 14 15:03:36 PDT 2015
Machine:        x86_64
Instance name: RLZY1
Redo thread mounted by this instance: 1
Oracle process number: 36
Unix process pid: 49119, image: oracle@db1 (MMON)


*** 2018-01-19 13:55:20.030
*** SESSION ID:(1369.1) 2018-01-19 13:55:20.030
*** CLIENT ID:() 2018-01-19 13:55:20.030
*** SERVICE NAME:() 2018-01-19 13:55:20.030
*** MODULE NAME:() 2018-01-19 13:55:20.030
*** ACTION NAME:() 2018-01-19 13:55:20.030
 
minact-scn slave-status: grec-scn:0x0000.00000000 gmin-scn:0x0000.00000000 gcalc-scn:0x0000.00000000

*** 2018-01-19 14:00:20.643
minact-scn master-status: grec-scn:0x0e0e.55ad96ef gmin-scn:0x0e0e.55abf256 gcalc-scn:0x0e0e.55ac2a0a

..........
KEBM: MMON action policy violation. 'Block Cleanout Optim, Undo Segment Scan' viol=1; err=12751
minact-scn master-status: grec-scn:0x0e0e.5f0ebf8c gmin-scn:0x0e0e.5f0eac2e gcalc-scn:0x0e0e.5f0ead91
DDE rules only execution for: ORA 12751

*** 2018-01-22 07:06:04.060
----- START Event Driven Actions Dump ----
---- END Event Driven Actions Dump ----
----- START DDE Actions Dump -----
Executing SYNC actions
Executing ASYNC actions
----- START DDE Action: 'ORA_12751_DUMP' (Sync) -----
Runtime exceeded 300 seconds
Time limit violation detected at:
ksedsts()+465< -kspol_12751_dump()+145<-dbgdaExecuteAction()+1065<-dbgerRunAction()+109<-dbgerRunActions()+4134<-dbgexPhaseII()+1873<-dbgexProcessError()+2680<-dbgeExecuteForError()+88<-dbgePostErrorKGE()+2136<-dbkePostKGE_kgsf()+71<-kge
selv()+276<-ksesecl0()+162
<-ksucin()+147<-kcbzwb()+2727<-kcbgtcr()+31325<-ktucloUsMinScn()+539<-ktucloUsegScan()+992<-ksb_run_managed_action()+384<-ksbcti()+2490<-ksbabs()+1735<-kebm_mmon_main()+209<-ksbrdp()+1045<-opirip()+623<-opidrv()+603<-sou2o()+103<-opimai
_real()+250<-ssthrdmain()+265
<-main()+201<-__libc_start_main()+253Current Wait Stack:
 0: waiting for 'gc buffer busy acquire'
    file#=0x5, block#=0x278, class#=0x49
    wait_id=255378 seq_num=59358 snap_id=1
    wait times: snap=5 min 5 sec, exc=5 min 5 sec, total=5 min 5 sec
    wait times: max=infinite, heur=5 min 5 sec
    wait counts: calls=358 os=358
    in_wait=1 iflags=0x15a2
There is at least one session blocking this session.
  Dumping 1 direct blocker(s):
    inst: 1, sid: 990, ser: 1
  Dumping final blocker:
    inst: 1, sid: 990, ser: 1
Wait State:
  fixed_waits=0 flags=0x22 boundary=(nil)/-1
Session Wait History:
    elapsed time of 0.000061 sec since current wait
 0: waited for 'gc cr block 2-way'
    =0x5, =0x258, =0x47
    wait_id=255377 seq_num=59357 snap_id=1
    wait times: snap=0.000478 sec, exc=0.000478 sec, total=0.000478 sec
    wait times: max=infinite
    wait counts: calls=1 os=1
    occurred after 0.000122 sec of elapsed time
 1: waited for 'gc cr block 2-way'
    =0x5, =0x228, =0x45
    wait_id=255376 seq_num=59356 snap_id=1
    wait times: snap=0.000741 sec, exc=0.000741 sec, total=0.000741 sec
    wait times: max=infinite
    wait counts: calls=1 os=1
    occurred after 0.000120 sec of elapsed time
 2: waited for 'gc cr block 2-way'
    =0x5, =0x138, =0x43
    wait_id=255375 seq_num=59355 snap_id=1
    wait times: snap=0.000528 sec, exc=0.000528 sec, total=0.000528 sec
    wait times: max=infinite
    wait counts: calls=1 os=1
    occurred after 0.000111 sec of elapsed time
 3: waited for 'gc cr block 2-way'
    =0x5, =0xb8, =0x41
    wait_id=255374 seq_num=59354 snap_id=1
    wait times: snap=0.000583 sec, exc=0.000583 sec, total=0.000583 sec
    wait times: max=infinite
    wait counts: calls=1 os=1
    occurred after 0.000139 sec of elapsed time
 4: waited for 'gc cr block 2-way'
    =0x5, =0x110, =0x37
    wait_id=255373 seq_num=59353 snap_id=1
    wait times: snap=0.000541 sec, exc=0.000541 sec, total=0.000541 sec
    wait times: max=infinite
    wait counts: calls=1 os=1
    occurred after 0.000110 sec of elapsed time
 5: waited for 'gc cr block 2-way'
    =0x5, =0x100, =0x35
    wait_id=255372 seq_num=59352 snap_id=1
    wait times: snap=0.000629 sec, exc=0.000629 sec, total=0.000629 sec
    wait times: max=infinite
    wait counts: calls=1 os=1
    occurred after 0.000158 sec of elapsed time
 6: waited for 'gc cr block 2-way'
    =0x5, =0xf0, =0x33
    wait_id=255371 seq_num=59351 snap_id=1
    wait times: snap=0.000617 sec, exc=0.000617 sec, total=0.000617 sec
    wait times: max=infinite
    wait counts: calls=1 os=1
    occurred after 0.000128 sec of elapsed time
 7: waited for 'gc cr block 2-way'
    =0x5, =0xe0, =0x31
    wait_id=255370 seq_num=59350 snap_id=1
    wait times: snap=0.000561 sec, exc=0.000561 sec, total=0.000561 sec
    wait times: max=infinite
    wait counts: calls=1 os=1
    occurred after 0.000124 sec of elapsed time
 8: waited for 'gc cr block 2-way'
    =0x5, =0xd0, =0x2f
    wait_id=255369 seq_num=59349 snap_id=1
    wait times: snap=0.000565 sec, exc=0.000565 sec, total=0.000565 sec
    wait times: max=infinite
    wait counts: calls=1 os=1
    occurred after 0.000128 sec of elapsed time
 9: waited for 'gc cr block 2-way'
    =0x5, =0xc0, =0x2d
    wait_id=255368 seq_num=59348 snap_id=1
    wait times: snap=0.000555 sec, exc=0.000555 sec, total=0.000555 sec
    wait times: max=infinite
    wait counts: calls=1 os=1
    occurred after 0.000125 sec of elapsed time
Sampled Session History of session 1369 serial 1
---------------------------------------------------
The sampled session history is constructed by sampling
the target session every 1 second. The sampling process
captures at each sample if the session is in a non-idle wait,
an idle wait, or not in a wait. If the session is in a
non-idle wait then one interval is shown for all the samples
the session was in the same non-idle wait. If the
session is in an idle wait or not in a wait for
consecutive samples then one interval is shown for all
the consecutive samples. Though we display these consecutive
samples  in a single interval the session may NOT be continuously
idle or not in a wait (the sampling process does not know).
 
The history is displayed in reverse chronological order.
 
sample interval: 1 sec, max history 120 sec
---------------------------------------------------
  [121 samples,                                            07:04:03 - 07:06:03]
    waited for 'gc buffer busy acquire', seq_num: 59358
      p1: 'file#'=0x5
      p2: 'block#'=0x278
      p3: 'class#'=0x49
      time_waited: >= 120 sec (still in wait)
---------------------------------------------------
Sampled Session History Summary:
  longest_non_idle_wait: 'gc buffer busy acquire'
  [121 samples, 07:04:03 - 07:06:03]
      time_waited: >= 120 sec (still in wait)
---------------------------------------------------
----- END DDE Action: 'ORA_12751_DUMP' (SUCCESS, 1 csec) -----
----- END DDE Actions Dump (total 1 csec) -----
KEBM: MMON action policy violation. 'Block Cleanout Optim, Undo Segment Scan' viol=1; err=12751
minact-scn master-status: grec-scn:0x0e0e.5f0ec4ce gmin-scn:0x0e0e.5f0eac2e gcalc-scn:0x0e0e.5f0ead91

*** 2018-01-22 07:11:11.071
DDE rules only execution for: ORA 12751
----- START Event Driven Actions Dump ----
---- END Event Driven Actions Dump ----

ORA12751的错误原因是陈旧的SYS对象统计数据会导致生成次优执行计划,从而使AWR自动刷新从操作的语句运行更长时间和超时。

解决方法就是收集新的SYS对象统计信息,为优化器提供更好的统计信息,并生成更高效的执行计划

SQL> EXEC DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;

PL/SQL procedure successfully completed.

SQL> EXEC DBMS_STATS.GATHER_SCHEMA_STATS ('SYS');

PL/SQL procedure successfully completed.

下面就是重启mmon和mmnl进程

SQL> alter system enable restricted session;

System altered.

SQL> alter system disable restricted session;

System altered.

查看alert日志可以看到mmon和mmnl进程已经重启了

Sat Aug 17 19:18:22 2019
Starting background process MMON
Sat Aug 17 19:18:22 2019
Starting background process MMNL
MMON started with pid=399, OS id=10373 
Sat Aug 17 19:18:22 2019
MMNL started with pid=405, OS id=10375 
ALTER SYSTEM enable restricted session;
Sat Aug 17 19:18:25 2019
Some DDE async actions failed or were cancelled
Sat Aug 17 19:18:25 2019
Sweep [inc][48021]: completed
Sweep [inc][48011]: completed
Sweep [inc][48002]: completed
Sweep [inc][35010]: completed
Sweep [inc][34706]: completed
Sweep [inc][34242]: completed
Sweep [inc][33546]: completed
Sweep [inc][33394]: completed
Sweep [inc2][48021]: completed
Sweep [inc2][48011]: completed
Sweep [inc2][48002]: completed
Sweep [inc2][35010]: completed
Sweep [inc2][34706]: completed
Sweep [inc2][34242]: completed
Sweep [inc2][33546]: completed
Sweep [inc2][33394]: completed
minact-scn: Inst 1 is a slave inc#:30 mmon proc-id:10373 status:0x2
minact-scn status: grec-scn:0x0e0e.61cb2e9c gmin-scn:0x0e0e.5f0eac2e gcalc-scn:0x0e0e.5f0ead91
Sat Aug 17 19:18:29 2019
db_recovery_file_dest_size of 10240 MB is 20.87% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
Sat Aug 17 19:18:42 2019
ALTER SYSTEM disable restricted session;

再查看1号实例的mmon与mmnl进程状态

[root@db1 ~]# ps -ef | grep mmnl
oracle    10375      1  0 19:18 ?        00:00:00 ora_mmnl_RLZY1
root      10611 238963  0 19:18 pts/2    00:00:00 grep mmnl

[root@db1 ~]# ps -ef | grep mmon
oracle    10373      1  7 19:18 ?        00:00:02 ora_mmon_RLZY1
root      10630 238963  0 19:18 pts/2    00:00:00 grep mmon
过了两个小时去查看1号实例已经生成了两条快照信息
SQL> set long 200
SQL> set linesize 200
SQL> select * from ( select SNAP_ID,END_INTERVAL_TIME,instance_number from dba_hist_snapshot where instance_number=1 order by SNAP_ID desc) where rownum < =10;

   SNAP_ID END_INTERVAL_TIME                                                           INSTANCE_NUMBER
---------- --------------------------------------------------------------------------- ---------------
     24407 17-AUG-19 09.00.58.595 PM                                                                 1
     24406 17-AUG-19 08.00.40.244 PM                                                                 1

到此问题解决了。

Linux使用源码来安装MySQL 5.7

Linux使用源码安装MySQL
有两种方法来使用源码安装MySQL:
.使用一种标准的MySQL源码安装。标准的可用源码文件被压缩成tar文件,zip文件或RPM包。文件名的格式为mysql-version.tar.gz,mysql-version.zip或mysql-version.rpm。其中version是版本号比例如5.7.25。发布的源码文件名与预先编译好的二进制文件名是有区别的,源码文件名通常不包含平台名,而二进制文件名包含平台名,例如pc-linux-i686或winx64。

.使用MySQL开发树。如何构建开发树将在使用开发源码树来安装MySQL中进行介绍。

使用源码安装MySQL操作系统所要满足的条件
使用源码来安装MySQL需要几个开发工具。无论您使用的是标准的源代码分发版还是开发源代码树,都需要这些工具中的一部分。是否需要其它工具依赖于你的安装方法。

为了使用源码来安装MySQL,不管使用何种安装方法下面的要求必须要满足:
.CMake,用来在所有平台上构建框架,可以从http://www.cmake.org来下载CMake。

.一个好的make程序,虽然一些平台有它们自己的make实现,但强烈建议使用GNU make 3.75或更高版本。它可能已经存在于你的系统中了gmake。可以从http://www.gnu.org/software/make/下载GNU make。

.ANSI C++编译器。可以对force_unsupported_compiler的描述。

.为了构建MySQL需要Boost C++库(但不使用它)。Boost 1.59.0必须被安装。为了获得Boost与它的安装指令,可以访问https://www.boost.org/网址。在Boost安装后,当调用CMake时通过使用WITH_BOOST选项来告诉构建系统在哪里定位Boost文件。

shell>cmake . -DWITH_BOOST=/usr/local/boost_1_59_0

根据实际情况来调整路径。

.ncurses库 https://www.gnu.org/software/ncurses/ncurses.html

.足够的空闲内存。当编译很大的源文件时如果遇到了”internal compiler error”错误,那么可能是因为你没有足够的内存。如果在一个虚拟机上进行编译,尝试增加内存分配。

.如果你希望运行测试脚本那么就需要安装perl。大多数像Unix的系统已经包含了perl。在windows上可以使用ActiveState Perl。

为了使用标准的源码发布版本来安装MySQL,需要以下一种工具来解压发布的源码文件:
.对于一个.tar.gz的压缩tar文件,GNU gunzip可以用来解压tar用来unpack。如果你的tar程序支持z选项,它可以用来解压与 unpack文件。GNU tar众所周知是有效的。一些操作系统提供的标准tar不能对MySQL发布版本的长文件名进行unpack操作。你应该安装GUN tar或者可能的话,使用预安装版本的GNU tar。常用的有gnutar,gtar,tar或者自由软件目录,比如/usr/sfw/bin或/usr/local/bin。GNU tar可以从http://www.gnu.org/software/tar/进行下载。

.对于一个.zip归档文件,winzip或另外的工具可以读取.zip文件。

.对于一个.rpm的RPM包,rpmbuild程序用来对构建的发布版本进行unpack操作。

为了使用开发源码树来安装MySQL,需要安装以下额外的工具:
.需要Git版本控制系统来获得开发源代码。https://help.github.com/en提供了指令在不同平台上下载与安装Git。MySQL官方组织已经于2014年9月加入了GitHub。

.bison 2.1或更高版本,可以从http://www.gnu.org/software/bison/网址进行下载(1版本不再支持),尽可能的使用最新版本,如果你遇到了问题,那么升级到最新的版本,而不是回退到更早的版本。

bison可以从http://www.gnu.org/software/bison/网址进行下载,对于Windows平台可以从http://gnuwin32.sourceforge.net/packages/bison.htm网址进行下载。在Windows平台上,bison的缺省目录是C:\Program Files\GnuWin32目录。有一些工具可以在查找bison会失败,因为在目录名中存在空隔。同样,Visual Studio如果在路径中存在空隔可能会出现hang住。为了解决这种问题的出现,可以将bison安装到C:\GnuWin32目录。

.在Solaris平台上,除了bison之外m4必须被安装。m4可以从http://www.gnu.org/software/m4/网址下载。

注意在安装任何程序之后,需要修改你的PATH环境变量来包含定位程序的目录。

源码安装MySQL的布局
缺省情况下,当使用源码编译后安装MySQL,安装操作会将文件安装在/usr/local/mysql目录中。这与使用二进制文件安装的安装目录是一样的。

使用标准源码安装MySQL
1.安装所需要的工具包

[root@localhost ~]# yum -y install gcc* gcc-c++ ncurses* ncurses-devel* cmake* bison* libgcrypt* perl* make*
.......
已安装:
  gcc-gnat.x86_64 0:4.8.5-36.0.1.el7                         gcc-objc.x86_64 0:4.8.5-36.0.1.el7                        gcc-objc++.x86_64 0:4.8.5-36.0.1.el7                    libgcrypt-devel.x86_64 0:1.5.3-14.el7
  ncurses-devel.x86_64 0:5.9-14.20130511.el7_4               ncurses-term.noarch 0:5.9-14.20130511.el7_4               perl-Algorithm-Diff.noarch 0:1.1902-17.el7              perl-App-cpanminus.noarch 0:1.6922-2.el7
  perl-Archive-Extract.noarch 1:0.68-3.el7                   perl-Archive-Zip.noarch 0:1.30-11.el7                     perl-Authen-SASL.noarch 0:2.15-10.el7                   perl-B-Lint.noarch 0:1.17-3.el7
  perl-Bit-Vector.x86_64 0:7.3-3.el7                         perl-CGI.noarch 0:3.63-4.el7                              perl-CGI-Session.noarch 0:4.35-16.el7                   perl-CPAN.noarch 0:1.9800-293.el7
  perl-CPAN-Meta.noarch 0:2.120921-5.el7                     perl-CPAN-Meta-Requirements.noarch 0:2.122-7.el7          perl-CPAN-Meta-YAML.noarch 0:0.008-14.el7               perl-CPANPLUS.noarch 0:0.91.38-4.el7
  perl-CPANPLUS-Dist-Build.noarch 0:0.70-3.el7               perl-Carp-Clan.noarch 0:6.04-10.el7                       perl-Class-ISA.noarch 0:0.36-1010.el7                   perl-Class-Load.noarch 0:0.20-3.el7
  perl-Class-Singleton.noarch 0:1.4-14.el7                   perl-Convert-ASN1.noarch 0:0.26-4.el7                     perl-DBD-MySQL.x86_64 0:4.023-6.0.1.el7                 perl-DBD-Pg.x86_64 0:2.19.3-4.el7
  perl-DBIx-Simple.noarch 0:1.35-7.el7                       perl-Data-OptList.noarch 0:0.107-9.el7                    perl-Date-Calc.noarch 0:6.3-14.el7                      perl-Date-Manip.noarch 0:6.41-2.el7
  perl-DateTime.x86_64 2:1.04-6.el7                          perl-DateTime-Format-DateParse.noarch 0:0.05-5.el7        perl-DateTime-Locale.noarch 0:0.45-6.el7                perl-DateTime-TimeZone.noarch 0:1.70-1.el7
  perl-Devel-Symdump.noarch 1:2.10-2.el7                     perl-Digest-SHA1.x86_64 0:2.13-9.el7                      perl-Env.noarch 0:1.04-2.el7                            perl-ExtUtils-CBuilder.noarch 1:0.28.2.6-293.el7
  perl-ExtUtils-Embed.noarch 0:1.30-293.el7                  perl-FCGI.x86_64 1:0.74-8.el7                             perl-File-CheckTree.noarch 0:4.42-3.el7                 perl-File-Fetch.noarch 0:0.42-2.el7
  perl-Font-AFM.noarch 0:1.20-13.el7                         perl-FreezeThaw.noarch 0:0.5001-10.el7                    perl-GD.x86_64 0:2.49-3.el7                             perl-GSSAPI.x86_64 0:0.28-9.el7
  perl-HTML-Format.noarch 0:2.10-7.el7                       perl-HTML-Tree.noarch 1:5.03-2.el7                        perl-IO-stringy.noarch 0:2.110-22.el7                   perl-IPC-Cmd.noarch 1:0.80-4.el7
  perl-JSON.noarch 0:2.59-2.el7                              perl-JSON-PP.noarch 0:2.27202-2.el7                       perl-LDAP.noarch 1:0.56-6.el7                           perl-LWP-Protocol-https.noarch 0:6.04-4.el7
  perl-List-MoreUtils.x86_64 0:0.33-9.el7                    perl-Locale-Codes.noarch 0:3.26-2.el7                     perl-Locale-Maketext.noarch 0:1.23-3.el7                perl-Locale-Maketext-Simple.noarch 1:0.21-293.el7
  perl-Log-Message.noarch 1:0.08-3.el7                       perl-Log-Message-Simple.noarch 0:0.10-2.el7               perl-Module-Build.noarch 2:0.40.05-2.el7                perl-Module-CoreList.noarch 1:2.76.02-293.el7
  perl-Module-Implementation.noarch 0:0.06-6.el7             perl-Module-Load.noarch 1:0.24-3.el7                      perl-Module-Load-Conditional.noarch 0:0.54-3.el7        perl-Module-Loaded.noarch 1:0.08-293.el7
  perl-Module-Metadata.noarch 0:1.000018-2.el7               perl-Module-Pluggable.noarch 1:4.8-3.el7                  perl-Module-Runtime.noarch 0:0.013-4.el7                perl-Module-Signature.noarch 0:0.73-2.el7
  perl-Mozilla-CA.noarch 0:20130114-5.el7                    perl-Newt.x86_64 0:1.08-36.el7                            perl-Object-Accessor.noarch 1:0.42-293.el7              perl-PAR-Dist.noarch 0:0.49-2.el7
  perl-Package-DeprecationManager.noarch 0:0.13-7.el7        perl-Package-Stash.noarch 0:0.34-2.el7                    perl-Package-Stash-XS.x86_64 0:0.26-3.el7               perl-Params-Check.noarch 1:0.38-2.el7
  perl-Params-Util.x86_64 0:1.07-6.el7                       perl-Params-Validate.x86_64 0:1.08-4.el7                  perl-Parse-CPAN-Meta.noarch 1:1.4404-5.el7              perl-Perl-OSType.noarch 0:1.003-3.el7
  perl-Perl4-CoreLibs.noarch 0:0.003-7.el7                   perl-Pod-Checker.noarch 0:1.60-2.el7                      perl-Pod-Coverage.noarch 0:0.23-3.el7                   perl-Pod-LaTeX.noarch 0:0.61-2.el7
  perl-Pod-Parser.noarch 0:1.61-2.el7                        perl-Pod-Plainer.noarch 0:1.03-4.el7                      perl-SGMLSpm.noarch 0:1.03ii-31.el7                     perl-SNMP_Session.noarch 0:1.13-5.el7
  perl-String-ShellQuote.noarch 0:1.04-10.el7                perl-Sub-Install.noarch 0:0.926-6.el7                     perl-Sys-CPU.x86_64 0:0.54-4.el7                        perl-Sys-Guestfs.x86_64 1:1.38.2-12.0.1.el7
  perl-Sys-MemInfo.x86_64 0:0.91-7.el7                       perl-Sys-Virt.x86_64 0:4.5.0-2.el7                        perl-Term-UI.noarch 0:0.36-2.el7                        perl-Test-Pod.noarch 0:1.48-3.el7
  perl-Test-Pod-Coverage.noarch 0:1.08-21.el7                perl-Test-Simple.noarch 0:0.98-243.el7                    perl-Text-Diff.noarch 0:1.41-5.el7                      perl-Text-Soundex.x86_64 0:3.04-4.el7
  perl-Text-Unidecode.noarch 0:0.04-20.el7                   perl-Time-Piece.x86_64 0:1.20.1-293.el7                   perl-Try-Tiny.noarch 0:0.12-2.el7                       perl-Version-Requirements.noarch 0:0.101022-244.el7
  perl-XML-Dumper.noarch 0:0.81-17.el7                       perl-XML-Filter-BufferText.noarch 0:1.01-17.el7           perl-XML-Grove.noarch 0:0.46alpha-52.el7                perl-XML-SAX-Writer.noarch 0:0.53-4.el7
  perl-XML-Twig.noarch 0:3.44-2.el7                          perl-XML-Writer.noarch 0:0.623-3.el7                      perl-XML-XPath.noarch 0:1.13-22.el7                     perl-YAML.noarch 0:0.84-5.el7
  perl-YAML-Tiny.noarch 0:1.51-6.el7                         perl-autodie.noarch 0:2.16-2.el7                          perl-core.x86_64 0:5.16.3-293.el7                       perl-gettext.x86_64 0:1.05-28.el7
  perl-homedir.noarch 0:1.008010-4.el7                       perl-libintl.x86_64 0:1.20-12.el7                         perl-libxml-perl.noarch 0:0.08-19.el7                   perl-local-lib.noarch 0:1.008010-4.el7
  perltidy.noarch 0:20121207-3.el7

作为依赖被安装:
  glusterfs-cli.x86_64 0:3.12.2-18.el7                                           glusterfs-client-xlators.x86_64 0:3.12.2-18.el7                              libgnat.x86_64 0:4.8.5-36.0.1.el7
  libgnat-devel.x86_64 0:4.8.5-36.0.1.el7                                        libgpg-error-devel.x86_64 0:1.12-3.el7                                       libobjc.x86_64 0:4.8.5-36.0.1.el7
  libvirt-bash-completion.x86_64 0:4.5.0-10.el7                                  libvirt-daemon-driver-storage-core.x86_64 0:4.5.0-10.el7                     libvirt-daemon-driver-storage-disk.x86_64 0:4.5.0-10.el7
  libvirt-daemon-driver-storage-gluster.x86_64 0:4.5.0-10.el7                    libvirt-daemon-driver-storage-iscsi.x86_64 0:4.5.0-10.el7                    libvirt-daemon-driver-storage-logical.x86_64 0:4.5.0-10.el7
  libvirt-daemon-driver-storage-mpath.x86_64 0:4.5.0-10.el7                      libvirt-daemon-driver-storage-rbd.x86_64 0:4.5.0-10.el7                      libvirt-daemon-driver-storage-scsi.x86_64 0:4.5.0-10.el7
  libvirt-libs.x86_64 0:4.5.0-10.el7                                             openjade.x86_64 0:1.3.2-45.el7                                               opensp.x86_64 0:1.5.2-19.el7
  pcp-selinux.x86_64 0:4.1.0-4.el7                                               postgresql-libs.x86_64 0:9.2.24-1.el7_5                                      squashfs-tools.x86_64 0:4.3-0.21.gitaae0aff4.el7

更新完毕:
  bison.x86_64 0:3.0.4-2.el7                 gcc.x86_64 0:4.8.5-36.0.1.el7                    gcc-c++.x86_64 0:4.8.5-36.0.1.el7                 gcc-gfortran.x86_64 0:4.8.5-36.0.1.el7           libgcrypt.x86_64 0:1.5.3-14.el7
  make.x86_64 1:3.82-23.el7                  ncurses.x86_64 0:5.9-14.20130511.el7_4           ncurses-base.noarch 0:5.9-14.20130511.el7_4       ncurses-libs.x86_64 0:5.9-14.20130511.el7_4      perl.x86_64 4:5.16.3-293.el7
  perl-Digest-SHA.x86_64 1:5.85-4.el7        perl-ExtUtils-Install.noarch 0:1.58-293.el7      perl-ExtUtils-ParseXS.noarch 1:3.18-3.el7         perl-Getopt-Long.noarch 0:2.40-3.el7             perl-Git.noarch 0:1.8.3.1-19.el7
  perl-HTTP-Daemon.noarch 0:6.01-8.el7       perl-IO-Socket-IP.noarch 0:0.21-5.el7            perl-IO-Socket-SSL.noarch 0:1.94-7.el7            perl-IO-Zlib.noarch 1:1.10-293.el7               perl-Net-DNS.x86_64 0:0.72-6.el7
  perl-Net-SSLeay.x86_64 0:1.55-6.el7        perl-PCP-PMDA.x86_64 0:4.1.0-4.el7               perl-Package-Constants.noarch 1:0.02-293.el7      perl-Pod-Escapes.noarch 1:1.04-293.el7           perl-Socket.x86_64 0:2.010-4.el7
  perl-Test-Harness.noarch 0:3.28-3.el7      perl-devel.x86_64 4:5.16.3-293.el7               perl-hivex.x86_64 0:1.3.10-6.9.el7                perl-libs.x86_64 4:5.16.3-293.el7                perl-macros.x86_64 4:5.16.3-293.el7
  perl-version.x86_64 3:0.99.07-3.el7

作为依赖被升级:
  cpp.x86_64 0:4.8.5-36.0.1.el7                              git.x86_64 0:1.8.3.1-19.el7                                 glusterfs.x86_64 0:3.12.2-18.el7                       glusterfs-api.x86_64 0:3.12.2-18.el7
  glusterfs-fuse.x86_64 0:3.12.2-18.el7                      glusterfs-libs.x86_64 0:3.12.2-18.el7                       glusterfs-rdma.x86_64 0:3.12.2-18.el7                  hivex.x86_64 0:1.3.10-6.9.el7
  libgcc.x86_64 0:4.8.5-36.0.1.el7                           libgfortran.x86_64 0:4.8.5-36.0.1.el7                       libgomp.x86_64 0:4.8.5-36.0.1.el7                      libguestfs.x86_64 1:1.38.2-12.0.1.el7
  libquadmath.x86_64 0:4.8.5-36.0.1.el7                      libquadmath-devel.x86_64 0:4.8.5-36.0.1.el7                 libstdc++.x86_64 0:4.8.5-36.0.1.el7                    libstdc++-devel.x86_64 0:4.8.5-36.0.1.el7
  libvirt.x86_64 0:4.5.0-10.el7                              libvirt-client.x86_64 0:4.5.0-10.el7                        libvirt-daemon.x86_64 0:4.5.0-10.el7                   libvirt-daemon-config-network.x86_64 0:4.5.0-10.el7
  libvirt-daemon-config-nwfilter.x86_64 0:4.5.0-10.el7       libvirt-daemon-driver-interface.x86_64 0:4.5.0-10.el7       libvirt-daemon-driver-lxc.x86_64 0:4.5.0-10.el7        libvirt-daemon-driver-network.x86_64 0:4.5.0-10.el7
  libvirt-daemon-driver-nodedev.x86_64 0:4.5.0-10.el7        libvirt-daemon-driver-nwfilter.x86_64 0:4.5.0-10.el7        libvirt-daemon-driver-qemu.x86_64 0:4.5.0-10.el7       libvirt-daemon-driver-secret.x86_64 0:4.5.0-10.el7
  libvirt-daemon-driver-storage.x86_64 0:4.5.0-10.el7        libvirt-daemon-kvm.x86_64 0:4.5.0-10.el7                    openssl.x86_64 1:1.0.2k-16.0.1.el7                     openssl-libs.x86_64 1:1.0.2k-16.0.1.el7
  pcp.x86_64 0:4.1.0-4.el7                                   pcp-conf.x86_64 0:4.1.0-4.el7                               pcp-libs.x86_64 0:4.1.0-4.el7                          python-pcp.x86_64 0:4.1.0-4.el7
  supermin5.x86_64 0:5.1.19-1.el7

完毕!

2.使用命令检查是否安装有MySQL Server包

[root@localhost ~]# rpm -qa | grep mysql


[root@localhost ~]# rpm -aq | grep mysql
mysql-community-libs-5.6.23-3.el7.x86_64
qt-mysql-4.8.5-8.0.1.el7.x86_64
akonadi-mysql-1.9.2-4.0.1.el7.x86_64
mysql-community-common-5.6.23-3.el7.x86_64
mysql-community-server-5.6.23-3.el7.x86_64
mysql-community-client-5.6.23-3.el7.x86_64

删除操作有以下两种
rpm -e mysql-libs //普通删除模式
rpm -e –nodeps mysql-lib// 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除

[root@localhost ~]# rpm -e --nodeps mysql-community-libs
[root@localhost ~]# rpm -e --nodeps akonadi-mysql
[root@localhost ~]# rpm -e --nodeps mysql-community-common
[root@localhost ~]# rpm -e --nodeps mysql-community-server
[root@localhost ~]# rpm -e --nodeps mysql-community-client
[root@localhost ~]# rpm -e --nodeps qt-mysql
[root@localhost ~]# rpm -aq | grep mysql

3.下载源码文件mysql-5.7.26.tar.gz并上传到服务器的/soft目录中

[root@localhost soft]# ls -lrt
总用量 79960
-rw-r--r--. 1 root root 54056899 5月  30 16:36 mysql-5.7.26.tar.gz

4.下载boost包并上传到服务器的/soft目录中

5. 创建mysql用户与用户组

[root@localhost /]# groupadd mysql
[root@localhost /]# useradd -r -g mysql -s /bin/false mysql

因为用户只用于所有权目的,而不是登录目的,useradd命令使用-r与-s /bin/false选项来创建一个用户没有登录服务器主机的权限。

6.创建并修改/mysqlsoft/mysql与/mysqldata/mysql目录权限

[root@localhost /]# mkdir -p /mysqlsoft/mysql
[root@localhost /]# mkdir -p /mysqldata/mysql
[root@localhost /]# chown -R mysql:mysql /mysqlsoft
[root@localhost /]# chown -R mysql:mysql /mysqldata/mysql
[root@localhost /]# chmod -R 775 /mysqlsoft/mysql
[root@localhost /]# chmod -R 775 /mysqldata/mysql

7.解压boost软件包与MySQL源码包

[root@localhost soft]# unzip boost_1_59_0.zip
[root@localhost soft]# ls -lrt
总用量 201556
drwx------. 8 root root      4096 8月  12 2015 boost_1_59_0
-rw-r--r--. 1 root root  54056899 5月  30 16:36 mysql-5.7.26.tar.gz
-rw-r--r--. 1 root root 124506259 6月  13 21:07 boost_1_59_0.zip

将MySQL文件解压到/soft目录下

[root@localhost soft]# tar zxvf mysql-5.7.26.tar.gz
[root@localhost soft]# ls -lrt
总用量 201560
drwx------.  8 root root       4096 8月  12 2015 boost_1_59_0
drwxr-xr-x. 35 7161 31415      4096 4月  13 21:46 mysql-5.7.26
-rw-r--r--.  1 root root   54056899 5月  30 16:36 mysql-5.7.26.tar.gz
-rw-r--r--.  1 root root   27816900 6月  10 11:32 docker-17.03.0-ce.tgz
-rw-r--r--.  1 root root  124506259 6月  13 21:07 boost_1_59_0.zip
总用量 4


[root@localhost soft]# chown -R mysql:mysql mysql-5.7.26
[root@localhost soft]# chmod -R 775 mysql-5.7.26

8.预编译MySQL

[root@localhost soft]# su - mysql
上一次登录:一 6月 17 12:21:54 CST 2019pts/0 上
-bash-4.2$ cd /soft/mysql-5.7.26/

-bash-4.2$ cmake . -DCMAKE_INSTALL_PREFIX=/mysqlsoft/mysql \
> -DMYSQL_DATADIR=/mysqldata/mysql \
> -DMYSQL_UNIX_ADDR=/mysqlsoft/mysql/mysql.sock \
> -DWITH_BOOST=../boost_1_59_0 \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_PARTITION_STORAGE_ENGINE=1 \
> -DWITH_FEDERATED_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DENABLED_LOCAL_INFILE=1 \
> -DENABLE_DTRACE=0 \
> -DDEFAULT_CHARSET=utf8mb4 \
> -DDEFAULT_COLLATION=utf8mb4_general_ci \
> -DWITH_EMBEDDED_SERVER=1

....................
-- Found PkgConfig: /bin/pkg-config (found version "0.27.1")
-- checking for module 'libtirpc'
--   package 'libtirpc' not found
-- Performing Test HAVE_STRUCT_SOCKADDR_SA_LEN
-- Performing Test HAVE_STRUCT_SOCKADDR_SA_LEN - Failed
-- Performing Test HAVE_STRUCT_IFREQ_IFR_NAME
-- Performing Test HAVE_STRUCT_IFREQ_IFR_NAME - Success
-- Performing Test HAVE_XDR_OPS_X_PUTINT32
-- Performing Test HAVE_XDR_OPS_X_PUTINT32 - Success
-- Performing Test HAVE_XDR_OPS_X_GETINT32
-- Performing Test HAVE_XDR_OPS_X_GETINT32 - Success
-- Performing Test HAVE___CONST
-- Performing Test HAVE___CONST - Success
-- Performing Test HAVE_RPC_INLINE_T
-- Performing Test HAVE_RPC_INLINE_T - Failed
-- Performing Test OLD_XDR
-- Performing Test OLD_XDR - Failed
-- Performing Test X_GETPOSTN_NOT_USE_CONST
-- Performing Test X_GETPOSTN_NOT_USE_CONST - Success
-- Performing Test HAS_INCOMPATIBLE_POINTER_TYPES
-- Performing Test HAS_INCOMPATIBLE_POINTER_TYPES - Failed
-- Performing Test X_PUTLONG_NOT_USE_CONST
-- Performing Test X_PUTLONG_NOT_USE_CONST - Failed
-- checking for module 'libtirpc'
--   package 'libtirpc' not found
-- RPC_INCLUDE_DIRS /usr/include
-- Using Boost headers from /soft/boost_1_59_0
-- Performing Test CXX_HAVE_SIGN_COMPARE
-- Performing Test CXX_HAVE_SIGN_COMPARE - Success
-- Performing Test CXX_HAVE_UNUSED_VARIABLE
-- Performing Test CXX_HAVE_UNUSED_VARIABLE - Success
-- MYSQLX - Text log of protobuf messages enabled
-- Performing Test HAVE_UNUSED_PARAMETER
-- Performing Test HAVE_UNUSED_PARAMETER - Success
-- Googletest was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an https proxy: export https_proxy=http://example.com:80
-- Performing Test HAVE_MISLEADING_INDENTATION
-- Performing Test HAVE_MISLEADING_INDENTATION - Failed
-- executable target mysqld debug_target /soft/debug/sql/mysqld
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- MERGE_CONVENIENCE_LIBRARIES TARGET mysqlserver
-- MERGE_CONVENIENCE_LIBRARIES LIBS dbug;strings;regex;mysys;mysys_ssl;vio;zlib;yassl;taocrypt;crypt;dl;archive_embedded;blackhole_embedded;csv_embedded;federated_embedded;heap_embedded;innobase_embedded;lz4_lib;myisam_embedded;myisammrg_embedded;partition_embedded;ngram_parser_embedded;sql_embedded
-- MERGE_CONVENIENCE_LIBRARIES MYLIBS dbug;strings;regex;mysys;mysys_ssl;vio;zlib;yassl;taocrypt;archive_embedded;blackhole_embedded;csv_embedded;federated_embedded;heap_embedded;innobase_embedded;lz4_lib;myisam_embedded;myisammrg_embedded;partition_embedded;ngram_parser_embedded;sql_embedded
-- library target mysqlserver debug_target /soft/debug/archive_output_directory/libmysqld.a
-- INSTALL mysqlclient.pc lib/pkgconfig
-- Skipping deb packaging on unsupported platform .
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H;HAVE_LIBEVENT2
-- CMAKE_C_FLAGS:  -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS:  -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_C_LINK_FLAGS:
-- CMAKE_CXX_LINK_FLAGS:
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /soft/mysql-5.7.26

9.编译源码,这时使用-j 6选项来使用6个进程同时进行编译

-bash-4.2$ make -j 6
.........
Building CXX object sql/CMakeFiles/sql.dir/event_data_objects.cc.o
Building CXX object sql/CMakeFiles/sql.dir/des_key_file.cc.o
Building CXX object sql/CMakeFiles/sql.dir/event_db_repository.cc.o
[ 97%] Building CXX object sql/CMakeFiles/sql.dir/event_parse_data.cc.o
[ 97%] Building CXX object sql/CMakeFiles/sql.dir/event_queue.cc.o
[ 97%] Building CXX object sql/CMakeFiles/sql.dir/event_scheduler.cc.o
[ 97%] Building CXX object sql/CMakeFiles/sql.dir/events.cc.o
[ 97%] Building CXX object sql/CMakeFiles/sql.dir/mf_iocache.cc.o
[ 97%] Building CXX object sql/CMakeFiles/sql.dir/mysqld.cc.o
[ 97%] Building CXX object sql/CMakeFiles/sql.dir/mysqld_thd_manager.cc.o
[ 97%] Building CXX object sql/CMakeFiles/sql.dir/protocol_callback.cc.o
[ 97%] Building CXX object sql/CMakeFiles/sql.dir/signal_handler.cc.o
[ 98%] Building CXX object sql/CMakeFiles/sql.dir/sql_audit.cc.o
[ 98%] Building CXX object sql/CMakeFiles/sql.dir/sql_client.cc.o
[ 98%] Building CXX object sql/CMakeFiles/sql.dir/srv_session.cc.o
[ 98%] Building CXX object sql/CMakeFiles/sql.dir/srv_session_info_service.cc.o
[ 98%] Building CXX object sql/CMakeFiles/sql.dir/srv_session_service.cc.o
[ 98%] Building CXX object sql/CMakeFiles/sql.dir/auth/sha2_password_common.cc.o
[ 98%] Building CXX object sql/CMakeFiles/sql.dir/mysqld_daemon.cc.o
Linking CXX static library ../archive_output_directory/libsql.a
[ 98%] Built target sql
Scanning dependencies of target mysqld
Scanning dependencies of target pfs_connect_attr-t
[ 99%] Building CXX object sql/CMakeFiles/mysqld.dir/main.cc.o
Linking CXX executable mysqld
[100%] [100%] [100%] Building CXX object storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/__/__/__/sql/sql_builtin.cc.o
Building CXX object storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/pfs_connect_attr-t.cc.o
Building C object storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/__/__/__/mysys/string.c.o
Linking CXX executable pfs_connect_attr-t
[100%] Built target mysqld
[100%] Built target pfs_connect_attr-t

10.安装

-bash-4.2$ make install
.................
-- Installing: /mysqlsoft/mysql/mysql-test/./t/wl6661.test
-- Installing: /mysqlsoft/mysql/mysql-test/./t/wl6711_heap_to_disk.test
-- Installing: /mysqlsoft/mysql/mysql-test/./t/wl6978.test
-- Installing: /mysqlsoft/mysql/mysql-test/./t/xa.test
-- Installing: /mysqlsoft/mysql/mysql-test/./t/xa_debug.test
-- Installing: /mysqlsoft/mysql/mysql-test/./t/xa_gtid-master.opt
-- Installing: /mysqlsoft/mysql/mysql-test/./t/xa_gtid.test
-- Installing: /mysqlsoft/mysql/mysql-test/./t/xa_prepared_binlog_off-master.opt
-- Installing: /mysqlsoft/mysql/mysql-test/./t/xa_prepared_binlog_off.test
-- Installing: /mysqlsoft/mysql/mysql-test/./t/xml.test
-- Installing: /mysqlsoft/mysql/mysql-test/./valgrind.supp
-- Installing: /mysqlsoft/mysql/mysql-test/./mtr
-- Installing: /mysqlsoft/mysql/mysql-test/./mysql-test-run
-- Installing: /mysqlsoft/mysql/mysql-test/./Makefile
-- Installing: /mysqlsoft/mysql/mysql-test/./cmake_install.cmake
-- Installing: /mysqlsoft/mysql/mysql-test/./CTestTestfile.cmake
-- Installing: /mysqlsoft/mysql/./COPYING-test
-- Installing: /mysqlsoft/mysql/./README-test
-- Up-to-date: /mysqlsoft/mysql/mysql-test/mtr
-- Up-to-date: /mysqlsoft/mysql/mysql-test/mysql-test-run
-- Installing: /mysqlsoft/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Up-to-date: /mysqlsoft/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Installing: /mysqlsoft/mysql/mysql-test/lib/My/SafeProcess/Base.pm
-- Installing: /mysqlsoft/mysql/support-files/mysqld_multi.server
-- Installing: /mysqlsoft/mysql/support-files/mysql-log-rotate
-- Installing: /mysqlsoft/mysql/support-files/magic
-- Installing: /mysqlsoft/mysql/share/aclocal/mysql.m4
-- Installing: /mysqlsoft/mysql/support-files/mysql.server

[root@localhost mysqlsoft]# chmod -R 775 mysql

11.配置mysql参数,只是设置几个简单的mysql运行参数

[root@localhost mysql]#  vi /mysqlsoft/mysql/my.cnf
[mysqld]
basedir=/mysqlsoft/mysql
datadir=/mysqldata/mysql
bind-address=0.0.0.0
user=mysql
port=3306
log-error=/mysqldata/mysql/mysql.err
pid-file=/mysqldata/mysql/mysqld.pid
socket = /mysqlsoft/mysql/mysql.sock
character-set-server=utf8mb4
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true

[root@localhost mysql]# cd bin
[root@localhost bin]# ./mysqld  --defaults-file=/mysqlsoft/mysql/my.cnf --initialize --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql --user=mysql

查看日志信息

[root@localhost mysql]# tail -f mysql.err
2019-06-17T06:28:34.137849Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-06-17T06:28:35.342112Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-06-17T06:28:35.465187Z 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: 2296e390-90c9-11e9-9a9f-005056a390e6.
2019-06-17T06:28:35.471829Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-06-17T06:28:35.474533Z 1 [Note] A temporary password is generated for root@localhost: Ldp#HUPR(7hH

其中[Note] A temporary password is generated for root@localhost:后面跟的是mysql数据库登录的临时密码,各人安装生成的临时密码不一样。可以看到到日志文件没有报错,而且有了临时密码,表示初始化成功。

12.如果想服务能够部署自动支持安全连接,使用mysql_ssl_rsa_setup工具来创建缺省SSL与RSA文件

[root@localhost bin]# ./mysql_ssl_rsa_setup --datadir=/mysqldata/mysql
Generating a 2048 bit RSA private key
...........................+++
.......+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
.......................................................................................................+++
...................................................................................................................................................+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
.....................................+++
...........+++
writing new private key to 'client-key.pem'
-----

13.启动MySQL

[root@localhost bin]# ./mysqld_safe --user=mysql &
[1] 19442
[root@localhost bin]# 2019-06-17T06:34:01.654203Z mysqld_safe Logging to '/mysqldata/mysql/mysql.err'.
2019-06-17T06:34:01.750954Z mysqld_safe Starting mysqld daemon with databases from /mysqldata/mysql

14.配置自动启动MySQL

[root@localhost ~]# cp /mysqlsoft/mysql/support-files/mysql.server  /etc/init.d/mysqld
[root@localhost ~]# chmod 755 /etc/init.d/mysqld
[root@localhost ~]# systemctl enable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld on

14.配置环境变量

[root@localhost ~]# vi /etc/profile
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

export MYSQL_HOME=/mysqlsoft/mysql/
export PATH=$PATH:$MYSQL_HOME/bin

15.登录MySQL并修改root用户密码

-bash-4.2$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)

到此使用源码来安装MySQL就完成了。

Install MySQL 5.7 in the Docker

Install Docker on Oracle Linux 7
在Oracle Linux 7.1上安装Docker
1.首先使用正确的yum设置来升级Oracle Linux 7.1实例。为了安装最新的Docker版本(18.9.1.ce),需要ol7_latest,ol7_uekr4与ol7_addons启用

[root@localhost /]# cd /etc/yum.repos.d/
[root@localhost /]#wget http://yum.oracle.com/public-yum-ol7.repo
[root@localhost yum.repos.d]# vi public-yum-ol7.repo
[ol7_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/latest/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

[ol7_UEKR4]
name=Latest Unbreakable Enterprise Kernel Release 4 for Oracle Linux $releasever ($basearch)
baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/UEKR4/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

[ol7_addons]
name=Oracle Linux $releasever Add ons ($basearch)
baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/addons/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

2.开始安装docker

[root@localhost yum.repos.d]# yum install docker-engine
Loaded plugins: langpacks
ol7_UEKR4                                                                                                                                                                                                            | 2.5 kB  00:00:00
ol7_addons                                                                                                                                                                                                           | 1.2 kB  00:00:00
ol7_latest                                                                                                                                                                                                           | 2.7 kB  00:00:00
(1/4): ol7_addons/x86_64/updateinfo                                                                                                                                                                                  |  60 kB  00:00:00
(2/4): ol7_UEKR4/x86_64/updateinfo                                                                                                                                                                                   |  82 kB  00:00:01
(3/4): ol7_addons/x86_64/primary                                                                                                                                                                                     |  82 kB  00:00:02
(4/4): ol7_UEKR4/x86_64/primary_db                                                                                                                                                                                   | 4.0 MB  00:03:38
ol7_addons                                                                                                                                                                                                                          328/328
Resolving Dependencies
--> Running transaction check
---> Package docker-engine.x86_64 0:18.09.1.ol-1.0.5.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.77 for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Processing Dependency: libseccomp >= 2.3 for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Processing Dependency: containerd for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Processing Dependency: docker-cli for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Processing Dependency: runc for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_97)(64bit) for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Processing Dependency: libsystemd.so.0(LIBSYSTEMD_209)(64bit) for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Processing Dependency: libsystemd.so.0()(64bit) for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.77-5.el7 will be installed
--> Processing Dependency: selinux-policy-base >= 3.13.1-216.el7 for package: 2:container-selinux-2.77-5.el7.noarch
--> Processing Dependency: selinux-policy >= 3.13.1-216.el7 for package: 2:container-selinux-2.77-5.el7.noarch
--> Processing Dependency: policycoreutils >= 2.5-11 for package: 2:container-selinux-2.77-5.el7.noarch
--> Processing Dependency: selinux-policy-targeted >= 3.13.1-216.el7 for package: 2:container-selinux-2.77-5.el7.noarch
---> Package containerd.x86_64 0:1.2.0-1.0.5.el7 will be installed
---> Package device-mapper-libs.x86_64 7:1.02.93-3.el7 will be updated
--> Processing Dependency: device-mapper-libs = 7:1.02.93-3.el7 for package: 7:device-mapper-1.02.93-3.el7.x86_64
---> Package device-mapper-libs.x86_64 7:1.02.149-10.0.3.el7_6.8 will be an update
---> Package docker-cli.x86_64 0:18.09.1.ol-1.0.5.el7 will be installed
---> Package libseccomp.x86_64 0:2.1.1-2.el7 will be updated
---> Package libseccomp.x86_64 0:2.3.1-3.el7 will be an update
---> Package runc.x86_64 0:1.0.0-19.rc5.git4bb1fe4.0.3.el7 will be installed
--> Processing Dependency: criu for package: runc-1.0.0-19.rc5.git4bb1fe4.0.3.el7.x86_64
---> Package systemd-libs.x86_64 0:208-20.0.1.el7 will be updated
--> Processing Dependency: systemd-libs = 208-20.0.1.el7 for package: systemd-208-20.0.1.el7.x86_64
---> Package systemd-libs.x86_64 0:219-62.0.4.el7_6.7 will be an update
--> Processing Dependency: liblz4.so.1()(64bit) for package: systemd-libs-219-62.0.4.el7_6.7.x86_64
--> Running transaction check
---> Package criu.x86_64 0:3.9-5.el7 will be installed
--> Processing Dependency: libprotobuf-c.so.1(LIBPROTOBUF_C_1.0.0)(64bit) for package: criu-3.9-5.el7.x86_64
--> Processing Dependency: libnl-3.so.200(libnl_3)(64bit) for package: criu-3.9-5.el7.x86_64
--> Processing Dependency: libprotobuf-c.so.1()(64bit) for package: criu-3.9-5.el7.x86_64
--> Processing Dependency: libnet.so.1()(64bit) for package: criu-3.9-5.el7.x86_64
---> Package device-mapper.x86_64 7:1.02.93-3.el7 will be updated
--> Processing Dependency: device-mapper = 7:1.02.93-3.el7 for package: 7:device-mapper-event-1.02.93-3.el7.x86_64
---> Package device-mapper.x86_64 7:1.02.149-10.0.3.el7_6.8 will be an update
---> Package lz4.x86_64 0:1.7.5-2.0.1.el7 will be installed
---> Package policycoreutils.x86_64 0:2.2.5-15.0.1.el7 will be updated
--> Processing Dependency: policycoreutils = 2.2.5-15.0.1.el7 for package: policycoreutils-python-2.2.5-15.0.1.el7.x86_64
---> Package policycoreutils.x86_64 0:2.5-29.0.1.el7_6.1 will be an update
--> Processing Dependency: libsemanage >= 2.5-14 for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64
--> Processing Dependency: libsepol >= 2.5-10 for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64
--> Processing Dependency: libselinux-utils >= 2.5-14 for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64
--> Processing Dependency: libsepol.so.1(LIBSEPOL_1.1)(64bit) for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64
--> Processing Dependency: libsemanage.so.1(LIBSEMANAGE_1.1)(64bit) for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64
--> Processing Dependency: libsepol.so.1(LIBSEPOL_1.0)(64bit) for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64
---> Package selinux-policy.noarch 0:3.13.1-23.0.1.el7 will be updated
---> Package selinux-policy.noarch 0:3.13.1-229.0.3.el7_6.12 will be an update
---> Package selinux-policy-targeted.noarch 0:3.13.1-23.0.1.el7 will be updated
---> Package selinux-policy-targeted.noarch 0:3.13.1-229.0.3.el7_6.12 will be an update
---> Package systemd.x86_64 0:208-20.0.1.el7 will be updated
--> Processing Dependency: systemd = 208-20.0.1.el7 for package: libgudev1-208-20.0.1.el7.x86_64
--> Processing Dependency: systemd = 208-20.0.1.el7 for package: systemd-sysv-208-20.0.1.el7.x86_64
--> Processing Dependency: systemd = 208-20.0.1.el7 for package: systemd-python-208-20.0.1.el7.x86_64
---> Package systemd.x86_64 0:219-62.0.4.el7_6.7 will be an update
--> Processing Dependency: kmod >= 18-4 for package: systemd-219-62.0.4.el7_6.7.x86_64
--> Processing Dependency: libcryptsetup.so.12(CRYPTSETUP_2.0)(64bit) for package: systemd-219-62.0.4.el7_6.7.x86_64
--> Processing Dependency: libcryptsetup.so.12()(64bit) for package: systemd-219-62.0.4.el7_6.7.x86_64
--> Running transaction check
---> Package cryptsetup-libs.x86_64 0:1.6.6-3.el7 will be updated
--> Processing Dependency: cryptsetup-libs = 1.6.6-3.el7 for package: cryptsetup-python-1.6.6-3.el7.x86_64
--> Processing Dependency: cryptsetup-libs(x86-64) = 1.6.6-3.el7 for package: cryptsetup-1.6.6-3.el7.x86_64
---> Package cryptsetup-libs.x86_64 0:2.0.3-3.el7 will be an update
---> Package device-mapper-event.x86_64 7:1.02.93-3.el7 will be updated
--> Processing Dependency: device-mapper-event = 7:1.02.93-3.el7 for package: 7:lvm2-libs-2.02.115-3.el7.x86_64
---> Package device-mapper-event.x86_64 7:1.02.149-10.0.3.el7_6.8 will be an update
--> Processing Dependency: device-mapper-event-libs = 7:1.02.149-10.0.3.el7_6.8 for package: 7:device-mapper-event-1.02.149-10.0.3.el7_6.8.x86_64
---> Package kmod.x86_64 0:14-10.el7 will be updated
---> Package kmod.x86_64 0:20-23.0.1.el7 will be an update
---> Package libgudev1.x86_64 0:208-20.0.1.el7 will be updated
---> Package libgudev1.x86_64 0:219-62.0.4.el7_6.7 will be an update
--> Processing Dependency: glib2 >= 2.42 for package: libgudev1-219-62.0.4.el7_6.7.x86_64
---> Package libnet.x86_64 0:1.1.6-7.el7 will be installed
---> Package libnl3.x86_64 0:3.2.21-8.0.1.el7 will be updated
--> Processing Dependency: libnl3 = 3.2.21-8.0.1.el7 for package: libnl3-cli-3.2.21-8.0.1.el7.x86_64
---> Package libnl3.x86_64 0:3.2.28-4.el7 will be an update
---> Package libselinux-utils.x86_64 0:2.2.2-6.el7 will be updated
---> Package libselinux-utils.x86_64 0:2.5-14.1.el7 will be an update
--> Processing Dependency: libselinux(x86-64) = 2.5-14.1.el7 for package: libselinux-utils-2.5-14.1.el7.x86_64
---> Package libsemanage.x86_64 0:2.1.10-16.el7 will be updated
--> Processing Dependency: libsemanage = 2.1.10-16.el7 for package: libsemanage-python-2.1.10-16.el7.x86_64
---> Package libsemanage.x86_64 0:2.5-14.el7 will be an update
---> Package libsepol.x86_64 0:2.1.9-3.el7 will be updated
---> Package libsepol.x86_64 0:2.5-10.el7 will be an update
---> Package policycoreutils-python.x86_64 0:2.2.5-15.0.1.el7 will be updated
---> Package policycoreutils-python.x86_64 0:2.5-29.0.1.el7_6.1 will be an update
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-29.0.1.el7_6.1.x86_64
---> Package protobuf-c.x86_64 0:1.0.2-3.el7 will be installed
---> Package systemd-python.x86_64 0:208-20.0.1.el7 will be updated
---> Package systemd-python.x86_64 0:219-62.0.4.el7_6.7 will be an update
---> Package systemd-sysv.x86_64 0:208-20.0.1.el7 will be updated
---> Package systemd-sysv.x86_64 0:219-62.0.4.el7_6.7 will be an update
--> Running transaction check
---> Package cryptsetup.x86_64 0:1.6.6-3.el7 will be updated
---> Package cryptsetup.x86_64 0:2.0.3-3.el7 will be an update
---> Package cryptsetup-python.x86_64 0:1.6.6-3.el7 will be updated
---> Package cryptsetup-python.x86_64 0:2.0.3-3.el7 will be an update
---> Package device-mapper-event-libs.x86_64 7:1.02.93-3.el7 will be updated
---> Package device-mapper-event-libs.x86_64 7:1.02.149-10.0.3.el7_6.8 will be an update
---> Package glib2.x86_64 0:2.40.0-4.el7 will be updated
---> Package glib2.x86_64 0:2.56.1-4.el7_6 will be an update
---> Package libnl3-cli.x86_64 0:3.2.21-8.0.1.el7 will be updated
---> Package libnl3-cli.x86_64 0:3.2.28-4.el7 will be an update
---> Package libselinux.x86_64 0:2.2.2-6.el7 will be updated
--> Processing Dependency: libselinux = 2.2.2-6.el7 for package: libselinux-python-2.2.2-6.el7.x86_64
---> Package libselinux.x86_64 0:2.5-14.1.el7 will be an update
---> Package libsemanage-python.x86_64 0:2.1.10-16.el7 will be updated
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be an update
---> Package lvm2-libs.x86_64 7:2.02.115-3.el7 will be updated
--> Processing Dependency: lvm2-libs = 7:2.02.115-3.el7 for package: 7:lvm2-2.02.115-3.el7.x86_64
--> Processing Dependency: lvm2-libs = 7:2.02.115-3.el7 for package: 7:lvm2-python-libs-2.02.115-3.el7.x86_64
---> Package lvm2-libs.x86_64 7:2.02.180-10.0.3.el7_6.8 will be an update
---> Package setools-libs.x86_64 0:3.3.7-46.el7 will be updated
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be an update
--> Running transaction check
---> Package libselinux-python.x86_64 0:2.2.2-6.el7 will be updated
---> Package libselinux-python.x86_64 0:2.5-14.1.el7 will be an update
---> Package lvm2.x86_64 7:2.02.115-3.el7 will be updated
---> Package lvm2.x86_64 7:2.02.180-10.0.3.el7_6.8 will be an update
--> Processing Dependency: device-mapper-persistent-data >= 0.7.0-0.1.rc6 for package: 7:lvm2-2.02.180-10.0.3.el7_6.8.x86_64
---> Package lvm2-python-libs.x86_64 7:2.02.115-3.el7 will be updated
---> Package lvm2-python-libs.x86_64 7:2.02.180-10.0.3.el7_6.8 will be an update
--> Running transaction check
---> Package device-mapper-persistent-data.x86_64 0:0.4.1-2.el7 will be updated
---> Package device-mapper-persistent-data.x86_64 0:0.7.3-3.el7 will be an update
--> Processing Conflict: systemd-219-62.0.4.el7_6.7.x86_64 conflicts initscripts < 9.49.28-1
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package initscripts.x86_64 0:9.49.24-1.0.1.el7 will be updated
---> Package initscripts.x86_64 0:9.49.46-1.0.1.el7 will be an update
--> Processing Conflict: initscripts-9.49.46-1.0.1.el7.x86_64 conflicts redhat-release < 7.5-0.11
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package redhat-release-server.x86_64 1:7.1-1.0.2.el7 will be updated
---> Package redhat-release-server.x86_64 1:7.6-4.0.1.el7 will be an update
--> Processing Conflict: initscripts-9.49.46-1.0.1.el7.x86_64 conflicts oraclelinux-release < 7:7.5-1.0.3
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package oraclelinux-release.x86_64 7:7.1-1.0.5.el7 will be updated
---> Package oraclelinux-release.x86_64 7:7.6-1.0.15.el7 will be an update
--> Processing Conflict: systemd-219-62.0.4.el7_6.7.x86_64 conflicts dracut < 033-243
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package dracut.x86_64 0:033-240.0.1.el7 will be updated
--> Processing Dependency: dracut = 033-240.0.1.el7 for package: dracut-config-rescue-033-240.0.1.el7.x86_64
--> Processing Dependency: dracut = 033-240.0.1.el7 for package: dracut-network-033-240.0.1.el7.x86_64
---> Package dracut.x86_64 0:033-554.0.3.el7 will be an update
--> Running transaction check
---> Package dracut-config-rescue.x86_64 0:033-240.0.1.el7 will be updated
---> Package dracut-config-rescue.x86_64 0:033-554.0.3.el7 will be an update
---> Package dracut-network.x86_64 0:033-240.0.1.el7 will be updated
---> Package dracut-network.x86_64 0:033-554.0.3.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================================================
 Package                                                            Arch                                        Version                                                               Repository                                       Size
============================================================================================================================================================================================================================================
Installing:
 docker-engine                                                      x86_64                                      18.09.1.ol-1.0.5.el7                                                  ol7_addons                                       19 M
Updating:
 dracut                                                             x86_64                                      033-554.0.3.el7                                                       ol7_latest                                      328 k
 initscripts                                                        x86_64                                      9.49.46-1.0.1.el7                                                     ol7_latest                                      439 k
 oraclelinux-release                                                x86_64                                      7:7.6-1.0.15.el7                                                      ol7_latest                                       54 k
 redhat-release-server                                              x86_64                                      1:7.6-4.0.1.el7                                                       ol7_latest                                      9.8 k
Installing for dependencies:
 container-selinux                                                  noarch                                      2:2.77-5.el7                                                          ol7_addons                                       37 k
 containerd                                                         x86_64                                      1.2.0-1.0.5.el7                                                       ol7_addons                                       21 M
 criu                                                               x86_64                                      3.9-5.el7                                                             ol7_latest                                      432 k
 docker-cli                                                         x86_64                                      18.09.1.ol-1.0.5.el7                                                  ol7_addons                                       14 M
 libnet                                                             x86_64                                      1.1.6-7.el7                                                           ol7_latest                                       57 k
 lz4                                                                x86_64                                      1.7.5-2.0.1.el7                                                       ol7_latest                                       98 k
 protobuf-c                                                         x86_64                                      1.0.2-3.el7                                                           ol7_latest                                       27 k
 runc                                                               x86_64                                      1.0.0-19.rc5.git4bb1fe4.0.3.el7                                       ol7_addons                                      1.9 M
Updating for dependencies:
 cryptsetup                                                         x86_64                                      2.0.3-3.el7                                                           ol7_latest                                      153 k
 cryptsetup-libs                                                    x86_64                                      2.0.3-3.el7                                                           ol7_latest                                      337 k
 cryptsetup-python                                                  x86_64                                      2.0.3-3.el7                                                           ol7_latest                                       35 k
 device-mapper                                                      x86_64                                      7:1.02.149-10.0.3.el7_6.8                                             ol7_latest                                      293 k
 device-mapper-event                                                x86_64                                      7:1.02.149-10.0.3.el7_6.8                                             ol7_latest                                      188 k
 device-mapper-event-libs                                           x86_64                                      7:1.02.149-10.0.3.el7_6.8                                             ol7_latest                                      188 k
 device-mapper-libs                                                 x86_64                                      7:1.02.149-10.0.3.el7_6.8                                             ol7_latest                                      320 k
 device-mapper-persistent-data                                      x86_64                                      0.7.3-3.el7                                                           ol7_latest                                      404 k
 dracut-config-rescue                                               x86_64                                      033-554.0.3.el7                                                       ol7_latest                                       60 k
 dracut-network                                                     x86_64                                      033-554.0.3.el7                                                       ol7_latest                                      102 k
 glib2                                                              x86_64                                      2.56.1-4.el7_6                                                        ol7_latest                                      2.5 M
 kmod                                                               x86_64                                      20-23.0.1.el7                                                         ol7_latest                                      121 k
 libgudev1                                                          x86_64                                      219-62.0.4.el7_6.7                                                    ol7_latest                                       96 k
 libnl3                                                             x86_64                                      3.2.28-4.el7                                                          ol7_latest                                      277 k
 libnl3-cli                                                         x86_64                                      3.2.28-4.el7                                                          ol7_latest                                      159 k
 libseccomp                                                         x86_64                                      2.3.1-3.el7                                                           ol7_latest                                       55 k
 libselinux                                                         x86_64                                      2.5-14.1.el7                                                          ol7_latest                                      162 k
 libselinux-python                                                  x86_64                                      2.5-14.1.el7                                                          ol7_latest                                      235 k
 libselinux-utils                                                   x86_64                                      2.5-14.1.el7                                                          ol7_latest                                      151 k
 libsemanage                                                        x86_64                                      2.5-14.el7                                                            ol7_latest                                      150 k
 libsemanage-python                                                 x86_64                                      2.5-14.el7                                                            ol7_latest                                      112 k
 libsepol                                                           x86_64                                      2.5-10.el7                                                            ol7_latest                                      297 k
 lvm2                                                               x86_64                                      7:2.02.180-10.0.3.el7_6.8                                             ol7_latest                                      1.3 M
 lvm2-libs                                                          x86_64                                      7:2.02.180-10.0.3.el7_6.8                                             ol7_latest                                      1.1 M
 lvm2-python-libs                                                   x86_64                                      7:2.02.180-10.0.3.el7_6.8                                             ol7_latest                                      186 k
 policycoreutils                                                    x86_64                                      2.5-29.0.1.el7_6.1                                                    ol7_latest                                      916 k
 policycoreutils-python                                             x86_64                                      2.5-29.0.1.el7_6.1                                                    ol7_latest                                      455 k
 selinux-policy                                                     noarch                                      3.13.1-229.0.3.el7_6.12                                               ol7_latest                                      484 k
 selinux-policy-targeted                                            noarch                                      3.13.1-229.0.3.el7_6.12                                               ol7_latest                                      6.9 M
 setools-libs                                                       x86_64                                      3.3.8-4.el7                                                           ol7_latest                                      620 k
 systemd                                                            x86_64                                      219-62.0.4.el7_6.7                                                    ol7_latest                                      5.1 M
 systemd-libs                                                       x86_64                                      219-62.0.4.el7_6.7                                                    ol7_latest                                      407 k
 systemd-python                                                     x86_64                                      219-62.0.4.el7_6.7                                                    ol7_latest                                      133 k
 systemd-sysv                                                       x86_64                                      219-62.0.4.el7_6.7                                                    ol7_latest                                       84 k

Transaction Summary
============================================================================================================================================================================================================================================
Install  1 Package  (+ 8 Dependent packages)
Upgrade  4 Packages (+34 Dependent packages)

Total download size: 81 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for ol7_latest
warning: /var/cache/yum/x86_64/7Server/ol7_latest/packages/cryptsetup-2.0.3-3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY                                                      ] 373 kB/s | 1.6 MB  00:03:39 ETA
Public key for cryptsetup-2.0.3-3.el7.x86_64.rpm is not installed
(1/47): cryptsetup-2.0.3-3.el7.x86_64.rpm                                                                                                                                                                            | 153 kB  00:00:04
(2/47): criu-3.9-5.el7.x86_64.rpm                                                                                                                                                                                    | 432 kB  00:00:04
Public key for container-selinux-2.77-5.el7.noarch.rpm is not installed
(3/47): container-selinux-2.77-5.el7.noarch.rpm                                                                                                                                                                      |  37 kB  00:00:04
(4/47): cryptsetup-python-2.0.3-3.el7.x86_64.rpm                                                                                                                                                                     |  35 kB  00:00:00
(5/47): cryptsetup-libs-2.0.3-3.el7.x86_64.rpm                                                                                                                                                                       | 337 kB  00:00:01
(6/47): device-mapper-event-1.02.149-10.0.3.el7_6.8.x86_64.rpm                                                                                                                                                       | 188 kB  00:00:00
(7/47): device-mapper-1.02.149-10.0.3.el7_6.8.x86_64.rpm                                                                                                                                                             | 293 kB  00:00:01
(8/47): device-mapper-event-libs-1.02.149-10.0.3.el7_6.8.x86_64.rpm                                                                                                                                                  | 188 kB  00:00:00
(9/47): device-mapper-persistent-data-0.7.3-3.el7.x86_64.rpm                                                                                                                                                         | 404 kB  00:00:00
(10/47): device-mapper-libs-1.02.149-10.0.3.el7_6.8.x86_64.rpm                                                                                                                                                       | 320 kB  00:00:02
(11/47): containerd-1.2.0-1.0.5.el7.x86_64.rpm                                                                                                                                                                       |  21 MB  00:00:13
(12/47): dracut-config-rescue-033-554.0.3.el7.x86_64.rpm                                                                                                                                                             |  60 kB  00:00:01
(13/47): dracut-network-033-554.0.3.el7.x86_64.rpm                                                                                                                                                                   | 102 kB  00:00:00
(14/47): dracut-033-554.0.3.el7.x86_64.rpm                                                                                                                                                                           | 328 kB  00:00:02
(15/47): initscripts-9.49.46-1.0.1.el7.x86_64.rpm                                                                                                                                                                    | 439 kB  00:00:00
(16/47): kmod-20-23.0.1.el7.x86_64.rpm                                                                                                                                                                               | 121 kB  00:00:00
(17/47): libgudev1-219-62.0.4.el7_6.7.x86_64.rpm                                                                                                                                                                     |  96 kB  00:00:00
(18/47): glib2-2.56.1-4.el7_6.x86_64.rpm                                                                                                                                                                             | 2.5 MB  00:00:02
(19/47): libnl3-3.2.28-4.el7.x86_64.rpm                                                                                                                                                                              | 277 kB  00:00:00
(20/47): docker-cli-18.09.1.ol-1.0.5.el7.x86_64.rpm                                                                                                                                                                  |  14 MB  00:00:12
(21/47): libnet-1.1.6-7.el7.x86_64.rpm                                                                                                                                                                               |  57 kB  00:00:01
(22/47): libseccomp-2.3.1-3.el7.x86_64.rpm                                                                                                                                                                           |  55 kB  00:00:00
(23/47): libselinux-2.5-14.1.el7.x86_64.rpm                                                                                                                                                                          | 162 kB  00:00:00
(24/47): libnl3-cli-3.2.28-4.el7.x86_64.rpm                                                                                                                                                                          | 159 kB  00:00:00
(25/47): libselinux-python-2.5-14.1.el7.x86_64.rpm                                                                                                                                                                   | 235 kB  00:00:00
(26/47): libselinux-utils-2.5-14.1.el7.x86_64.rpm                                                                                                                                                                    | 151 kB  00:00:00
(27/47): libsemanage-python-2.5-14.el7.x86_64.rpm                                                                                                                                                                    | 112 kB  00:00:00
(28/47): libsemanage-2.5-14.el7.x86_64.rpm                                                                                                                                                                           | 150 kB  00:00:00
(29/47): libsepol-2.5-10.el7.x86_64.rpm                                                                                                                                                                              | 297 kB  00:00:00
(30/47): lvm2-2.02.180-10.0.3.el7_6.8.x86_64.rpm                                                                                                                                                                     | 1.3 MB  00:00:00
(31/47): lvm2-python-libs-2.02.180-10.0.3.el7_6.8.x86_64.rpm                                                                                                                                                         | 186 kB  00:00:00
(32/47): lvm2-libs-2.02.180-10.0.3.el7_6.8.x86_64.rpm                                                                                                                                                                | 1.1 MB  00:00:01
(33/47): lz4-1.7.5-2.0.1.el7.x86_64.rpm                                                                                                                                                                              |  98 kB  00:00:00
(34/47): oraclelinux-release-7.6-1.0.15.el7.x86_64.rpm                                                                                                                                                               |  54 kB  00:00:00
(35/47): policycoreutils-2.5-29.0.1.el7_6.1.x86_64.rpm                                                                                                                                                               | 916 kB  00:00:00
(36/47): policycoreutils-python-2.5-29.0.1.el7_6.1.x86_64.rpm                                                                                                                                                        | 455 kB  00:00:00
(37/47): redhat-release-server-7.6-4.0.1.el7.x86_64.rpm                                                                                                                                                              | 9.8 kB  00:00:00
(38/47): docker-engine-18.09.1.ol-1.0.5.el7.x86_64.rpm                                                                                                                                                               |  19 MB  00:00:10
(39/47): selinux-policy-3.13.1-229.0.3.el7_6.12.noarch.rpm                                                                                                                                                           | 484 kB  00:00:00
(40/47): protobuf-c-1.0.2-3.el7.x86_64.rpm                                                                                                                                                                           |  27 kB  00:00:02
(41/47): setools-libs-3.3.8-4.el7.x86_64.rpm                                                                                                                                                                         | 620 kB  00:00:00
(42/47): runc-1.0.0-19.rc5.git4bb1fe4.0.3.el7.x86_64.rpm                                                                                                                                                             | 1.9 MB  00:00:04
(43/47): selinux-policy-targeted-3.13.1-229.0.3.el7_6.12.noarch.rpm                                                                                                                                                  | 6.9 MB  00:00:03
(44/47): systemd-libs-219-62.0.4.el7_6.7.x86_64.rpm                                                                                                                                                                  | 407 kB  00:00:00
(45/47): systemd-python-219-62.0.4.el7_6.7.x86_64.rpm                                                                                                                                                                | 133 kB  00:00:00
(46/47): systemd-sysv-219-62.0.4.el7_6.7.x86_64.rpm                                                                                                                                                                  |  84 kB  00:00:00
(47/47): systemd-219-62.0.4.el7_6.7.x86_64.rpm                                                                                                                                                                       | 5.1 MB  00:00:04
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                       2.8 MB/s |  81 MB  00:00:29
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Importing GPG key 0xEC551F03:
 Userid     : "Oracle OSS group (Open Source Software group) "
 Fingerprint: 4214 4123 fecf c55b 9086 313d 72f9 7b74 ec55 1f03
 Package    : 7:oraclelinux-release-7.1-1.0.5.el7.x86_64 (@anaconda/7.1)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libsepol-2.5-10.el7.x86_64                                                                                                                                                                                              1/85
  Updating   : libselinux-2.5-14.1.el7.x86_64                                                                                                                                                                                          2/85
  Updating   : libsemanage-2.5-14.el7.x86_64                                                                                                                                                                                           3/85
  Installing : lz4-1.7.5-2.0.1.el7.x86_64                                                                                                                                                                                              4/85
  Updating   : systemd-libs-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                  5/85
  Updating   : 1:redhat-release-server-7.6-4.0.1.el7.x86_64                                                                                                                                                                            6/85
  Updating   : cryptsetup-libs-2.0.3-3.el7.x86_64                                                                                                                                                                                      7/85
  Updating   : 7:device-mapper-libs-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                                     8/85
  Updating   : 7:device-mapper-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                                          9/85
  Updating   : systemd-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                      10/85
  Updating   : dracut-033-554.0.3.el7.x86_64                                                                                                                                                                                          11/85
  Updating   : kmod-20-23.0.1.el7.x86_64                                                                                                                                                                                              12/85
  Updating   : 7:device-mapper-event-libs-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                              13/85
  Updating   : libseccomp-2.3.1-3.el7.x86_64                                                                                                                                                                                          14/85
  Updating   : glib2-2.56.1-4.el7_6.x86_64                                                                                                                                                                                            15/85
  Updating   : libselinux-utils-2.5-14.1.el7.x86_64                                                                                                                                                                                   16/85
  Updating   : policycoreutils-2.5-29.0.1.el7_6.1.x86_64                                                                                                                                                                              17/85
  Updating   : selinux-policy-3.13.1-229.0.3.el7_6.12.noarch                                                                                                                                                                          18/85
  Updating   : libnl3-3.2.28-4.el7.x86_64                                                                                                                                                                                             19/85
  Updating   : selinux-policy-targeted-3.13.1-229.0.3.el7_6.12.noarch                                                                                                                                                                 20/85
  Updating   : 7:device-mapper-event-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                                   21/85
  Updating   : 7:lvm2-libs-2.02.180-10.0.3.el7_6.8.x86_64                                                                                                                                                                             22/85
  Updating   : 7:oraclelinux-release-7.6-1.0.15.el7.x86_64                                                                                                                                                                            23/85
  Updating   : libsemanage-python-2.5-14.el7.x86_64                                                                                                                                                                                   24/85
  Updating   : libselinux-python-2.5-14.1.el7.x86_64                                                                                                                                                                                  25/85
  Updating   : setools-libs-3.3.8-4.el7.x86_64                                                                                                                                                                                        26/85
  Updating   : policycoreutils-python-2.5-29.0.1.el7_6.1.x86_64                                                                                                                                                                       27/85
  Installing : 2:container-selinux-2.77-5.el7.noarch                                                                                                                                                                                  28/85
  Installing : containerd-1.2.0-1.0.5.el7.x86_64                                                                                                                                                                                      29/85
  Installing : docker-cli-18.09.1.ol-1.0.5.el7.x86_64                                                                                                                                                                                 30/85
  Installing : libnet-1.1.6-7.el7.x86_64                                                                                                                                                                                              31/85
  Installing : protobuf-c-1.0.2-3.el7.x86_64                                                                                                                                                                                          32/85
  Installing : criu-3.9-5.el7.x86_64                                                                                                                                                                                                  33/85
  Installing : runc-1.0.0-19.rc5.git4bb1fe4.0.3.el7.x86_64                                                                                                                                                                            34/85
  Updating   : device-mapper-persistent-data-0.7.3-3.el7.x86_64                                                                                                                                                                       35/85
  Updating   : 7:lvm2-2.02.180-10.0.3.el7_6.8.x86_64                                                                                                                                                                                  36/85
Created symlink from /etc/systemd/system/sysinit.target.wants/lvm2-lvmpolld.socket to /usr/lib/systemd/system/lvm2-lvmpolld.socket.
  Installing : docker-engine-18.09.1.ol-1.0.5.el7.x86_64                                                                                                                                                                              37/85
  Updating   : initscripts-9.49.46-1.0.1.el7.x86_64                                                                                                                                                                                   38/85
  Updating   : 7:lvm2-python-libs-2.02.180-10.0.3.el7_6.8.x86_64                                                                                                                                                                      39/85
  Updating   : libnl3-cli-3.2.28-4.el7.x86_64                                                                                                                                                                                         40/85
  Updating   : libgudev1-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                    41/85
  Updating   : dracut-network-033-554.0.3.el7.x86_64                                                                                                                                                                                  42/85
  Updating   : dracut-config-rescue-033-554.0.3.el7.x86_64                                                                                                                                                                            43/85
  Updating   : systemd-sysv-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                 44/85
  Updating   : systemd-python-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                               45/85
  Updating   : cryptsetup-python-2.0.3-3.el7.x86_64                                                                                                                                                                                   46/85
  Updating   : cryptsetup-2.0.3-3.el7.x86_64                                                                                                                                                                                          47/85
  Cleanup    : 7:lvm2-2.02.115-3.el7.x86_64                                                                                                                                                                                           48/85
  Cleanup    : policycoreutils-python-2.2.5-15.0.1.el7.x86_64                                                                                                                                                                         49/85

UPGRADE: Automatically re-enabling default systemd units:
        brandbot.path
        rhel-autorelabel.service
        rhel-autorelabel-mark.service
        rhel-configure.service
        rhel-dmesg.service
        rhel-domainname.service
        rhel-import-state.service
        rhel-loadmodules.service
        rhel-readonly.service

  Cleanup    : initscripts-9.49.24-1.0.1.el7.x86_64                                                                                                                                                                                   50/85
  Cleanup    : libgudev1-208-20.0.1.el7.x86_64                                                                                                                                                                                        51/85
  Cleanup    : selinux-policy-targeted-3.13.1-23.0.1.el7.noarch                                                                                                                                                                       52/85
  Cleanup    : selinux-policy-3.13.1-23.0.1.el7.noarch                                                                                                                                                                                53/85
  Cleanup    : 7:oraclelinux-release-7.1-1.0.5.el7.x86_64                                                                                                                                                                             54/85
  Cleanup    : dracut-config-rescue-033-240.0.1.el7.x86_64                                                                                                                                                                            55/85
  Cleanup    : systemd-sysv-208-20.0.1.el7.x86_64                                                                                                                                                                                     56/85
  Cleanup    : dracut-network-033-240.0.1.el7.x86_64                                                                                                                                                                                  57/85
  Cleanup    : policycoreutils-2.2.5-15.0.1.el7.x86_64                                                                                                                                                                                58/85
  Cleanup    : systemd-python-208-20.0.1.el7.x86_64                                                                                                                                                                                   59/85
  Cleanup    : dracut-033-240.0.1.el7.x86_64                                                                                                                                                                                          60/85
  Cleanup    : setools-libs-3.3.7-46.el7.x86_64                                                                                                                                                                                       61/85
  Cleanup    : libselinux-utils-2.2.2-6.el7.x86_64                                                                                                                                                                                    62/85
  Cleanup    : glib2-2.40.0-4.el7.x86_64                                                                                                                                                                                              63/85
  Cleanup    : libselinux-python-2.2.2-6.el7.x86_64                                                                                                                                                                                   64/85
  Cleanup    : libsemanage-python-2.1.10-16.el7.x86_64                                                                                                                                                                                65/85
  Cleanup    : libsemanage-2.1.10-16.el7.x86_64                                                                                                                                                                                       66/85
  Cleanup    : cryptsetup-1.6.6-3.el7.x86_64                                                                                                                                                                                          67/85
  Cleanup    : libnl3-cli-3.2.21-8.0.1.el7.x86_64                                                                                                                                                                                     68/85
  Cleanup    : cryptsetup-python-1.6.6-3.el7.x86_64                                                                                                                                                                                   69/85
  Cleanup    : 7:lvm2-python-libs-2.02.115-3.el7.x86_64                                                                                                                                                                               70/85
  Cleanup    : 7:lvm2-libs-2.02.115-3.el7.x86_64                                                                                                                                                                                      71/85
  Cleanup    : 7:device-mapper-event-1.02.93-3.el7.x86_64                                                                                                                                                                             72/85
  Cleanup    : 7:device-mapper-event-libs-1.02.93-3.el7.x86_64                                                                                                                                                                        73/85
  Cleanup    : cryptsetup-libs-1.6.6-3.el7.x86_64                                                                                                                                                                                     74/85
  Cleanup    : systemd-208-20.0.1.el7.x86_64                                                                                                                                                                                          75/85
  Cleanup    : 7:device-mapper-1.02.93-3.el7.x86_64                                                                                                                                                                                   76/85
  Cleanup    : 7:device-mapper-libs-1.02.93-3.el7.x86_64                                                                                                                                                                              77/85
  Cleanup    : 1:redhat-release-server-7.1-1.0.2.el7.x86_64                                                                                                                                                                           78/85
  Cleanup    : systemd-libs-208-20.0.1.el7.x86_64                                                                                                                                                                                     79/85
  Cleanup    : libselinux-2.2.2-6.el7.x86_64                                                                                                                                                                                          80/85
  Cleanup    : libsepol-2.1.9-3.el7.x86_64                                                                                                                                                                                            81/85
  Cleanup    : kmod-14-10.el7.x86_64                                                                                                                                                                                                  82/85
  Cleanup    : libnl3-3.2.21-8.0.1.el7.x86_64                                                                                                                                                                                         83/85
  Cleanup    : device-mapper-persistent-data-0.4.1-2.el7.x86_64                                                                                                                                                                       84/85
  Cleanup    : libseccomp-2.1.1-2.el7.x86_64                                                                                                                                                                                          85/85
  Verifying  : 7:device-mapper-event-libs-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                               1/85
  Verifying  : glib2-2.56.1-4.el7_6.x86_64                                                                                                                                                                                             2/85
  Verifying  : docker-engine-18.09.1.ol-1.0.5.el7.x86_64                                                                                                                                                                               3/85
  Verifying  : policycoreutils-2.5-29.0.1.el7_6.1.x86_64                                                                                                                                                                               4/85
  Verifying  : libseccomp-2.3.1-3.el7.x86_64                                                                                                                                                                                           5/85
  Verifying  : kmod-20-23.0.1.el7.x86_64                                                                                                                                                                                               6/85
  Verifying  : 7:device-mapper-libs-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                                     7/85
  Verifying  : 7:lvm2-python-libs-2.02.180-10.0.3.el7_6.8.x86_64                                                                                                                                                                       8/85
  Verifying  : libgudev1-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                     9/85
  Verifying  : cryptsetup-libs-2.0.3-3.el7.x86_64                                                                                                                                                                                     10/85
  Verifying  : selinux-policy-3.13.1-229.0.3.el7_6.12.noarch                                                                                                                                                                          11/85
  Verifying  : 7:lvm2-2.02.180-10.0.3.el7_6.8.x86_64                                                                                                                                                                                  12/85
  Verifying  : 2:container-selinux-2.77-5.el7.noarch                                                                                                                                                                                  13/85
  Verifying  : initscripts-9.49.46-1.0.1.el7.x86_64                                                                                                                                                                                   14/85
  Verifying  : cryptsetup-python-2.0.3-3.el7.x86_64                                                                                                                                                                                   15/85
  Verifying  : libsemanage-python-2.5-14.el7.x86_64                                                                                                                                                                                   16/85
  Verifying  : 1:redhat-release-server-7.6-4.0.1.el7.x86_64                                                                                                                                                                           17/85
  Verifying  : 7:oraclelinux-release-7.6-1.0.15.el7.x86_64                                                                                                                                                                            18/85
  Verifying  : device-mapper-persistent-data-0.7.3-3.el7.x86_64                                                                                                                                                                       19/85
  Verifying  : dracut-network-033-554.0.3.el7.x86_64                                                                                                                                                                                  20/85
  Verifying  : systemd-sysv-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                 21/85
  Verifying  : containerd-1.2.0-1.0.5.el7.x86_64                                                                                                                                                                                      22/85
  Verifying  : policycoreutils-python-2.5-29.0.1.el7_6.1.x86_64                                                                                                                                                                       23/85
  Verifying  : protobuf-c-1.0.2-3.el7.x86_64                                                                                                                                                                                          24/85
  Verifying  : dracut-config-rescue-033-554.0.3.el7.x86_64                                                                                                                                                                            25/85
  Verifying  : libselinux-2.5-14.1.el7.x86_64                                                                                                                                                                                         26/85
  Verifying  : systemd-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                      27/85
  Verifying  : criu-3.9-5.el7.x86_64                                                                                                                                                                                                  28/85
  Verifying  : libsemanage-2.5-14.el7.x86_64                                                                                                                                                                                          29/85
  Verifying  : systemd-libs-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                 30/85
  Verifying  : libnl3-cli-3.2.28-4.el7.x86_64                                                                                                                                                                                         31/85
  Verifying  : systemd-python-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                               32/85
  Verifying  : libselinux-python-2.5-14.1.el7.x86_64                                                                                                                                                                                  33/85
  Verifying  : libnet-1.1.6-7.el7.x86_64                                                                                                                                                                                              34/85
  Verifying  : libsepol-2.5-10.el7.x86_64                                                                                                                                                                                             35/85
  Verifying  : runc-1.0.0-19.rc5.git4bb1fe4.0.3.el7.x86_64                                                                                                                                                                            36/85
  Verifying  : selinux-policy-targeted-3.13.1-229.0.3.el7_6.12.noarch                                                                                                                                                                 37/85
  Verifying  : libselinux-utils-2.5-14.1.el7.x86_64                                                                                                                                                                                   38/85
  Verifying  : dracut-033-554.0.3.el7.x86_64                                                                                                                                                                                          39/85
  Verifying  : 7:device-mapper-event-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                                   40/85
  Verifying  : 7:device-mapper-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                                         41/85
  Verifying  : libnl3-3.2.28-4.el7.x86_64                                                                                                                                                                                             42/85
  Verifying  : docker-cli-18.09.1.ol-1.0.5.el7.x86_64                                                                                                                                                                                 43/85
  Verifying  : 7:lvm2-libs-2.02.180-10.0.3.el7_6.8.x86_64                                                                                                                                                                             44/85
  Verifying  : setools-libs-3.3.8-4.el7.x86_64                                                                                                                                                                                        45/85
  Verifying  : lz4-1.7.5-2.0.1.el7.x86_64                                                                                                                                                                                             46/85
  Verifying  : cryptsetup-2.0.3-3.el7.x86_64                                                                                                                                                                                          47/85
  Verifying  : libselinux-utils-2.2.2-6.el7.x86_64                                                                                                                                                                                    48/85
  Verifying  : libsemanage-python-2.1.10-16.el7.x86_64                                                                                                                                                                                49/85
  Verifying  : dracut-config-rescue-033-240.0.1.el7.x86_64                                                                                                                                                                            50/85
  Verifying  : systemd-libs-208-20.0.1.el7.x86_64                                                                                                                                                                                     51/85
  Verifying  : systemd-sysv-208-20.0.1.el7.x86_64                                                                                                                                                                                     52/85
  Verifying  : policycoreutils-2.2.5-15.0.1.el7.x86_64                                                                                                                                                                                53/85
  Verifying  : policycoreutils-python-2.2.5-15.0.1.el7.x86_64                                                                                                                                                                         54/85
  Verifying  : cryptsetup-python-1.6.6-3.el7.x86_64                                                                                                                                                                                   55/85
  Verifying  : 7:oraclelinux-release-7.1-1.0.5.el7.x86_64                                                                                                                                                                             56/85
  Verifying  : 7:device-mapper-event-libs-1.02.93-3.el7.x86_64                                                                                                                                                                        57/85
  Verifying  : dracut-033-240.0.1.el7.x86_64                                                                                                                                                                                          58/85
  Verifying  : cryptsetup-1.6.6-3.el7.x86_64                                                                                                                                                                                          59/85
  Verifying  : setools-libs-3.3.7-46.el7.x86_64                                                                                                                                                                                       60/85
  Verifying  : initscripts-9.49.24-1.0.1.el7.x86_64                                                                                                                                                                                   61/85
  Verifying  : kmod-14-10.el7.x86_64                                                                                                                                                                                                  62/85
  Verifying  : systemd-python-208-20.0.1.el7.x86_64                                                                                                                                                                                   63/85
  Verifying  : cryptsetup-libs-1.6.6-3.el7.x86_64                                                                                                                                                                                     64/85
  Verifying  : dracut-network-033-240.0.1.el7.x86_64                                                                                                                                                                                  65/85
  Verifying  : glib2-2.40.0-4.el7.x86_64                                                                                                                                                                                              66/85
  Verifying  : libnl3-cli-3.2.21-8.0.1.el7.x86_64                                                                                                                                                                                     67/85
  Verifying  : libnl3-3.2.21-8.0.1.el7.x86_64                                                                                                                                                                                         68/85
  Verifying  : 7:device-mapper-event-1.02.93-3.el7.x86_64                                                                                                                                                                             69/85
  Verifying  : libselinux-python-2.2.2-6.el7.x86_64                                                                                                                                                                                   70/85
  Verifying  : libsemanage-2.1.10-16.el7.x86_64                                                                                                                                                                                       71/85
  Verifying  : libseccomp-2.1.1-2.el7.x86_64                                                                                                                                                                                          72/85
  Verifying  : libsepol-2.1.9-3.el7.x86_64                                                                                                                                                                                            73/85
  Verifying  : 7:lvm2-python-libs-2.02.115-3.el7.x86_64                                                                                                                                                                               74/85
  Verifying  : 7:device-mapper-1.02.93-3.el7.x86_64                                                                                                                                                                                   75/85
  Verifying  : selinux-policy-3.13.1-23.0.1.el7.noarch                                                                                                                                                                                76/85
  Verifying  : libselinux-2.2.2-6.el7.x86_64                                                                                                                                                                                          77/85
  Verifying  : 1:redhat-release-server-7.1-1.0.2.el7.x86_64                                                                                                                                                                           78/85
  Verifying  : libgudev1-208-20.0.1.el7.x86_64                                                                                                                                                                                        79/85
  Verifying  : 7:lvm2-2.02.115-3.el7.x86_64                                                                                                                                                                                           80/85
  Verifying  : 7:lvm2-libs-2.02.115-3.el7.x86_64                                                                                                                                                                                      81/85
  Verifying  : 7:device-mapper-libs-1.02.93-3.el7.x86_64                                                                                                                                                                              82/85
  Verifying  : device-mapper-persistent-data-0.4.1-2.el7.x86_64                                                                                                                                                                       83/85
  Verifying  : selinux-policy-targeted-3.13.1-23.0.1.el7.noarch                                                                                                                                                                       84/85
  Verifying  : systemd-208-20.0.1.el7.x86_64                                                                                                                                                                                          85/85

Installed:
  docker-engine.x86_64 0:18.09.1.ol-1.0.5.el7

Dependency Installed:
  container-selinux.noarch 2:2.77-5.el7     containerd.x86_64 0:1.2.0-1.0.5.el7               criu.x86_64 0:3.9-5.el7     docker-cli.x86_64 0:18.09.1.ol-1.0.5.el7     libnet.x86_64 0:1.1.6-7.el7     lz4.x86_64 0:1.7.5-2.0.1.el7
  protobuf-c.x86_64 0:1.0.2-3.el7           runc.x86_64 0:1.0.0-19.rc5.git4bb1fe4.0.3.el7

Updated:
  dracut.x86_64 0:033-554.0.3.el7                   initscripts.x86_64 0:9.49.46-1.0.1.el7                   oraclelinux-release.x86_64 7:7.6-1.0.15.el7                   redhat-release-server.x86_64 1:7.6-4.0.1.el7

Dependency Updated:
  cryptsetup.x86_64 0:2.0.3-3.el7                              cryptsetup-libs.x86_64 0:2.0.3-3.el7                          cryptsetup-python.x86_64 0:2.0.3-3.el7                  device-mapper.x86_64 7:1.02.149-10.0.3.el7_6.8
  device-mapper-event.x86_64 7:1.02.149-10.0.3.el7_6.8         device-mapper-event-libs.x86_64 7:1.02.149-10.0.3.el7_6.8     device-mapper-libs.x86_64 7:1.02.149-10.0.3.el7_6.8     device-mapper-persistent-data.x86_64 0:0.7.3-3.el7
  dracut-config-rescue.x86_64 0:033-554.0.3.el7                dracut-network.x86_64 0:033-554.0.3.el7                       glib2.x86_64 0:2.56.1-4.el7_6                           kmod.x86_64 0:20-23.0.1.el7
  libgudev1.x86_64 0:219-62.0.4.el7_6.7                        libnl3.x86_64 0:3.2.28-4.el7                                  libnl3-cli.x86_64 0:3.2.28-4.el7                        libseccomp.x86_64 0:2.3.1-3.el7
  libselinux.x86_64 0:2.5-14.1.el7                             libselinux-python.x86_64 0:2.5-14.1.el7                       libselinux-utils.x86_64 0:2.5-14.1.el7                  libsemanage.x86_64 0:2.5-14.el7
  libsemanage-python.x86_64 0:2.5-14.el7                       libsepol.x86_64 0:2.5-10.el7                                  lvm2.x86_64 7:2.02.180-10.0.3.el7_6.8                   lvm2-libs.x86_64 7:2.02.180-10.0.3.el7_6.8
  lvm2-python-libs.x86_64 7:2.02.180-10.0.3.el7_6.8            policycoreutils.x86_64 0:2.5-29.0.1.el7_6.1                   policycoreutils-python.x86_64 0:2.5-29.0.1.el7_6.1      selinux-policy.noarch 0:3.13.1-229.0.3.el7_6.12
  selinux-policy-targeted.noarch 0:3.13.1-229.0.3.el7_6.12     setools-libs.x86_64 0:3.3.8-4.el7                             systemd.x86_64 0:219-62.0.4.el7_6.7                     systemd-libs.x86_64 0:219-62.0.4.el7_6.7
  systemd-python.x86_64 0:219-62.0.4.el7_6.7                   systemd-sysv.x86_64 0:219-62.0.4.el7_6.7

Complete!

一旦安装完成,就可以启动docker服务

[root@localhost soft]# service docker start
Redirecting to /bin/systemctl start docker.service

[root@localhost soft]# systemctl enable docker

[root@localhost soft]# service docker status
Redirecting to /bin/systemctl status docker.service
鈼[0m docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/docker.service.d
           鈹斺攢docker-sysconfig.conf
   Active: active (running) since Mon 2019-06-10 23:15:05 CST; 6h left
     Docs: https://docs.docker.com
 Main PID: 1452 (dockerd)
   Memory: 132.2M
   CGroup: /system.slice/docker.service
           鈹溾攢1452 /usr/bin/dockerd --selinux-enabled --storage-driver devicemapper --storage-opt dm.basesize=25G
           鈹斺攢2436 containerd --config /var/run/docker/containerd/containerd.toml --log-level info

Jun 10 23:15:03 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:03.843382248+08:00" level=info msg="Successfully created filesystem xfs on device docker-253:0-1047242-base" storage-driver=devicemapper
Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.076789613+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.078665673+08:00" level=warning msg="mountpoint for pids not found"
Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.079906275+08:00" level=info msg="Loading containers: start."
Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.554467519+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to...rred IP address"
Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.859786800+08:00" level=info msg="Loading containers: done."
Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.959099871+08:00" level=info msg="Docker daemon" commit=c3ab8a8 graphdriver(s)=devicemapper version=18.09.1-ol
Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.959938124+08:00" level=info msg="Daemon has completed initialization"
Jun 10 23:15:05 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:05.053166130+08:00" level=info msg="API listen on /var/run/docker.sock"
Jun 10 23:15:05 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.

然后可以下载镜像文件

[root@localhost soft]# docker pull mysql/mysql-server:5.7
Trying to pull repository docker.io/mysql/mysql-server ...
5.7: Pulling from docker.io/mysql/mysql-server
35defbf6c365: Pull complete
0fa46ab0f51d: Pull complete
f70f5000008c: Pull complete
892ac46af8c0: Pull complete
Digest: sha256:ddb046076781a15200d36cb01f8f512431c3481bedebd5e92646d8c617ae212c
Status: Downloaded newer image for mysql/mysql-server:5.7
[root@localhost soft]# docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
mysql/mysql-server   5.7                 857eadf53a54        6 weeks ago         258MB



使用Docker来部署MySQL
下载MySQL Server Docker镜像文件
严格来说,不需要在单独的步骤中下载服务器镜像,但是,在创建Docker容器之前执行此步骤可以确保本地映像是最新的。为了下载MySQL社区版镜像,执行以下命令:

docker pull mysql/mysql-server:tag

tag是你想要pull镜像版本的标识(例如,5.5,5.6,5.7,8.0或最新版本)。如果:tag被忽略,latest标记会被使用并且最新通用可用版本的MySQL社区版本镜像将会被下载。网址
https://hub.docker.com/r/mysql/mysql-server/tags/列出了所有可用版本信息.

[root@localhost soft]# docker pull mysql/mysql-server:5.7
Trying to pull repository docker.io/mysql/mysql-server ...
5.7: Pulling from docker.io/mysql/mysql-server
35defbf6c365: Pull complete
0fa46ab0f51d: Pull complete
f70f5000008c: Pull complete
892ac46af8c0: Pull complete
Digest: sha256:ddb046076781a15200d36cb01f8f512431c3481bedebd5e92646d8c617ae212c
Status: Downloaded newer image for mysql/mysql-server:5.7

如果要显示Docker镜像可以执行以下命令:

[root@localhost soft]# docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
mysql/mysql-server   5.7                 857eadf53a54        6 weeks ago         258MB

为了下载MySQL企业版本镜像,执行以下命令:

docker pull store/oracle/mysql-enterprise-server:5.7

5.7是我们想要pull的镜像版本。MySQL企业版本容器只提供了最新的通用可用版本5.7

启动MySQL Server实例
为MySQL社区版本服务器启动一个新的Docker容器执行以下命令:

[root@localhost ~]# docker run --name=mysql1 -d mysql/mysql-server:5.7
5128014e440f10c557b52e6203445a01c97728e432d0f231c6027bf4b15520bd

为MySQL企业版本服务器启动一个新的Docker容器执行以下命令:

docker run --name=mysql1 -d store/oracle/mysql-enterprise-server:tag

–name选项,用来为你的服务容器指定名字(例如mysql1),它是可选项。如果没有提供容器名,会生成一个随机容器名。如果之前的docker pull或docker run命令所指定名称或标记的Docker镜像没有下载,那么镜像现在就会被下载。在下载完成后,开始初始化容器,并且当你执行docker ps命令时容器会出现在正在运行的容器列表中。例如:

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS                             PORTS                 NAMES
5128014e440f        mysql/mysql-server:5.7   "/entrypoint.sh mysq鈥   42 seconds ago      Up 39 seconds (health: starting)   3306/tcp, 33060/tcp   mysql1

IMAGE列的输出对于MySQL社区版本读取的值为mysql/mysql-server,对于MySQL企业版本读取的值为store/oracle/mysql-enterprise-server。
容器初始化可能会花费一些时间。当服务准备好使用时,docker ps命令输出的STATUS列将从(health: starting)改变为(healthy)。

在上面的docker run命令中-d选项使容器在后台运行。使用下面的命令可以监控容器的输出信息:

[root@localhost ~]# docker logs mysql1
[Entrypoint] MySQL Docker Image 5.7.26-1.1.11
[Entrypoint] No password option specified for new database.
[Entrypoint]   A random onetime password will be generated.
[Entrypoint] Initializing database
[Entrypoint] Database initialized
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
[Entrypoint] GENERATED ROOT PASSWORD: 3z[omLAk4Jaz@sYxDiLYnyPySYfR

[Entrypoint] ignoring /docker-entrypoint-initdb.d/*

[Entrypoint] Server shut down
[Entrypoint] Setting root user as expired. Password will need to be changed before database can be used.

[Entrypoint] MySQL init process done. Ready for start up.

[Entrypoint] Starting MySQL 5.7.26-1.1.11

一旦初始化完成,命令的输出将会包含为root用户生成随机密码的信息,也可以执行下面的命令来检查密码:

[root@localhost ~]# docker logs mysql1 2>&1 | grep GENERATED
[Entrypoint] GENERATED ROOT PASSWORD: 3z[omLAk4Jaz@sYxDiLYnyPySYfR

在容器中连接MySQL服务器
一旦服务可以使用后,可以在刚刚启动的MySQL服务容器中运行mysql客户端程序并连接到MySQL服务。在刚刚启动的Docker容器中使用docker exec -it命令来启动mysql客户端程序,例如:

[root@localhost ~]# docker exec -it mysql1 mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 107
Server version: 5.7.26

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

在执行上面的命令时需要输入root用户生成的密码。因为mysql_onetime_password选项缺省情况为true(对于MySQL社区版本来说),在mysql客户端连接到MySQL服务后,必须要通过执行以下命令来修改root用户的密码:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)

一旦修改密码后,MySQL服务就可以使用。

容器Shell访问
为了使用shell访问你的MySQL服务器容器,在容器中使用docker exec -it命令来启动bash shell:

[root@localhost ~]# docker exec -it mysql1 bash
bash-4.2#

在启动bash shell后,在容器中可以运行linux命令,例如,为了查看容器中的MySQL数据库的数据目录中的内容,执行以下命令:

bash-4.2# ls /var/lib/mysql
auto.cnf    ca.pem           client-key.pem  ib_logfile0  ibdata1  mysql       mysql.sock.lock     private_key.pem  server-cert.pem  sys
ca-key.pem  client-cert.pem  ib_buffer_pool  ib_logfile1  ibtmp1   mysql.sock  performance_schema  public_key.pem   server-key.pem

停止与删除一个MySQL容器
为了停止已经创建的MySQL服务容器执行下面的命令:

[root@localhost ~]# docker stop mysql1
mysql1
[root@localhost ~]# docker ps -l
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS                     PORTS               NAMES
5128014e440f        mysql/mysql-server:5.7   "/entrypoint.sh mysql"   21 hours ago        Exited (0) 8 seconds ago                       mysql1

docker stop将发送一个SIGTERM信号给mysqld进程,因此服务将被优雅的关闭。
还可以观察到当一个容器的主进程(一个MySQL服务容器的主进程为mysqld)被关闭,Docker容器也会自动关闭。

启动MySQL服务容器:

[root@localhost ~]# docker start mysql1
mysql1
[root@localhost ~]# docker ps -l
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS                            PORTS                 NAMES
5128014e440f        mysql/mysql-server:5.7   "/entrypoint.sh mysql"   22 hours ago        Up 5 seconds (health: starting)   3306/tcp, 33060/tcp   mysql1
[root@localhost ~]# docker ps -l
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS                             PORTS                 NAMES
5128014e440f        mysql/mysql-server:5.7   "/entrypoint.sh mysql"   22 hours ago        Up 15 seconds (health: starting)   3306/tcp, 33060/tcp   mysql1
[root@localhost ~]# docker ps -l
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS                             PORTS                 NAMES
5128014e440f        mysql/mysql-server:5.7   "/entrypoint.sh mysql"   22 hours ago        Up 21 seconds (health: starting)   3306/tcp, 33060/tcp   mysql1
[root@localhost ~]# docker ps -l
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS                    PORTS                 NAMES
5128014e440f        mysql/mysql-server:5.7   "/entrypoint.sh mysql"   22 hours ago        Up 32 seconds (healthy)   3306/tcp, 33060/tcp   mysql1

为了使用单个命令停止与再次启动MySQL服务容器:

[root@localhost ~]# docker restart mysql1
mysql1
[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS                            PORTS                 NAMES
5128014e440f        mysql/mysql-server:5.7   "/entrypoint.sh mysql"   24 hours ago        Up 6 seconds (health: starting)   3306/tcp, 33060/tcp   mysql1

为了删除MySQL容器,首先停止容器,然后再使用docker rm命令:

[root@localhost ~]# docker stop mysql1
mysql1
[root@localhost ~]# docker ps -l
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS                      PORTS               NAMES
5128014e440f        mysql/mysql-server:5.7   "/entrypoint.sh mysq1"  24 hours ago        Exited (0) 12 seconds ago                       mysql1
[root@localhost ~]# docker rm mysql1
mysql1
[root@localhost ~]# docker ps -l
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

为Docker优化MySQL的安装
MySQL的Docker映像针对代码大小进行了优化,这意味着它们只包含与大多数在Docker容器中运行MySQL实例的用户相关的关键组件。一个MySQL Docker安装与常见的非Docker安装在以下方面不同:
包含的二进制文件是有限的:

/usr/bin/my_print_defaults
/usr/bin/mysql
/usr/bin/mysql_config
/usr/bin/mysql_install_db
/usr/bin/mysql_tzinfo_to_sql
/usr/bin/mysql_upgrade
/usr/bin/mysqladmin
/usr/bin/mysqlcheck
/usr/bin/mysqldump
/usr/bin/mysqlpump
/usr/sbin/mysqld

所有的二进制文件被stripped;它们不包含调试信息。

配置MySQL Server
当你启动MySQL Docker容器时,可以通过docker run命令来传递配置选项给服务,例如,对于MySQL社区版本服务器

docker run --name mysql1 -d mysql/mysql-server:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_col

对于MySQL企业版本服务器:

docker run --name mysql1 -d store/oracle/mysql-enterprise-server --character-set-server=utf8mb4 --collation-server=utf8mb4_col

命令以utf8mb4作为默认字符集和utf8mb4col作为您的数据库的默认排序启动MySQL服务器。另一种配置MySQL服务器的方法是准备一个配置文件,并将其挂载到容器内的服务器配置文件的位置。有关详细信息,请参阅持久数据和配置更改。

持久数据和配置更改
Docker容器在原则上是临时的,如果容器被删除或损坏,任何数据或配置都将丢失(参见讨论)。然而,Docker卷提供了一种机制,可以在Docker容器中保存数据。在初始化时,MySQL服务器容器为服务器数据目录创建Docker卷。运行docker检查容器命令的JSON输出有一个挂载键,其值提供数据目录卷的信息:

[root@localhost ~]# docker inspect mysql1
...
"Mounts": [
            {
                "Type": "volume",
                "Name": "a74fb4e3348635ddc0b3eb32e3f82b4feb38eeadd8d5b3ae60b4389ab83a86d8",
                "Source": "/var/lib/docker/volumes/a74fb4e3348635ddc0b3eb32e3f82b4feb38eeadd8d5b3ae60b4389ab83a86d8/_data",
                "Destination": "/var/lib/mysql",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],
...

输出显示源文件夹
/var/lib/docker/volumes/a74fb4e3348635ddc0b3eb32e3f82b4feb38eeadd8d5b3ae60b4389ab83a86d8/_data将数据持久化到主机上的数据,已经安装在/var/lib/mysql中,容器内的服务器数据目录。

保存数据的另一种方法是在创建容器时使用 –mount 选项挂载主机目录。同样的技术可以用来持久化服务器的配置。
下面的命令创建一个MySQL服务器容器,并将数据目录和服务器配置文件绑定在一起:

docker run --name=mysql1 \
--mount type=bind,src=/path-on-host-machine/my.cnf,dst=/etc/my.cnf \
--mount type=bind,src=/path-on-host-machine/datadir,dst=/var/lib/mysql \
-d mysql/mysql-server:tag

配置文件path-on-host-machine/my.cnf必须存在,同时包含指定的用户:

[mysqld]
user=mysql

path-on-host-machine.datadir目录必须存在。要发生服务器初始化,目录必须是空的。您还可以安装一个带有数据的目录,并使用它启动服务器;但是,您必须确保启动Docker容器,其配置与创建数据的服务器具有相同的配置,并且启动容器时所需的任何主机文件或目录都被安装。

运行额外的初始化脚本
如果您想在创建后立即在数据库上运行任何.sh或.sql脚本,您可以将它们放入主机目录中,然后mount目录在/docker-entrypoint-initdb.d

docker run --name=mysql1 \
--mount type=bind,src=/path-on-host-machine/scripts/,dst=/docker-entrypoint-initdb.d/ \
-d mysql/mysql-server:tag

对于MySQL企业版本服务器容器:

docker run --name=mysql1 \
--mount type=bind,src=/path-on-host-machine/scripts/,dst=/docker-entrypoint-initdb.d/ \
-d store/oracle/mysql-enterprise-server:tag

从另一个Docker容器中的应用程序连接到MySQL
通过建立一个Docker网络,你可以让多个Docker容器相互通信,这样,在另一个Docker容器中的客户端应用程序就可以在服务器容器中访问MySQL服务器。首先,创建一个Docker网络:

docker network create my-custom-net

然后,当您创建并启动服务器和客户端容器时,使用-network选项将它们放在您创建的网络上。例如:

docker run --name=mysql1 --network=my-custom-net -d mysql/mysql-server
docker run --name=myapp1 --network=my-custom-net -d myapp

当使用MySQL企业版本服务器容器:

docker run --name=mysql1 --network=my-custom-net -d store/oracle/mysql-enterprise-server
docker run --name=myapp1 --network=my-custom-net -d myapp

myapp1容器随后可以与mysql1主机连接到mysql1容器,反之亦然,因为Docker会自动为给定的容器名称设置一个DNS。在下面的例子中,我们从myapp1容器中运行mysql客户端,以便在自己的容器中连接主机mysql1:

docker exec -it myapp1 mysql --host=mysql1 --user=myuser --password

windows 7 vs 2013编译与安装MySQL 5.7

操作环境准备
1.在Win7上安装好Visual Studio 2013
2.下载MySQL 5.7.25源代码
3.安装CMake https://cmake.org/ 安装的时候,选择在PATH中加入
4.安装Bison: http://gnuwin32.sourceforge.net/packages/bison.htm 安装路径不要有空格
5.安装perl tool:ActivePerl-5.16.3.1604-MSWin32-x64-298023.msi

为了验证成功,可以执行以下命令:

C:\Users\Administrator>where bison
C:\GnuWin32\bin\bison.exe

C:\Users\Administrator>where cmake
C:\CMake\bin\cmake.exe

C:\Users\Administrator>where perl
C:\Perl64\bin\perl.exe

如果出现找不到,那就自己加path就行了

编译操作如下:
1. MySQL5.7.25的源文件存放在D:\Code_workspace\mysql-5.7.25目录下

D:\Code_workspace\mysql-5.7.25>dir
 驱动器 D 中的卷是 软件
 卷的序列号是 5D84-49C8

 D:\Code_workspace\mysql-5.7.25 的目录

2018-12-21  11:52              .
2018-12-21  11:52              ..
2018-12-21  11:52              BUILD
2018-12-21  11:52              client
2018-12-21  11:52              cmake
2018-12-21  11:39            27,753 CMakeLists.txt
2018-12-21  11:52              cmd-line-utils
2018-12-21  11:39            13,900 config.h.cmake
2018-12-21  11:39            25,850 configure.cmake
2018-12-21  11:39            17,987 COPYING
2018-12-21  11:52              dbug
2018-12-21  11:52              Docs
2018-12-21  11:39            66,241 Doxyfile-perfschema
2018-12-21  11:52              extra
2018-12-21  11:52              include
2018-12-21  11:39               333 INSTALL
2018-12-21  11:52              libbinlogevents
2018-12-21  11:52              libbinlogstandalone
2018-12-21  11:52              libevent
2018-12-21  11:52              libmysql
2018-12-21  11:52              libmysqld
2018-12-21  11:52              libservices
2018-12-21  11:52              man
2018-12-21  11:52              mysql-test
2018-12-21  11:52              mysys
2018-12-21  11:52              mysys_ssl
2018-12-21  11:52              packaging
2018-12-21  11:52              plugin
2018-12-21  11:52              rapid
2018-12-21  11:39             2,478 README
2018-12-21  11:52              regex
2018-12-21  11:52              scripts
2018-12-21  11:52              sql
2018-12-21  11:52              sql-common
2018-12-21  11:52              storage
2018-12-21  11:52              strings
2018-12-21  11:52              support-files
2018-12-21  11:52              testclients
2018-12-21  11:52              unittest
2018-12-21  11:39                88 VERSION
2018-12-21  11:52              vio
2018-12-21  11:52              win
2018-12-21  11:52              zlib
               8 个文件        154,630 字节
              35 个目录 18,364,108,800 可用字节

2.将boost文件存放在D:\Code_workspace\boost_1_59_0目录下

3.创建BLD文件夹并进入该文件夹。

D:\Code_workspace\mysql-5.7.25>mkdir BLD

D:\Code_workspace\mysql-5.7.25>cd BLD

D:\Code_workspace\mysql-5.7.25\BLD>

4.执行下面的命令,会下载boost文件夹,并在BLD文件夹下创建相关的项目文件:

D:\Code_workspace\mysql-5.7.25\BLD>cmake .. -DDOWNLOAD_BOOST=1 -DWITH_BOOST="D:\Code_workspace\boost_1_59_0"
-- Building for: Visual Studio 12 2013
CMake Deprecation Warning at CMakeLists.txt:28 (CMAKE_POLICY):
  The OLD behavior for policy CMP0018 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:34 (CMAKE_POLICY):
  The OLD behavior for policy CMP0022 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:41 (CMAKE_POLICY):
  The OLD behavior for policy CMP0045 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:42 (CMAKE_POLICY):
  The OLD behavior for policy CMP0042 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Running cmake version 3.15.0-rc1
-- Could NOT find Git (missing: GIT_EXECUTABLE)
-- Configuring with MAX_INDEXES = 64U
-- The C compiler identification is MSVC 18.0.21005.1
-- The CXX compiler identification is MSVC 18.0.21005.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_GENERATOR: Visual Studio 12 2013
-- Looking for sys/types.h
CMake Warning (dev) at C:/CMake/share/cmake-3.15/Modules/CheckIncludeFile.cmake:80 (message):
  Policy CMP0075 is not set: Include file check macros honor
  CMAKE_REQUIRED_LIBRARIES.  Run "cmake --help-policy CMP0075" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  CMAKE_REQUIRED_LIBRARIES is set to:

    ws2_32

  For compatibility with CMake 3.11 and below this check is ignoring it.
Call Stack (most recent call first):
  C:/CMake/share/cmake-3.15/Modules/CheckTypeSize.cmake:230 (check_include_file)
  CMakeLists.txt:190 (CHECK_TYPE_SIZE)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void *
-- Check size of void * - done
-- SIZEOF_VOIDP 4
-- MySQL 5.7.25
-- Packaging as: mysql-5.7.25-win32
-- Local boost dir D:/Code_workspace/boost_1_59_0
-- Found D:/Code_workspace/boost_1_59_0/boost/version.hpp
-- BOOST_VERSION_NUMBER is #define BOOST_VERSION 105900
-- BOOST_INCLUDE_DIR D:/Code_workspace/boost_1_59_0
-- Found Threads: TRUE
-- Looking for include file crypt.h
-- Looking for include file crypt.h - not found
-- Looking for getnameinfo
-- Looking for getnameinfo - not found
-- Looking for inet_ntop
-- Looking for inet_ntop - not found
-- Looking for log2
-- Looking for log2 - found
-- Looking for isinf
-- Looking for isinf - found
-- Performing Test HAVE_CXX_ISINF
-- Performing Test HAVE_CXX_ISINF - Success
-- Check size of struct timespec
-- Check size of struct timespec - failed
-- Performing Test HAVE_VISIBILITY_HIDDEN
-- Performing Test HAVE_VISIBILITY_HIDDEN - Success
-- Check size of struct sockaddr_in6
-- Check size of struct sockaddr_in6 - done
-- Check size of struct in6_addr
-- Check size of struct in6_addr - done
-- Performing Test HAVE_IMPLICIT_DEPENDENT_NAME_TYPING
-- Performing Test HAVE_IMPLICIT_DEPENDENT_NAME_TYPING - Success
-- Looking for chown
-- Looking for chown - not found
-- Looking for include file numa.h
-- Looking for include file numa.h - not found
-- Looking for include file numaif.h
-- Looking for include file numaif.h - not found
-- NUMA library missing or required version not available
-- Check size of socklen_t
-- Check size of socklen_t - failed
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Performing Test HAVE_STRINGOP_OVERFLOW
-- Performing Test HAVE_STRINGOP_OVERFLOW - Failed
-- Performing Test HAVE_NO_UNUSED_CONST_VAR
-- Performing Test HAVE_NO_UNUSED_CONST_VAR - Failed
-- Cannot find system sasl libraries.
-- WITH_PROTOBUF=bundled
-- Performing Test HAVE_NO_SIGN_COMPARE
-- Performing Test HAVE_NO_SIGN_COMPARE - Failed
-- Performing Test HAVE_NO_UNUSED_TYPEDEFS
-- Performing Test HAVE_NO_UNUSED_TYPEDEFS - Failed
-- Performing Test HAVE_NO_IGNORED_QUALIFIERS
-- Performing Test HAVE_NO_IGNORED_QUALIFIERS - Failed
-- Performing Test HAVE_NO_RETURN_TYPE
-- Performing Test HAVE_NO_RETURN_TYPE - Failed
-- Performing Test HAVE_NO_UNUSED_FUNCTION
-- Performing Test HAVE_NO_UNUSED_FUNCTION - Failed
-- Performing Test HAVE_MAYBE_UNINITIALIZED
-- Performing Test HAVE_MAYBE_UNINITIALIZED - Failed
-- Performing Test HAVE_UNUSED_BUT_SET
-- Performing Test HAVE_UNUSED_BUT_SET - Failed
-- protobuf version is 2.6
-- Performing Test HAVE_SYS_THREAD_SELFID
-- Performing Test HAVE_SYS_THREAD_SELFID - Failed
-- Performing Test HAVE_SYS_GETTID
-- Performing Test HAVE_SYS_GETTID - Failed
-- Performing Test HAVE_PTHREAD_GETTHREADID_NP
-- Performing Test HAVE_PTHREAD_GETTHREADID_NP - Failed
-- Performing Test HAVE_INTEGER_PTHREAD_SELF
-- Performing Test HAVE_INTEGER_PTHREAD_SELF - Failed
-- Performing Test HAVE_STRINGOP_TRUNCATION
-- Performing Test HAVE_STRINGOP_TRUNCATION - Failed
-- Creating LDAP authentication SASL client library.
--  You need to set WITH_SASL path to build LDAP SASL client authentication plugin.
-- Library mysqlclient depends on OSLIBS ws2_32;Secur32
-- MERGE_CONVENIENCE_LIBRARIES TARGET mysqlclient
-- MERGE_CONVENIENCE_LIBRARIES LIBS clientlib;dbug;strings;vio;mysys;mysys_ssl;zlib;yassl;taocrypt;auth_win_client
-- MERGE_CONVENIENCE_LIBRARIES MYLIBS clientlib;dbug;strings;vio;mysys;mysys_ssl;zlib;yassl;taocrypt;auth_win_client
-- Looking for include file endian.h
-- Looking for include file endian.h - not found
-- Check size of long long
-- Check size of long long - done
-- Check size of long
-- Check size of long - done
-- Check size of int
-- Check size of int - done
-- Check if the system is big endian
-- Searching 16 bit integer
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Performing Test HAVE_CAST_FUNCTION_TYPE
-- Performing Test HAVE_CAST_FUNCTION_TYPE - Failed
-- Using cmake version 3.15.0-rc1
-- Not building NDB
-- Performing Test HAVE_UNUSED_TYPEDEFS
-- Performing Test HAVE_UNUSED_TYPEDEFS - Failed
-- Performing Test HAVE_STRUCT_SOCKADDR_SA_LEN
-- Performing Test HAVE_STRUCT_SOCKADDR_SA_LEN - Failed
-- Performing Test HAVE_STRUCT_IFREQ_IFR_NAME
-- Performing Test HAVE_STRUCT_IFREQ_IFR_NAME - Failed
-- Performing Test HAVE_XDR_OPS_X_PUTINT32
-- Performing Test HAVE_XDR_OPS_X_PUTINT32 - Success
-- Performing Test HAVE_XDR_OPS_X_GETINT32
-- Performing Test HAVE_XDR_OPS_X_GETINT32 - Success
-- Performing Test HAVE___CONST
-- Performing Test HAVE___CONST - Success
-- Performing Test HAVE_RPC_INLINE_T
-- Performing Test HAVE_RPC_INLINE_T - Failed
-- Using Boost headers from D:/Code_workspace/boost_1_59_0
-- Performing Test CXX_HAVE_SIGN_COMPARE
-- Performing Test CXX_HAVE_SIGN_COMPARE - Failed
-- Performing Test CXX_HAVE_UNUSED_VARIABLE
-- Performing Test CXX_HAVE_UNUSED_VARIABLE - Failed
-- MYSQLX - Text log of protobuf messages enabled
-- Performing Test HAVE_UNUSED_PARAMETER
-- Performing Test HAVE_UNUSED_PARAMETER - Failed
-- Googletest was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an https proxy: export https_proxy=http://example.com:80
-- Performing Test HAVE_MISLEADING_INDENTATION
-- Performing Test HAVE_MISLEADING_INDENTATION - Failed
-- Performing Test HAVE_NO_BUILTIN_MEMCMP
-- Performing Test HAVE_NO_BUILTIN_MEMCMP - Success
-- executable target mysqld debug_target D:/Code_workspace/mysql-5.7.25/BLD/sql/Debug/mysqld.exe
-- Library mysqlserver depends on OSLIBS ws2_32
-- MERGE_CONVENIENCE_LIBRARIES TARGET mysqlserver
-- MERGE_CONVENIENCE_LIBRARIES LIBS dbug;strings;regex;mysys;mysys_ssl;vio;zlib;yassl;taocrypt;archive_embedded;blackhole_embedded;csv_embedded;federated_embedded;heap_embedded;inn
obase;lz4_lib;myisam_embedded;myisammrg_embedded;partition_embedded;ngram_parser;sql_embedded
-- MERGE_CONVENIENCE_LIBRARIES MYLIBS dbug;strings;regex;mysys;mysys_ssl;vio;zlib;yassl;taocrypt;archive_embedded;blackhole_embedded;csv_embedded;federated_embedded;heap_embedded;i
nnobase;lz4_lib;myisam_embedded;myisammrg_embedded;partition_embedded;ngram_parser;sql_embedded
-- WIX_DIR WIX_DIR-NOTFOUND path C:\Program Files/WiX Toolset V3.8
-- WIX_DIR WIX_DIR-NOTFOUND path C:\Program Files/WiX Toolset V3.8/bin
-- WIX_DIR WIX_DIR-NOTFOUND path C:\Program Files (x86)/WiX Toolset V3.8
-- WIX_DIR WIX_DIR-NOTFOUND path C:\Program Files (x86)/WiX Toolset V3.8/bin
-- WIX_DIR WIX_DIR-NOTFOUND looked at
-- Cannot find wix 3, installer project will not be generated
-- COMPILE_DEFINITIONS: _WIN32_WINNT=0x0601;WIN32_LEAN_AND_MEAN;NOGDI;NOMINMAX;BOOST_GEOMETRY_SQRT_CHECK_FINITENESS;HAVE_CONFIG_H;HAVE_LIBEVENT1
-- CMAKE_C_FLAGS: /DWIN32 /D_WINDOWS /W3 /MP /wd4800 /wd4805 /wd4996
-- CMAKE_CXX_FLAGS: /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MP /wd4800 /wd4805 /wd4996 /we4099
-- CMAKE_C_LINK_FLAGS:
-- CMAKE_CXX_LINK_FLAGS:
-- CMAKE_C_FLAGS_DEBUG: /MDd /Z7 /Ob1 /Od /RTC1 /EHsc -DENABLED_DEBUG_SYNC -DSAFE_MUTEX
-- CMAKE_CXX_FLAGS_DEBUG: /MDd /Z7 /Ob1 /Od /RTC1 /EHsc -DENABLED_DEBUG_SYNC -DSAFE_MUTEX
-- CMAKE_C_FLAGS_RELWITHDEBINFO: /MD /Z7 /O2 /Ob1 /DNDEBUG /EHsc -DDBUG_OFF
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: /MD /Z7 /O2 /Ob1 /DNDEBUG /EHsc -DDBUG_OFF
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Code_workspace/mysql-5.7.25/BLD

D:\Code_workspace\mysql-5.7.25\BLD>

如果是编译64位,需要加参数 cmake .. –G “Visual Studio 12 2013 Win64”

5.打开sql\sql_locale.cc文件,用UTF-8的格式,再保存一遍,否则编译会出错。

6.运行下面的命令开始编译源码

D:\Code_workspace\mysql-5.7.25\BLD>cmake --build . --config relwithdebinfo --target package
........
     正在创建库 D:/Code_workspace/mysql-5.7.25/BLD/sql/RelWithDebInfo/udf_example.lib 和对象 D:/Code_workspace/mysql-5.7.25/BLD/sql/RelWithDebInfo/udf_example.exp
  udf_example.vcxproj -> D:\Code_workspace\mysql-5.7.25\BLD\sql\RelWithDebInfo\udf_example.dll
  Building Custom Rule D:/Code_workspace/mysql-5.7.25/plugin/password_validation/CMakeLists.txt
  validate_password.cc
     正在创建库 D:/Code_workspace/mysql-5.7.25/BLD/plugin/password_validation/RelWithDebInfo/validate_password.lib 和对象 D:/Code_workspace/mysql-5.7.25/BLD/plugin/password_validat
ion/Rel
  WithDebInfo/validate_password.exp
  validate_password.vcxproj -> D:\Code_workspace\mysql-5.7.25\BLD\plugin\password_validation\RelWithDebInfo\validate_password.dll
  Building Custom Rule D:/Code_workspace/mysql-5.7.25/plugin/version_token/CMakeLists.txt
  version_token.cc
     正在创建库 D:/Code_workspace/mysql-5.7.25/BLD/plugin/version_token/RelWithDebInfo/version_token.lib 和对象 D:/Code_workspace/mysql-5.7.25/BLD/plugin/version_token/RelWithDebIn
fo/vers
  ion_token.exp
  version_token.vcxproj -> D:\Code_workspace\mysql-5.7.25\BLD\plugin\version_token\RelWithDebInfo\version_token.dll
  Building Custom Rule D:/Code_workspace/mysql-5.7.25/extra/CMakeLists.txt
  zlib_decompress.cc
  zlib_decompress.vcxproj -> D:\Code_workspace\mysql-5.7.25\BLD\extra\RelWithDebInfo\zlib_decompress.exe
  Building Custom Rule D:/Code_workspace/mysql-5.7.25/CMakeLists.txt
  CPack: Create package using ZIP
  CPack: Install projects
  CPack: - Install project: MySQL
  CPack: Create package
  CPack: - package: D:/Code_workspace/mysql-5.7.25/BLD/mysql-5.7.25-win32.zip generated.

在文件夹中,有MySQL文件夹和winzip包产生:

D:\Code_workspace\mysql-5.7.25\BLD\_CPack_Packages\win32\ZIP>dir
 驱动器 D 中的卷是 软件
 卷的序列号是 5D84-49C8

 D:\Code_workspace\mysql-5.7.25\BLD\_CPack_Packages\win32\ZIP 的目录

2019-06-13  23:26              .
2019-06-13  23:26              ..
2019-06-13  23:25              mysql-5.7.25-win32
2019-06-13  23:26       426,298,188 mysql-5.7.25-win32.zip
               1 个文件    426,298,188 字节
               3 个目录  6,277,496,832 可用字节

下面使用自己编译的安装包来进行安装
1.将生成的安装包mysql-5.7.25-win32.zip解压D:\mysql-5.7.25-win32目录中,

2.在D:\mysql-5.7.25-win32目录中创建一个data目录用来存放数据文件

3.在mysql-5.7.25-win32根目录下创建my.ini文件添加以下内容

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4

[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=D:\mysql-5.7.25-win32
# 设置 mysql数据库的数据的存放目录
datadir=D:\mysql-5.7.25-win32\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
explicit_defaults_for_timestamp=true
log-error=D:\mysql-5.7.25-win32\mysql.err
pid-file=D:\mysql-5.7.25-win32\mysqld.pid
socket =D:\mysql-5.7.25-win32\mysql.sock

4.文件目录切换至cmd所在路径(C:\Windows\System32\cmd.exe),右键以管理员身份运行cmd.exe,命令行进入mysql的bin目录,初始化数据库文件

C:\Users\Administrator>D:

D:\>cd D:\mysql-5.7.25-win32\bin

D:\mysql-5.7.25-win32\bin>mysqld --defaults-file=D:\mysql-5.7.25-win32\my.ini  -
-initialize

D:\mysql-5.7.25-win32\bin>

5.初始化成功后会在my.ini配置文件的datadir的目录下生成一些文件,其中mysql.err文件里说明了root账户的临时密码。例如:)CRHHke1mik=就是root账户的临时密码

2019-06-14T02:21:39.232301Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-06-14T02:21:39.335307Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-06-14T02:21:39.388310Z 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: 2447abd5-8e4b-11e9-81b2-00505683446c.
2019-06-14T02:21:39.395311Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-06-14T02:21:39.442313Z 1 [Note] A temporary password is generated for root@localhost: )CRHHke1mik=

6.注册MySQL服务

D:\mysql-5.7.25-win32\bin>mysqld -install MySQL
Service successfully installed.

7.启动MySQL服务

C:\Users\Administrator>net start MySQL
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

8.使用root账号登录MySQL数据库

D:\mysql-5.7.25-win32\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.25

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement befo
re executing this statement.
mysql>

9.修改root用户密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)

10.使用修改后的密码进行登录

D:\mysql-5.7.25-win32\bin>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.25 Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

到此使用vs2013编译的MySQL源码在Win7上安装完成了。

在Oracle Linux 7.1上安装Docker

在Oracle Linux 7.1上安装Docker
1.首先使用正确的yum设置来升级Oracle Linux 7.1实例。为了安装最新的Docker版本(18.9.1.ce),需要ol7_latest,ol7_uekr4与ol7_addons启用

[root@localhost /]# cd /etc/yum.repos.d/
[root@localhost /]#wget http://yum.oracle.com/public-yum-ol7.repo
[root@localhost yum.repos.d]# vi public-yum-ol7.repo
[ol7_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/latest/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

[ol7_UEKR4]
name=Latest Unbreakable Enterprise Kernel Release 4 for Oracle Linux $releasever ($basearch)
baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/UEKR4/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

[ol7_addons]
name=Oracle Linux $releasever Add ons ($basearch)
baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/addons/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

2.开始安装docker

[root@localhost yum.repos.d]# yum install docker-engine
Loaded plugins: langpacks
ol7_UEKR4                                                                                                                                                                                                            | 2.5 kB  00:00:00
ol7_addons                                                                                                                                                                                                           | 1.2 kB  00:00:00
ol7_latest                                                                                                                                                                                                           | 2.7 kB  00:00:00
(1/4): ol7_addons/x86_64/updateinfo                                                                                                                                                                                  |  60 kB  00:00:00
(2/4): ol7_UEKR4/x86_64/updateinfo                                                                                                                                                                                   |  82 kB  00:00:01
(3/4): ol7_addons/x86_64/primary                                                                                                                                                                                     |  82 kB  00:00:02
(4/4): ol7_UEKR4/x86_64/primary_db                                                                                                                                                                                   | 4.0 MB  00:03:38
ol7_addons                                                                                                                                                                                                                          328/328
Resolving Dependencies
--> Running transaction check
---> Package docker-engine.x86_64 0:18.09.1.ol-1.0.5.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.77 for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Processing Dependency: libseccomp >= 2.3 for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Processing Dependency: containerd for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Processing Dependency: docker-cli for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Processing Dependency: runc for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_97)(64bit) for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Processing Dependency: libsystemd.so.0(LIBSYSTEMD_209)(64bit) for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Processing Dependency: libsystemd.so.0()(64bit) for package: docker-engine-18.09.1.ol-1.0.5.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.77-5.el7 will be installed
--> Processing Dependency: selinux-policy-base >= 3.13.1-216.el7 for package: 2:container-selinux-2.77-5.el7.noarch
--> Processing Dependency: selinux-policy >= 3.13.1-216.el7 for package: 2:container-selinux-2.77-5.el7.noarch
--> Processing Dependency: policycoreutils >= 2.5-11 for package: 2:container-selinux-2.77-5.el7.noarch
--> Processing Dependency: selinux-policy-targeted >= 3.13.1-216.el7 for package: 2:container-selinux-2.77-5.el7.noarch
---> Package containerd.x86_64 0:1.2.0-1.0.5.el7 will be installed
---> Package device-mapper-libs.x86_64 7:1.02.93-3.el7 will be updated
--> Processing Dependency: device-mapper-libs = 7:1.02.93-3.el7 for package: 7:device-mapper-1.02.93-3.el7.x86_64
---> Package device-mapper-libs.x86_64 7:1.02.149-10.0.3.el7_6.8 will be an update
---> Package docker-cli.x86_64 0:18.09.1.ol-1.0.5.el7 will be installed
---> Package libseccomp.x86_64 0:2.1.1-2.el7 will be updated
---> Package libseccomp.x86_64 0:2.3.1-3.el7 will be an update
---> Package runc.x86_64 0:1.0.0-19.rc5.git4bb1fe4.0.3.el7 will be installed
--> Processing Dependency: criu for package: runc-1.0.0-19.rc5.git4bb1fe4.0.3.el7.x86_64
---> Package systemd-libs.x86_64 0:208-20.0.1.el7 will be updated
--> Processing Dependency: systemd-libs = 208-20.0.1.el7 for package: systemd-208-20.0.1.el7.x86_64
---> Package systemd-libs.x86_64 0:219-62.0.4.el7_6.7 will be an update
--> Processing Dependency: liblz4.so.1()(64bit) for package: systemd-libs-219-62.0.4.el7_6.7.x86_64
--> Running transaction check
---> Package criu.x86_64 0:3.9-5.el7 will be installed
--> Processing Dependency: libprotobuf-c.so.1(LIBPROTOBUF_C_1.0.0)(64bit) for package: criu-3.9-5.el7.x86_64
--> Processing Dependency: libnl-3.so.200(libnl_3)(64bit) for package: criu-3.9-5.el7.x86_64
--> Processing Dependency: libprotobuf-c.so.1()(64bit) for package: criu-3.9-5.el7.x86_64
--> Processing Dependency: libnet.so.1()(64bit) for package: criu-3.9-5.el7.x86_64
---> Package device-mapper.x86_64 7:1.02.93-3.el7 will be updated
--> Processing Dependency: device-mapper = 7:1.02.93-3.el7 for package: 7:device-mapper-event-1.02.93-3.el7.x86_64
---> Package device-mapper.x86_64 7:1.02.149-10.0.3.el7_6.8 will be an update
---> Package lz4.x86_64 0:1.7.5-2.0.1.el7 will be installed
---> Package policycoreutils.x86_64 0:2.2.5-15.0.1.el7 will be updated
--> Processing Dependency: policycoreutils = 2.2.5-15.0.1.el7 for package: policycoreutils-python-2.2.5-15.0.1.el7.x86_64
---> Package policycoreutils.x86_64 0:2.5-29.0.1.el7_6.1 will be an update
--> Processing Dependency: libsemanage >= 2.5-14 for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64
--> Processing Dependency: libsepol >= 2.5-10 for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64
--> Processing Dependency: libselinux-utils >= 2.5-14 for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64
--> Processing Dependency: libsepol.so.1(LIBSEPOL_1.1)(64bit) for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64
--> Processing Dependency: libsemanage.so.1(LIBSEMANAGE_1.1)(64bit) for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64
--> Processing Dependency: libsepol.so.1(LIBSEPOL_1.0)(64bit) for package: policycoreutils-2.5-29.0.1.el7_6.1.x86_64
---> Package selinux-policy.noarch 0:3.13.1-23.0.1.el7 will be updated
---> Package selinux-policy.noarch 0:3.13.1-229.0.3.el7_6.12 will be an update
---> Package selinux-policy-targeted.noarch 0:3.13.1-23.0.1.el7 will be updated
---> Package selinux-policy-targeted.noarch 0:3.13.1-229.0.3.el7_6.12 will be an update
---> Package systemd.x86_64 0:208-20.0.1.el7 will be updated
--> Processing Dependency: systemd = 208-20.0.1.el7 for package: libgudev1-208-20.0.1.el7.x86_64
--> Processing Dependency: systemd = 208-20.0.1.el7 for package: systemd-sysv-208-20.0.1.el7.x86_64
--> Processing Dependency: systemd = 208-20.0.1.el7 for package: systemd-python-208-20.0.1.el7.x86_64
---> Package systemd.x86_64 0:219-62.0.4.el7_6.7 will be an update
--> Processing Dependency: kmod >= 18-4 for package: systemd-219-62.0.4.el7_6.7.x86_64
--> Processing Dependency: libcryptsetup.so.12(CRYPTSETUP_2.0)(64bit) for package: systemd-219-62.0.4.el7_6.7.x86_64
--> Processing Dependency: libcryptsetup.so.12()(64bit) for package: systemd-219-62.0.4.el7_6.7.x86_64
--> Running transaction check
---> Package cryptsetup-libs.x86_64 0:1.6.6-3.el7 will be updated
--> Processing Dependency: cryptsetup-libs = 1.6.6-3.el7 for package: cryptsetup-python-1.6.6-3.el7.x86_64
--> Processing Dependency: cryptsetup-libs(x86-64) = 1.6.6-3.el7 for package: cryptsetup-1.6.6-3.el7.x86_64
---> Package cryptsetup-libs.x86_64 0:2.0.3-3.el7 will be an update
---> Package device-mapper-event.x86_64 7:1.02.93-3.el7 will be updated
--> Processing Dependency: device-mapper-event = 7:1.02.93-3.el7 for package: 7:lvm2-libs-2.02.115-3.el7.x86_64
---> Package device-mapper-event.x86_64 7:1.02.149-10.0.3.el7_6.8 will be an update
--> Processing Dependency: device-mapper-event-libs = 7:1.02.149-10.0.3.el7_6.8 for package: 7:device-mapper-event-1.02.149-10.0.3.el7_6.8.x86_64
---> Package kmod.x86_64 0:14-10.el7 will be updated
---> Package kmod.x86_64 0:20-23.0.1.el7 will be an update
---> Package libgudev1.x86_64 0:208-20.0.1.el7 will be updated
---> Package libgudev1.x86_64 0:219-62.0.4.el7_6.7 will be an update
--> Processing Dependency: glib2 >= 2.42 for package: libgudev1-219-62.0.4.el7_6.7.x86_64
---> Package libnet.x86_64 0:1.1.6-7.el7 will be installed
---> Package libnl3.x86_64 0:3.2.21-8.0.1.el7 will be updated
--> Processing Dependency: libnl3 = 3.2.21-8.0.1.el7 for package: libnl3-cli-3.2.21-8.0.1.el7.x86_64
---> Package libnl3.x86_64 0:3.2.28-4.el7 will be an update
---> Package libselinux-utils.x86_64 0:2.2.2-6.el7 will be updated
---> Package libselinux-utils.x86_64 0:2.5-14.1.el7 will be an update
--> Processing Dependency: libselinux(x86-64) = 2.5-14.1.el7 for package: libselinux-utils-2.5-14.1.el7.x86_64
---> Package libsemanage.x86_64 0:2.1.10-16.el7 will be updated
--> Processing Dependency: libsemanage = 2.1.10-16.el7 for package: libsemanage-python-2.1.10-16.el7.x86_64
---> Package libsemanage.x86_64 0:2.5-14.el7 will be an update
---> Package libsepol.x86_64 0:2.1.9-3.el7 will be updated
---> Package libsepol.x86_64 0:2.5-10.el7 will be an update
---> Package policycoreutils-python.x86_64 0:2.2.5-15.0.1.el7 will be updated
---> Package policycoreutils-python.x86_64 0:2.5-29.0.1.el7_6.1 will be an update
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-29.0.1.el7_6.1.x86_64
---> Package protobuf-c.x86_64 0:1.0.2-3.el7 will be installed
---> Package systemd-python.x86_64 0:208-20.0.1.el7 will be updated
---> Package systemd-python.x86_64 0:219-62.0.4.el7_6.7 will be an update
---> Package systemd-sysv.x86_64 0:208-20.0.1.el7 will be updated
---> Package systemd-sysv.x86_64 0:219-62.0.4.el7_6.7 will be an update
--> Running transaction check
---> Package cryptsetup.x86_64 0:1.6.6-3.el7 will be updated
---> Package cryptsetup.x86_64 0:2.0.3-3.el7 will be an update
---> Package cryptsetup-python.x86_64 0:1.6.6-3.el7 will be updated
---> Package cryptsetup-python.x86_64 0:2.0.3-3.el7 will be an update
---> Package device-mapper-event-libs.x86_64 7:1.02.93-3.el7 will be updated
---> Package device-mapper-event-libs.x86_64 7:1.02.149-10.0.3.el7_6.8 will be an update
---> Package glib2.x86_64 0:2.40.0-4.el7 will be updated
---> Package glib2.x86_64 0:2.56.1-4.el7_6 will be an update
---> Package libnl3-cli.x86_64 0:3.2.21-8.0.1.el7 will be updated
---> Package libnl3-cli.x86_64 0:3.2.28-4.el7 will be an update
---> Package libselinux.x86_64 0:2.2.2-6.el7 will be updated
--> Processing Dependency: libselinux = 2.2.2-6.el7 for package: libselinux-python-2.2.2-6.el7.x86_64
---> Package libselinux.x86_64 0:2.5-14.1.el7 will be an update
---> Package libsemanage-python.x86_64 0:2.1.10-16.el7 will be updated
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be an update
---> Package lvm2-libs.x86_64 7:2.02.115-3.el7 will be updated
--> Processing Dependency: lvm2-libs = 7:2.02.115-3.el7 for package: 7:lvm2-2.02.115-3.el7.x86_64
--> Processing Dependency: lvm2-libs = 7:2.02.115-3.el7 for package: 7:lvm2-python-libs-2.02.115-3.el7.x86_64
---> Package lvm2-libs.x86_64 7:2.02.180-10.0.3.el7_6.8 will be an update
---> Package setools-libs.x86_64 0:3.3.7-46.el7 will be updated
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be an update
--> Running transaction check
---> Package libselinux-python.x86_64 0:2.2.2-6.el7 will be updated
---> Package libselinux-python.x86_64 0:2.5-14.1.el7 will be an update
---> Package lvm2.x86_64 7:2.02.115-3.el7 will be updated
---> Package lvm2.x86_64 7:2.02.180-10.0.3.el7_6.8 will be an update
--> Processing Dependency: device-mapper-persistent-data >= 0.7.0-0.1.rc6 for package: 7:lvm2-2.02.180-10.0.3.el7_6.8.x86_64
---> Package lvm2-python-libs.x86_64 7:2.02.115-3.el7 will be updated
---> Package lvm2-python-libs.x86_64 7:2.02.180-10.0.3.el7_6.8 will be an update
--> Running transaction check
---> Package device-mapper-persistent-data.x86_64 0:0.4.1-2.el7 will be updated
---> Package device-mapper-persistent-data.x86_64 0:0.7.3-3.el7 will be an update
--> Processing Conflict: systemd-219-62.0.4.el7_6.7.x86_64 conflicts initscripts < 9.49.28-1
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package initscripts.x86_64 0:9.49.24-1.0.1.el7 will be updated
---> Package initscripts.x86_64 0:9.49.46-1.0.1.el7 will be an update
--> Processing Conflict: initscripts-9.49.46-1.0.1.el7.x86_64 conflicts redhat-release < 7.5-0.11
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package redhat-release-server.x86_64 1:7.1-1.0.2.el7 will be updated
---> Package redhat-release-server.x86_64 1:7.6-4.0.1.el7 will be an update
--> Processing Conflict: initscripts-9.49.46-1.0.1.el7.x86_64 conflicts oraclelinux-release < 7:7.5-1.0.3
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package oraclelinux-release.x86_64 7:7.1-1.0.5.el7 will be updated
---> Package oraclelinux-release.x86_64 7:7.6-1.0.15.el7 will be an update
--> Processing Conflict: systemd-219-62.0.4.el7_6.7.x86_64 conflicts dracut < 033-243
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package dracut.x86_64 0:033-240.0.1.el7 will be updated
--> Processing Dependency: dracut = 033-240.0.1.el7 for package: dracut-config-rescue-033-240.0.1.el7.x86_64
--> Processing Dependency: dracut = 033-240.0.1.el7 for package: dracut-network-033-240.0.1.el7.x86_64
---> Package dracut.x86_64 0:033-554.0.3.el7 will be an update
--> Running transaction check
---> Package dracut-config-rescue.x86_64 0:033-240.0.1.el7 will be updated
---> Package dracut-config-rescue.x86_64 0:033-554.0.3.el7 will be an update
---> Package dracut-network.x86_64 0:033-240.0.1.el7 will be updated
---> Package dracut-network.x86_64 0:033-554.0.3.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================================================
 Package                                                            Arch                                        Version                                                               Repository                                       Size
============================================================================================================================================================================================================================================
Installing:
 docker-engine                                                      x86_64                                      18.09.1.ol-1.0.5.el7                                                  ol7_addons                                       19 M
Updating:
 dracut                                                             x86_64                                      033-554.0.3.el7                                                       ol7_latest                                      328 k
 initscripts                                                        x86_64                                      9.49.46-1.0.1.el7                                                     ol7_latest                                      439 k
 oraclelinux-release                                                x86_64                                      7:7.6-1.0.15.el7                                                      ol7_latest                                       54 k
 redhat-release-server                                              x86_64                                      1:7.6-4.0.1.el7                                                       ol7_latest                                      9.8 k
Installing for dependencies:
 container-selinux                                                  noarch                                      2:2.77-5.el7                                                          ol7_addons                                       37 k
 containerd                                                         x86_64                                      1.2.0-1.0.5.el7                                                       ol7_addons                                       21 M
 criu                                                               x86_64                                      3.9-5.el7                                                             ol7_latest                                      432 k
 docker-cli                                                         x86_64                                      18.09.1.ol-1.0.5.el7                                                  ol7_addons                                       14 M
 libnet                                                             x86_64                                      1.1.6-7.el7                                                           ol7_latest                                       57 k
 lz4                                                                x86_64                                      1.7.5-2.0.1.el7                                                       ol7_latest                                       98 k
 protobuf-c                                                         x86_64                                      1.0.2-3.el7                                                           ol7_latest                                       27 k
 runc                                                               x86_64                                      1.0.0-19.rc5.git4bb1fe4.0.3.el7                                       ol7_addons                                      1.9 M
Updating for dependencies:
 cryptsetup                                                         x86_64                                      2.0.3-3.el7                                                           ol7_latest                                      153 k
 cryptsetup-libs                                                    x86_64                                      2.0.3-3.el7                                                           ol7_latest                                      337 k
 cryptsetup-python                                                  x86_64                                      2.0.3-3.el7                                                           ol7_latest                                       35 k
 device-mapper                                                      x86_64                                      7:1.02.149-10.0.3.el7_6.8                                             ol7_latest                                      293 k
 device-mapper-event                                                x86_64                                      7:1.02.149-10.0.3.el7_6.8                                             ol7_latest                                      188 k
 device-mapper-event-libs                                           x86_64                                      7:1.02.149-10.0.3.el7_6.8                                             ol7_latest                                      188 k
 device-mapper-libs                                                 x86_64                                      7:1.02.149-10.0.3.el7_6.8                                             ol7_latest                                      320 k
 device-mapper-persistent-data                                      x86_64                                      0.7.3-3.el7                                                           ol7_latest                                      404 k
 dracut-config-rescue                                               x86_64                                      033-554.0.3.el7                                                       ol7_latest                                       60 k
 dracut-network                                                     x86_64                                      033-554.0.3.el7                                                       ol7_latest                                      102 k
 glib2                                                              x86_64                                      2.56.1-4.el7_6                                                        ol7_latest                                      2.5 M
 kmod                                                               x86_64                                      20-23.0.1.el7                                                         ol7_latest                                      121 k
 libgudev1                                                          x86_64                                      219-62.0.4.el7_6.7                                                    ol7_latest                                       96 k
 libnl3                                                             x86_64                                      3.2.28-4.el7                                                          ol7_latest                                      277 k
 libnl3-cli                                                         x86_64                                      3.2.28-4.el7                                                          ol7_latest                                      159 k
 libseccomp                                                         x86_64                                      2.3.1-3.el7                                                           ol7_latest                                       55 k
 libselinux                                                         x86_64                                      2.5-14.1.el7                                                          ol7_latest                                      162 k
 libselinux-python                                                  x86_64                                      2.5-14.1.el7                                                          ol7_latest                                      235 k
 libselinux-utils                                                   x86_64                                      2.5-14.1.el7                                                          ol7_latest                                      151 k
 libsemanage                                                        x86_64                                      2.5-14.el7                                                            ol7_latest                                      150 k
 libsemanage-python                                                 x86_64                                      2.5-14.el7                                                            ol7_latest                                      112 k
 libsepol                                                           x86_64                                      2.5-10.el7                                                            ol7_latest                                      297 k
 lvm2                                                               x86_64                                      7:2.02.180-10.0.3.el7_6.8                                             ol7_latest                                      1.3 M
 lvm2-libs                                                          x86_64                                      7:2.02.180-10.0.3.el7_6.8                                             ol7_latest                                      1.1 M
 lvm2-python-libs                                                   x86_64                                      7:2.02.180-10.0.3.el7_6.8                                             ol7_latest                                      186 k
 policycoreutils                                                    x86_64                                      2.5-29.0.1.el7_6.1                                                    ol7_latest                                      916 k
 policycoreutils-python                                             x86_64                                      2.5-29.0.1.el7_6.1                                                    ol7_latest                                      455 k
 selinux-policy                                                     noarch                                      3.13.1-229.0.3.el7_6.12                                               ol7_latest                                      484 k
 selinux-policy-targeted                                            noarch                                      3.13.1-229.0.3.el7_6.12                                               ol7_latest                                      6.9 M
 setools-libs                                                       x86_64                                      3.3.8-4.el7                                                           ol7_latest                                      620 k
 systemd                                                            x86_64                                      219-62.0.4.el7_6.7                                                    ol7_latest                                      5.1 M
 systemd-libs                                                       x86_64                                      219-62.0.4.el7_6.7                                                    ol7_latest                                      407 k
 systemd-python                                                     x86_64                                      219-62.0.4.el7_6.7                                                    ol7_latest                                      133 k
 systemd-sysv                                                       x86_64                                      219-62.0.4.el7_6.7                                                    ol7_latest                                       84 k

Transaction Summary
============================================================================================================================================================================================================================================
Install  1 Package  (+ 8 Dependent packages)
Upgrade  4 Packages (+34 Dependent packages)

Total download size: 81 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for ol7_latest
warning: /var/cache/yum/x86_64/7Server/ol7_latest/packages/cryptsetup-2.0.3-3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY                                                      ] 373 kB/s | 1.6 MB  00:03:39 ETA
Public key for cryptsetup-2.0.3-3.el7.x86_64.rpm is not installed
(1/47): cryptsetup-2.0.3-3.el7.x86_64.rpm                                                                                                                                                                            | 153 kB  00:00:04
(2/47): criu-3.9-5.el7.x86_64.rpm                                                                                                                                                                                    | 432 kB  00:00:04
Public key for container-selinux-2.77-5.el7.noarch.rpm is not installed
(3/47): container-selinux-2.77-5.el7.noarch.rpm                                                                                                                                                                      |  37 kB  00:00:04
(4/47): cryptsetup-python-2.0.3-3.el7.x86_64.rpm                                                                                                                                                                     |  35 kB  00:00:00
(5/47): cryptsetup-libs-2.0.3-3.el7.x86_64.rpm                                                                                                                                                                       | 337 kB  00:00:01
(6/47): device-mapper-event-1.02.149-10.0.3.el7_6.8.x86_64.rpm                                                                                                                                                       | 188 kB  00:00:00
(7/47): device-mapper-1.02.149-10.0.3.el7_6.8.x86_64.rpm                                                                                                                                                             | 293 kB  00:00:01
(8/47): device-mapper-event-libs-1.02.149-10.0.3.el7_6.8.x86_64.rpm                                                                                                                                                  | 188 kB  00:00:00
(9/47): device-mapper-persistent-data-0.7.3-3.el7.x86_64.rpm                                                                                                                                                         | 404 kB  00:00:00
(10/47): device-mapper-libs-1.02.149-10.0.3.el7_6.8.x86_64.rpm                                                                                                                                                       | 320 kB  00:00:02
(11/47): containerd-1.2.0-1.0.5.el7.x86_64.rpm                                                                                                                                                                       |  21 MB  00:00:13
(12/47): dracut-config-rescue-033-554.0.3.el7.x86_64.rpm                                                                                                                                                             |  60 kB  00:00:01
(13/47): dracut-network-033-554.0.3.el7.x86_64.rpm                                                                                                                                                                   | 102 kB  00:00:00
(14/47): dracut-033-554.0.3.el7.x86_64.rpm                                                                                                                                                                           | 328 kB  00:00:02
(15/47): initscripts-9.49.46-1.0.1.el7.x86_64.rpm                                                                                                                                                                    | 439 kB  00:00:00
(16/47): kmod-20-23.0.1.el7.x86_64.rpm                                                                                                                                                                               | 121 kB  00:00:00
(17/47): libgudev1-219-62.0.4.el7_6.7.x86_64.rpm                                                                                                                                                                     |  96 kB  00:00:00
(18/47): glib2-2.56.1-4.el7_6.x86_64.rpm                                                                                                                                                                             | 2.5 MB  00:00:02
(19/47): libnl3-3.2.28-4.el7.x86_64.rpm                                                                                                                                                                              | 277 kB  00:00:00
(20/47): docker-cli-18.09.1.ol-1.0.5.el7.x86_64.rpm                                                                                                                                                                  |  14 MB  00:00:12
(21/47): libnet-1.1.6-7.el7.x86_64.rpm                                                                                                                                                                               |  57 kB  00:00:01
(22/47): libseccomp-2.3.1-3.el7.x86_64.rpm                                                                                                                                                                           |  55 kB  00:00:00
(23/47): libselinux-2.5-14.1.el7.x86_64.rpm                                                                                                                                                                          | 162 kB  00:00:00
(24/47): libnl3-cli-3.2.28-4.el7.x86_64.rpm                                                                                                                                                                          | 159 kB  00:00:00
(25/47): libselinux-python-2.5-14.1.el7.x86_64.rpm                                                                                                                                                                   | 235 kB  00:00:00
(26/47): libselinux-utils-2.5-14.1.el7.x86_64.rpm                                                                                                                                                                    | 151 kB  00:00:00
(27/47): libsemanage-python-2.5-14.el7.x86_64.rpm                                                                                                                                                                    | 112 kB  00:00:00
(28/47): libsemanage-2.5-14.el7.x86_64.rpm                                                                                                                                                                           | 150 kB  00:00:00
(29/47): libsepol-2.5-10.el7.x86_64.rpm                                                                                                                                                                              | 297 kB  00:00:00
(30/47): lvm2-2.02.180-10.0.3.el7_6.8.x86_64.rpm                                                                                                                                                                     | 1.3 MB  00:00:00
(31/47): lvm2-python-libs-2.02.180-10.0.3.el7_6.8.x86_64.rpm                                                                                                                                                         | 186 kB  00:00:00
(32/47): lvm2-libs-2.02.180-10.0.3.el7_6.8.x86_64.rpm                                                                                                                                                                | 1.1 MB  00:00:01
(33/47): lz4-1.7.5-2.0.1.el7.x86_64.rpm                                                                                                                                                                              |  98 kB  00:00:00
(34/47): oraclelinux-release-7.6-1.0.15.el7.x86_64.rpm                                                                                                                                                               |  54 kB  00:00:00
(35/47): policycoreutils-2.5-29.0.1.el7_6.1.x86_64.rpm                                                                                                                                                               | 916 kB  00:00:00
(36/47): policycoreutils-python-2.5-29.0.1.el7_6.1.x86_64.rpm                                                                                                                                                        | 455 kB  00:00:00
(37/47): redhat-release-server-7.6-4.0.1.el7.x86_64.rpm                                                                                                                                                              | 9.8 kB  00:00:00
(38/47): docker-engine-18.09.1.ol-1.0.5.el7.x86_64.rpm                                                                                                                                                               |  19 MB  00:00:10
(39/47): selinux-policy-3.13.1-229.0.3.el7_6.12.noarch.rpm                                                                                                                                                           | 484 kB  00:00:00
(40/47): protobuf-c-1.0.2-3.el7.x86_64.rpm                                                                                                                                                                           |  27 kB  00:00:02
(41/47): setools-libs-3.3.8-4.el7.x86_64.rpm                                                                                                                                                                         | 620 kB  00:00:00
(42/47): runc-1.0.0-19.rc5.git4bb1fe4.0.3.el7.x86_64.rpm                                                                                                                                                             | 1.9 MB  00:00:04
(43/47): selinux-policy-targeted-3.13.1-229.0.3.el7_6.12.noarch.rpm                                                                                                                                                  | 6.9 MB  00:00:03
(44/47): systemd-libs-219-62.0.4.el7_6.7.x86_64.rpm                                                                                                                                                                  | 407 kB  00:00:00
(45/47): systemd-python-219-62.0.4.el7_6.7.x86_64.rpm                                                                                                                                                                | 133 kB  00:00:00
(46/47): systemd-sysv-219-62.0.4.el7_6.7.x86_64.rpm                                                                                                                                                                  |  84 kB  00:00:00
(47/47): systemd-219-62.0.4.el7_6.7.x86_64.rpm                                                                                                                                                                       | 5.1 MB  00:00:04
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                       2.8 MB/s |  81 MB  00:00:29
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Importing GPG key 0xEC551F03:
 Userid     : "Oracle OSS group (Open Source Software group) "
 Fingerprint: 4214 4123 fecf c55b 9086 313d 72f9 7b74 ec55 1f03
 Package    : 7:oraclelinux-release-7.1-1.0.5.el7.x86_64 (@anaconda/7.1)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libsepol-2.5-10.el7.x86_64                                                                                                                                                                                              1/85
  Updating   : libselinux-2.5-14.1.el7.x86_64                                                                                                                                                                                          2/85
  Updating   : libsemanage-2.5-14.el7.x86_64                                                                                                                                                                                           3/85
  Installing : lz4-1.7.5-2.0.1.el7.x86_64                                                                                                                                                                                              4/85
  Updating   : systemd-libs-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                  5/85
  Updating   : 1:redhat-release-server-7.6-4.0.1.el7.x86_64                                                                                                                                                                            6/85
  Updating   : cryptsetup-libs-2.0.3-3.el7.x86_64                                                                                                                                                                                      7/85
  Updating   : 7:device-mapper-libs-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                                     8/85
  Updating   : 7:device-mapper-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                                          9/85
  Updating   : systemd-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                      10/85
  Updating   : dracut-033-554.0.3.el7.x86_64                                                                                                                                                                                          11/85
  Updating   : kmod-20-23.0.1.el7.x86_64                                                                                                                                                                                              12/85
  Updating   : 7:device-mapper-event-libs-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                              13/85
  Updating   : libseccomp-2.3.1-3.el7.x86_64                                                                                                                                                                                          14/85
  Updating   : glib2-2.56.1-4.el7_6.x86_64                                                                                                                                                                                            15/85
  Updating   : libselinux-utils-2.5-14.1.el7.x86_64                                                                                                                                                                                   16/85
  Updating   : policycoreutils-2.5-29.0.1.el7_6.1.x86_64                                                                                                                                                                              17/85
  Updating   : selinux-policy-3.13.1-229.0.3.el7_6.12.noarch                                                                                                                                                                          18/85
  Updating   : libnl3-3.2.28-4.el7.x86_64                                                                                                                                                                                             19/85
  Updating   : selinux-policy-targeted-3.13.1-229.0.3.el7_6.12.noarch                                                                                                                                                                 20/85
  Updating   : 7:device-mapper-event-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                                   21/85
  Updating   : 7:lvm2-libs-2.02.180-10.0.3.el7_6.8.x86_64                                                                                                                                                                             22/85
  Updating   : 7:oraclelinux-release-7.6-1.0.15.el7.x86_64                                                                                                                                                                            23/85
  Updating   : libsemanage-python-2.5-14.el7.x86_64                                                                                                                                                                                   24/85
  Updating   : libselinux-python-2.5-14.1.el7.x86_64                                                                                                                                                                                  25/85
  Updating   : setools-libs-3.3.8-4.el7.x86_64                                                                                                                                                                                        26/85
  Updating   : policycoreutils-python-2.5-29.0.1.el7_6.1.x86_64                                                                                                                                                                       27/85
  Installing : 2:container-selinux-2.77-5.el7.noarch                                                                                                                                                                                  28/85
  Installing : containerd-1.2.0-1.0.5.el7.x86_64                                                                                                                                                                                      29/85
  Installing : docker-cli-18.09.1.ol-1.0.5.el7.x86_64                                                                                                                                                                                 30/85
  Installing : libnet-1.1.6-7.el7.x86_64                                                                                                                                                                                              31/85
  Installing : protobuf-c-1.0.2-3.el7.x86_64                                                                                                                                                                                          32/85
  Installing : criu-3.9-5.el7.x86_64                                                                                                                                                                                                  33/85
  Installing : runc-1.0.0-19.rc5.git4bb1fe4.0.3.el7.x86_64                                                                                                                                                                            34/85
  Updating   : device-mapper-persistent-data-0.7.3-3.el7.x86_64                                                                                                                                                                       35/85
  Updating   : 7:lvm2-2.02.180-10.0.3.el7_6.8.x86_64                                                                                                                                                                                  36/85
Created symlink from /etc/systemd/system/sysinit.target.wants/lvm2-lvmpolld.socket to /usr/lib/systemd/system/lvm2-lvmpolld.socket.
  Installing : docker-engine-18.09.1.ol-1.0.5.el7.x86_64                                                                                                                                                                              37/85
  Updating   : initscripts-9.49.46-1.0.1.el7.x86_64                                                                                                                                                                                   38/85
  Updating   : 7:lvm2-python-libs-2.02.180-10.0.3.el7_6.8.x86_64                                                                                                                                                                      39/85
  Updating   : libnl3-cli-3.2.28-4.el7.x86_64                                                                                                                                                                                         40/85
  Updating   : libgudev1-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                    41/85
  Updating   : dracut-network-033-554.0.3.el7.x86_64                                                                                                                                                                                  42/85
  Updating   : dracut-config-rescue-033-554.0.3.el7.x86_64                                                                                                                                                                            43/85
  Updating   : systemd-sysv-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                 44/85
  Updating   : systemd-python-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                               45/85
  Updating   : cryptsetup-python-2.0.3-3.el7.x86_64                                                                                                                                                                                   46/85
  Updating   : cryptsetup-2.0.3-3.el7.x86_64                                                                                                                                                                                          47/85
  Cleanup    : 7:lvm2-2.02.115-3.el7.x86_64                                                                                                                                                                                           48/85
  Cleanup    : policycoreutils-python-2.2.5-15.0.1.el7.x86_64                                                                                                                                                                         49/85

UPGRADE: Automatically re-enabling default systemd units:
        brandbot.path
        rhel-autorelabel.service
        rhel-autorelabel-mark.service
        rhel-configure.service
        rhel-dmesg.service
        rhel-domainname.service
        rhel-import-state.service
        rhel-loadmodules.service
        rhel-readonly.service

  Cleanup    : initscripts-9.49.24-1.0.1.el7.x86_64                                                                                                                                                                                   50/85
  Cleanup    : libgudev1-208-20.0.1.el7.x86_64                                                                                                                                                                                        51/85
  Cleanup    : selinux-policy-targeted-3.13.1-23.0.1.el7.noarch                                                                                                                                                                       52/85
  Cleanup    : selinux-policy-3.13.1-23.0.1.el7.noarch                                                                                                                                                                                53/85
  Cleanup    : 7:oraclelinux-release-7.1-1.0.5.el7.x86_64                                                                                                                                                                             54/85
  Cleanup    : dracut-config-rescue-033-240.0.1.el7.x86_64                                                                                                                                                                            55/85
  Cleanup    : systemd-sysv-208-20.0.1.el7.x86_64                                                                                                                                                                                     56/85
  Cleanup    : dracut-network-033-240.0.1.el7.x86_64                                                                                                                                                                                  57/85
  Cleanup    : policycoreutils-2.2.5-15.0.1.el7.x86_64                                                                                                                                                                                58/85
  Cleanup    : systemd-python-208-20.0.1.el7.x86_64                                                                                                                                                                                   59/85
  Cleanup    : dracut-033-240.0.1.el7.x86_64                                                                                                                                                                                          60/85
  Cleanup    : setools-libs-3.3.7-46.el7.x86_64                                                                                                                                                                                       61/85
  Cleanup    : libselinux-utils-2.2.2-6.el7.x86_64                                                                                                                                                                                    62/85
  Cleanup    : glib2-2.40.0-4.el7.x86_64                                                                                                                                                                                              63/85
  Cleanup    : libselinux-python-2.2.2-6.el7.x86_64                                                                                                                                                                                   64/85
  Cleanup    : libsemanage-python-2.1.10-16.el7.x86_64                                                                                                                                                                                65/85
  Cleanup    : libsemanage-2.1.10-16.el7.x86_64                                                                                                                                                                                       66/85
  Cleanup    : cryptsetup-1.6.6-3.el7.x86_64                                                                                                                                                                                          67/85
  Cleanup    : libnl3-cli-3.2.21-8.0.1.el7.x86_64                                                                                                                                                                                     68/85
  Cleanup    : cryptsetup-python-1.6.6-3.el7.x86_64                                                                                                                                                                                   69/85
  Cleanup    : 7:lvm2-python-libs-2.02.115-3.el7.x86_64                                                                                                                                                                               70/85
  Cleanup    : 7:lvm2-libs-2.02.115-3.el7.x86_64                                                                                                                                                                                      71/85
  Cleanup    : 7:device-mapper-event-1.02.93-3.el7.x86_64                                                                                                                                                                             72/85
  Cleanup    : 7:device-mapper-event-libs-1.02.93-3.el7.x86_64                                                                                                                                                                        73/85
  Cleanup    : cryptsetup-libs-1.6.6-3.el7.x86_64                                                                                                                                                                                     74/85
  Cleanup    : systemd-208-20.0.1.el7.x86_64                                                                                                                                                                                          75/85
  Cleanup    : 7:device-mapper-1.02.93-3.el7.x86_64                                                                                                                                                                                   76/85
  Cleanup    : 7:device-mapper-libs-1.02.93-3.el7.x86_64                                                                                                                                                                              77/85
  Cleanup    : 1:redhat-release-server-7.1-1.0.2.el7.x86_64                                                                                                                                                                           78/85
  Cleanup    : systemd-libs-208-20.0.1.el7.x86_64                                                                                                                                                                                     79/85
  Cleanup    : libselinux-2.2.2-6.el7.x86_64                                                                                                                                                                                          80/85
  Cleanup    : libsepol-2.1.9-3.el7.x86_64                                                                                                                                                                                            81/85
  Cleanup    : kmod-14-10.el7.x86_64                                                                                                                                                                                                  82/85
  Cleanup    : libnl3-3.2.21-8.0.1.el7.x86_64                                                                                                                                                                                         83/85
  Cleanup    : device-mapper-persistent-data-0.4.1-2.el7.x86_64                                                                                                                                                                       84/85
  Cleanup    : libseccomp-2.1.1-2.el7.x86_64                                                                                                                                                                                          85/85
  Verifying  : 7:device-mapper-event-libs-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                               1/85
  Verifying  : glib2-2.56.1-4.el7_6.x86_64                                                                                                                                                                                             2/85
  Verifying  : docker-engine-18.09.1.ol-1.0.5.el7.x86_64                                                                                                                                                                               3/85
  Verifying  : policycoreutils-2.5-29.0.1.el7_6.1.x86_64                                                                                                                                                                               4/85
  Verifying  : libseccomp-2.3.1-3.el7.x86_64                                                                                                                                                                                           5/85
  Verifying  : kmod-20-23.0.1.el7.x86_64                                                                                                                                                                                               6/85
  Verifying  : 7:device-mapper-libs-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                                     7/85
  Verifying  : 7:lvm2-python-libs-2.02.180-10.0.3.el7_6.8.x86_64                                                                                                                                                                       8/85
  Verifying  : libgudev1-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                     9/85
  Verifying  : cryptsetup-libs-2.0.3-3.el7.x86_64                                                                                                                                                                                     10/85
  Verifying  : selinux-policy-3.13.1-229.0.3.el7_6.12.noarch                                                                                                                                                                          11/85
  Verifying  : 7:lvm2-2.02.180-10.0.3.el7_6.8.x86_64                                                                                                                                                                                  12/85
  Verifying  : 2:container-selinux-2.77-5.el7.noarch                                                                                                                                                                                  13/85
  Verifying  : initscripts-9.49.46-1.0.1.el7.x86_64                                                                                                                                                                                   14/85
  Verifying  : cryptsetup-python-2.0.3-3.el7.x86_64                                                                                                                                                                                   15/85
  Verifying  : libsemanage-python-2.5-14.el7.x86_64                                                                                                                                                                                   16/85
  Verifying  : 1:redhat-release-server-7.6-4.0.1.el7.x86_64                                                                                                                                                                           17/85
  Verifying  : 7:oraclelinux-release-7.6-1.0.15.el7.x86_64                                                                                                                                                                            18/85
  Verifying  : device-mapper-persistent-data-0.7.3-3.el7.x86_64                                                                                                                                                                       19/85
  Verifying  : dracut-network-033-554.0.3.el7.x86_64                                                                                                                                                                                  20/85
  Verifying  : systemd-sysv-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                 21/85
  Verifying  : containerd-1.2.0-1.0.5.el7.x86_64                                                                                                                                                                                      22/85
  Verifying  : policycoreutils-python-2.5-29.0.1.el7_6.1.x86_64                                                                                                                                                                       23/85
  Verifying  : protobuf-c-1.0.2-3.el7.x86_64                                                                                                                                                                                          24/85
  Verifying  : dracut-config-rescue-033-554.0.3.el7.x86_64                                                                                                                                                                            25/85
  Verifying  : libselinux-2.5-14.1.el7.x86_64                                                                                                                                                                                         26/85
  Verifying  : systemd-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                      27/85
  Verifying  : criu-3.9-5.el7.x86_64                                                                                                                                                                                                  28/85
  Verifying  : libsemanage-2.5-14.el7.x86_64                                                                                                                                                                                          29/85
  Verifying  : systemd-libs-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                                 30/85
  Verifying  : libnl3-cli-3.2.28-4.el7.x86_64                                                                                                                                                                                         31/85
  Verifying  : systemd-python-219-62.0.4.el7_6.7.x86_64                                                                                                                                                                               32/85
  Verifying  : libselinux-python-2.5-14.1.el7.x86_64                                                                                                                                                                                  33/85
  Verifying  : libnet-1.1.6-7.el7.x86_64                                                                                                                                                                                              34/85
  Verifying  : libsepol-2.5-10.el7.x86_64                                                                                                                                                                                             35/85
  Verifying  : runc-1.0.0-19.rc5.git4bb1fe4.0.3.el7.x86_64                                                                                                                                                                            36/85
  Verifying  : selinux-policy-targeted-3.13.1-229.0.3.el7_6.12.noarch                                                                                                                                                                 37/85
  Verifying  : libselinux-utils-2.5-14.1.el7.x86_64                                                                                                                                                                                   38/85
  Verifying  : dracut-033-554.0.3.el7.x86_64                                                                                                                                                                                          39/85
  Verifying  : 7:device-mapper-event-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                                   40/85
  Verifying  : 7:device-mapper-1.02.149-10.0.3.el7_6.8.x86_64                                                                                                                                                                         41/85
  Verifying  : libnl3-3.2.28-4.el7.x86_64                                                                                                                                                                                             42/85
  Verifying  : docker-cli-18.09.1.ol-1.0.5.el7.x86_64                                                                                                                                                                                 43/85
  Verifying  : 7:lvm2-libs-2.02.180-10.0.3.el7_6.8.x86_64                                                                                                                                                                             44/85
  Verifying  : setools-libs-3.3.8-4.el7.x86_64                                                                                                                                                                                        45/85
  Verifying  : lz4-1.7.5-2.0.1.el7.x86_64                                                                                                                                                                                             46/85
  Verifying  : cryptsetup-2.0.3-3.el7.x86_64                                                                                                                                                                                          47/85
  Verifying  : libselinux-utils-2.2.2-6.el7.x86_64                                                                                                                                                                                    48/85
  Verifying  : libsemanage-python-2.1.10-16.el7.x86_64                                                                                                                                                                                49/85
  Verifying  : dracut-config-rescue-033-240.0.1.el7.x86_64                                                                                                                                                                            50/85
  Verifying  : systemd-libs-208-20.0.1.el7.x86_64                                                                                                                                                                                     51/85
  Verifying  : systemd-sysv-208-20.0.1.el7.x86_64                                                                                                                                                                                     52/85
  Verifying  : policycoreutils-2.2.5-15.0.1.el7.x86_64                                                                                                                                                                                53/85
  Verifying  : policycoreutils-python-2.2.5-15.0.1.el7.x86_64                                                                                                                                                                         54/85
  Verifying  : cryptsetup-python-1.6.6-3.el7.x86_64                                                                                                                                                                                   55/85
  Verifying  : 7:oraclelinux-release-7.1-1.0.5.el7.x86_64                                                                                                                                                                             56/85
  Verifying  : 7:device-mapper-event-libs-1.02.93-3.el7.x86_64                                                                                                                                                                        57/85
  Verifying  : dracut-033-240.0.1.el7.x86_64                                                                                                                                                                                          58/85
  Verifying  : cryptsetup-1.6.6-3.el7.x86_64                                                                                                                                                                                          59/85
  Verifying  : setools-libs-3.3.7-46.el7.x86_64                                                                                                                                                                                       60/85
  Verifying  : initscripts-9.49.24-1.0.1.el7.x86_64                                                                                                                                                                                   61/85
  Verifying  : kmod-14-10.el7.x86_64                                                                                                                                                                                                  62/85
  Verifying  : systemd-python-208-20.0.1.el7.x86_64                                                                                                                                                                                   63/85
  Verifying  : cryptsetup-libs-1.6.6-3.el7.x86_64                                                                                                                                                                                     64/85
  Verifying  : dracut-network-033-240.0.1.el7.x86_64                                                                                                                                                                                  65/85
  Verifying  : glib2-2.40.0-4.el7.x86_64                                                                                                                                                                                              66/85
  Verifying  : libnl3-cli-3.2.21-8.0.1.el7.x86_64                                                                                                                                                                                     67/85
  Verifying  : libnl3-3.2.21-8.0.1.el7.x86_64                                                                                                                                                                                         68/85
  Verifying  : 7:device-mapper-event-1.02.93-3.el7.x86_64                                                                                                                                                                             69/85
  Verifying  : libselinux-python-2.2.2-6.el7.x86_64                                                                                                                                                                                   70/85
  Verifying  : libsemanage-2.1.10-16.el7.x86_64                                                                                                                                                                                       71/85
  Verifying  : libseccomp-2.1.1-2.el7.x86_64                                                                                                                                                                                          72/85
  Verifying  : libsepol-2.1.9-3.el7.x86_64                                                                                                                                                                                            73/85
  Verifying  : 7:lvm2-python-libs-2.02.115-3.el7.x86_64                                                                                                                                                                               74/85
  Verifying  : 7:device-mapper-1.02.93-3.el7.x86_64                                                                                                                                                                                   75/85
  Verifying  : selinux-policy-3.13.1-23.0.1.el7.noarch                                                                                                                                                                                76/85
  Verifying  : libselinux-2.2.2-6.el7.x86_64                                                                                                                                                                                          77/85
  Verifying  : 1:redhat-release-server-7.1-1.0.2.el7.x86_64                                                                                                                                                                           78/85
  Verifying  : libgudev1-208-20.0.1.el7.x86_64                                                                                                                                                                                        79/85
  Verifying  : 7:lvm2-2.02.115-3.el7.x86_64                                                                                                                                                                                           80/85
  Verifying  : 7:lvm2-libs-2.02.115-3.el7.x86_64                                                                                                                                                                                      81/85
  Verifying  : 7:device-mapper-libs-1.02.93-3.el7.x86_64                                                                                                                                                                              82/85
  Verifying  : device-mapper-persistent-data-0.4.1-2.el7.x86_64                                                                                                                                                                       83/85
  Verifying  : selinux-policy-targeted-3.13.1-23.0.1.el7.noarch                                                                                                                                                                       84/85
  Verifying  : systemd-208-20.0.1.el7.x86_64                                                                                                                                                                                          85/85

Installed:
  docker-engine.x86_64 0:18.09.1.ol-1.0.5.el7

Dependency Installed:
  container-selinux.noarch 2:2.77-5.el7     containerd.x86_64 0:1.2.0-1.0.5.el7               criu.x86_64 0:3.9-5.el7     docker-cli.x86_64 0:18.09.1.ol-1.0.5.el7     libnet.x86_64 0:1.1.6-7.el7     lz4.x86_64 0:1.7.5-2.0.1.el7
  protobuf-c.x86_64 0:1.0.2-3.el7           runc.x86_64 0:1.0.0-19.rc5.git4bb1fe4.0.3.el7

Updated:
  dracut.x86_64 0:033-554.0.3.el7                   initscripts.x86_64 0:9.49.46-1.0.1.el7                   oraclelinux-release.x86_64 7:7.6-1.0.15.el7                   redhat-release-server.x86_64 1:7.6-4.0.1.el7

Dependency Updated:
  cryptsetup.x86_64 0:2.0.3-3.el7                              cryptsetup-libs.x86_64 0:2.0.3-3.el7                          cryptsetup-python.x86_64 0:2.0.3-3.el7                  device-mapper.x86_64 7:1.02.149-10.0.3.el7_6.8
  device-mapper-event.x86_64 7:1.02.149-10.0.3.el7_6.8         device-mapper-event-libs.x86_64 7:1.02.149-10.0.3.el7_6.8     device-mapper-libs.x86_64 7:1.02.149-10.0.3.el7_6.8     device-mapper-persistent-data.x86_64 0:0.7.3-3.el7
  dracut-config-rescue.x86_64 0:033-554.0.3.el7                dracut-network.x86_64 0:033-554.0.3.el7                       glib2.x86_64 0:2.56.1-4.el7_6                           kmod.x86_64 0:20-23.0.1.el7
  libgudev1.x86_64 0:219-62.0.4.el7_6.7                        libnl3.x86_64 0:3.2.28-4.el7                                  libnl3-cli.x86_64 0:3.2.28-4.el7                        libseccomp.x86_64 0:2.3.1-3.el7
  libselinux.x86_64 0:2.5-14.1.el7                             libselinux-python.x86_64 0:2.5-14.1.el7                       libselinux-utils.x86_64 0:2.5-14.1.el7                  libsemanage.x86_64 0:2.5-14.el7
  libsemanage-python.x86_64 0:2.5-14.el7                       libsepol.x86_64 0:2.5-10.el7                                  lvm2.x86_64 7:2.02.180-10.0.3.el7_6.8                   lvm2-libs.x86_64 7:2.02.180-10.0.3.el7_6.8
  lvm2-python-libs.x86_64 7:2.02.180-10.0.3.el7_6.8            policycoreutils.x86_64 0:2.5-29.0.1.el7_6.1                   policycoreutils-python.x86_64 0:2.5-29.0.1.el7_6.1      selinux-policy.noarch 0:3.13.1-229.0.3.el7_6.12
  selinux-policy-targeted.noarch 0:3.13.1-229.0.3.el7_6.12     setools-libs.x86_64 0:3.3.8-4.el7                             systemd.x86_64 0:219-62.0.4.el7_6.7                     systemd-libs.x86_64 0:219-62.0.4.el7_6.7
  systemd-python.x86_64 0:219-62.0.4.el7_6.7                   systemd-sysv.x86_64 0:219-62.0.4.el7_6.7

Complete!

3.一旦安装完成,就可以启动docker服务

[root@localhost soft]# service docker start
Redirecting to /bin/systemctl start docker.service

[root@localhost soft]# systemctl enable docker

[root@localhost soft]# service docker status
Redirecting to /bin/systemctl status docker.service
鈼[0m docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/docker.service.d
           鈹斺攢docker-sysconfig.conf
   Active: active (running) since Mon 2019-06-10 23:15:05 CST; 6h left
     Docs: https://docs.docker.com
 Main PID: 1452 (dockerd)
   Memory: 132.2M
   CGroup: /system.slice/docker.service
           鈹溾攢1452 /usr/bin/dockerd --selinux-enabled --storage-driver devicemapper --storage-opt dm.basesize=25G
           鈹斺攢2436 containerd --config /var/run/docker/containerd/containerd.toml --log-level info

Jun 10 23:15:03 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:03.843382248+08:00" level=info msg="Successfully created filesystem xfs on device docker-253:0-1047242-base" storage-driver=devicemapper
Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.076789613+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.078665673+08:00" level=warning msg="mountpoint for pids not found"
Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.079906275+08:00" level=info msg="Loading containers: start."
Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.554467519+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to...rred IP address"
Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.859786800+08:00" level=info msg="Loading containers: done."
Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.959099871+08:00" level=info msg="Docker daemon" commit=c3ab8a8 graphdriver(s)=devicemapper version=18.09.1-ol
Jun 10 23:15:04 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:04.959938124+08:00" level=info msg="Daemon has completed initialization"
Jun 10 23:15:05 localhost.localdomain dockerd[1452]: time="2019-06-10T23:15:05.053166130+08:00" level=info msg="API listen on /var/run/docker.sock"
Jun 10 23:15:05 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.

4.然后可以下载镜像文件

[root@localhost soft]# docker pull mysql/mysql-server:5.7
Trying to pull repository docker.io/mysql/mysql-server ...
5.7: Pulling from docker.io/mysql/mysql-server
35defbf6c365: Pull complete
0fa46ab0f51d: Pull complete
f70f5000008c: Pull complete
892ac46af8c0: Pull complete
Digest: sha256:ddb046076781a15200d36cb01f8f512431c3481bedebd5e92646d8c617ae212c
Status: Downloaded newer image for mysql/mysql-server:5.7
[root@localhost soft]# docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
mysql/mysql-server   5.7                 857eadf53a54        6 weeks ago         258MB

到此安装就完成了,还是很简单。

在Oracle Linux 7.1中使用源码来安装PostgreSQL 9.6

在Oracle Linux 7.1中使用源码来安装PostgreSQL 9.6
编译PostgreSQL需要下列软件包:
1.GUN make版本3.80或新的要求。

[root@cs1 /]# make --version
GNU Make 3.82
Built for x86_64-redhat-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

2.需要一个ISO/ANSI C 编译器(至少是 C89兼容的)。我们推荐使用最近版本的GCC

[root@cs1 /]# gcc --version
gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9)
Copyright (C) 2013 Free Software Foundation, Inc.
本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
包括没有适销性和某一专用目的下的适用性担保。

3.除了gzip和bzip2之外,我们还需要tar来解包源代码发布。

4.GNU Readline库

[root@cs1 /]# rpm -aq | grep readline
readline-6.2-9.el7.x86_64
[root@cs1 /]# rpm -aq | grep readline-deve
readline-devel-6.2-9.el7.x86_64
[root@cs1 /]# rpm -aq | grep libedit
libedit-3.0-12.20121213cvs.el7.x86_64

5.可选工具包在默认配置的时候并不要求它们,但是如果打开了一些编译选项之后就需要它们了

perl 5.8 or later
python
Kerberos
OpenSSL
OpenLDAP and/or PAM
Flex 2.5.31 or later
Bison 1.875 or later

6.创建用户与组

[root@cs1 local]# groupadd pgsql
[root@cs1 local]# useradd -g pgsql pgsql

7.下载源码包postgresql-9.6.6.tar.gz并上传到服务器并解压

[root@cs1 local]# gunzip  postgresql-9.6.6.tar.gz

创建一个软链接

[root@cs1 local]# ln -s postgresql-9.6.6 pgsql
[root@cs1 local]# ls -lrt
总用量 8
drwxr-xr-x.  2 root  root     6 5月   8 2014 src
drwxr-xr-x.  2 root  root     6 5月   8 2014 sbin
drwxr-xr-x.  2 root  root     6 5月   8 2014 libexec
drwxr-xr-x.  2 root  root     6 5月   8 2014 lib64
drwxr-xr-x.  2 root  root     6 5月   8 2014 lib
drwxr-xr-x.  2 root  root     6 5月   8 2014 include
drwxr-xr-x.  2 root  root     6 5月   8 2014 games
drwxr-xr-x.  2 root  root     6 5月   8 2014 etc
drwxr-xr-x.  5 root  root    46 10月 12 2017 share
drwxrwxrwx   6 pgsql pgsql 4096 11月  7 2017 postgresql-9.6.6
drwxr-xr-x.  2 root  root    46 3月   9 2018 bin
drwxrwxr-x  13 root  mysql 4096 1月  31 02:40 mariadb-10.0.38-linux-glibc_214-x86_64
lrwxrwxrwx   1 root  root    38 6月   4 14:43 mysql -> mariadb-10.0.38-linux-glibc_214-x86_64
lrwxrwxrwx   1 root  root    16 6月   4 21:24 pgsql -> postgresql-9.6.6

8.安装

root@cs1 local]# cd pgsql

8.1安装过程的第一步就是为你的系统配置源代码树并选择你喜欢的选项。这个工作是通过运行configure脚本实现的,对于默认安装,你只需要简单地输入:

[root@cs1 pgsql]# ./configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... yes
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc supports -Wdeclaration-after-statement... yes
checking whether gcc supports -Wendif-labels... yes
checking whether gcc supports -Wmissing-format-attribute... yes
checking whether gcc supports -Wformat-security... yes
checking whether gcc supports -fno-strict-aliasing... yes
checking whether gcc supports -fwrapv... yes
checking whether gcc supports -fexcess-precision=standard... yes
checking whether gcc supports -funroll-loops... yes
checking whether gcc supports -ftree-vectorize... yes
checking whether gcc supports -Wunused-command-line-argument... no
checking whether the C compiler still works... yes
checking how to run the C preprocessor... gcc -E
checking allow thread-safe client libraries... yes
checking whether to build with Tcl... no
checking whether to build Perl modules... no
checking whether to build Python modules... no
checking whether to build with GSSAPI support... no
checking whether to build with PAM support... no
checking whether to build with BSD Authentication support... no
checking whether to build with LDAP support... no
checking whether to build with Bonjour support... no
checking whether to build with OpenSSL support... no
checking whether to build with SELinux support... no
checking whether to build with systemd support... no
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for ranlib... ranlib
checking for strip... strip
checking whether it is possible to strip libraries... yes
checking for ar... ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for tar... /usr/bin/tar
checking whether ln -s works... yes
checking for gawk... gawk
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for bison... /usr/bin/bison
configure: using bison (GNU Bison) 2.7
checking for flex... /usr/bin/flex
configure: using flex 2.5.37
checking for perl... /usr/bin/perl
configure: using perl 5.16.3
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking if compiler needs certain flags to reject unknown flags... no
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for strerror_r... yes
checking for getpwuid_r... yes
checking for gethostbyname_r... yes
checking whether strerror_r returns int... no
checking for main in -lm... yes
checking for library containing setproctitle... no
checking for library containing dlopen... -ldl
checking for library containing socket... none required
checking for library containing shl_load... no
checking for library containing getopt_long... none required
checking for library containing crypt... -lcrypt
checking for library containing shm_open... -lrt
checking for library containing shm_unlink... none required
checking for library containing fdatasync... none required
checking for library containing sched_yield... none required
checking for library containing gethostbyname_r... none required
checking for library containing shmget... none required
checking for library containing readline... -lreadline
checking for inflate in -lz... yes
checking atomic.h usability... no
checking atomic.h presence... no
checking for atomic.h... no
checking crypt.h usability... yes
checking crypt.h presence... yes
checking for crypt.h... yes
checking dld.h usability... no
checking dld.h presence... no
checking for dld.h... no
checking fp_class.h usability... no
checking fp_class.h presence... no
checking for fp_class.h... no
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking ieeefp.h usability... no
checking ieeefp.h presence... no
checking for ieeefp.h... no
checking ifaddrs.h usability... yes
checking ifaddrs.h presence... yes
checking for ifaddrs.h... yes
checking langinfo.h usability... yes
checking langinfo.h presence... yes
checking for langinfo.h... yes
checking mbarrier.h usability... no
checking mbarrier.h presence... no
checking for mbarrier.h... no
checking poll.h usability... yes
checking poll.h presence... yes
checking for poll.h... yes
checking pwd.h usability... yes
checking pwd.h presence... yes
checking for pwd.h... yes
checking sys/epoll.h usability... yes
checking sys/epoll.h presence... yes
checking for sys/epoll.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/ipc.h usability... yes
checking sys/ipc.h presence... yes
checking for sys/ipc.h... yes
checking sys/poll.h usability... yes
checking sys/poll.h presence... yes
checking for sys/poll.h... yes
checking sys/pstat.h usability... no
checking sys/pstat.h presence... no
checking for sys/pstat.h... no
checking sys/resource.h usability... yes
checking sys/resource.h presence... yes
checking for sys/resource.h... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking sys/sem.h usability... yes
checking sys/sem.h presence... yes
checking for sys/sem.h... yes
checking sys/shm.h usability... yes
checking sys/shm.h presence... yes
checking for sys/shm.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking sys/sockio.h usability... no
checking sys/sockio.h presence... no
checking for sys/sockio.h... no
checking sys/tas.h usability... no
checking sys/tas.h presence... no
checking for sys/tas.h... no
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/un.h usability... yes
checking sys/un.h presence... yes
checking for sys/un.h... yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking ucred.h usability... no
checking ucred.h presence... no
checking for ucred.h... no
checking utime.h usability... yes
checking utime.h presence... yes
checking for utime.h... yes
checking wchar.h usability... yes
checking wchar.h presence... yes
checking for wchar.h... yes
checking wctype.h usability... yes
checking wctype.h presence... yes
checking for wctype.h... yes
checking for net/if.h... yes
checking for sys/ucred.h... no
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking for netinet/tcp.h... yes
checking readline/readline.h usability... yes
checking readline/readline.h presence... yes
checking for readline/readline.h... yes
checking readline/history.h usability... yes
checking readline/history.h presence... yes
checking for readline/history.h... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking whether byte ordering is bigendian... no
checking for inline... inline
checking for printf format archetype... gnu_printf
checking for flexible array members... yes
checking for signed types... yes
checking for __func__... yes
checking for _Static_assert... yes
checking for __builtin_types_compatible_p... yes
checking for __builtin_bswap32... yes
checking for __builtin_bswap64... yes
checking for __builtin_constant_p... yes
checking for __builtin_unreachable... yes
checking for __VA_ARGS__... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for struct tm.tm_zone... yes
checking for tzname... yes
checking for union semun... no
checking for struct sockaddr_un... yes
checking for struct sockaddr_storage... yes
checking for struct sockaddr_storage.ss_family... yes
checking for struct sockaddr_storage.__ss_family... no
checking for struct sockaddr_storage.ss_len... no
checking for struct sockaddr_storage.__ss_len... no
checking for struct sockaddr.sa_len... no
checking for struct addrinfo... yes
checking for intptr_t... yes
checking for uintptr_t... yes
checking for unsigned long long int... yes
checking for long long int... yes
checking for locale_t... yes
checking for struct cmsgcred... no
checking for struct option... yes
checking for z_streamp... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking size of off_t... 8
checking for int timezone... yes
checking types of arguments for accept()... int, int, struct sockaddr *, socklen_t *
checking whether gettimeofday takes only one argument... no
checking for wcstombs_l declaration... no
checking for cbrt... yes
checking for dlopen... yes
checking for fdatasync... yes
checking for getifaddrs... yes
checking for getpeerucred... no
checking for getrlimit... yes
checking for mbstowcs_l... no
checking for memmove... yes
checking for poll... yes
checking for posix_fallocate... yes
checking for pstat... no
checking for pthread_is_threaded_np... no
checking for readlink... yes
checking for setproctitle... no
checking for setsid... yes
checking for shm_open... yes
checking for symlink... yes
checking for sync_file_range... yes
checking for towlower... yes
checking for utime... yes
checking for utimes... yes
checking for wcstombs... yes
checking for wcstombs_l... no
checking for fseeko... yes
checking for _LARGEFILE_SOURCE value needed for large files... no
checking for posix_fadvise... yes
checking whether posix_fadvise is declared... yes
checking whether fdatasync is declared... yes
checking whether strlcat is declared... no
checking whether strlcpy is declared... no
checking whether F_FULLFSYNC is declared... no
checking for struct sockaddr_in6... yes
checking for PS_STRINGS... no
checking for snprintf... yes
checking for vsnprintf... yes
checking whether snprintf is declared... yes
checking whether vsnprintf is declared... yes
checking for isinf... yes
checking for crypt... yes
checking for fls... no
checking for getopt... yes
checking for getrusage... yes
checking for inet_aton... yes
checking for mkdtemp... yes
checking for random... yes
checking for rint... yes
checking for srandom... yes
checking for strerror... yes
checking for strlcat... no
checking for strlcpy... no
checking for unsetenv... yes
checking for getpeereid... no
checking for getaddrinfo... yes
checking for getopt_long... yes
checking whether sys_siglist is declared... yes
checking for syslog... yes
checking syslog.h usability... yes
checking syslog.h presence... yes
checking for syslog.h... yes
checking for opterr... yes
checking for optreset... no
checking for strtoll... yes
checking for strtoull... yes
checking for rl_completion_append_character... yes
checking for rl_completion_matches... yes
checking for rl_filename_completion_function... yes
checking for rl_reset_screen_size... yes
checking for append_history... yes
checking for history_truncate_file... yes
checking test program... ok
checking whether long int is 64 bits... yes
checking whether snprintf supports the %z modifier... yes
checking size of void *... 8
checking size of size_t... 8
checking size of long... 8
checking whether to build with float4 passed by value... yes
checking whether to build with float8 passed by value... yes
checking alignment of short... 2
checking alignment of int... 4
checking alignment of long... 8
checking alignment of double... 8
checking for int8... no
checking for uint8... no
checking for int64... no
checking for uint64... no
checking for __int128... yes
checking for builtin __sync char locking functions... yes
checking for builtin __sync int32 locking functions... yes
checking for builtin __sync int32 atomic operations... yes
checking for builtin __sync int64 atomic operations... yes
checking for builtin __atomic int32 atomic operations... yes
checking for builtin __atomic int64 atomic operations... yes
checking for __get_cpuid... yes
checking for __cpuid... no
checking for _mm_crc32_u8 and _mm_crc32_u32 with CFLAGS=... no
checking for _mm_crc32_u8 and _mm_crc32_u32 with CFLAGS=-msse4.2... yes
checking which CRC-32C implementation to use... SSE 4.2 with runtime check
checking for onsgmls... no
checking for nsgmls... no
checking for openjade... no
checking for jade... no
checking for DocBook V4.2... no
checking for DocBook stylesheets... no
checking for collateindex.pl... no
checking for dbtoepub... no
checking for xmllint... xmllint
checking for xsltproc... xsltproc
checking for osx... no
checking for sgml2xml... no
checking for sx... sx
checking thread safety of required library functions... yes
checking whether gcc supports -Wl,--as-needed... yes
configure: using compiler=gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9)
configure: using CFLAGS=-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2
configure: using CPPFLAGS= -D_GNU_SOURCE 
configure: using LDFLAGS=  -Wl,--as-needed
configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating src/Makefile.global
config.status: creating src/include/pg_config.h
config.status: creating src/include/pg_config_ext.h
config.status: creating src/interfaces/ecpg/include/ecpg_config.h
config.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking src/backend/port/dynloader/linux.c to src/backend/port/dynloader.c
config.status: linking src/backend/port/sysv_sema.c to src/backend/port/pg_sema.c
config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
config.status: linking src/backend/port/dynloader/linux.h to src/include/dynloader.h
config.status: linking src/include/port/linux.h to src/include/pg_config_os.h
config.status: linking src/makefiles/Makefile.linux to src/Makefile.port

默认安装目录/usr/local/pgsql,可以使用–prefix=path进行修改,./configure –help

8.2 编译
要开始编译,键入:

root@cs1 local]# make

(一定要记得用GNU make)。依你的硬件而异,编译过程可能需要 5 分钟到半小时。显示的最后一行应该是:

All of PostgreSQL successfully made. Ready to install.

如果你希望编译所有能编译的东西,包括文档(HTML和手册页)以及附加模块(contrib),这样键入:

[root@cs1 pgsql]# make world
.....省略.....
make[2]: 离开目录“/usr/local/postgresql-9.6.6/contrib/vacuumlo”
make[1]: 离开目录“/usr/local/postgresql-9.6.6/contrib”
PostgreSQL, contrib, and documentation successfully made. Ready to install.

8.3安装文件
要安装PostgreSQL,输入:

make install

这条命令将把文件安装到在步骤 1中指定的目录。确保你有足够的权限向该区域写入。通常你需要用 root 权限做这一步。或者你也可以事先创建目标目录并且分派合适的权限。

要安装文档(HTML和手册页),输入:

make install-docs

如果你按照上面的方法编译了所有东西,输入:

make install-world

这也会安装文档。

[root@cs1 pgsql]# make install-world
......省略....
make[2]: 离开目录“/usr/local/postgresql-9.6.6/contrib/vacuumlo”
make[1]: 离开目录“/usr/local/postgresql-9.6.6/contrib”
PostgreSQL, contrib, and documentation installation complete.

9.设置环境变量
创建目录/usr/local/pgsql/data用来存放数据

[root@cs1 pgsql]# mkdir /usr/local/pgsql/data
[root@cs1 pgsql]# chown pgsql:pgsql data

[root@cs1 pgsql]# su - pgsql
[pgsql@cs1 ~]$ vi .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH
export LD_LIBRARY_PATH=/usr/local/pgsql/lib
export PG_HOME=/usr/local/pgsql
export PATH=$PG_HOME/bin/:$PATH
export PGDATA=/usr/local/pgsql/data

10.初始化数据库
使用pgsql用户来执行

[pgsql@cs1 ~]$ initdb --help
initdb initializes a PostgreSQL database cluster.

Usage:
  initdb [OPTION]... [DATADIR]

Options:
  -A, --auth=METHOD         default authentication method for local connections
      --auth-host=METHOD    default authentication method for local TCP/IP connections
      --auth-local=METHOD   default authentication method for local-socket connections
 [-D, --pgdata=]DATADIR     location for this database cluster
  -E, --encoding=ENCODING   set default encoding for new databases
      --locale=LOCALE       set default locale for new databases
      --lc-collate=, --lc-ctype=, --lc-messages=LOCALE
      --lc-monetary=, --lc-numeric=, --lc-time=LOCALE
                            set default locale in the respective category for
                            new databases (default taken from environment)
      --no-locale           equivalent to --locale=C
      --pwfile=FILE         read password for the new superuser from file
  -T, --text-search-config=CFG
                            default text search configuration
  -U, --username=NAME       database superuser name
  -W, --pwprompt            prompt for a password for the new superuser
  -X, --xlogdir=XLOGDIR     location for the transaction log directory

Less commonly used options:
  -d, --debug               generate lots of debugging output
  -k, --data-checksums      use data page checksums
  -L DIRECTORY              where to find the input files
  -n, --noclean             do not clean up after errors
  -N, --nosync              do not wait for changes to be written safely to disk
  -s, --show                show internal settings
  -S, --sync-only           only sync data directory

Other options:
  -V, --version             output version information, then exit
  -?, --help                show this help, then exit

If the data directory is not specified, the environment variable PGDATA
is used.

Report bugs to .
[pgsql@cs1 ~]$ initdb -D /usr/local/pgsql/data
The files belonging to this database system will be owned by user "pgsql".
This user must also own the server process.

The database cluster will be initialized with locale "zh_CN.gb2312".
The default database encoding has accordingly been set to "EUC_CN".
initdb: could not find suitable text search configuration for locale "zh_CN.gb2312"
The default text search configuration will be set to "simple".

Data page checksums are disabled.

fixing permissions on existing directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /usr/local/pgsql/data -l logfile start

同时在pgsql的目录可以看到生成的数据目录data以及该目录的相关数据和配置文件:

[root@cs1 soft]# cd /usr/local/pgsql
[root@cs1 pgsql]# ls -lrt
总用量 1080
-rw-r--r--  1 pgsql pgsql   1212 11月  7 2017 README
-rw-r--r--  1 pgsql pgsql   1529 11月  7 2017 Makefile
-rw-r--r--  1 pgsql pgsql    284 11月  7 2017 HISTORY
-rw-r--r--  1 pgsql pgsql   3638 11月  7 2017 GNUmakefile.in
-rw-r--r--  1 pgsql pgsql   1192 11月  7 2017 COPYRIGHT
-rw-r--r--  1 pgsql pgsql  74867 11月  7 2017 configure.in
-rwxr-xr-x  1 pgsql pgsql 471555 11月  7 2017 configure
-rw-r--r--  1 pgsql pgsql    384 11月  7 2017 aclocal.m4
drwxrwxrwx 55 pgsql pgsql   4096 11月  7 2017 contrib
drwxrwxrwx  2 pgsql pgsql   4096 11月  7 2017 config
drwxrwxrwx  3 pgsql pgsql    101 11月  7 2017 doc
-rw-r--r--  1 pgsql pgsql  76016 11月  7 2017 INSTALL
-rwxr-xr-x  1 root  root   39264 6月   4 21:29 config.status
-rw-r--r--  1 root  root    3638 6月   4 21:29 GNUmakefile
drwxrwxrwx 16 pgsql pgsql   4096 6月   4 21:29 src
-rw-r--r--  1 root  root  370213 6月   4 21:29 config.log
drwxr-xr-x  4 root  root      26 6月   4 21:43 tmp_install
drwxr-xr-x  6 root  root    4096 6月   4 21:45 include
drwxr-xr-x  8 root  root    4096 6月   4 21:45 share
drwxr-xr-x  4 root  root    4096 6月   4 21:45 lib
drwxr-xr-x  2 root  root    4096 6月   4 21:45 bin
drwx------ 19 pgsql pgsql   4096 6月   4 21:56 data
[root@cs1 pgsql]# cd data
[root@cs1 data]# ls -lrt
总用量 48
drwx------ 2 pgsql pgsql     6 6月   4 21:56 pg_twophase
drwx------ 2 pgsql pgsql     6 6月   4 21:56 pg_snapshots
drwx------ 2 pgsql pgsql     6 6月   4 21:56 pg_serial
drwx------ 2 pgsql pgsql     6 6月   4 21:56 pg_replslot
drwx------ 4 pgsql pgsql    34 6月   4 21:56 pg_multixact
drwx------ 2 pgsql pgsql     6 6月   4 21:56 pg_dynshmem
drwx------ 2 pgsql pgsql     6 6月   4 21:56 pg_commit_ts
-rw------- 1 pgsql pgsql     4 6月   4 21:56 PG_VERSION
drwx------ 2 pgsql pgsql     6 6月   4 21:56 pg_tblspc
drwx------ 2 pgsql pgsql     6 6月   4 21:56 pg_stat_tmp
drwx------ 2 pgsql pgsql     6 6月   4 21:56 pg_stat
drwx------ 4 pgsql pgsql    37 6月   4 21:56 pg_logical
-rw------- 1 pgsql pgsql 22304 6月   4 21:56 postgresql.conf
-rw------- 1 pgsql pgsql    88 6月   4 21:56 postgresql.auto.conf
-rw------- 1 pgsql pgsql  1636 6月   4 21:56 pg_ident.conf
-rw------- 1 pgsql pgsql  4459 6月   4 21:56 pg_hba.conf
drwx------ 3 pgsql pgsql    58 6月   4 21:56 pg_xlog
drwx------ 2 pgsql pgsql    17 6月   4 21:56 pg_subtrans
drwx------ 2 pgsql pgsql    17 6月   4 21:56 pg_clog
drwx------ 2 pgsql pgsql    17 6月   4 21:56 pg_notify
drwx------ 2 pgsql pgsql  4096 6月   4 21:56 global
drwx------ 5 pgsql pgsql    38 6月   4 21:56 base

11.启动数据库
在初始化数据库结束后看到了启动命令:

Success. You can now start the database server using:

    pg_ctl -D /usr/local/pgsql/data -l logfile start
[pgsql@cs1 ~]$ echo $PGDATA
/usr/local/pgsql/data

由于我们设置了环境变量,所以已经指定了数据目录PGDATA, -l表示日志文件目录,通常需要指定,所以我们在/usr/local/pgsql根目录下再创建一个log目录用来存放日志文件(注意别忘记赋予可写的权限)

[root@cs1 pgsql]# chown -R pgsql:pgsql log
[root@cs1 pgsql]# chmod -R 775 log
[root@cs1 pgsql]# ls -lrt
总用量 1080
-rw-r--r--  1 pgsql pgsql   1212 11月  7 2017 README
-rw-r--r--  1 pgsql pgsql   1529 11月  7 2017 Makefile
-rw-r--r--  1 pgsql pgsql    284 11月  7 2017 HISTORY
-rw-r--r--  1 pgsql pgsql   3638 11月  7 2017 GNUmakefile.in
-rw-r--r--  1 pgsql pgsql   1192 11月  7 2017 COPYRIGHT
-rw-r--r--  1 pgsql pgsql  74867 11月  7 2017 configure.in
-rwxr-xr-x  1 pgsql pgsql 471555 11月  7 2017 configure
-rw-r--r--  1 pgsql pgsql    384 11月  7 2017 aclocal.m4
drwxrwxrwx 55 pgsql pgsql   4096 11月  7 2017 contrib
drwxrwxrwx  2 pgsql pgsql   4096 11月  7 2017 config
drwxrwxrwx  3 pgsql pgsql    101 11月  7 2017 doc
-rw-r--r--  1 pgsql pgsql  76016 11月  7 2017 INSTALL
-rwxr-xr-x  1 root  root   39264 6月   4 21:29 config.status
-rw-r--r--  1 root  root    3638 6月   4 21:29 GNUmakefile
drwxrwxrwx 16 pgsql pgsql   4096 6月   4 21:29 src
-rw-r--r--  1 root  root  370213 6月   4 21:29 config.log
drwxr-xr-x  4 root  root      26 6月   4 21:43 tmp_install
drwxr-xr-x  6 root  root    4096 6月   4 21:45 include
drwxr-xr-x  8 root  root    4096 6月   4 21:45 share
drwxr-xr-x  4 root  root    4096 6月   4 21:45 lib
drwxr-xr-x  2 root  root    4096 6月   4 21:45 bin
drwx------ 19 pgsql pgsql   4096 6月   4 21:56 data
drwxrwxr-x  2 pgsql pgsql      6 6月   4 22:04 log

运行pg_ctl start -l /usr/local/pgsql/log/pg_server.log即可启动数据库

[pgsql@cs1 ~]$ pg_ctl start -l /usr/local/pgsql/log/pg_server.log
server starting

通过ps -ef|grep postgres查看一下postgres相关是否存在相关进程

[root@cs1 log]# ps -ef|grep postgres
pgsql     4977     1  0 22:05 pts/3    00:00:00 /usr/local/postgresql-9.6.6/bin/postgres
pgsql     4980  4977  0 22:05 ?        00:00:00 postgres: checkpointer process   
pgsql     4981  4977  0 22:05 ?        00:00:00 postgres: writer process   
pgsql     4982  4977  0 22:05 ?        00:00:00 postgres: wal writer process   
pgsql     4983  4977  0 22:05 ?        00:00:00 postgres: autovacuum launcher process   
pgsql     4984  4977  0 22:05 ?        00:00:00 postgres: stats collector process   
root      5145 15622  0 22:06 pts/4    00:00:00 grep --color=auto postgres

从数据库日志文件可以看到如下信息:

[root@cs1 log]# tail -f pg_server.log 
LOG:  database system was shut down at 2019-06-04 21:56:12 CST
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

12.连接数据库

[pgsql@cs1 ~]$ psql --list
                               List of databases
   Name    | Owner | Encoding |   Collate    |    Ctype     | Access privileges 
-----------+-------+----------+--------------+--------------+-------------------
 postgres  | pgsql | EUC_CN   | zh_CN.gb2312 | zh_CN.gb2312 | 
 template0 | pgsql | EUC_CN   | zh_CN.gb2312 | zh_CN.gb2312 | =c/pgsql         +
           |       |          |              |              | pgsql=CTc/pgsql
 template1 | pgsql | EUC_CN   | zh_CN.gb2312 | zh_CN.gb2312 | =c/pgsql         +
           |       |          |              |              | pgsql=CTc/pgsql
(3 rows)

启动成功后我们就可以通过postgresql自带的客户端工具psql来进行连接,直接输入psql看到版本信息则说明连接成功:

[pgsql@cs1 ~]$ psql postgres
psql (9.6.6)
Type "help" for help.

postgres=# 

接下来要做的第一件事就是设置postgres用户的密码(默认为空),用psql连接成功后直接输入\password即会提示输入两次密码

[pgsql@cs1 ~]$ psql postgres
psql (9.6.6)
Type "help" for help.

postgres=# \password
Enter new password: 
Enter it again: 
postgres=# \l
                               List of databases
   Name    | Owner | Encoding |   Collate    |    Ctype     | Access privileges 
-----------+-------+----------+--------------+--------------+-------------------
 postgres  | pgsql | EUC_CN   | zh_CN.gb2312 | zh_CN.gb2312 | 
 template0 | pgsql | EUC_CN   | zh_CN.gb2312 | zh_CN.gb2312 | =c/pgsql         +
           |       |          |              |              | pgsql=CTc/pgsql
 template1 | pgsql | EUC_CN   | zh_CN.gb2312 | zh_CN.gb2312 | =c/pgsql         +
           |       |          |              |              | pgsql=CTc/pgsql
(3 rows)


postgres=# \l
                               List of databases
   Name    | Owner | Encoding |   Collate    |    Ctype     | Access privileges 
-----------+-------+----------+--------------+--------------+-------------------
 postgres  | pgsql | EUC_CN   | zh_CN.gb2312 | zh_CN.gb2312 | 
 template0 | pgsql | EUC_CN   | zh_CN.gb2312 | zh_CN.gb2312 | =c/pgsql         +
           |       |          |              |              | pgsql=CTc/pgsql
 template1 | pgsql | EUC_CN   | zh_CN.gb2312 | zh_CN.gb2312 | =c/pgsql         +
           |       |          |              |              | pgsql=CTc/pgsql
(3 rows)

postgres=# select version();
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9), 64-bit
(1 row)

postgres=# select current_date;
    date    
------------
 2019-06-04
(1 row)

postgres=# 

到此使用源码来安装pg数据库就完成了。

Oracle Linux 7.1中安装MariaDB

在Oracle Linux 7.1中安装Mariadb 10.0.38,因为Mariadb是Mysql的分支,安装操作基本类似。
1.首先下载安装介质mariadb-10.0.38-linux-glibc_214-x86_64.tar.gz 并将其上传到服务器的/soft目录

2.创建用户与用户组

[root@cs1 soft]# groupadd mysql

[root@cs1 soft]# useradd -g mysql mysql

3.将介质解压到/usr/local/目录下

[root@cs1 soft]# cd /usr/local

[root@cs1 local]# gunzip < /soft/mariadb-10.0.38-linux-glibc_214-x86_64.tar.gz | tar xvf -
mariadb-10.0.38-linux-glibc_214-x86_64/
mariadb-10.0.38-linux-glibc_214-x86_64/man/
mariadb-10.0.38-linux-glibc_214-x86_64/man/man8/
mariadb-10.0.38-linux-glibc_214-x86_64/man/man8/mysqld.8
........省略..........

[root@cs1 local]# ls -lrt
总用量 4
drwxr-xr-x.  2 root root    6 5月   8 2014 src
drwxr-xr-x.  2 root root    6 5月   8 2014 sbin
drwxr-xr-x.  2 root root    6 5月   8 2014 libexec
drwxr-xr-x.  2 root root    6 5月   8 2014 lib64
drwxr-xr-x.  2 root root    6 5月   8 2014 lib
drwxr-xr-x.  2 root root    6 5月   8 2014 include
drwxr-xr-x.  2 root root    6 5月   8 2014 games
drwxr-xr-x.  2 root root    6 5月   8 2014 etc
drwxr-xr-x.  5 root root   46 10月 12 2017 share
drwxr-xr-x.  2 root root   46 3月   9 2018 bin
drwxrwxr-x  13 1021 1004 4096 1月  31 02:40 mariadb-10.0.38-linux-glibc_214-x86_64

4.创建软链接

[root@cs1 local]# ln -s mariadb-10.0.38-linux-glibc_214-x86_64 mysql
[root@cs1 local]# ls -lrt
总用量 4
drwxr-xr-x.  2 root root    6 5月   8 2014 src
drwxr-xr-x.  2 root root    6 5月   8 2014 sbin
drwxr-xr-x.  2 root root    6 5月   8 2014 libexec
drwxr-xr-x.  2 root root    6 5月   8 2014 lib64
drwxr-xr-x.  2 root root    6 5月   8 2014 lib
drwxr-xr-x.  2 root root    6 5月   8 2014 include
drwxr-xr-x.  2 root root    6 5月   8 2014 games
drwxr-xr-x.  2 root root    6 5月   8 2014 etc
drwxr-xr-x.  5 root root   46 10月 12 2017 share
drwxr-xr-x.  2 root root   46 3月   9 2018 bin
drwxrwxr-x  13 1021 1004 4096 1月  31 02:40 mariadb-10.0.38-linux-glibc_214-x86_64
lrwxrwxrwx   1 root root   38 6月   4 14:43 mysql -> mariadb-10.0.38-linux-glibc_214-x86_64

5.确保目录mysql能够被用户mysql访问

[root@cs1 local]# cd mysql
[root@cs1 mysql]# chown -R mysql .
[root@cs1 mysql]# chgrp -R mysql .

6.在安装Mariadb之前,必须创建Mariadb存放数据的目录并初始化grant表,执行mysql_install_db命令来安装Mariadb,如果使用root用户来执行,必须包含–user选项来指定用户,如果是mysql用户来执行可以忽略–user选项。使用 –basedir=path 选项指定Mariadb安装目录的路径,–datadir=path选项指定Mariadb数据目录的路径。如果没有指定–basedir与–datadir选项它们在/usr/local/mysql目录下创建一个data目录。

[root@cs1 mysql]# scripts/mysql_install_db --user=mysql
Installing MariaDB/MySQL system tables in './data' ...
190604 14:44:44 [Note] ./bin/mysqld (mysqld 10.0.38-MariaDB) starting as process 19627 ...
190604 14:44:45 [Note] InnoDB: innodb_empty_free_list_algorithm has been changed to legacy because of small buffer pool size. In order to use backoff, increase buffer pool at least up to 20MB.

190604 14:44:45 [Note] InnoDB: Using mutexes to ref count buffer pool pages
190604 14:44:45 [Note] InnoDB: The InnoDB memory heap is disabled
190604 14:44:45 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
190604 14:44:45 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
190604 14:44:45 [Note] InnoDB: Compressed tables use zlib 1.2.11
190604 14:44:45 [Note] InnoDB: Using Linux native AIO
190604 14:44:45 [Note] InnoDB: Using CPU crc32 instructions
190604 14:44:45 [Note] InnoDB: Initializing buffer pool, size = 128.0M
190604 14:44:45 [Note] InnoDB: Completed initialization of buffer pool
190604 14:44:45 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
190604 14:44:45 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
190604 14:44:45 [Note] InnoDB: Database physically writes the file full: wait...
190604 14:44:45 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
190604 14:44:45 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
190604 14:44:46 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
190604 14:44:46 [Warning] InnoDB: New log files created, LSN=45781
190604 14:44:46 [Note] InnoDB: Doublewrite buffer not found: creating new
190604 14:44:46 [Note] InnoDB: Doublewrite buffer created
190604 14:44:46 [Note] InnoDB: 128 rollback segment(s) are active.
190604 14:44:46 [Warning] InnoDB: Creating foreign key constraint system tables.
190604 14:44:46 [Note] InnoDB: Foreign key constraint system tables created
190604 14:44:46 [Note] InnoDB: Creating tablespace and datafile system tables.
190604 14:44:46 [Note] InnoDB: Tablespace and datafile system tables created.
190604 14:44:46 [Note] InnoDB: Waiting for purge to start
190604 14:44:46 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.42-84.2 started; log sequence number 0
190604 14:44:48 [Note] InnoDB: FTS optimize thread exiting.
190604 14:44:48 [Note] InnoDB: Starting shutdown...
190604 14:44:48 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
190604 14:44:50 [Note] InnoDB: Shutdown completed; log sequence number 1616697
OK
Filling help tables...
190604 14:44:50 [Note] ./bin/mysqld (mysqld 10.0.38-MariaDB) starting as process 19661 ...
190604 14:44:50 [Note] InnoDB: innodb_empty_free_list_algorithm has been changed to legacy because of small buffer pool size. In order to use backoff, increase buffer pool at least up to 20MB.

190604 14:44:50 [Note] InnoDB: Using mutexes to ref count buffer pool pages
190604 14:44:50 [Note] InnoDB: The InnoDB memory heap is disabled
190604 14:44:50 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
190604 14:44:50 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
190604 14:44:50 [Note] InnoDB: Compressed tables use zlib 1.2.11
190604 14:44:50 [Note] InnoDB: Using Linux native AIO
190604 14:44:50 [Note] InnoDB: Using CPU crc32 instructions
190604 14:44:50 [Note] InnoDB: Initializing buffer pool, size = 128.0M
190604 14:44:50 [Note] InnoDB: Completed initialization of buffer pool
190604 14:44:50 [Note] InnoDB: Highest supported file format is Barracuda.
190604 14:44:50 [Note] InnoDB: 128 rollback segment(s) are active.
190604 14:44:50 [Note] InnoDB: Waiting for purge to start
190604 14:44:50 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.42-84.2 started; log sequence number 1616697
190604 14:44:50 [Note] InnoDB: FTS optimize thread exiting.
190604 14:44:50 [Note] InnoDB: Starting shutdown...
190604 14:44:51 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
190604 14:44:53 [Note] InnoDB: Shutdown completed; log sequence number 1616707
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'./bin/mysqladmin' -u root password 'new-password'
'./bin/mysqladmin' -u root -h cs1.jy.net password 'new-password'

Alternatively you can run:
'./bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '.' ; ./bin/mysqld_safe --datadir='./data'

You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
Get Involved

7.因为安装Mariadb的用户是root用户,而data目录必须要被mysql用户访问,因此修改data目录的用户与组权限

[root@cs1 mysql]# chown -R root .
[root@cs1 mysql]# chown -R mysql data

8.在安装完成后来测试Mariadb的启动

[root@cs1 mysql]# bin/mysqld_safe --user=mysql &
[1] 19770
[root@cs1 mysql]# 190604 14:45:25 mysqld_safe Logging to '/usr/local/mysql/data/cs1.jy.net.err'.
190604 14:45:25 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

mysqld_safe是服务端工具,用于启动mysqld,并且是mysqld的守护进程,mysqld_safe加&在后台运行$BASEDIR/bin/mysqld_safe &。因为mysqld_safe是mysqld的守护进程,所以mysqld_safe脚本会在启动MySQL服务器后继续监控其运行情况,并在其死机时重新启动它。直接使用mysqld_safe启动mysqld时,mysqld_safe可以使用参数选项见mysqld_safe –help,此时可以使用其他配置文件,相当于mysqld_safe把参数传递给mysqld。mysql.server脚本其实也是调用mysqld_safe脚本去启动MySQL服务器的,但此时mysqld_safe不能使用参数选项即不能mysqld_safe –defaults-file这样的模式。

9.将启动Mariadb的脚本配置成服务通过service name start命令来启用

[root@cs1 mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@cs1 mysql]# cat /etc/init.d/mysqld

[root@cs1 Packages]# service mysqld status
 SUCCESS! MariaDB running (19839)
[root@cs1 Packages]# service mysqld stop
Shutting down MariaDB... SUCCESS! 
[root@cs1 Packages]# service mysqld start
Starting MariaDB.190604 18:26:04 mysqld_safe Logging to '/usr/local/mysql/data/cs1.jy.net.err'.
190604 18:26:05 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
 SUCCESS! 

10.修改root用户密码

-bash-4.2$ mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.0.38-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
MariaDB [mysql]> set password=password("123456");
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> exit

-bash-4.2$ mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.0.38-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.01 sec)

MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

11.使用mytop工具来监控Mariadb,mytop在Mariadb安装时也会自动安装,而mysql中需要单独安装

-bash-4.2$ mytop --prompt -u root -d mysql
Password: 
install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at (eval 13) line 3,  line 1.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge.
 at /usr/local/mysql//bin/mytop line 253.

错误信息说明没有安装perl-DBD-MySQL工具包

12.安装perl-DBD-MySQ工具包

[root@cs1 bin]# yum install perl-DBD-MySQL
已加载插件:langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
file:///run/media/jy/OL-7.1%20Server.x86_64/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /run/media/jy/OL-7.1%20Server.x86_64/repodata/repomd.xml"
正在尝试其它镜像。
正在解决依赖关系
--> 正在检查事务
---> 软件包 perl-DBD-MySQL.x86_64.0.4.023-5.0.1.el7 将被 安装
--> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被软件包 perl-DBD-MySQL-4.023-5.0.1.el7.x86_64 需要
--> 正在处理依赖关系 libmysqlclient.so.18()(64bit),它被软件包 perl-DBD-MySQL-4.023-5.0.1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 mysql-community-libs.x86_64.0.5.6.23-3.el7 将被 安装
--> 正在处理依赖关系 mysql-community-common(x86-64) = 5.6.23-3.el7,它被软件包 mysql-community-libs-5.6.23-3.el7.x86_64 需要
--> 正在检查事务
---> 软件包 mysql-community-common.x86_64.0.5.6.23-3.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

============================================================================================================================================================================================================================================
 Package                                                            架构                                               版本                                                         源                                                 大小
============================================================================================================================================================================================================================================
正在安装:
 perl-DBD-MySQL                                                     x86_64                                             4.023-5.0.1.el7                                              local                                             140 k
为依赖而安装:
 mysql-community-common                                             x86_64                                             5.6.23-3.el7                                                 local                                             256 k
 mysql-community-libs                                               x86_64                                             5.6.23-3.el7                                                 local                                             2.0 M

事务概要
============================================================================================================================================================================================================================================
安装  1 软件包 (+2 依赖软件包)

总下载量:2.4 M
安装大小:12 M
Is this ok [y/d/N]: y
Downloading packages:


Error downloading packages:
  mysql-community-common-5.6.23-3.el7.x86_64: [Errno 256] No more mirrors to try.
  perl-DBD-MySQL-4.023-5.0.1.el7.x86_64: [Errno 256] No more mirrors to try.
  mysql-community-libs-5.6.23-3.el7.x86_64: [Errno 256] No more mirrors to try.

出现不能下载相关工具包的错误

13.将操作系统ISO文件挂载到系统中并进入Packages目录执行rpm命令来安装

root@cs1 Packages]# ls -lrt mysql*
-rw-rw-r-- 1 root root  1313664 5月  14 2014 mysql-connector-java-5.1.25-3.el7.noarch.rpm
-rw-rw-r-- 1 root root   145144 8月   6 2014 mysql-connector-odbc-5.2.5-6.0.1.el7.x86_64.rpm
-rw-r--r-- 1 root root   420364 2月  19 2015 mysql-community-bench-5.6.23-3.el7.x86_64.rpm
-rw-r--r-- 1 root root 19378376 2月  19 2015 mysql-community-client-5.6.23-3.el7.i686.rpm
-rw-r--r-- 1 root root  3435828 2月  19 2015 mysql-community-devel-5.6.23-3.el7.i686.rpm
-rw-r--r-- 1 root root   262464 2月  19 2015 mysql-community-common-5.6.23-3.el7.x86_64.rpm
-rw-r--r-- 1 root root   262516 2月  19 2015 mysql-community-common-5.6.23-3.el7.i686.rpm
-rw-r--r-- 1 root root 19979168 2月  19 2015 mysql-community-client-5.6.23-3.el7.x86_64.rpm
-rw-r--r-- 1 root root  3543424 2月  19 2015 mysql-community-devel-5.6.23-3.el7.x86_64.rpm
-rw-r--r-- 1 root root 23060740 2月  19 2015 mysql-community-embedded-5.6.23-3.el7.i686.rpm
-rw-r--r-- 1 root root 23733580 2月  19 2015 mysql-community-embedded-5.6.23-3.el7.x86_64.rpm
-rw-r--r-- 1 root root 64644916 2月  19 2015 mysql-community-embedded-devel-5.6.23-3.el7.i686.rpm
-rw-r--r-- 1 root root  2104968 2月  19 2015 mysql-community-libs-5.6.23-3.el7.x86_64.rpm
-rw-r--r-- 1 root root  2040356 2月  19 2015 mysql-community-libs-5.6.23-3.el7.i686.rpm
-rw-r--r-- 1 root root 68058508 2月  19 2015 mysql-community-embedded-devel-5.6.23-3.el7.x86_64.rpm
-rw-r--r-- 1 root root 60224180 2月  19 2015 mysql-community-server-5.6.23-3.el7.x86_64.rpm
-rw-r--r-- 1 root root 59280136 2月  19 2015 mysql-community-test-5.6.23-3.el7.x86_64.rpm

[root@cs1 Packages]# rpm -ihv mysql-community-libs-5.6.23-3.el7.x86_64.rpm
警告:mysql-community-libs-5.6.23-3.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY
错误:依赖检测失败:
        mysql-community-common(x86-64) = 5.6.23-3.el7 被 mysql-community-libs-5.6.23-3.el7.x86_64 需要
[root@cs1 Packages]# rpm -ivh mysql-community-common-5.6.23-3.el7.x86_64.rpm
警告:mysql-community-common-5.6.23-3.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY
准备中...                             ################################# [100%]
正在升级/安装...
   1:mysql-community-common-5.6.23-3.e################################# [100%]
[root@cs1 Packages]# rpm -ihv mysql-community-libs-5.6.23-3.el7.x86_64.rpm
警告:mysql-community-libs-5.6.23-3.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY
准备中...                             ################################# [100%]
正在升级/安装...
   1:mysql-community-libs-5.6.23-3.el7################################# [100%]

[root@cs1 Packages]# ls -lrt perl-DBD-MySQL
ls: 无法访问perl-DBD-MySQL: 没有那个文件或目录
[root@cs1 Packages]# ls -lrt perl-DBD-MySQL*
-rw-rw-r-- 1 root root 143092 8月   6 2014 perl-DBD-MySQL-4.023-5.0.1.el7.x86_64.rpm
[root@cs1 Packages]# rpm -ivh perl-DBD-MySQL-4.023-5.0.1.el7.x86_64.rpm
警告:perl-DBD-MySQL-4.023-5.0.1.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY
准备中...                             ################################# [100%]
正在升级/安装...
   1:perl-DBD-MySQL-4.023-5.0.1.el7   ################################# [100%]

14.执行mytop命令来监控Mariadb

-bash-4.2$ mytop -u root -p 123456
MariaDB on localhost (10.0.38-MariaDB)                                                                                                                                                                  up 0+01:04:21 [15:49:46]
 Queries: 170.0   qps:    0 Slow:     0.0         Se/In/Up/De(%):    06/00/00/00
 Sorts:     0 qps now:    1 Slow qps: 0.0  Threads:    2 (   1/   0) 00/00/00/00
 Handler: (R/W/U/D)     0/    0/    0/    0        Tmp: R/W/U:    89/   89/    0
 ISAM Key Efficiency: 0.0%  Bps in/out:   1.4/ 66.6   Now in/out:  22.6/ 2.9k

       Id     User         Host/IP        DB   Time     %    Cmd           State Query
       --     ----         -------        --   ----     -    ---           ----- ----------
       12     root       localhost     mysql     10   0.0  Sleep                                                                                                                                                                          
       10     root       localhost      test      0   0.0  Query            init show full processlist   

到此安装也就完成了。