CentOS7完全离线安装配置NTP、MySQL

版权声明:本文为博主原创文章,转载请加上原文地址,谢谢! https://blog.csdn.net/Dr_Guo/article/details/80928545

NTP及依赖 rpm包下载:

https://download.csdn.net/download/dr_guo/10522197

MySQL及依赖 rpm包下载:

https://download.csdn.net/download/dr_guo/10522212


NTP安装

# 修改系统时间
[root@10-121-2-96 opt]# timedatectl set-ntp no
[root@10-121-2-96 opt]# timedatectl set-time "2018-07-05 15:06:00"
[root@10-121-2-96 opt]# timedatectl set-timezone Asia/Shanghai
[root@10-121-2-96 opt]# date
Fri Jul  5 15:06:16 CST 2018


# rpm安装ntp
[root@10-121-2-96 ~]# cd /opt
[root@10-121-2-96 opt]# ls
autogen-libopts-5.18-5.el7.x86_64.rpm  cloudera-manager-centos7-cm5.13.0_x86_64.tar.gz  ntp-4.2.6p5-18.el7.centos.x86_64.rpm  ntpdate-4.2.6p5-18.el7.centos.x86_64.rpm  soft
[root@10-121-2-96 opt]# rpm -ivh autogen-libopts-5.18-5.el7.x86_64.rpm
warning: autogen-libopts-5.18-5.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:autogen-libopts-5.18-5.el7       ################################# [100%] 
[root@10-121-2-96 opt]# rpm -ivh ntpdate-4.2.6p5-18.el7.centos.x86_64.rpm 
warning: ntpdate-4.2.6p5-18.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:ntpdate-4.2.6p5-18.el7.centos    ################################# [100%]
[root@10-121-2-96 opt]# rpm -ivh ntp-4.2.6p5-18.el7.centos.x86_64.rpm 
warning: ntp-4.2.6p5-18.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:ntp-4.2.6p5-18.el7.centos        ################################# [100%]


# ntp server 10.121.2.106
[root@10-121-2-106 opt]# vi /etc/ntp.conf
restrict 10.121.2.106 mask 255.255.255.0 nomodify notrap     # 允许内网其他机器同步时间
server 127.127.1.0                 # 外部时间服务器不可用时,以本地时间作为时间服务
fudge  127.127.1.0 stratum 10

[root@10-121-2-106 opt]# service ntpd restart
Redirecting to /bin/systemctl restart ntpd.service
[root@10-121-2-106 opt]# systemctl disable chronyd.service
[root@10-121-2-106 opt]# systemctl enable ntpd.service # 设置开机启动
[root@10-121-2-106 opt]# ntpstat
synchronised to local net at stratum 11 
   time correct to within 7948 ms
   polling server every 64 s
[root@10-121-2-106 opt]# systemctl status ntpd.service
● ntpd.service - Network Time Service
   Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2018-07-06 09:18:49 CST; 22s ago
  Process: 12428 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 12429 (ntpd)
   CGroup: /system.slice/ntpd.service
           └─12429 /usr/sbin/ntpd -u ntp:ntp -g

Jul 06 09:18:49 adrmbda106 ntpd[12429]: Listen and drop on 1 v6wildcard :: UDP 123
Jul 06 09:18:49 adrmbda106 ntpd[12429]: Listen normally on 2 lo 127.0.0.1 UDP 123
Jul 06 09:18:49 adrmbda106 ntpd[12429]: Listen normally on 3 bond0 10.121.2.106 UDP 123
Jul 06 09:18:49 adrmbda106 ntpd[12429]: Listen normally on 4 lo ::1 UDP 123
Jul 06 09:18:49 adrmbda106 ntpd[12429]: Listen normally on 5 bond0 fe80::92ec:baff:fe20:e0f2 UDP 123
Jul 06 09:18:49 adrmbda106 ntpd[12429]: Listening on routing socket on fd #22 for interface updates
Jul 06 09:18:49 adrmbda106 ntpd[12429]: 0.0.0.0 c016 06 restart
Jul 06 09:18:49 adrmbda106 ntpd[12429]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
Jul 06 09:18:49 adrmbda106 ntpd[12429]: 0.0.0.0 c011 01 freq_not_set
Jul 06 09:18:50 adrmbda106 ntpd[12429]: 0.0.0.0 c514 04 freq_mode


# ntp client 96-105
[root@10-121-2-96 opt]# vi /etc/ntp.conf
server 10.121.2.106  #<--该IP是NTP主机端的IP
restrict  10.121.2.106  nomodify notrap noquery   # 允许上层时间服务器主动修改本机时间
[root@10-121-2-96 opt]# ntpdate -u 10.121.2.106   # 手动同步主机端,免得本地时间与主机端相差太大导致无法同步。
 6 Jul 03:15:45 ntpdate[3107]: adjust time server 10.121.2.106 offset -0.050032 sec
[root@10-121-2-96 opt]# service ntpd restart
Redirecting to /bin/systemctl restart ntpd.service
[root@10-121-2-96 opt]# systemctl disable chronyd.service
[root@10-121-2-96 opt]# systemctl enable ntpd.service # 设置开机启动
[root@10-121-2-96 opt]# ntpstat
synchronised to NTP server (10.121.2.106) at stratum 12 
   time correct to within 8415 ms
   polling server every 64 s

MySQL安装

[root@10-121-2-97 opt]# rpm -qa|grep -i mysql
[root@10-121-2-97 opt]# rpm -qa | grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[root@10-121-2-97 opt]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
[root@10-121-2-97 opt]# rpm -ivh net-tools-2.0-0.22.20131004git.el7.x86_64.rpm 
warning: net-tools-2.0-0.22.20131004git.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:net-tools-2.0-0.22.20131004git.el################################# [100%]
[root@10-121-2-97 opt]# rpm -ivh MySQL-server-5.6.31-1.el6.x86_64.rpm MySQL-client-5.6.31-1.el6.x86_64.rpm MySQL-devel-5.6.31-1.el6.x86_64.rpm
warning: MySQL-server-5.6.31-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:MySQL-devel-5.6.31-1.el6         ################################# [ 33%]
   2:MySQL-client-5.6.31-1.el6        ################################# [ 67%]
   3:MySQL-server-5.6.31-1.el6        ################################# [100%]
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
...

[root@10-121-2-97 opt]# vi /root/.mysql_secret
[root@10-121-2-97 opt]# mysql -uroot -p6TJB64cHxR4V62SK
Warning: Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@10-121-2-97 opt]# service mysql start
Starting MySQL. SUCCESS! 
[root@10-121-2-97 opt]# mysql -uroot -p6TJB64cHxR4V62SK
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 1
Server version: 5.6.31

Copyright (c) 2000, 2016, 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> update user set password=PASSWORD('xxx') where USER='root';
ERROR 1046 (3D000): No database selected
mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> set password=password('xxx');
Query OK, 0 rows affected (0.00 sec)

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

mysql> 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
mysql> update user set password=PASSWORD('xxx') where USER='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 4  Changed: 3  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit;
Bye


[root@10-121-2-97 opt]# chkconfig mysql on
[root@10-121-2-97 opt]# mysql -uroot -pxxx
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.6.31 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit;
Bye

猜你喜欢

转载自blog.csdn.net/Dr_Guo/article/details/80928545