linux系统下开发环境安装与配置

安装系统环境

CentOS 6.8 64位

jdk版本

7u80 64位

Tomcat版本

Tomcat7

maven版本

Apache Maven 3.6.0

vsftpd版本

vsftpd-2.2.2-24.el6.x86_64

Nginx版本

nginx-1.14.2

mysql版本

mysql-server-5.1.73-8.el6_8.x86_64

git版本

git version 2.18.0

阿里源配置

#备份
[root@192 yum.repos.d]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
#下载新的CentOS-Base.repo 到/etc/yum.repos.d/
[root@192 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
#生成缓存
[root@192 yum.repos.d]# yum makecache

设置开机时关闭防火墙

[root@192 vsftpd]# chkconfig iptables off

jdk安装

下载

清理系统默认自带jdk

[root@192 yum.repos.d]# rpm -qa | grep jdk
java-1.6.0-openjdk-1.6.0.38-1.13.10.4.el6.x86_64
java-1.7.0-openjdk-1.7.0.99-2.6.5.1.el6.x86_64
[root@192 yum.repos.d]# yum remove java-1.6.0-openjdk-1.6.0.38-1.13.10.4.el6.x86_64
[root@192 yum.repos.d]# yum remove java-1.7.0-openjdk-1.7.0.99-2.6.5.1.el6.x86_64

授权

[root@192 soft]# chmod 777 jdk-7u80-linux-x64.rpm 

安装

[root@192 soft]# rpm -ivh jdk-7u80-linux-x64.rpm 

默认安装路径/user/java

jdk配置环境变量,编辑/etc/profile文件,末尾追加

#jdk
export JAVA_HOME=/usr/java/jdk1.7.0_80
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

使得/etc/profile文件立即生效

[root@192 apache-maven-3.6.0]# source /etc/profile

Tomcat安装

下载

解压


[root@192 soft]# tar -zxvf apache-tomcat-7.0.93.tar.gz -C /opt/module/

Tomcat配置环境变量,编辑/etc/profile文件,末尾追加

#tomcat
export CATALINA_HOME=/opt/module/apache-tomcat-7.0.93
export PATH=$PATH:$CATALINA_HOME/bin

使得/etc/profile文件立即生效

[root@192 apache-maven-3.6.0]# source /etc/profile

配置UTF-8字符集,进入Tomcat安装的conf文件夹,编辑server.xml文件,找到配置8080默认端口的位置,在xml节点末尾增加URIEncoding="UTF-8"

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" URIEncoding="UTF-8" />

启动Tomcat,进入/opt/module/apache-tomcat-7.0.93/bin目录,执行./startup.sh

访问http://192.168.1.104:8080/

Maven安装

下载

解压

[root@192 soft]# tar -zxvf apache-maven-3.6.0-bin.tar.gz -C /opt/module/

Maven配置环境变量,编辑/etc/profile文件,末尾追加

#maven
export MAVEN_HOME=/opt/module/apache-maven-3.6.0
export PATH=$PATH:$MAVEN_HOME/bin

使得/etc/profile文件立即生效

[root@192 apache-maven-3.6.0]# source /etc/profile

验证

[root@192 apache-maven-3.6.0]# mvn -version

vsftpd安装

安装

[root@192 apache-maven-3.6.0]# yum -y install vsftpd

查看是否已安装

[root@192 apache-maven-3.6.0]# rpm -qa | grep vsftpd
vsftpd-2.2.2-24.el6.x86_64

默认配置文件/etc/vsftpd/vsftpd.conf

创建虚拟用户

根目录下创建ftp文件夹

[root@192 vsftpd]# cd /
[root@192 /]# mkdir ftpfile

添加匿名用户

[root@192 /]# useradd ftpuser -d /ftpfile/ -s /sbin/nologin 

修改ftpfile权限

[root@192 /]# chown -R ftpuser.ftpuser /ftpfile/

重设ftpuser密码

[root@192 /]# passwd ftpuser

将刚刚新增的虚拟用户添加到此配置文件中

[root@192 ~]# cd /etc/vsftpd/
[root@192 vsftpd]# vim chroo_list 
[root@192 bin]# cat /etc/vsftpd/chroo_list 
ftpuser

编辑配置文件/etc/vsftpd/vsftpd.conf,末尾追加

local_root=/ftpfile
anon_root=/ftpfile
use_localtime=YES
anonymous_enable=no

登录验证的时候出现500提示,编辑/etc/selinux/config文件,设置SELINUX=disabled

[root@192 vsftpd]# vim /etc/selinux/config

如果还报500,执行

[root@192 vsftpd]# setsebool -P ftp_home_dir 1

设置开启启动vsftpd服务

[root@192 vsftpd]# chkconfig vsftpd on

访问ftp://192.168.1.104/

安装Nginx

安装步骤

下载

安装依赖gcc、pcre、zlib、openssl

[root@192 vsftpd]# yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

解压

[root@192 soft]# tar -zxvf nginx-1.14.2.tar.gz -C /opt/module/

编译安装

[root@192 nginx-1.14.2]# pwd
/opt/module/nginx-1.14.2
[root@192 nginx-1.14.2]# ./configure
[root@192 nginx-1.14.2]# make
[root@192 nginx-1.14.2]# make install

查看Nginx安装目录、版本

[root@192 nginx-1.14.2]# whereis nginx
nginx: /usr/local/nginx
[root@192 nginx-1.14.2]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.14.2

测试配置文件nginx.conf的正确性

[root@192 nginx-1.14.2]# /usr/local/nginx/sbin/nginx  -t

启动Nginx

[root@192 nginx-1.14.2]# /usr/local/nginx/sbin/nginx
[root@192 nginx-1.14.2]# ps -ef | grep nginx
root       5606      1  0 01:02 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody     5607   5606  0 01:02 ?        00:00:00 nginx: worker process      
root       5626   2868  0 01:09 pts/0    00:00:00 grep nginx

停止Nginx

[root@192 nginx-1.14.2]# /usr/local/nginx/sbin/nginx -s stop

访问http://192.168.1.104/

配置虚拟域名

配置虚拟域名映射

[root@192 vhost]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6


#centos
#192.168.1.104  www.imooc.com
127.0.0.1 www.imooc.com

测试

[root@192 sbin]# ping www.imooc.com
PING www.imooc.com (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.013 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.032 ms

编辑/usr/local/nginx/conf/nginx.conf文件,追加

 ###########################vhost##############################################
    include vhost/*.conf;

/usr/local/nginx/conf目录下,新建vhost文件夹

/usr/local/nginx/conf/vhost目录下,新建域名转发www.mytest.com.conf配置文件

[root@192 vhost]# cat /usr/local/nginx/conf/vhost/www.mytest.com.conf 
#Start www.mytest.com
server {
    listen 80;
    server_name  www.mytest.com;

    access_log  /usr/local/nginx/logs/access.log combined;
    index  index.html index.htm index.php;

    if ( $query_string ~* ".*[\;'\<\>].*" ){ 
    return 404;
     }

    # send request back to apach
    location / {
       proxy_pass http://127.0.0.1:8080/; 
   }
}

访问www.mytest.com

Nginx配置静态资源转发

编辑/usr/local/nginx/conf/nginx.conf文件,追加

 ###########################vhost##############################################
    include vhost/*.conf;

/usr/local/nginx/conf目录下,新建vhost文件夹

/usr/local/nginx/conf/vhost目录下,新建域名转发www.mytest.com.conf配置文件

[root@192 vhost]# cat /usr/local/nginx/conf/vhost/www.mytest.com.conf 
#Start www.mytest.com
server {
    listen 80;
    server_name  www.mytest.com;

    access_log  /usr/local/nginx/logs/access.log combined;
    index  index.html index.htm index.php;

    if ( $query_string ~* ".*[\;'\<\>].*" ){ 
    return 404;
     }

    # send request back to apach
    location / {
       root /ftpfile/; 
   }
}

mysql安装

yum安装

安装

[root@192 ~]# yum -y install mysql-server

配置字符集,编辑/etc/my.cnf文件,追加

#utf8
default-character-set=utf8

设置mysql服务随系统自动启动

[root@192 ~]# chkconfig mysqld on
[root@192 ~]# chkconfig --list mysqld
mysqld             0:关闭    1:关闭    2:启用    3:启用    4:启用    5:启用    6:关闭

启动mysql服务

[root@192 ~]# service mysqld start
正在启动 mysqld:                                          [确定]

登录,使用非密码登录

[root@192 mysql]# mysql -uroot 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, 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> 

查看mysql的用户

mysql> select user,host,password from  mysql.user;
+------+---------------+----------+
| user | host          | password |
+------+---------------+----------+
| root | localhost     |          |
| root | 192.168.1.104 |          |
| root | 127.0.0.1     |          |
|      | localhost     |          |
|      | 192.168.1.104 |          |
+------+---------------+----------+
5 rows in set (0.00 sec)

删除匿名用户

mysql> delete from mysql.user where user='';
Query OK, 2 rows affected (0.00 sec)

刷新,立即生效

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

修改root密码

mysql> set password for root@localhost=password("000000");
Query OK, 0 rows affected (0.00 sec)

插入mysql新用户

mysql> insert into mysql.user(Host,User,Password) values("localhost","admin",password("000000"));
Query OK, 1 row affected, 3 warnings (0.01 sec)

查看用户权限

mysql> select * from mysql.user \G
*************************** 1. row ***************************
                 Host: localhost
                 User: root
             Password: *032197AE5731D4664921A6CCAC7CFCE6A0698693
          Select_priv: Y
          Insert_priv: Y
          Update_priv: Y
          Delete_priv: Y
          Create_priv: Y
            Drop_priv: Y
          Reload_priv: Y
        Shutdown_priv: Y
         Process_priv: Y
            File_priv: Y
           Grant_priv: Y
      References_priv: Y
           Index_priv: Y
           Alter_priv: Y
         Show_db_priv: Y
           Super_priv: Y
Create_tmp_table_priv: Y
     Lock_tables_priv: Y
         Execute_priv: Y
      Repl_slave_priv: Y
     Repl_client_priv: Y
     Create_view_priv: Y
       Show_view_priv: Y
  Create_routine_priv: Y
   Alter_routine_priv: Y
     Create_user_priv: Y
           Event_priv: Y
         Trigger_priv: Y
             ssl_type: 
           ssl_cipher: 
          x509_issuer: 
         x509_subject: 
        max_questions: 0
          max_updates: 0
      max_connections: 0
 max_user_connections: 0
*************************** 2. row ***************************
                 Host: 192.168.1.104
                 User: root
             Password: 
          Select_priv: Y
          Insert_priv: Y
          Update_priv: Y
          Delete_priv: Y
          Create_priv: Y
            Drop_priv: Y
          Reload_priv: Y
        Shutdown_priv: Y
         Process_priv: Y
            File_priv: Y
           Grant_priv: Y
      References_priv: Y
           Index_priv: Y
           Alter_priv: Y
         Show_db_priv: Y
           Super_priv: Y
Create_tmp_table_priv: Y
     Lock_tables_priv: Y
         Execute_priv: Y
      Repl_slave_priv: Y
     Repl_client_priv: Y
     Create_view_priv: Y
       Show_view_priv: Y
  Create_routine_priv: Y
   Alter_routine_priv: Y
     Create_user_priv: Y
           Event_priv: Y
         Trigger_priv: Y
             ssl_type: 
           ssl_cipher: 
          x509_issuer: 
         x509_subject: 
        max_questions: 0
          max_updates: 0
      max_connections: 0
 max_user_connections: 0
*************************** 3. row ***************************
                 Host: 127.0.0.1
                 User: root
             Password: 
          Select_priv: Y
          Insert_priv: Y
          Update_priv: Y
          Delete_priv: Y
          Create_priv: Y
            Drop_priv: Y
          Reload_priv: Y
        Shutdown_priv: Y
         Process_priv: Y
            File_priv: Y
           Grant_priv: Y
      References_priv: Y
           Index_priv: Y
           Alter_priv: Y
         Show_db_priv: Y
           Super_priv: Y
Create_tmp_table_priv: Y
     Lock_tables_priv: Y
         Execute_priv: Y
      Repl_slave_priv: Y
     Repl_client_priv: Y
     Create_view_priv: Y
       Show_view_priv: Y
  Create_routine_priv: Y
   Alter_routine_priv: Y
     Create_user_priv: Y
           Event_priv: Y
         Trigger_priv: Y
             ssl_type: 
           ssl_cipher: 
          x509_issuer: 
         x509_subject: 
        max_questions: 0
          max_updates: 0
      max_connections: 0
 max_user_connections: 0
*************************** 4. row ***************************
                 Host: localhost
                 User: admin
             Password: *032197AE5731D4664921A6CCAC7CFCE6A0698693
          Select_priv: N
          Insert_priv: N
          Update_priv: N
          Delete_priv: N
          Create_priv: N
            Drop_priv: N
          Reload_priv: N
        Shutdown_priv: N
         Process_priv: N
            File_priv: N
           Grant_priv: N
      References_priv: N
           Index_priv: N
           Alter_priv: N
         Show_db_priv: N
           Super_priv: N
Create_tmp_table_priv: N
     Lock_tables_priv: N
         Execute_priv: N
      Repl_slave_priv: N
     Repl_client_priv: N
     Create_view_priv: N
       Show_view_priv: N
  Create_routine_priv: N
   Alter_routine_priv: N
     Create_user_priv: N
           Event_priv: N
         Trigger_priv: N
             ssl_type: 
           ssl_cipher: 
          x509_issuer: 
         x509_subject: 
        max_questions: 0
          max_updates: 0
      max_connections: 0
 max_user_connections: 0
4 rows in set (0.00 sec)

查库,新建database数据库

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.01 sec)
mysql> create database mytest default character set utf8 collate utf8_general_ci;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| mytest             |
| test               |
+--------------------+
4 rows in set (0.00 sec)

本地用户赋予所有权限、给账号开通外网所有权限

mysql> grant all privileges on mytest.* to admin@'%' identified by '000000' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> grant select,delete,create on mytest.* to admin@'192.168.1.104' identified by '000000' with grant option;
Query OK, 0 rows affected (0.00 sec)

导入sql文件

mysql> source /opt/module/mmall.sql

tar包安装

centos版本为7

关闭防火墙

[zbiti@hadoop106 mysql]$ systemctl stop firewalld.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password: 
==== AUTHENTICATION COMPLETE ===
[zbiti@hadoop106 mysql]$ sudo firewall-cmd --state
running
[zbiti@hadoop106 mysql]$ firewall-cmd --state
not running

关闭开机自启

[zbiti@hadoop106 mysql]$ systemctl disable firewalld.service 
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ===
Authentication is required to manage system service or unit files.
Authenticating as: root
Password: 
==== AUTHENTICATION COMPLETE ===
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: root
Password: 
==== AUTHENTICATION COMPLETE ===
[zbiti@hadoop106 mysql]$ 

上传mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz

解压

[zbiti@hadoop106 soft]$ tar -xvf mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz -C /opt/module/

重命名

[zbiti@hadoop106 soft]$ cd /opt/module/
[zbiti@hadoop106 module]$ pwd
/opt/module
[zbiti@hadoop106 module]$ ll
总用量 0
drwxrwxr-x. 9 zbiti zbiti 172 1月   7 16:01 mysql-8.0.13-linux-glibc2.12-x86_64
[zbiti@hadoop106 module]$ mv mysql-8.0.13-linux-glibc2.12-x86_64/ mysql
[zbiti@hadoop106 module]$ ll
总用量 0
drwxrwxr-x. 9 zbiti zbiti 172 1月   7 16:01 mysql

创建数据目录data

[zbiti@hadoop106 module]$ cd mysql/
[zbiti@hadoop106 mysql]$ pwd
/opt/module/mysql
[zbiti@hadoop106 mysql]$ ll
总用量 448
drwxrwxr-x.  2 zbiti zbiti   4096 1月   7 16:01 bin
drwxrwxr-x.  2 zbiti zbiti     86 1月   7 16:01 docs
drwxrwxr-x.  3 zbiti zbiti    266 1月   7 16:01 include
drwxrwxr-x.  6 zbiti zbiti   4096 1月   7 16:01 lib
-rw-r--r--.  1 zbiti zbiti 335809 10月  7 2018 LICENSE
-rw-r--r--.  1 zbiti zbiti 101807 10月  7 2018 LICENSE.router
drwxrwxr-x.  4 zbiti zbiti     30 1月   7 16:01 man
-rw-r--r--.  1 zbiti zbiti    687 10月  7 2018 README
-rw-r--r--.  1 zbiti zbiti    700 10月  7 2018 README.router
drwxrwxr-x. 28 zbiti zbiti   4096 1月   7 16:01 share
drwxrwxr-x.  2 zbiti zbiti     90 1月   7 16:01 support-files
[zbiti@hadoop106 mysql]$ mkdir data
[zbiti@hadoop106 mysql]$ ll
总用量 448
drwxrwxr-x.  2 zbiti zbiti   4096 1月   7 16:01 bin
drwxrwxr-x.  2 zbiti zbiti      6 1月   7 16:03 data
drwxrwxr-x.  2 zbiti zbiti     86 1月   7 16:01 docs
drwxrwxr-x.  3 zbiti zbiti    266 1月   7 16:01 include
drwxrwxr-x.  6 zbiti zbiti   4096 1月   7 16:01 lib
-rw-r--r--.  1 zbiti zbiti 335809 10月  7 2018 LICENSE
-rw-r--r--.  1 zbiti zbiti 101807 10月  7 2018 LICENSE.router
drwxrwxr-x.  4 zbiti zbiti     30 1月   7 16:01 man
-rw-r--r--.  1 zbiti zbiti    687 10月  7 2018 README
-rw-r--r--.  1 zbiti zbiti    700 10月  7 2018 README.router
drwxrwxr-x. 28 zbiti zbiti   4096 1月   7 16:01 share
drwxrwxr-x.  2 zbiti zbiti     90 1月   7 16:01 support-files

初始化数据目录,会生成临时密码

[zbiti@hadoop106 mysql]$ pwd
/opt/module/mysql
[zbiti@hadoop106 mysql]$ bin/mysqld --initialize --user=mysql --basedir=/opt/module/mysql --datadir=/opt/module/mysql/data &
[1] 54448
[zbiti@hadoop106 mysql]$ 2020-01-07T08:16:32.971228Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 1024 (requested 8161)
2020-01-07T08:16:32.971340Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 431 (requested 4000)
2020-01-07T08:16:32.971790Z 0 [System] [MY-013169] [Server] /opt/module/mysql/bin/mysqld (mysqld 8.0.13) initializing of server in progress as process 54448
2020-01-07T08:16:32.975278Z 0 [Warning] [MY-010122] [Server] One can only use the --user switch if running as root
2020-01-07T08:16:34.180140Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 8r+,,tfiozPl
2020-01-07T08:16:35.062294Z 0 [System] [MY-013170] [Server] /opt/module/mysql/bin/mysqld (mysqld 8.0.13) initializing of server has completed

[1]+  完成                  bin/mysqld --initialize --user=mysql --basedir=/opt/module/mysql --datadir=/opt/module/mysql/data
[zbiti@hadoop106 mysql]$ ll data/
总用量 155700
-rw-r-----. 1 zbiti zbiti       56 1月   7 16:16 auto.cnf
-rw-------. 1 zbiti zbiti     1676 1月   7 16:16 ca-key.pem
-rw-r--r--. 1 zbiti zbiti     1112 1月   7 16:16 ca.pem
-rw-r--r--. 1 zbiti zbiti     1112 1月   7 16:16 client-cert.pem
-rw-------. 1 zbiti zbiti     1680 1月   7 16:16 client-key.pem
-rw-r-----. 1 zbiti zbiti     5772 1月   7 16:16 ib_buffer_pool
-rw-r-----. 1 zbiti zbiti 12582912 1月   7 16:16 ibdata1
-rw-r-----. 1 zbiti zbiti 50331648 1月   7 16:16 ib_logfile0
-rw-r-----. 1 zbiti zbiti 50331648 1月   7 16:16 ib_logfile1
drwxr-x---. 2 zbiti zbiti        6 1月   7 16:16 #innodb_temp
drwxr-x---. 2 zbiti zbiti      143 1月   7 16:16 mysql
-rw-r-----. 1 zbiti zbiti 25165824 1月   7 16:16 mysql.ibd
drwxr-x---. 2 zbiti zbiti     4096 1月   7 16:16 performance_schema
-rw-------. 1 zbiti zbiti     1676 1月   7 16:16 private_key.pem
-rw-r--r--. 1 zbiti zbiti      452 1月   7 16:16 public_key.pem
-rw-r--r--. 1 zbiti zbiti     1112 1月   7 16:16 server-cert.pem
-rw-------. 1 zbiti zbiti     1680 1月   7 16:16 server-key.pem
drwxr-x---. 2 zbiti zbiti       28 1月   7 16:16 sys
-rw-r-----. 1 zbiti zbiti 10485760 1月   7 16:16 undo_001
-rw-r-----. 1 zbiti zbiti 10485760 1月   7 16:16 undo_002

MySQL加入到服务自启动

[zbiti@hadoop106 mysql]$ cp support-files/mysql.server /etc/init.d/
cp: 无法创建普通文件"/etc/init.d/mysql.server": 权限不够
[zbiti@hadoop106 mysql]$ sudo cp support-files/mysql.server /etc/init.d/

手动创建/etc/my.cnf,并指定MySQL启动路径和数据存放路径

[zbiti@hadoop106 mysql]$ cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

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

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

[zbiti@hadoop106 mysql]$ rm -rf /etc/my.cnf
rm: 无法删除"/etc/my.cnf": 权限不够
[zbiti@hadoop106 mysql]$ sudo rm -rf /etc/my.cnf
[zbiti@hadoop106 mysql]$ sudo vim /etc/my.cnf
[zbiti@hadoop106 mysql]$ cat /etc/my.cnf
# The MySQL server
[mysqld]
basedir=/opt/module/mysql
datadir=/opt/module/mysql/data

[zbiti@hadoop106 mysql]$ 

启动服务

[zbiti@hadoop106 mysql]$ /etc/init.d/mysql.server start
Starting MySQL. SUCCESS! 
[zbiti@hadoop106 mysql]$ ps -ef|grep mysql
zbiti     54531      1  0 16:18 pts/1    00:00:00 /bin/sh /opt/module/mysql/bin/mysqld_safe --datadir=/opt/module/mysql/data --pid-file=/opt/module/mysql/data/hadoop106.pid
zbiti     54649  54531  9 16:18 pts/1    00:00:00 /opt/module/mysql/bin/mysqld --basedir=/opt/module/mysql --datadir=/opt/module/mysql/data --plugin-dir=/opt/module/mysql/lib/plugin --log-error=hadoop106.err --pid-file=/opt/module/mysql/data/hadoop106.pid
zbiti     54692   3101  0 16:18 pts/1    00:00:00 grep --color=auto mysql

连接数据库,将MySQL命令加入到环境变量

[zbiti@hadoop106 mysql]$ mysql -u root -p 8r+,,tfiozPl
bash: mysql: 未找到命令...
[zbiti@hadoop106 mysql]$ sudo vim /etc/profile

#MYSQL_HOME
export MYSQL_HOME=/opt/module/mysql
export PATH=$PATH:$MYSQL_HOME/bin
[zbiti@hadoop106 mysql]$ source /etc/profile
[zbiti@hadoop106 mysql]$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.13

Copyright (c) 2000, 2018, 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> 

修改密码

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user root@localhost identified by '123456';
Query OK, 0 rows affected (0.10 sec)

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

mysql> 

查看数据和日志存放目录

mysql> SHOW VARIABLES LIKE '%datadir%';
+---------------+-------------------------+
| Variable_name | Value                   |
+---------------+-------------------------+
| datadir       | /opt/module/mysql/data/ |
+---------------+-------------------------+
1 row in set (0.01 sec)

mysql> SHOW  GLOBAL VARIABLES LIKE '%log%';
+--------------------------------------------+--------------------------------------------------+
| Variable_name                              | Value                                            |
+--------------------------------------------+--------------------------------------------------+
| activate_all_roles_on_login                | OFF                                              |
| back_log                                   | 151                                              |
| binlog_cache_size                          | 32768                                            |
| binlog_checksum                            | CRC32                                            |
| binlog_direct_non_transactional_updates    | OFF                                              |
| binlog_error_action                        | ABORT_SERVER                                     |
| binlog_expire_logs_seconds                 | 2592000                                          |
| binlog_format                              | ROW                                              |
| binlog_group_commit_sync_delay             | 0                                                |
| binlog_group_commit_sync_no_delay_count    | 0                                                |
| binlog_gtid_simple_recovery                | ON                                               |
| binlog_max_flush_queue_time                | 0                                                |
| binlog_order_commits                       | ON                                               |
| binlog_row_image                           | FULL                                             |
| binlog_row_metadata                        | MINIMAL                                          |
| binlog_row_value_options                   |                                                  |
| binlog_rows_query_log_events               | OFF                                              |
| binlog_stmt_cache_size                     | 32768                                            |
| binlog_transaction_dependency_history_size | 25000                                            |
| binlog_transaction_dependency_tracking     | COMMIT_ORDER                                     |
| expire_logs_days                           | 0                                                |
| general_log                                | OFF                                              |
| general_log_file                           | /opt/module/mysql/data/hadoop106.log             |
| innodb_api_enable_binlog                   | OFF                                              |
| innodb_flush_log_at_timeout                | 1                                                |
| innodb_flush_log_at_trx_commit             | 1                                                |
| innodb_log_buffer_size                     | 16777216                                         |
| innodb_log_checksums                       | ON                                               |
| innodb_log_compressed_pages                | ON                                               |
| innodb_log_file_size                       | 50331648                                         |
| innodb_log_files_in_group                  | 2                                                |
| innodb_log_group_home_dir                  | ./                                               |
| innodb_log_spin_cpu_abs_lwm                | 80                                               |
| innodb_log_spin_cpu_pct_hwm                | 50                                               |
| innodb_log_wait_for_flush_spin_hwm         | 400                                              |
| innodb_log_write_ahead_size                | 8192                                             |
| innodb_max_undo_log_size                   | 1073741824                                       |
| innodb_online_alter_log_max_size           | 134217728                                        |
| innodb_print_ddl_logs                      | OFF                                              |
| innodb_redo_log_encrypt                    | OFF                                              |
| innodb_undo_log_encrypt                    | OFF                                              |
| innodb_undo_log_truncate                   | ON                                               |
| log_bin                                    | ON                                               |
| log_bin_basename                           | /opt/module/mysql/data/binlog                    |
| log_bin_index                              | /opt/module/mysql/data/binlog.index              |
| log_bin_trust_function_creators            | OFF                                              |
| log_bin_use_v1_row_events                  | OFF                                              |
| log_error                                  | ./hadoop106.err                                  |
| log_error_services                         | log_filter_internal; log_sink_internal           |
| log_error_suppression_list                 |                                                  |
| log_error_verbosity                        | 2                                                |
| log_output                                 | FILE                                             |
| log_queries_not_using_indexes              | OFF                                              |
| log_slave_updates                          | ON                                               |
| log_slow_admin_statements                  | OFF                                              |
| log_slow_slave_statements                  | OFF                                              |
| log_statements_unsafe_for_binlog           | ON                                               |
| log_throttle_queries_not_using_indexes     | 0                                                |
| log_timestamps                             | UTC                                              |
| max_binlog_cache_size                      | 18446744073709547520                             |
| max_binlog_size                            | 1073741824                                       |
| max_binlog_stmt_cache_size                 | 18446744073709547520                             |
| max_relay_log_size                         | 0                                                |
| relay_log                                  | hadoop106-relay-bin                              |
| relay_log_basename                         | /opt/module/mysql/data/hadoop106-relay-bin       |
| relay_log_index                            | /opt/module/mysql/data/hadoop106-relay-bin.index |
| relay_log_info_file                        | relay-log.info                                   |
| relay_log_info_repository                  | TABLE                                            |
| relay_log_purge                            | ON                                               |
| relay_log_recovery                         | OFF                                              |
| relay_log_space_limit                      | 0                                                |
| slow_query_log                             | OFF                                              |
| slow_query_log_file                        | /opt/module/mysql/data/hadoop106-slow.log        |
| sql_log_off                                | OFF                                              |
| sync_binlog                                | 1                                                |
| sync_relay_log                             | 10000                                            |
| sync_relay_log_info                        | 10000                                            |
+--------------------------------------------+--------------------------------------------------+
77 rows in set (0.01 sec)

使用systemd管理mysql

[zbiti@hadoop106 ~]$ sudo vim /etc/systemd/system/mysqld.service 

[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=zbiti
Group=zbiti
ExecStart=/opt/module/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000

[zbiti@hadoop106 ~]$ sudo systemctl start mysqld.service 
[zbiti@hadoop106 ~]$ ps -ef|grep mysql
zbiti      5127      1 10 16:11 ?        00:00:00 /opt/module/mysql/bin/mysqld --defaults-file=/etc/my.cnf
zbiti      5174   2977  0 16:11 pts/1    00:00:00 grep --color=auto mysql
[zbiti@hadoop106 ~]$ sudo systemctl stop mysqld.service 
[zbiti@hadoop106 ~]$ ps -ef|grep mysql
zbiti      5193   2977  0 16:11 pts/1    00:00:00 grep --color=auto mysql

git安装

下载

解压

[root@192 ~]# tar -zxvf git-2.18.0.tar.gz -C /opt/module/

安装依赖

[root@192 ~]# yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker cpio

编译安装

[root@192 git-2.18.0]# make prefix=/usr/local/ install

验证

[root@192 ~]# git --version
git version 2.18.0

生成公私密钥对

[root@192 ~]# ssh-keygen -t rsa -C "782125244@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
85:1e:ef:5a:33:ab:e7:79:a4:46:f6:8e:8f:7f:af:cd 782125244@qq.com
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|         .       |
|        o .      |
|       . +       |
|        S .      |
|         .o .    |
|         o=+     |
|         o+Bo .o |
|        o=*=+..oE|
+-----------------+

复制公钥粘贴到码云或者GitHub上SSH公钥上

[root@192 .ssh]# cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1sZvTnjQyVn7r2C7G9Q/WyVTTmJYqWhQdVfh3tBCUX8kJHaAcThwR4sl8ROz6xXl/22wbzlsKtfsiyr5zrV0Ifnq7KuCeNVNUYjOQCTn+ODaRzdj7DYC4Mz9BvxZAr0MDfSbgpLp6ZLAvZlkP3DioOPda7VnfJSAHGEYztOVPITj31pVnP1nXkPZRQlsTwImXEGJpuU+zOaurMShpaukrY/ONxWHR6xlG5M1FgOLdBvEnlbhOFoME1HHziI4/08Xw/NrHIUhvjZZgkAzWUo5NvYZLEwrUjOPtlVxHbYwBEtgBWRgWLFMfTlxQnEJVKzbwUDPLvZWac9WSpGLx5xiww== 782125244@qq.com

配置用户名、邮箱,提交时会引用

[root@192 mytest]# git config --global user.name "shenlibng"
[root@192 mytest]# git config --global user.email "782125244@qq.com"
[root@192 mytest]# git config --global core.autocrlf false
[root@192 mytest]# git config --global core.quotepath off
[root@192 mytest]# git config --global gui.encoding utf-8

开启防火墙配置

查看防火墙初始化配置

[root@192 ~]# cat /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

开放Tomcat端口

重启生效防火墙

[root@192 ~]# service iptables restart
iptables:将链设置为政策 ACCEPT:filter                    [确定]
iptables:清除防火墙规则:                                 [确定]
iptables:正在卸载模块:                                   [确定]
iptables:应用防火墙规则:                                 [确定]

查看防火墙状态

[root@192 ~]# service iptables status
表格:filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
5    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:8080 
6    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination  

  目录