裸机配置Centos应用部署环境

1、安装扩展包

// yum -y install epel-release
sudo yum install -y lrzsz
sudo yum install -y zip
sudo yum install -y unzip
sudo yum install -y telnet

2、安装nginx

//安装nginx前置工具
sudo yum install yum-utils
//添加repo
vi /etc/yum.repos.d/nginx.repo

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

//配置repo
sudo yum-config-manager --enable nginx-mainline
//安装nginx
sudo yum install nginx

//启动nginx
systemctl start nginx

//设置开机启动
systemctl enable nginx

关闭Linux权限验证
setenforce 0
vi /etc/selinux/config,SELINUX=disabled,然后保存退出。
vi /etc/sysconfig/selinux,SELINUX=disabled,然后保存退出。

3、安装keepalived

//安装
yum install -y keepalived
//启动 keepalived
systemctl start keepalived
//加入开机启动 keepalived
systemctl enable keepalived
 //查看 keepalived 状态
systemctl status keepalived
//停止
systemctl stop keepalived.service
//重新启动 keepalived
systemctl restart keepalived

//添加脚本检测用户权限
global_defs {
	script_user root
	enable_script_security
}
//授权检测脚本
chmod 755 /etc/keepalived/nginx_check.sh

vip ping不通

4、安装jdk1.8

上传或下载jdk安装包,并使用rpm安装:

sudo rpm -ivh jdk-8u381-linux-x64.rpm

5、安装数据库

//检测并删除marialdb包
rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs
//下载安装包
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.34-1.el7.x86_64.rpm-bundle.tar
//解压安装包
tar -xvf mysql-8.0.34-1.el7.x86_64.rpm-bundle.tar
//逐一安装
sudo rpm -ivh mysql-community-common-8.0.34-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-client-plugins-8.0.34-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-libs-8.0.34-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-libs-compat-8.0.34-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-icu-data-files-8.0.34-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-client-8.0.34-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-server-8.0.34-1.el7.x86_64.rpm
//server安装报错
yum install -y perl-Module-Install.noarch

//忽略大小写配置【该配置必须在初始化之前做,如果已初始化,就只能删除mysql重新初始化(rm -rf /var/lib/mysql/*)】
vi /etc/my.cnf

[mysqld] 
lower_case_table_names=1

//初始化数据库
mysqld --initialize
//文件夹授权
cd /var/lib/mysql
chmod -R 777 *

//启动数据库服务
systemctl start mysqld
//设置开机启动
sudo systemctl enable mysqld
//查看状态
systemctl status mysqld.service

//设置root临时密码
sudo grep 'temporary password' /var/log/mysqld.log
//用临时密码登录mysql
mysql -uroot -p输入临时密码
//修改密码
alter user user() identified by "你的新密码";
//修改root任何地方访问
UPDATE mysql.user SET Host='%' WHERE User='root';
//刷新权限
FLUSH PRIVILEGES;

//给用户授权
GRANT All PRIVILEGES ON 数据库名.* TO '账号'@'%';

6、安装Redis

//安装Redis
sudo yum install redis
//启动Redis服务
sudo systemctl start redis
//检测Redis状态(PONG)
redis-cli ping
//设置Redis开机自启动
sudo systemctl enable redis

7、配置防火墙

//添加端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
//移除端口
firewall-cmd --zone=public --remove-port=123/udp
//开启防火墙
systemctl start firewalld
//关闭防火墙
systemctl stop firewalld.service
//重启防火墙
systemctl restart firewalld.service
//查看所有开放端口
firewall-cmd --list-ports

参考:https://blog.csdn.net/ZQXqqq/article/details/127485955

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值