#查看系统版本
cat /proc/version
#查看源 (包含Base.repo的文件 系统版本不一样文件名称不一样)
cat /etc/yum.repos.d/CentOS-Base.repo
# yum源备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# 复制中科大的源
mv /opt/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo
# 清除缓存
yum clean all
# 把yum源缓存到本地,加快软件的搜索安装速度
yum makecache
# 列出包
yum list
# 安装wget
yum install -y wget
yum -y install java-1.8.0-openjdk-devel.x86_64
# 验证安装
java -version
# 创建目录
mkdir /opt/mysql
cd /opt/mysql
# 下载
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
rpm -Uvh mysql57-community-release-el7-11.noarch.rpm
yum -y install mysql-community-server
#公钥未安装问题则加上--nogpgcheck 参数
yum install --nogpgcheck mysql-community-server
# 启动 mysql
systemctl start mysqld
# 开机自启动
systemctl enable mysqld
# 查看临时密码
grep password /var/log/mysqld.log
# 使用临时密码登录数据库
mysql -p
# 设置新密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Demo@123';
# 添加用户并且添加远程访问权限
GRANT ALL PRIVILEGES ON *.* TO 'demo'@'%' IDENTIFIED BY 'Demo@123' WITH GRANT OPTION;
FLUSH PRIVILEGES;
#查看是否生效
select host,user from mysql.user
# 退出登录
quit;
sudo vim /etc/my.cnf
# 添加下列配置
# 配置支持emoji表情符号
character_set_server=utf8mb4
collation-server=utf8mb4_unicode_ci
# 配置MySQL时区
default-time_zone = '+8:00'
# 配置MySQL不区分大小写
lower_case_table_names=1
# 重启mysql
systemctl restart mysqld
#进入mysql查看是否生效
mysql -uomo -p
show variables like '%char%';
# 退出登录
quit;
# 设置服务器时区
timedatectl set-timezone Asia/Shanghai
# 同步网络时间-需要服务器可访问外网
yum -y install ntpdate
ntpdate -u ntp.api.bz
# 重启mysql
systemctl restart mysqld
# 开通防火墙
firewall-cmd --zone=public --add-port=3306/tcp --permanent
# 重启防火墙
systemctl restart firewalld.service
# 查看是否生效
firewall-cmd --list-ports --permanent
# 卸载MySQL
rpm -qa | grep mysql
[root@localhost /]# mkdir /opt/redis
[root@localhost /]# cd /opt/redis
# 当前目录
[root@localhost redis]# pwd
/opt/redis
[root@localhost redis]# wget https://download.redis.io/releases/redis-6.2.6.tar.gz
redis-6.2.6.tar.gz
[root@localhost redis]#
Redis官网也可自行下载对应版本
2. 安装
# 源码安装 创建redis 文件夹
# 解压包
tar -zxvf redis-6.2.6.tar.gz
# 进入目录
cd redis-6.2.6/
# 如果失败则运行 yum clean all yum makecache
yum install gcc-c++
# 编译 报错则先 make distclean
make
# 在/usr/local/下创建文件夹
mkdir -p /usr/local/redis/data
# 安装Redis, 将Redis安装在/usr/local/redis目录下
make PREFIX=/usr/local/redis install
# 复制redis.conf配置文件到/etc目录下
cp redis.conf /etc
# 打开配置文件
vi /etc/redis.conf
# 修改下列配置(必须一个个改不要直接复制)
# 修改后台启动, 默认为daemonize no, 修改为daemonize yes
daemonize yes
# 客户端闲置多长时间后断开连接, 默认为0关闭此功能, 修改为300
timeout 300
# 设置密码, 默认被注释, 取消注释修改为自定义密码 一定要设置
requirepass 123456
# 监听ip, 允许访问的ip, 默认为127.0.0.1, 修改为0.0.0.0(允许所有服务器ip访问)或者注释掉
bind 0.0.0.0
# 指定监听端口, 默认为6379, 此处我保持默认
port 6379
# 修改AOF及RBD存放路径, 默认为./, 修改为/usr/local/redis/data
dir /usr/local/redis/data
# 修改log存放路径, 默认为"", 修改为"/usr/local/redis/data/redis_6379.log"
logfile "/usr/local/redis/data/redis_6379.log"
# 开机脚本
vi /lib/systemd/system/redis.service
#内容
[Unit]
Description=redis.server
After=network.target
[Service]
Type=forking
PIDFILE=/usr/local/redis/data/redis_6379.pid
ExecStart=/usr/local/redis/bin/redis-server /etc/redis.conf
ExecStop=/usr/local/redis/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown
PrivateTmp=true
[Install]
WantedBy=multi-user.target
#启动redis
/usr/local/redis/bin/redis-server /etc/redis.conf
# 开启自动重启
systemctl enable redis.service
# 开通防火墙
firewall-cmd --zone=public --add-port=6379/tcp --permanent
# 重启防火墙
systemctl restart firewalld.service
#这里需要确认系统版本 如果是超过7版本的可能会下载到高版本的 会跟mq版本不一致 冲突 后续补充指定版本安装
curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash
yum install -y erlang
# 验证
erl -version
rpm --import https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
rpm --import https://packagecloud.io/gpg.key
rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc
yum -y install epel-release socat
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash
# 下载至对应目录
mkdir /opt/rabbitmq
cd /opt/rabbitmq
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.5/rabbitmq-server-3.8.5-1.el7.noarch.rpm
[root@localhost rabbitmq]# pwd
/opt/rabbitmq
[root@localhost rabbitmq]# ls
rabbitmq-server-3.8.5-1.el7.noarch.rpm
[root@localhost rabbitmq]#
# 安装rabbitmq-server
rpm -ivh rabbitmq-server-3.8.5-1.el7.noarch.rpm
# 启用管理平台插件
rabbitmq-plugins enable rabbitmq_management
# 启动RabbitMQ
systemctl start rabbitmq-server
# 开机自启
systemctl enable rabbitmq-server
rabbitmq-server也可以自行下载,但需对应版本号,避免版本冲突
4. 安装延迟插件
cd /usr/lib/rabbitmq/lib/rabbitmq_server-3.8.5/plugins/
wget https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases/download/v3.8.0/rabbitmq_delayed_message_exchange-3.8.0.ez
rabbitmq-plugins enable rabbitmq_delayed_message_exchange
# 开通防火墙
firewall-cmd --zone=public --add-port=5672/tcp --permanent
firewall-cmd --zone=public --add-port=15672/tcp --permanent
#firewall-cmd --zone=public --add-port=25672/tcp --permanent
# 重启防火墙
systemctl restart firewalld.service
rabbitmqctl add_user root root
# 赋予权限
rabbitmqctl set_permissions -p / root '.*' '.*' '.*'
# 设置为管理员
rabbitmqctl set_user_tags root administrator
# 设置重启用户保留
# 列出所有用户
rabbitmqctl list_users
#重启服务器
reboot
# 检查 redis 是否开机自启
ps aux | grep redis
# 检查 mq 是否开机自启
ps aux | grep mq
# 检查mq 用户列表 root 用户是否存在
rabbitmqctl list_users
#如果重启后root用户不在则需要改
# 添加hosts
vi /etc/hosts
# 添加内容
127.0.0.1 localhost.localdomain
cd /opt/minio
[root@localhost minio]# pwd
/opt/minio
[root@localhost minio]# ls
minio
# 赋予权限
chmod +x minio
cd /mnt
mkdir miniodata
sudo touch /mnt/miniodata/minio.log
# 设置账号密码
export MINIO_ACCESS_KEY=admin
export MINIO_SECRET_KEY=Admin@123
# 后台启动
nohup /opt/minio/minio server /home --address 0.0.0.0:9400 --console-address :9500 > /mnt/miniodata/minio.log 2>&1 &
firewall-cmd --add-port=9400/tcp --permanent
firewall-cmd --add-port=9500/tcp --permanent
# 重启防火墙
systemctl restart firewalld.service
# 打开开机自启文件
vi /etc/rc.local
# 添加自启脚本
export MINIO_ACCESS_KEY=admin
export MINIO_SECRET_KEY=Admin@123
nohup /opt/minio/minio server /home --address 0.0.0.0:9400 --console-address :9500 > /mnt/miniodata/minio.log 2>&1 &
# 保存
# 修改权限
chmod +x /etc/rc.local
# 重启测试
reboot
设置存储桶
创建桶:Buckets > Create Buckets
设置桶权限:Buckets > Summary > Access Policy 改为 public
注意!!!
本次minio上传的文件存储在/home目录下
mkdir /opt/nginx
cd /opt/nginx
#上传压缩包
[root@localhost nginx]# pwd
/opt/nginx
[root@localhost nginx]# ls
nginx-1.8.1.tar.gz
# 安装依赖
yum -y install gcc gcc-c++
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl openssl-devel
# 编译安装(默认安装路径:/usr/local/nginx)
tar xzvf nginx-1.8.1.tar.gz
cd nginx-1.8.1/
./configure --with-http_ssl_module
make && make install
#创建所需文件夹以及文件
mkdir -p /var/log/nginx && mkdir -p /var/run/
sudo touch /var/log/nginx/error.log && sudo touch /var/run/nginx.pid
vi /usr/local/nginx/conf/nginx.conf
sudo /usr/local/nginx/sbin/nginx -t
# 启动
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
# 设置nginx开机自启动
vi /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl enable nginx.service
# 开放80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
# 重启防火墙
systemctl restart firewalld.service
#创建文件夹
mkdir /opt/script
#创建nginx分割日志脚本
vi /opt/script/cut_nginx_log.sh
#复制以下内容
#!/bin/sh
cd /var/log/nginx/
sudo mv access.log access_$(date +%F -d -1day).log
sudo /usr/local/nginx/sbin/nginx -s reload
#增加执行权限
chmod +x /opt/script/cut_nginx_log.sh
#创建定时任务
crontab -e
#复制以下内容
00 00 * * * /opt/script/cut_nginx_log.sh
#查看定时列表
crontab -l
#重启 cron
sudo service crond restart
# 查看机器上都插了哪些安装盘
sudo fdisk -l
# 创建硬盘分区(/dev/sdb是示例,根据具体情况输入)
# n:添加一个分区 p:主分区 w:写入磁盘
fdisk /dev/sdb
# 格式化硬盘
mkfs.ext4 /dev/sdb
# 建立挂载目录
mkdir /mnt/miniodata
# 挂载硬盘
mount /dev/sdb /mnt/miniodata
# 设置开机自动挂载
vi /etc/fstab
/dev/sdb /data ext4 defaults 0 0
# 重启服务器
shutdown -r now
#查看当前时区
timedatectl
#设置当前时区为上海常用:Asia/Shanghai
timedatectl set-timezone Asia/Shanghai
#安装时间同步应用
yum install -y ntp
#同步上海授时中心时间
ntpdate ntp.api.bz
#打开定时任务编辑器
crontab -e
#每天晚上23:59同步时间
59 23 * * * ntpdate ntp.api.bz
# 查看数据库当前时间
SELECT NOW();
#查看时区
show variables like '%zone%';
select @@time_zone;
#修改mysql全局时区为北京时间
set global time_zone = '+8:00';
#修改当前会话时区
set time_zone = '+8:00';
#立即生效
flush privileges;
wget http://www.rarlab.com/rar/rarlinux-x64-5.3.0.tar.gz
tar zxf rarlinux-x64-5.3.0.tar.gz
rm -rf /usr/local/bin/rar
rm -rf /usr/local/bin/unrar
ln -s /root/rar/rar /usr/local/bin/rar
ln -s /root/rar/unrar /usr/local/bin/unrar
# 解压
unrar -o 解压目录 压缩包
set @@GLOBAL.sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
set @@SESSION.sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';