Centos7
2020-08-28 14:01:02 0 举报
AI智能生成
centos7
作者其他创作
大纲/内容
查询版本
Centos版本号
cat /etc/centos-release
内核版本
uname -r
操作系统位数
getconf LONG_BIT
防火墙
查看状态
firewall-cmd --state
关闭
systemctl stop firewalld.service
取消开机启动
systemctl disable firewalld.service
SELinux
关闭(需重启)
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
验证
grep SELINUX=disabled /etc/selinux/config
临时关闭
setenforce 0
验证
getenforce
vi命令
删除全部
ggdG
IP
查看
ip addr
修改
vim /etc/sysconfig/network-scripts/ifcfg-ens33
重启
systemctl restart network.service
关闭IPv6
vim /etc/sysctl.conf
保存修改
sysctl -p
时间
查看
timedatectl status|grep 'Time zone'
设置
硬件时钟调整为与本地时钟一致
timedatectl set-local-rtc 1
时区为上海
timedatectl set-timezone Asia/Shanghai
ntpdate
安装
yum -y install ntpdate
同步
ntpdate -u ntp.aliyun.com
查看
date
crotab
创建
crontab -e
添加
*/5 * * * * /usr/sbin/ntpdate ntp.aliyun.com > /dev/null 2>&1
重启
service crond reload
java
jdk下载
jdk-8u131-linux-x64.tar.gz
安装
创建目录
mkdir /usr/local/java/
解压
tar -zxvf jdk-8u131-linux-x64.tar.gz -C /usr/local/java/
设置环境变量
添加
vim /etc/profile
生效
source /etc/profile
添加软连接
ln -s /usr/local/java/jdk1.8.0_131/bin/java /usr/bin/java
检查
java -version
sh脚本
增加环境变量引用
#!/bin/bash
source /etc/profile
source /etc/profile
赋予执行权限
chmod +x /root/autostart.sh
设置开机启动
echo "/root/autostart.sh > /dev/null 2>&1" >> /etc/rc.d/rc.local
赋予执行权限
chmod +x /etc/rc.d/rc.local
mysql5.7
检查mysql是否存在
rpm -qa | grep mysql
rpm -qa |grep mariadb
rpm -qa |grep mariadb
yum remove mariadb-libs-5.5.64-1.el7.x86_64
配置阿里云镜像
yum install wget -y
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum update -y
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum update -y
下载mysql包
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-server-5.7.31-1.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-client-5.7.31-1.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-common-5.7.31-1.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-libs-5.7.31-1.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-client-5.7.31-1.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-common-5.7.31-1.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-libs-5.7.31-1.el7.x86_64.rpm
安装依赖环境
yum install -y perl.x86_64
yum install -y libaio.x86_64
yum install -y net-tools.x86_64
yum install -y libaio.x86_64
yum install -y net-tools.x86_64
安装mysql
rpm -ivh mysql-community-common-5.7.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.31-1.el7.x86_64.rpm
重启mysql
service mysqld.service restart
查询默认密码
grep 'temporary password' /var/log/mysqld.log
修改远程密码
set global validate_password_policy=0;
set global validate_password_length=4;
set password=password('123456');
update mysql.user set Host = '%' where Host = 'localhost' and User='root';
flush privileges;
set global validate_password_length=4;
set password=password('123456');
update mysql.user set Host = '%' where Host = 'localhost' and User='root';
flush privileges;
0 条评论
下一页