码迷,mamicode.com
首页 > 数据库 > 详细

Centos7安装MySQL5.7和Redis6.0流水账

时间:2021-01-19 11:40:29      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:echo   password   ecs   rip   char   util   remove   backup   limited   

安装mysql

使用rpm包安装

yum remove mariadb-libs.x86_64
yum install perl
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 
systemctl is-enabled mysqld
systemctl start mysqld
systemctl status mysqld
# 查看密码
vi /var/log/mysqld.log

配置mysql

mysql> set password=password(‘Test.123‘);
mysql> create user ‘testuser‘@‘%‘ identified by ‘testuser.123‘;
mysql> create database testdb default character set utf8 collate utf8_general_ci;
mysql> grant all on testdb.* to ‘testuser‘@‘%‘;

防火墙

firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --reload

编译安装Redis

yum install gcc-c++
yum install centos-release-scl
yum install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash

tar zxvf redis-6.0.10.tar.gz 
cd redis-6.0.10
make
yum install tcl
make test
make PREFIX=/opt/redis/redis-6.0.10 install

配置

cp ~/backup/redis-6.0.10/redis.conf ./redis_6379.conf
vi redis_6379.conf
# 修改
bind 0.0.0.0
port 6379
daemonize yes
logfile "/data/redis/logs/redis_6379.log"
dir /data/redis/db/
requirepass foobared
maxmemory 1073741824
# 结束

优化项 transparent_hugepage

cd /etc/rc.d/
chmod +x rc.local 
vi /etc/rc.d/rc.local 
# 结尾增加
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
  echo madvise > /sys/kernel/mm/transparent_hugepage/enabled
fi
# 结束

优化项 open files

vi /etc/security/limits.d/20-nproc.conf 
# 修改为
*          soft    nofile    10240
*          hard    nofile    10240
*          soft    nproc     10240
*          hard    nproc     10240
root       soft    nproc     unlimited
#

优化项 net.core.somaxconn, vm.overcommit_memory

vi /etc/sysctl.conf 
# 末尾增加
net.core.somaxconn = 1024
vm.overcommit_memory = 1
# 结束
sysctl -p

添加到服务

vi /usr/lib/systemd/system/redis.service
# 内容
[Unit]
Description=Redis
After=network.target
 
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/opt/redis/latest/bin/redis-server /opt/redis/latest/conf/redis_6379.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/opt/redis/latest/bin/redis-cli -p 6379 shutdown
PrivateTmp=true
 
[Install]
WantedBy=multi-user.target
# 内容结束
systemctl enable redis

Centos7安装MySQL5.7和Redis6.0流水账

标签:echo   password   ecs   rip   char   util   remove   backup   limited   

原文地址:https://www.cnblogs.com/milton/p/14290748.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!