首页 > 系统相关 >Centos7 配置备忘

Centos7 配置备忘

时间:2023-10-19 11:25:17浏览次数:39  
标签:-- 配置 备忘 Centos7 nginx yum mysql var docker

一、静态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

相关文章

  • 海外apple 登陆 快速配置 Sign In with Apple
    登录Apple开发者账号。我们需要获得具有SignInwithApple功能的AppId。•进入Certificates,Identifiers&Profiles>Identifiers,然后单击Identifiers旁边左上角的+号;•选择AppIDs并点击继续; 在此处输入任意Description和BundleID(Apple建议使用反......
  • ArmSoM-W3之RK3588 MPP环境配置
    1.简介瑞芯微提供的媒体处理软件平台(MediaProcessPlatform,简称MPP)是适用于瑞芯微芯片系列的通用媒体处理软件平台。该平台对应用软件屏蔽了芯片相关的复杂底层处理,其目的是为了屏蔽不同芯片的差异,为使用者提供统一的视频媒体处理接口(MediaProcessInterface,缩写MPI)。MPP......
  • 配置自定义服务为linux系统服务
    背景使用go语言写了一个测试环境部署上报的备份服务,以防因为主服务挂了影响部署操作。 想把这个backup服务设置了系统服务,如果因环境重启等异常,可以自动重启使用的环境的Centos71、首先需要创建一个systemdunit存储配置文件[Unit]Description=deployreportbackupse......
  • laravel:配置回退路由404(10.27.0)
    一,相关文档:https://learnku.com/docs/laravel/10.x/routing/14845#ad9737二,php代码在routes/web.php中添加以下代码:12345678//配置回退路由,起兜底作用Route::fallback(function(){    $rs=[        'code'=>404,        '......
  • aruba ac配置
    学习aruba配置,初次使用时,参考网上文档进行初始化配置在初始化配置后,可以进入网页进行配置,也可以使用命令行配置我的环境中,AC与AP使用同一网段,172.16.47.0子网掩码255.255.255.0网关172.16.47.1核心交换机172.16.250.1 47网段的网关也在核心交换机上在aruba控制器中,开启DHCP......
  • Windows配置MSVC环境
    Windows下GraalVM要把jar编译成二进程可执行文件,需要依赖MSVC环境。Windows下想要MSVC环境但又不想安装笨重的VisualStudio的10几个G容量,可以用以下方法:1、使用PortableBuildTools来下载MSVC最小集https://github.com/Data-Oriented-House/PortableBuildTools2、使用绿色版......
  • pom.xml配置文件(五)
    SPRINGBOOT相关JUnitstarter<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope><exclusions><exclusion>......
  • 案例4 配置SSH协议
    1.在华为设备上配置SSH协议1.1按图配置端口的ip地址,并做连通性测试[R1]interfaceg0/0/0[R1-GigabitEthernet0/0/0]ipaddress202.100.1.1255.255.255.252[R2]intg0/0/0[R2-GigabitEthernet0/0/0]ipaddress202.100.1.2255.255.255.252[R1-GigabitEthernet0/0/0]pi......
  • EF Core学习笔记 - 配置
    约定配置1、主要规则表名采用DbContext中对应的DbSet的属性名数据表列的名字采用实体类属性的名字,列的数据类型采用喝实体类属性类型最兼容的类型,可以自定义设置数据表列的可空性取决于对应实体类属性的可空性名字为Id的属性为主键如果主键为short,int或者lo......
  • centos7设置固定IP地址
    在CentOS7中设置固定IP地址涉及到修改网络配置文件1、进入超级用户sudosuroot2、使用vim编辑或者Vi编辑器编辑:#进入目录cd/etc/sysconfig/network-scripts/#注:将<interface>替换为你要设置固定IP的网络接口,例如eth0、ens33vimifcfg-<interface>#比如:vi......