一、静态IP配置
vi /etc/sysconfig/network-scripts/ifcfg-enp0s8
#更改为
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.56.101
NETMASK=255.255.255.0
GATEWAY=192.168.56.1
#重启服务
systemctl restart network
二、SELINUX禁用
#编辑配置文件
vi /etc/selinux/config
SELINUX=enforcing => SELINUX=disabled
#保存,重启生效
reboot
三、配置yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
四、安装docker
#安装
yum install -y docker
#查看是否安装成功
yum list installed | grep docker
->docker.x86_64 2:1.13.1-209.git7d71120.el7.centos @extras
->docker-client.x86_64 2:1.13.1-209.git7d71120.el7.centos @extras
->docker-common.x86_64 2:1.13.1-209.git7d71120.el7.centos @extras
#出现上述内容,则标识安装成功
#启动docker服务systemctl start docker,下面命令即添加到开机启动
systemctl enable --now docker
#查看是否启动成功
systemctl status docker
#更改docker 源为阿里 https://xasdxasds.mirror.aliyuncs.com 替换为自己的的
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xasdxasds.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
4-1 mysql安装
#拉取镜像
docker pull mysql
#创建数据存放位置
mkdir -p /var/own/datadir
mkdir -p /var/own/conf
#在/var/own/conf新建my.cnf并填写内容
vi my.cnf
#创建mysql容器
docker run --name mysql -p 3307:3306 -v /var/own/conf:/etc/mysql/conf.d -v /var/own/datadir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:latest --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
#默认已经开启用户远程登录,进入容器方法
docker exec -it mysql bash
my.cnf
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# The MySQL Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= NULL
default-time-zone = '+8:00'
#最大链接数
max_connections=1024
#是否对sql语句大小写敏感,1表示不敏感
lower_case_table_names=1
log_bin_trust_function_creators=1
#启用log-bin
log-bin=mysql-bin
#设置日志格式
binlog_format=mixed
#设置binlog清理时间
expire_logs_days=7
# 数据表默认时区
default-time-zone='+08:00'
# Custom config should go here
!includedir /etc/mysql/conf.d/
4-2 Nacos(user/pass : nacos/nacos)
docker pull nacos/nacos-server
docker run --name nacos -e MODE=standalone -p 8848:8848 -d nacos/nacos-server
4-3 minio
下载镜像
docker pull bitnami/minio
mkdir -p /var/minio/data
chomd -R 777 /var/minio/data
docker run -d --name minio \
--publish 9000:9000 \
--publish 9001:9001 \
--volume /var/minio/data:/data \
bitnami/minio:latest
4-4 Sentinel (user/pass:sentinel/sentinel)
how to download
docker pull bladex/sentinel-dashboard:tagname
how to start
docker run --name sentinel -d -p 8858:8858 -d bladex/sentinel-dashboard:tagname
how to login web-dashboard
visit: http://localhost:8858/
account and password: [sentinel sentinel]
just enjoy :)
4-5 RabbitMQ
docker pull rabbitmq
docker run -itd --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq
## 启动控制面板 (guest/guest) http://host:15672
docker exec -it rabbitmq /bin/bash
rabbitmq-plugins enable rabbitmq_management
## docker update --restart=always containerID
## docker update --restart=on-failure:10 containerID 最多重启10次
docker update --restart=on-failure:10 rabbitmq
五、nginx安装
5-1 编译安装
#一、安装编译工具及库文件
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
#二、首先要安装 PCRE
cd /usr/local/src/
# centos7 没有wget
yum install -y wget
# 下载pcre安装包
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
tar -zxvf pcre-8.35.tar.gz && cd pcre-8.35
# 编译安装
./configure
make && make install
#查看pcre版本
pcre-config --version
#### 前置安装完成,下面开始安装nginx
cd /usr/local/src/
wget https://nginx.org/download/nginx-1.24.0.tar.gz
tar -zxvf nginx-1.24.0.tar.gz
cd nginx-1.24.0
#配置
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
make && make install
5-2 yum安装
# 1、添加CentOS 7 Nginx yum资源库
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
# 2、安装nginx
yum -y install nginx
# 3、启动nginx (开机启动systemctl enable nginx)
systemctl start nginx
# /etc/nginx/nginx.conf //yum方式安装后默认配置文件的路径
# /usr/share/nginx/html //nginx网站默认存放目录
# /usr/share/nginx/html/index.html //网站默认主页路径
# nginx基本操作
[root@localhost ~]# yum -y instal nginx //安装nginx
[root@localhost ~]# service nginx start //启动nginx
[root@localhost ~]# service nginx stop //停止nginx
[root@localhost ~]# service nginx reload //重载nginx
[root@localhost ~]# ps -ef | grep nginx //查看进程apache/httpd
[root@localhost ~]# netstat -anpl | grep 'nginx' //查看服务端口
[root@localhost ~]# rpm -Uvh http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.18.0-1.el7.ngx.x86_64.rpm // rpm方式升级并安装某个版本的Nginx
六、防火墙
# 1、开启防火墙 (systemctl status firewalld)
firewall-cmd --state
systemctl start firewalld.service 开启防火墙
systemctl stop firewalld.service 关闭防火墙
systemctl disable firewalld.service 彻底关闭防火墙,开机不启动
systemctl enable firewalld.service 开启防火墙,开机启动
# 2.列出当前防火墙的配置情况:
firewall-cmd --list-all
# 3.永久开放8888端口:
sudo firewall-cmd --permanent --zone=public --add-port=8888/tcp
sudo firewall-cmd --permanent --zone=public --add-port=8888/udp
# 说明:permanent #永久生效,没有此参数重启后失效
# zone #作用域
add-port=8888/tcp #添加端口,格式为:端口/通讯协议
add-port=88-90/tcp #一次添加多个端口
# 4.让firewall-cmd重新加载配置:
sudo firewall-cmd --reload
# 5.再次列一下当前防火墙配置看是否开放成功:
firewall-cmd --list-all
# 6.删除已开放的端口号:
sudo firewall-cmd --permanent --zone=public --remove-port=8888/udp
标签:--,配置,备忘,Centos7,nginx,yum,mysql,var,docker
From: https://www.cnblogs.com/paylove/p/17774289.html