安装mysql数据库
# 下载mysql源安装包wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm# 安装mysql源yum localinstall mysql57-community-release-el7-8.noarch.rpm -y # 检查mysql源是否安装成功yum repolist enabled | grep "mysql.*-community.*"# 安装MySQLyum install mysql-community-server -y # 3、启动MySQL服务systemctl start mysqld# 查看MySQL的启动状态systemctl status mysqld#4、开机启动systemctl enable mysqldsystemctl daemon-reload# 5、修改root本地登录密码# mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:grep 'temporary password' /var/log/mysqld.logmysql -uroot -p# mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,# 并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误# 如果不需要密码策略,添加my.cnf文件中添加如下配置禁用即可:# 配置默认编码为utf8# 关闭客户端dns反解echo -e "validate_password = off\ncharacter_set_server=utf8\ninit_connect='SET NAMES utf8'\nskip-name-resolve\n" >> /etc/my.cnf systemctl restart mysqld mysql -uroot -p ## 授权alter user 'root'@'localhost' identified by '123123';grant all privileges on *.* to root@'%' identified by '123123' with grant option;flush privileges;
安装Redis
yum 安装redis 3.2yum -y install redis
文档 https://redis.io/download编译安装redis-6.2.1yum install -y gcc gcc-c++ tclwget -O /opt/tgzs/redis-6.2.1.tar.gz https://download.redis.io/releases/redis-6.2.1.tar.gzcd /opt/tgzs/#解压redistar xf redis-6.2.1.tar.gz#进入解压后的目录cd redis-6.2.1#分配器allocator,如果有MALLOC 这个 环境变量, 会有用这个环境变量的 去建立Redis。#而且libc 并不是默认的分配器, 默认的是 jemalloc, 因为 jemalloc 被证明 有更少的 fragmentation problems 比libc。#但是如果你又没有jemalloc而只有 libc 当然 make 出错。 所以加这么一个参数,运行如下命令:make MALLOC=libc -j 20#编译# make -j 20#创建redis安装目录,主要用于存放redis所需bin文件mkdir -p /usr/local/redis#安装redis并指定安装目录make PREFIX=/usr/local/redis/ install# 设置pathexport PATH=$PATH:/usr/local/redis/bin#复制默认配置文件到/etcegrep -v "^$|#" redis.conf > redis_sample.conf#修改配置文件监听IP为0.0.0.0,否则只能本地登录sed -i s/bind\ 127.0.0.1/bind\ 0.0.0.0/g redis_sample.conf#修改运行方式为后台运行sed -i s/daemonize\ no/daemonize\ yes/g redis_sample.conf/bin/cp -f redis_sample.conf /etc/redis_6379.conf /bin/cp -f redis_sample.conf /etc/redis_6479.conf #设置日志文件路径sed -i s@logfile\ \"\"@logfile\ \"/opt/logs/redis_6379.log\"@g /etc/redis_6379.conf sed -i s@logfile\ \"\"@logfile\ \"/opt/logs/redis_6479.log\"@g /etc/redis_6479.conf #设置数据目录sed -i s@dir\ \./@dir\ /var/lib/redis_6379@g /etc/redis_6379.conf sed -i s@dir\ \./@dir\ /var/lib/redis_6479@g /etc/redis_6479.conf # 修改portsed -i 's/port 6379/port 6379/g' /etc/redis_6379.conf sed -i 's/port 6379/port 6479/g' /etc/redis_6479.conf mkdir /var/lib/redis_6379mkdir /var/lib/redis_6479mkdir /opt/logscat <<EOF > /etc/systemd/system/redis_6379.service [Unit]Description=The redis-server Process ManagerAfter=syslog.target network.target[Service]Type=forkingExecStart=/usr/local/redis/bin/redis-server /etc/redis_6379.conf#ExecStop=/usr/local/redis/bin/redis-shutdown[Install]WantedBy=multi-user.targetEOFcat <<EOF > /etc/systemd/system/redis_6479.service [Unit]Description=The redis-server Process ManagerAfter=syslog.target network.target[Service]Type=forkingExecStart=/usr/local/redis/bin/redis-server /etc/redis_6479.conf#ExecStop=/usr/local/redis/bin/redis-shutdown[Install]WantedBy=multi-user.targetEOFsystemctl daemon-reload#设置redis开机自启system enable redis_6379system enable redis_6479#启动redissystemctl restart redis_6379systemctl restart redis_6479#查看redis状态systemctl status redis_6379systemctl status redis_6479