Centos 7.8配置并初始化
1. 下载镜像
http://mirrors.nju.edu.cn/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso
禁用 ipv6 原文章 https://www.unixmen.com/disable-ipv6-centos-7/
编辑文件 /etc/sysctl.conf
vi /etc/sysctl.conf
添加下面的行:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
如果你想要为特定的网卡禁止IPv6,比如,对于enp0s3,添加下面的行。
net.ipv6.conf.enp0s3.disable_ipv6 = 1
保存并退出文件。
执行下面的命令来使设置生效。
sysctl -p
要在运行的系统中禁止IPv6,依次输入下面的命令:
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
或者
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
如果你在禁止IPv6后SSH遇到问题,可以这样。
编辑 /etc/ssh/sshd_config 文件
vi /etc/ssh/sshd_config
找到下面的行:
#AddressFamily any
把它改成:
AddressFamily inet
或者,注释掉ListenAddress的#
#ListenAddress 0.0.0.0
开启root账号登录
#LoginGraceTime 20m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
接着重启ssh来使改变生效。
生成key命令: ssh-keygen 无密认证
systemctl restart sshd
如果你在禁止Ipv6后启动postfix遇到问题,编辑/etc/postfix/main.cf:
vi /etc/postfix/main.cf
注释掉配置中的localhost部分,并且使用ipv4回环。
#inet_interfaces = localhost
inet_interfaces = 127.0.0.1
防火墙 https://cloud.tencent.com/developer/article/1157535
// 关闭并且禁用防火墙
systemctl status firewalld.service
systemctl stop firewalld.service
systemctl disable firewalld.service
配置网络 https://www.php.cn/centos/446267.html
设置自动DHCP
// ifcfg-enp0s8 是我的网卡名字
vi /etc/sysconfig/network-scripts/ifcfg-enp0s8
// 配置1
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
NAME=enp0s3
UUID=848e0df1-400e-4df3-adaa-e266e7aee942
DEVICE=enp0s3
ONBOOT=yes
// 配置2
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
#IPV6INIT=no
#IPV6_AUTOCONF=no
#IPV6_DEFROUTE=no
#IPV6_FAILURE_FATAL=no
#IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s8
UUID=3f529446-022d-440d-8ecd-cc3d8d0a3aff
DEVICE=enp0s8
ONBOOT=yes
IPADDR=192.168.99.10
NETMASK=255.255.255.0
DNS1=8.8.8.8
DNS=114.114.114.114
可以为 BOOTPRTO(表示网卡配置静态还是动态IP地址)设置以下4种选项。
none:表示无须启动协议。
bootp:表示使用BOOTP协议。
dhcp:表示使用DHCP协议动态获取IP地址。
static:表示手工设置静态IP地址。
ONBOOT=yes 表示启动系统时是否激活该网卡,yes表示激活,no表示不激活
systemctl restart network (重启网络服务)
systemctl start network (启动网络服务)
systemctl stop network (停止网络服务)
配置DNS
/etc/resolv.conf
nameserver 118.89.102.82
配置华为源
cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
yum clean all && yum makecache && yum update
- 安装docker
yum update
yum install tree wget net-tools -y
yum install docker python3 -y
systemctl start docker
systemctl enable docker
systemctl status docker
systemctl restart docker
- 安装 supervisor
yum install python-setuptools
1. install:
`pip install supervisor`
2. configure:
1. `mkdir -p /etc/supervisord/conf.d`
2. `echo_supervisord_conf > /etc/supervisord/supervisord.conf`
3. `echo "files = conf.d/*.conf" >> /etc/supervisord/supervisord.conf`
3. setup as service:
`wget supervisord.service -O /usr/lib/systemd/system/supervisord.service`
4. start service
`systemctl start supervisord`
5. view service status:
`systemctl status supervisord`
6. auto start service on system startup:
`systemctl enable supervisord`
yum install -y epel-release
yum install -y supervisor
systemctl daemon-reload
systemctl start supervisord
https://gist.github.com/mozillazg/6cbdcccbf46fe96a4edd
/usr/lib/systemd/system/supervisord.service
supervisord.service
[Unit]
Description=supervisord - Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target
[Service]
Type=forking
ExecStart=/bin/supervisord -c /etc/supervisord/supervisord.conf
ExecReload=/bin/supervisorctl reload
ExecStop=/bin/supervisorctl shutdown
User=root
[Install]
WantedBy=multi-user.target
// 错误处理
supervisor "unix:///var/run/supervisor/supervisor.sock no such file"
sudo touch /var/run/supervisor.sock
sudo chmod 777 /var/run/supervisor.sock
sudo service supervisor restart