首页 > 系统相关 >rockey linux 9.1安装配置

rockey linux 9.1安装配置

时间:2023-04-19 18:44:24浏览次数:41  
标签:-- rockey mysql port ## install linux data 9.1

查看内核版本

uname -a
dmesg | grep Linux

查看主机名称

hostname
hostnamectl status
shutdown -h now

修改主机名称

vi /etc/hostname# 编辑
hostnamectl set-hostname sys-blog.local# hostnamectl命令
nmtui# nmtui命令

添加用户

useradd username# 添加用户和用户组
usermod -G wheel username# 扩展用户组

dnf常用参数

#安装软件包
dnf install <package>
#卸载软件包
dnf remove <package>
#查找提供文件、包名或者能力的软件包
dnf provides <provides>
#下载源码包
dnf download --source <package>

替换源

cp -r /etc/yum.repos.d/ /etc/yum.repos.d_bak

sed -e 's|^mirrorlist=|#mirrorlist=|g' \
   -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \
   -i.bak \
  /etc/yum.repos.d/rocky-*.repo

dnf makecache

安装中文语言包

localectl list-locales |grep zh
dnf list |grep glibc-langpack
dnf install glibc-langpack-zh

安装semanage

sestatus
dnf provides semanage
dnf install policycoreutils-python-utils
semanage -h
semodule -l
semanage port -a -t ssh_port_t -p tcp 3576
semanage port -l | grep ssh
semanage fcontext -l | grep -i mysql

端口监听

dnf install net-tools
netstat -lnpt

安装配置SSH

rpm -qa |grep openssh
dnf install openssh-server openssh-clients
systemctl start sshd
systemctl stop sshd
systemctl enable sshd
systemctl disable sshd
systemctl status sshd
systemctl status firewalld
firewall-cmd --zone=public --permanent --add-service=ssh
firewall-cmd --reload

## 帐号密码登录
vi /etc/ssh/sshd_config
#PermitRootLogin prohibit-password
PermitRootLogin yes

## 免密登录
dnf install ssh-keygen ssh-copy-id
ssh-keygen -t rsa -b 4096 -C "[email protected]"
ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]
grep -Ev '^$|^[# ]' /etc/ssh/sshd_config
vim /etc/ssh/sshd_config
Port 3576
RSAAuthentication yes   #是否允许RSA验证
  PubkeyAuthentication yes   #是否允许公钥验证
  AuthorizedKeysFile .ssh/authorized_keys  #公钥文件存放的位置
  ChallengeResponseAuthentication no   #设置是否允许使用提示应答式认证。sshd支持login.conf文件中定义的所有认证类型
  PasswordAuthentication no   #设置是否需要口令验证,默认为yes
  PermitEmptyPasswords no   #设置是否允许用空口令登录
  UsePAM yes   #是否启用PAM插件式认证模块,默认为yes RHEL系不允许设置
  PermitRootLogin no   #如果为yes则允许root用户使用ssh登录
  AllowUsers   aliyun [email protected]
  DenyUsers   d4rksec aliyun
   
semanage port -a -t ssh_port_t -p tcp 3576
semanage port -l | grep ssh
systemctl status firewalld
firewall-cmd --permanent --zone=public --add-port=3576/tcp
firewall-cmd --reload
   
systemctl restart sshd

安装 Mysql 8

## 默认安装
dnf install mysql-server
systemctl start mysqld
systemctl status mysqld
systemctl enable mysqld
mysql_secure_installation
create user 'user'@'%' identified by 'password';
grant all on *.* to 'user'@'%';
firewall-cmd --permanent --zone=public --add-service=mysql
firewall-cmd --reload

## 自定义
mkdir -p /data/mysql/{data,log}
chown -R mysql:mysql /data/mysql
semanage fcontext -a -t mysqld_db_t "/data/mysql/data(/.*)?"
restorecon -RvvF /data/mysql/data
ls -Zd /data/mysql/data/
systemctl start mysqld
mysql_secure_installation
journalctl -xeu mysqld.service

## https://dev.mysql.com/doc/refman/8.0/en/selinux-file-context.html
## 设置数据目录上下文
semanage fcontext -a -t mysqld_db_t "/path/to/my/custom/datadir(/.*)?"
restorecon -Rv /path/to/my/custom/datadir
semanage fcontext -a -t mysqld_db_t "/path/to/my/custom/logdir(/.*)?"
restorecon -Rv /path/to/my/custom/logdir
## error log
semanage fcontext -a -t mysqld_log_t "/path/to/my/custom/error.log"
restorecon -Rv /path/to/my/custom/error.log
## pid
semanage fcontext -a -t mysqld_var_run_t "/path/to/my/custom/pidfile/directory/.*?"
restorecon -Rv /path/to/my/custom/pidfile/directory
## sock
semanage fcontext -a -t mysqld_var_run_t "/path/to/my/custom/mysql\.sock"
restorecon -Rv /path/to/my/custom/mysql.sock
## secure_file_priv目录上下文
semanage fcontext -a -t mysqld_db_t "/var/lib/mysql-files/(/.*)?"
restorecon -Rv /var/lib/mysql-files
## tcp
$> semanage port -l | grep mysqld
mysqld_port_t                 tcp      1186, 3306, 63132-63164
semanage port -a -t mysqld_port_t -p tcp 3306
semanage port -l | grep ssh

percona-xtrabackup

yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
yum remove percona-release
yum list | grep percona-xtrabackup
dnf install percona-xtrabackup-80
## backup
xtrabackup -u username -p --backup --target-dir=/home/virgil/backup/## full back
xtrabackup -u username -p --backup --target-dir=/home/virgil/backup_inc1 \--incremental-basedir=/home/virgil/backup## full incremental

## restore prepare


## full restore
xtrabackup --prepare --target-dir=/home/virgil/backup1## prepare
systemctl stop mysqld## stop mysqld
mv /data/mysql/data/ /data/mysql/data_bak## backup files
xtrabackup -u username -p --copy-back --target-dir=/home/virgil/backup## restore

## increment restore
xtrabackup --prepare --apply-log-only --target-dir=/home/virgil/backup
xtrabackup --prepare --apply-log-only --target-dir=/home/virgil/backup \--incremental-dir=/home/virgil/backup_inc1
xtrabackup --prepare --target-dir=/data/backups/base \--incremental-dir=/data/backups/inc2
systemctl stop mysqld## stop mysqld
mv /data/mysql/data/ /data/mysql/data_bak## backup files
xtrabackup -u username -p --copy-back --target-dir=/home/virgil/backup## restore

## restroe ownership and permissions.
chown -R mysql:mysql /data/mysql
semanage fcontext -a -t mysqld_db_t "/data/mysql/data(/.*)?"
restorecon -RvvF /data/mysql/data
ls -Zd /data/mysql/data/
systemctl start mysqld

redis

dnf provides redis
dnf install redis
systemctl start redis
systemctl enable redis
redis-server --version
redis-cli --version
vim /etc/redis/redis.conf
#bind
protected-mode no
daemonize yes
requirepass
grep -Ev '^$|^[# ]' /etc/redis/redis.conf
systemctl daemon-reload
systemctl restart redis
firewall-cmd --zone=public --permanent --add-port=6379/tcp
firewall-cmd --reload
firewall-cmd --list-all

java npm nodejs

  java 1.8.0 TLS13 TLS12 错误修改参数设置无效(仅centos7)

dnf search java | grep openjdk
dnf install java-17-openjdk java-17-openjdk-devel
dnf install java-1.8.0-openjdk java-1.8.0-openjdk-devel
java-version
alternatives --config java
vim /etc/profile
JAVA_HOME="/path/to/java/install"
source /etc/profile

## java 8
java-version
cat <<EOF | tee /etc/profile.d/java8.sh
export JAVA_HOME=/usr/lib/jvm/jre-openjdk
export PATH=\$PATH:\$JAVA_HOME/bin
export CLASSPATH=.:\$JAVA_HOME/jre/lib:\$JAVA_HOME/lib:\$JAVA_HOME/lib/tools.jar
EOF
source /etc/profile.d/java8.sh

dnf provides npm nodejs
dnf install npm nodejs
npm config set registry http://registry.npmmirror.com

java -jar packages.jar

nginx

dnf install nginx
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
# Or, in some other cases:
firewall-cmd --permanent --zone=public --add-port=443/tcp
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --reload

mkdir /usr/share/nginx/html/www
groupadd www
adduser -G nginx -g www -d /usr/share/nginx/html/www www --system --shell=/bin/false

chown -R www:www /usr/share/nginx/html/www
find /usr/share/nginx/html/www -type d -exec chmod 555 "{}" \;
find /usr/share/nginx/html/www -type f -exec chmod 444 "{}" \;
setsebool httpd_can_network_connect 1 -P
 

查看内核版本

uname -a
dmesg | grep Linux

查看主机名称

hostname
hostnamectl status
shutdown -h now

修改主机名称

vi /etc/hostname# 编辑
hostnamectl set-hostname sys-blog.local# hostnamectl命令
nmtui# nmtui命令

添加用户

useradd username# 添加用户和用户组
usermod -G wheel username# 扩展用户组

dnf常用参数

#安装软件包
dnf install <package>
#卸载软件包
dnf remove <package>
#查找提供文件、包名或者能力的软件包
dnf provides <provides>
#下载源码包
dnf download --source <package>

替换源

cp -r /etc/yum.repos.d/ /etc/yum.repos.d_bak

sed -e 's|^mirrorlist=|#mirrorlist=|g' \
   -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \
   -i.bak \
  /etc/yum.repos.d/rocky-*.repo

dnf makecache

安装中文语言包

localectl list-locales |grep zh
dnf list |grep glibc-langpack
dnf install glibc-langpack-zh

安装semanage

sestatus
dnf provides semanage
dnf install policycoreutils-python-utils
semanage -h
semodule -l
semanage port -a -t ssh_port_t -p tcp 3576
semanage port -l | grep ssh
semanage fcontext -l | grep -i mysql

端口监听

dnf install net-tools
netstat -lnpt

安装配置SSH

rpm -qa |grep openssh
dnf install openssh-server openssh-clients
systemctl start sshd
systemctl stop sshd
systemctl enable sshd
systemctl disable sshd
systemctl status sshd
systemctl status firewalld
firewall-cmd --zone=public --permanent --add-service=ssh
firewall-cmd --reload

## 帐号密码登录
vi /etc/ssh/sshd_config
#PermitRootLogin prohibit-password
PermitRootLogin yes

## 免密登录
dnf install ssh-keygen ssh-copy-id
ssh-keygen -t rsa -b 4096 -C "[email protected]"
ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]
grep -Ev '^$|^[# ]' /etc/ssh/sshd_config
vim /etc/ssh/sshd_config
Port 3576
RSAAuthentication yes   #是否允许RSA验证
  PubkeyAuthentication yes   #是否允许公钥验证
  AuthorizedKeysFile .ssh/authorized_keys  #公钥文件存放的位置
  ChallengeResponseAuthentication no   #设置是否允许使用提示应答式认证。sshd支持login.conf文件中定义的所有认证类型
  PasswordAuthentication no   #设置是否需要口令验证,默认为yes
  PermitEmptyPasswords no   #设置是否允许用空口令登录
  UsePAM yes   #是否启用PAM插件式认证模块,默认为yes RHEL系不允许设置
  PermitRootLogin no   #如果为yes则允许root用户使用ssh登录
  AllowUsers   aliyun [email protected]
  DenyUsers   d4rksec aliyun
   
semanage port -a -t ssh_port_t -p tcp 3576
semanage port -l | grep ssh
systemctl status firewalld
firewall-cmd --permanent --zone=public --add-port=3576/tcp
firewall-cmd --reload
   
systemctl restart sshd

安装 Mysql 8

## 默认安装
dnf install mysql-server
systemctl start mysqld
systemctl status mysqld
systemctl enable mysqld
mysql_secure_installation
create user 'user'@'%' identified by 'password';
grant all on *.* to 'user'@'%';
firewall-cmd --permanent --zone=public --add-service=mysql
firewall-cmd --reload

## 自定义
mkdir -p /data/mysql/{data,log}
chown -R mysql:mysql /data/mysql
semanage fcontext -a -t mysqld_db_t "/data/mysql/data(/.*)?"
restorecon -RvvF /data/mysql/data
ls -Zd /data/mysql/data/
systemctl start mysqld
mysql_secure_installation
journalctl -xeu mysqld.service

## https://dev.mysql.com/doc/refman/8.0/en/selinux-file-context.html
## 设置数据目录上下文
semanage fcontext -a -t mysqld_db_t "/path/to/my/custom/datadir(/.*)?"
restorecon -Rv /path/to/my/custom/datadir
semanage fcontext -a -t mysqld_db_t "/path/to/my/custom/logdir(/.*)?"
restorecon -Rv /path/to/my/custom/logdir
## error log
semanage fcontext -a -t mysqld_log_t "/path/to/my/custom/error.log"
restorecon -Rv /path/to/my/custom/error.log
## pid
semanage fcontext -a -t mysqld_var_run_t "/path/to/my/custom/pidfile/directory/.*?"
restorecon -Rv /path/to/my/custom/pidfile/directory
## sock
semanage fcontext -a -t mysqld_var_run_t "/path/to/my/custom/mysql\.sock"
restorecon -Rv /path/to/my/custom/mysql.sock
## secure_file_priv目录上下文
semanage fcontext -a -t mysqld_db_t "/var/lib/mysql-files/(/.*)?"
restorecon -Rv /var/lib/mysql-files
## tcp
$> semanage port -l | grep mysqld
mysqld_port_t                 tcp      1186, 3306, 63132-63164
semanage port -a -t mysqld_port_t -p tcp 3306
semanage port -l | grep ssh

percona-xtrabackup

yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
yum remove percona-release
yum list | grep percona-xtrabackup
dnf install percona-xtrabackup-80
## backup
xtrabackup -u username -p --backup --target-dir=/home/virgil/backup/## full back
xtrabackup -u username -p --backup --target-dir=/home/virgil/backup_inc1 \--incremental-basedir=/home/virgil/backup## full incremental

## restore prepare


## full restore
xtrabackup --prepare --target-dir=/home/virgil/backup1## prepare
systemctl stop mysqld## stop mysqld
mv /data/mysql/data/ /data/mysql/data_bak## backup files
xtrabackup -u username -p --copy-back --target-dir=/home/virgil/backup## restore

## increment restore
xtrabackup --prepare --apply-log-only --target-dir=/home/virgil/backup
xtrabackup --prepare --apply-log-only --target-dir=/home/virgil/backup \--incremental-dir=/home/virgil/backup_inc1
xtrabackup --prepare --target-dir=/data/backups/base \--incremental-dir=/data/backups/inc2
systemctl stop mysqld## stop mysqld
mv /data/mysql/data/ /data/mysql/data_bak## backup files
xtrabackup -u username -p --copy-back --target-dir=/home/virgil/backup## restore

## restroe ownership and permissions.
chown -R mysql:mysql /data/mysql
semanage fcontext -a -t mysqld_db_t "/data/mysql/data(/.*)?"
restorecon -RvvF /data/mysql/data
ls -Zd /data/mysql/data/
systemctl start mysqld

redis

dnf provides redis
dnf install redis
systemctl start redis
systemctl enable redis
redis-server --version
redis-cli --version
vim /etc/redis/redis.conf
#bind
protected-mode no
daemonize yes
requirepass
grep -Ev '^$|^[# ]' /etc/redis/redis.conf
systemctl daemon-reload
systemctl restart redis
firewall-cmd --zone=public --permanent --add-port=6379/tcp
firewall-cmd --reload
firewall-cmd --list-all

java npm nodejs

dnf search java | grep openjdk
dnf install java-17-openjdk java-17-openjdk-devel
dnf install java-1.8.0-openjdk java-1.8.0-openjdk-devel
java-version
alternatives --config java

## java 8
java-version
cat <<EOF | tee /etc/profile.d/java8.sh
export JAVA_HOME=/usr/lib/jvm/jre-openjdk
export PATH=\$PATH:\$JAVA_HOME/bin
export CLASSPATH=.:\$JAVA_HOME/jre/lib:\$JAVA_HOME/lib:\$JAVA_HOME/lib/tools.jar
EOF
source /etc/profile.d/java8.sh

dnf provides npm nodejs
dnf install npm nodejs
npm config set registry http://registry.npmmirror.com

java -jar packages.jar

nginx

dnf install nginx
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --permanent --zone=public --add-port=443/tcp
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --reload
systemctl start nginx

vim /etc/nginx/nginx.conf

mkdir /usr/share/nginx/html/www
groupadd www
adduser -G nginx -g www -d /usr/share/nginx/html/www www --system --shell=/bin/false

chown -R www:www /usr/share/nginx/html/www
find /usr/share/nginx/html/www -type d -exec chmod 555 "{}" \;
find /usr/share/nginx/html/www -type f -exec chmod 444 "{}" \;
setsebool httpd_can_network_connect 1 -P
 

标签:--,rockey,mysql,port,##,install,linux,data,9.1
From: https://www.cnblogs.com/neoo9901/p/17334287.html

相关文章

  • linux中if -z -d什么意思?
    [-aFILE]如果FILE存在则为真。[-bFILE]如果FILE存在且是一个块特殊文件则为真。[-cFILE]如果FILE存在且是一个字特殊文件则为真。[-dFILE]如果FILE存在且是一个目录则为真。[-eFILE]如果FILE存在则为真。[-fFILE]如果FILE......
  • linux ls 列出全路径
    1、列出当前目录的文件、文件夹完整路径ls-1|awk'{printi$0}'i=pwd'/'2、列出当前目录及子目录的文件、文件夹完整路径ls-R|awk'{printi$0}'i=pwd'/'2b)列出当前目录及子目录下的文件夹完整路径ls-FR|grep/|......
  • Linux内存管理之mem_map对象.md
    在linux内核中,所有的物理内存都用structpage结构来描述,这些对象以数组形式存放,而这个数组的地址就是mem_map。内核以节点node为单位,每个node下的物理内存统一管理,也就是说在表示内存node的描述类型structpglist_data中,有node_mem_map这个成员,其针对平坦型内存进行描述(CONFIG_FL......
  • Linux系统下判断硬盘是hdd还是ssd
    查看centos系统中/sys/block/sd*/queue/rotational这个文件里存的数据是判断该盘是否为ssd最基本的方法,0代表ssd,1代表hdd。HDD直通盘查询结果为1,结果正常。单盘SSD查询结果为0,结果正常。......
  • .Net 6.0 部署Linux+Nginx +PM2教程
    今天带大家将本地.Net6.0项目部署到Linux系统中,其中有用到Nginx反向代理和PM2进程管理工具,希望本偏文章能对你有所帮助,成为你成功路上的垫脚石!背景:在.Net5.0横空出世之后,.Net已经支持夸平台了,身为一名合格的码农,你敢说你不会用Linux?哈哈哈开个玩笑,因为工作最近......
  • linux系统记录用户操作命令
    #审计用户'''shellmkdir-m777-p/tmp/log2>&-declare-rHISTTIMEFORMAT='%F%T###'declare-rHISTCONTROL=''RSSHTTY=$(whoami|awk'{print$2}')if["$SSH_CONNECTION"];then  RSSH_CLIENTI......
  • linux Irq domain
    文章引用:https://blog.csdn.net/longwang155069/article/details/105812097为什么会引入IRQ_domain?早期中断数量较少,所以可以分布在一个interrupt_controler,中断映射也很简单,每个中断号对应一个interrupt_controler。 而当一个系统中有多个interrupt-controller的时候,而且中......
  • Linux课程(大数据、JavaEE,Python通用版)
    尚硅谷Linux课程(大数据、JavaEE,Python通用版)整理:韩顺平Linux课程笔记第1章LINUX开山篇1.1本套LINUX课程的内容介绍1.2LINUX的学习方向1.2.1Linux运维工程师.1.2.2Linux嵌入式开发工程师.123在linux下做各种程序开发.1.2.4示意图.1.3LINUX的应用领域......
  • linux中定时脚本logrotate是做什么的?
    centos7环境/etc/cron.daily/logrotatelogrotate是Linux系统中的一个定时脚本,它用于管理日志文件,自动地进行日志文件的轮换、压缩和删除等操作,以避免日志文件过大导致系统崩溃,同时也有利于日志查询和分析。具体来说,logrotate可以实现以下功能:日志文件的轮换:logrotate会按......
  • Linux最常见的三个应用领域详解!
    Linux应用领域有很多,其中最为主要的就是这三种:IT服务器Linux系统应用领域、嵌入式Linux系统应用领域和个人桌面linux应用领域,接下来我们来看看具体的内容介绍。与Windows操作系统软件一样,Linux也是一个操作系统软件。但与Windows不同的是,Linux是一套开放源代码程序的,并可以......