• 我的运维笔记之Linux安装篇



    工作了一段时间,是该总结一些在日常运维的东西了,后面有空再补充

    一 Nginx 在Linux上的安装

    1.1 下载上传

    image.png

    1.2 解压配置

    • 解压配置
    # 解压
    tar -zxvf nginx-1.8.1.tar.gz
    # 进入目录
    cd  nginx-1.8.1
    # 检查依赖且安装配置ssl
     yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
    # 检查依赖
    ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
    # 编译
    make
    # 
    make install
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    1.3 文件配置

    • 文件配置

    进入编译目录

    # 进入目录
    cd /usr/local/nginx/
    # 编辑ngnix.conf
    
    • 1
    • 2
    • 3
    
    
    worker_processes  1;
    
    
    events {
        worker_connections  1024;
    }
    
    
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;
        keepalive_timeout  65;
    
    
     server {
         listen 80;
        # 域名地址
         server_name shuzhilin.top www.shuzhilin.top;
         client_max_body_size 1024m;
         location / {
            proxy_set_header HOST $host;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            # 代理地址
            proxy_pass http://127.0.0.1:8090/;
        }
    }
    
    
    
    # 华为ssl证书配置
    server {
            listen  443 ssl;
            server_name shuzhilin.top www.shuzhilin.top;
            ssl_certificate     /usr/local/nginx/cert/server.crt; #替换成您的证书文件的路径。
            ssl_certificate_key /usr/local/nginx/cert/server.key; #替换成您的私钥文件的路径。
            ssl_session_cache   shared:SSL:1m;
            ssl_session_timeout 5m;
            ssl_ciphers         HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers  on;
            location / {
               proxy_set_header HOST $host;
              proxy_set_header X-Forwarded-Proto $scheme;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_pass http://127.0.0.1:8090/;
        }
    }
    
    
    
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59

    SSL证书的获取请参考华为SSL:https://support.huaweicloud.com/usermanual-ccm/ccm_01_0082.html

    • 其他命令
    # 启动
    /usr/local/nginx/sbin/nginx
    # 停止
    /usr/local/nginx/sbin/nginx -s stop
    # 重启
    /usr/local/nginx/sbin/nginx -s reload
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    二 Redis在Linux上的安装

    2.1 解压上传

    image.png

    • 解压配置
    # 解压
     tar -zxvf redis-6.2.7.tar.gz
    # 进入目录
    cd  redis-6.2.7
    # 编译
    make
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    2.2 编译配置

    • 进入编译目录配置文件
    # 创建配置文件目录
    mkdir /usr/local/redis/etc
    # 移动配置文件
    mv redis.conf /usr/local/redis/etc
    # 编辑配置文件
    vim redis.conf
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    image.png
    image.png

    • 添加开机启动
     vi /etc/rc.local
     # 添加
    /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf 
    
    • 1
    • 2
    • 3
    • 将redis-cli,redis-server拷贝到bin下,让redis-cli指令可以在任意目录下直接使用
    cp /usr/local/redis/bin/redis-server /usr/local/bin/
    cp /usr/local/redis/bin/redis-cli /usr/local/bin/
    
    • 1
    • 2

    注意防火墙端口的开放:https://www.yuque.com/docs/share/7d73fe1f-d204-42d3-b849-167a4177c5e1?# 《日常工作Linux命令》

    • 验证

    window中cmd:telnet ip 端口

    • 其他
    # 启动redis
    redis-server /usr/local/redis/etc/redis.conf 
    # 停止redis
    pkill redis  
    # 卸载redis:
    rm -rf /usr/local/redis //删除安装目录
    rm -rf /usr/bin/redis-* //删除所有redis相关命令脚本
    rm -rf /root/download/redis-4.0.4 //删除redis解压文件夹
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    三 Mysql在Linux上的安装

    3.1 解压上传

    image.png

    • 上传服务器解压

    image.png

    # 解压
    tar -xvf mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar
    
    • 1
    • 2

    image.png

    3.2 安装配置

    # 安装openssl-devel 插件
    yum install openssl-devel
    # 依次安装
    rpm -ivh mysql-community-common-8.0.26-1.el7.x86_64.rpm 
    rpm -ivh mysql-community-client-plugins-8.0.26-1.el7.x86_64.rpm 
    rpm -ivh mysql-community-libs-8.0.26-1.el7.x86_64.rpm
    rpm -ivh mysql-community-libs-compat-8.0.26-1.el7.x86_64.rpm
    rpm -ivh  mysql-community-devel-8.0.26-1.el7.x86_64.rpm
    rpm -ivh mysql-community-client-8.0.26-1.el7.x86_64.rpm
    rpm -ivh  mysql-community-server-8.0.26-1.el7.x86_64.rpm
    # 如果rpm报错
    rpm -e mariadb-libs --nodeps
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 服务管理

    启动服务

    #启动 MySQL 服务:
    systemctl start mysqld
    #重启 MySQL 服务:
    systemctl restart mysqld
    #关闭 MySQL 服务:
    systemctl stop mysqld
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 查看默认密码
    cat /var/log/mysqld.log
    
    • 1

    image.png

    • 登录
    # 连接 MySQL 
    mysql -u root -p
    
    • 1
    • 2

    image.png

    • 修改密码
    # 将密码复杂度校验调整简单类型
    set global validate_password.policy = 0;
    # 设置密码最少位数限制为 4 位
    set global validate_password.length = 4;
    # 修改密码
    ALTER  USER  'root'@'localhost'  IDENTIFIED BY '自己的密码';
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 创建其他用户授权

    3.3 卸载或其他问题

    • 卸载
    # 停止服务
    systemctl stop mysqld
    # 卸载依赖
    rpm -e mysql-community-client-plugins-8.0.26-1.el7.x86_64 --nodeps
    rpm -e mysql-community-server-8.0.26-1.el7.x86_64 --nodeps
    rpm -e mysql-community-common-8.0.26-1.el7.x86_64 --nodeps
    rpm -e mysql-community-libs-8.0.26-1.el7.x86_64 --nodeps
    rpm -e mysql-community-client-8.0.26-1.el7.x86_64 --nodeps
    rpm -e mysql-community-libs-compat-8.0.26-1.el7.x86_64 --nodeps
    # 删除数据目录
    rm -rf /var/lib/mysql/
    # 删除MySQL的配置文件备份
    rm -rf /etc/my.cnf.rpmsave
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 其他
    # 开放端口
    firewall-cmd --zone=public --add-port=3306/tcp --permanent
    # 重启防火墙
    systemctl restart firewalld.service
    # 重载配置
    firewall-cmd --reload
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    四 Oracle在Linux上的安装

    4.1 软件包下载

    该版本为:11.2.0.4
    链接:https://pan.baidu.com/s/1sZTfplAcbaGYDQKHzz51KA?pwd=8ygj
    提取码:8ygj

    4.2 解压上传服务器

    注意是一起解压不要漏掉文件
    image.png

    4.3 关闭selinux

    [root@localhost ~]# vim /etc/selinux/config
    [root@localhost ~]# setenforce 0
    
    • 1
    • 2

    image.png

    4.4 关闭防火墙

    [root@localhost ~]# systemctl restart firewalld.service
    [root@localhost ~]# systemctl list-unit-files|grep firewalld.service
    firewalld.service                             enabled
    [root@localhost ~]# systemctl disable firewalld.service
    Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
    Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    4.5 检测依赖

    [root@localhost ~]# yum install gcc make binutils gcc-c++ compat-libstdc++-33elfutils-libelf-devel elfutils-libelf-devel-static ksh libaio libaio-develnumactl-devel sysstat unixODBC unixODBC-devel pcre-devel –y
    
    • 1

    image.png

    4.6 添加用户与组

    [root@localhost ~]# groupadd admin
    [root@localhost ~]# groupadd dba
    [root@localhost ~]# useradd -g admin -G dba oracle
    [root@localhost ~]# passwd oracle
    更改用户 oracle 的密码 。
    新的 密码:
    重新输入新的 密码:
    passwd:所有的身份验证令牌已经成功更新。
    [root@localhost ~]# id oracle
    uid=1001(oracle) gid=1001(admin)=1001(admin),1002(dba)
    [root@localhost ~]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    4.7 修改内核配置参数

    [root@localhost ~]# vim /etc/sysctl.conf
    [root@localhost ~]# sysctl -p
    fs.aio-max-nr = 1048576
    fs.file-max = 6815744
    kernel.shmall = 2097152
    kernel.shmmax = 2073741824
    kernel.shmmni = 4096
    kernel.sem = 250 32000 100 128
    net.ipv4.ip_local_port_range = 9000 65500
    net.core.rmem_default = 262144
    net.core.rmem_max = 4194304
    net.core.wmem_default = 262144
    net.core.wmem_max = 1048576
    [root@localhost ~]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    添加下面的参数,注意kernel.shmmax为运行内存的一半

    fs.aio-max-nr = 1048576
    fs.file-max = 6815744
    kernel.shmall = 2097152
    kernel.shmmax = 2073741824
    kernel.shmmni = 4096
    kernel.sem = 250 32000 100 128
    net.ipv4.ip_local_port_range = 9000 65500
    net.core.rmem_default = 262144
    net.core.rmem_max = 4194304
    net.core.wmem_default = 262144
    net.core.wmem_max = 1048576
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    image.png

    4.8 修改用户的限制文件

    • 修改/etc/security/limits.conf文件
    [root@localhost ~]# vim /etc/security/limits.conf
    [root@localhost ~]#
    
    • 1
    • 2
    oracle           soft    nproc           2047
    oracle           hard    nproc           16384
    oracle           soft    nofile          1024
    oracle           hard    nofile         65536
    oracle           soft    stack           10240 
    
    • 1
    • 2
    • 3
    • 4
    • 5

    image.png

    • 修改/etc/pam.d/login文件
    [root@localhost ~]# vim /etc/pam.d/login
    [root@localhost ~]#
    
    • 1
    • 2
    session required  /lib64/security/pam_limits.so
    session required   pam_limits.so 
    
    • 1
    • 2

    image.png

    • 修改/etc/profile文件
    
    [root@localhost ~]# vim /etc/profile
    [root@localhost ~]#
    
    
    • 1
    • 2
    • 3
    • 4
    #oracle配置
    if [ $USER = "oracle" ]; then
      if [ $SHELL = "/bin/ksh" ]; then
          ulimit -p 16384
          ulimit -n 65536
      else
          ulimit -u 16384 -n 65536
      fi
    fi
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    image.png

    4.8 创建安装目录与权限配置

    [root@localhost ~]# mkdir -p /data/oracle/product/11.2.0.4
    [root@localhost ~]# mkdir /data/oracle/oradata
    [root@localhost ~]# mkdir /data/oracle/inventory
    [root@localhost ~]# mkdir /data/oracle/fast_recovery_area
    [root@localhost ~]# chown -R oracle:admin /data/oracle
    [root@localhost ~]# chmod -R 775 /data/oracle
    # 对解压目录进行授权
    [root@localhost ~]# chown -R oracle:admin /media/oracleinstall/
    [root@localhost ~]# chmod -R 775 /media/oracleinstall/
    [root@localhost ~]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    4.9 设置Oracle 环境变量

    
    [root@localhost ~]#  su -l oracle
    最后一次失败的登录:五 916 09:16:28 CST 2022120.48.37.84ssh:notty 上
    最有一次成功登录后有 63 次失败的登录尝试。
    [oracle@localhost ~]$ vim .bash_profile
    # 注意 第一次配置完记得source一下
    [oracle@localhost ~]$ source .bash_profile
    [oracle@localhost ~]$
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    ORACLE_BASE=/data/oracle
    ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4
    ORACLE_SID=orcl
    PATH=$PATH:$ORACLE_HOME/bin
    export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
    
    • 1
    • 2
    • 3
    • 4
    • 5

    image.png

    4.10 编辑静默安装响应文件

    进入解压包安装目录的database/response下

    [root@localhost response]# pwd
    /media/oracleinstall/database/response
    [root@localhost response]# vim db_install.rsp
    [root@localhost response]#
    
    • 1
    • 2
    • 3
    • 4

    需要设置的选项如下:

    oracle.install.option=INSTALL_DB_SWONLY
    
    ORACLE_HOSTNAME=CentOS
    
    UNIX_GROUP_NAME=admin
    
    INVENTORY_LOCATION=/data/oracle/inventory
    
    SELECTED_LANGUAGES=en,zh_CN
    
    ORACLE_HOME=/data/oracle/product/11.2.0.4
    
    ORACLE_BASE=/data/oracle
    
    oracle.install.db.InstallEdition=EE
    
    oracle.install.db.DBA_GROUP=dba
    
    oracle.install.db.OPER_GROUP=dba
    
    DECLINE_SECURITY_UPDATES=true
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    4.11 安装oracle

    过程比较漫长耐心等待

    [root@localhost database]# ls
    install  readme.html  response  rpm  runInstaller  sshsetup  stage  welcome.html
    [root@localhost database]# ./runInstaller -silent -responseFile /media/oracleinstall/database/response/db_install.rsp -ignorePrereq
    
    该用户是 root 用户。如果用户是 root 用户, Oracle Universal Installer 将无法继续安装。
    : 没有那个文件或目录
    [root@localhost database]# su oracle
    [oracle@localhost database]$  ./runInstaller -silent -responseFile /media/oracleinstall/database/response/db_install.rsp -ignorePrereq
    正在启动 Oracle Universal Installer...
    
    检查临时空间: 必须大于 120 MB。   实际为 35586 MB    通过
    检查交换空间: 必须大于 150 MB。   实际为 5887 MB    通过
    准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2022-09-16_09-31-26AM. 请稍候...[oracle@localhost database]$ MoTTY X11 proxy: Unsupported authorisation protocol
    [WARNING] [INS-32055] 主产品清单位于 Oracle 基目录中。
       原因: 主产品清单位于 Oracle 基目录中。
       操作: Oracle 建议将此主产品清单放置在 Oracle 基目录之外的位置中。
    可以在以下位置找到本次安装会话的日志:
     /data/oracle/inventory/logs/installActions2022-09-16_09-31-26AM.log
    Oracle Database 11g 的 安装 已成功。
    请查看 '/data/oracle/inventory/logs/silentInstall2022-09-16_09-31-26AM.log' 以获取详细资料。
    
    以 root 用户的身份执行以下脚本:
            1. /data/oracle/inventory/orainstRoot.sh
            2. /data/oracle/product/11.2.0.4/root.sh
    
    
    Successfully Setup Software.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    image.png
    验证

    [oracle@localhost database]$ su root
    密码:
    [root@localhost database]# sh /data/oracle/inventory/orainstRoot.sh
    更改权限/data/oracle/inventory.
    添加组的读取和写入权限。
    删除全局的读取, 写入和执行权限。
    
    更改组名/data/oracle/inventory 到 admin.
    脚本的执行已完成。
    [root@localhost database]# sh /data/oracle/inventory/orainstRoot.sh
    更改权限/data/oracle/inventory.
    添加组的读取和写入权限。
    删除全局的读取, 写入和执行权限。
    
    更改组名/data/oracle/inventory 到 admin.
    脚本的执行已完成。
    [root@localhost database]# sh  /data/oracle/product/11.2.0.4/root.sh
    Check /data/oracle/product/11.2.0.4/install/root_localhost.localdomain_2022-09-16_09-43-28.log for the output of root script
    [root@localhost database]#
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    4.12 配置监听

    [root@localhost database]# su -l oracle
    上一次登录:五 916 09:31:16 CST 2022pts/0 上
    [oracle@localhost ~]$ netca /silent /responseFile /media/oracleinstall/database/response/netca.rsp
    
    正在对命令行参数进行语法分析:
    参数"silent" = true
    参数"responsefile" = /media/oracleinstall/database/response/netca.rsp
    完成对命令行参数进行语法分析。
    Oracle Net Services 配置:
    完成概要文件配置。
    Oracle Net 监听程序启动:
        正在运行监听程序控制:
          /data/oracle/product/11.2.0.4/bin/lsnrctl start LISTENER
        监听程序控制完成。
        监听程序已成功启动。
    监听程序配置完成。
    成功完成 Oracle Net Services 配置。退出代码是0
    [oracle@localhost ~]$
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    image.png
    成功运行后,在/data/oracle/product/11.2.0/network/admin中生成listener.ora和sqlnet.ora,通过netstat命令可以查看1521端口正在监听。

    
    [oracle@localhost ~]$ netstat -anp |grep 1521
    (Not all processes could be identified, non-owned process info
     will not be shown, you would have to be root to see it all.)
    tcp6       0      0 :::1521                 :::*                    LISTEN      15233/tnslsnr
    unix  2      [ ACC ]     STREAM     LISTENING     300044   15233/tnslsnr        /var/tmp/.oracle/sEXTPROC1521
    unix  3      [ ]         STREAM     CONNECTED     211521   -                    /run/systemd/journal/stdout
    [oracle@localhost ~]$
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    4.13 建库

    [oracle@localhost root]$ vim /media/oracleinstall/database/response/dbca.rsp
    [oracle@localhost root]$ dbca -silent -responseFile /media/oracleinstall/database/response/dbca.rsp
    复制数据库文件
    1% 已完成
    3% 已完成
    11% 已完成
    18% 已完成
    26% 已完成
    37% 已完成
    正在创建并启动 Oracle 实例
    40% 已完成
    45% 已完成
    50% 已完成
    55% 已完成
    56% 已完成
    60% 已完成
    62% 已完成
    正在进行数据库创建
    66% 已完成
    70% 已完成
    73% 已完成
    85% 已完成
    96% 已完成
    100% 已完成
    有关详细信息, 请参阅日志文件 "/data/oracle/cfgtoollogs/dbca/orcl/orcl.log"[oracle@localhost root]$
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26

    修改文件中以下参数

    [GENERAL]
    
    # oracle版本,不能更改
    RESPONSEFILE_VERSION = "11.2.0"
    
    # Description   : Type of operation
    OPERATION_TYPE = "createDatabase"
    
    [CREATEDATABASE]
    
    # Description   : Global database name of the database
    # 全局数据库的名字=SID+主机域名# 第三方工具链接数据库的时候使用的service名称
    GDBNAME = "orcl.test"
    
    # Description   : System identifier (SID) of the database
    # 对应的实例名字
    SID = "orcl"
    
    # Description   : Name of the template
    # 建库用的模板文件
    TEMPLATENAME = "General_Purpose.dbc"
    
    # Description   : Password for SYS user
    # SYS管理员密码
    SYSPASSWORD = "123456"
    
    # Description   : Password for SYSTEM user
    # SYSTEM管理员密码
    SYSTEMPASSWORD = "123456"
    
    # Description   : Password for SYSMAN user
    # SYSMAN管理员密码
    SYSMANPASSWORD = "123456"
    
    # Description   : Password for DBSNMP user
    # DBSNMP管理员密码
    DBSNMPPASSWORD = "123456"
    
    # Description   : Location of the data file's
    # 数据文件存放目录
    DATAFILEDESTINATION =/data/oracle/oradata
    
    # Description   : Location of the data file's
    # 恢复数据存放目录
    RECOVERYAREADESTINATION=/data/oracle/fast_recovery_area
    
    # Description   : Character set of the database
    # 字符集,重要!!! 建库后一般不能更改,所以建库前要确定清楚。
    # (CHARACTERSET = "AL32UTF8" NATIONALCHARACTERSET= "UTF8")
    CHARACTERSET = "ZHS16GBK"
    
    # Description   : total memory in MB to allocate to Oracle
    # oracle内存1638MB,物理内存2G*80%
    TOTALMEMORY = "1638"
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54

    image.png

    4.14 检查进程

    
    [oracle@localhost root]$ ps -ef | grep ora_ | grep -v grep
    oracle   25828     1  0 10:21 ?        00:00:00 ora_pmon_orcl
    oracle   25830     1  0 10:21 ?        00:00:00 ora_psp0_orcl
    oracle   25838     1  1 10:21 ?        00:00:02 ora_vktm_orcl
    oracle   25842     1  0 10:21 ?        00:00:00 ora_gen0_orcl
    oracle   25844     1  0 10:21 ?        00:00:00 ora_diag_orcl
    oracle   25846     1  0 10:21 ?        00:00:00 ora_dbrm_orcl
    oracle   25848     1  0 10:21 ?        00:00:00 ora_dia0_orcl
    oracle   25850     1  0 10:21 ?        00:00:00 ora_mman_orcl
    oracle   25852     1  0 10:21 ?        00:00:00 ora_dbw0_orcl
    oracle   25857     1  0 10:21 ?        00:00:00 ora_lgwr_orcl
    oracle   25862     1  0 10:21 ?        00:00:00 ora_ckpt_orcl
    oracle   25864     1  0 10:21 ?        00:00:00 ora_smon_orcl
    oracle   25866     1  0 10:21 ?        00:00:00 ora_reco_orcl
    oracle   25868     1  0 10:21 ?        00:00:00 ora_mmon_orcl
    oracle   25870     1  0 10:21 ?        00:00:00 ora_mmnl_orcl
    oracle   25872     1  0 10:21 ?        00:00:00 ora_d000_orcl
    oracle   25874     1  0 10:21 ?        00:00:00 ora_s000_orcl
    oracle   25926     1  0 10:21 ?        00:00:00 ora_qmnc_orcl
    oracle   25948     1  0 10:21 ?        00:00:00 ora_cjq0_orcl
    oracle   26004     1  0 10:21 ?        00:00:00 ora_q000_orcl
    oracle   26006     1  0 10:21 ?        00:00:00 ora_q001_orcl
    [oracle@localhost root]$
    [oracle@localhost root]$
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26

    4.15 查看监听

    [oracle@localhost root]$ lsnrctl status
    
    LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 16-SEP-2022 10:25:20
    
    Copyright (c) 1991, 2013, Oracle.  All rights reserved.
    
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
    Start Date                16-SEP-2022 09:45:43
    Uptime                    0 days 0 hr. 39 min. 39 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /data/oracle/product/11.2.0.4/network/admin/listener.ora
    Listener Log File         /data/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
    Services Summary...
    Service "orcl.test" has 1 instance(s).
      Instance "orcl", status READY, has 1 handler(s) for this service...
    Service "orclXDB.test" has 1 instance(s).
      Instance "orcl", status READY, has 1 handler(s) for this service...
    The command completed successfully
    [oracle@localhost root]$
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29

    数据库创建完成,有关详细信息, 请查看以下位置的日志文件: /data/oracle/cfgtoollogs/dbca/orcl/orcl.log。数据库信息:,全局数据库名:orcl.test,系统标识符 (SID):orcl

    4.16 检查状态

    [oracle@localhost root]$ sqlplus / as sysdba
    
    SQL*Plus: Release 11.2.0.4.0 Production on Fri Sep 16 10:26:29 2022
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL> select status from v$instance;
    
    STATUS
    ------------
    OPEN
    
    SQL>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    4.17 创建新用户,新增表空间

    [root@localhost ~]# mkdir  /home/oracle_space
    [root@localhost ~]# chmod -Rf 777 /home/oracle_space
    [root@localhost ~]# sqlplus / as sysdba
    
    SQL*Plus: Release 11.2.0.4.0 Production on Fri Sep 16 10:31:18 2022
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    ERROR:
    ORA-01017: invalid username/password; logon denied
    
    Enter user-name: system
    Enter password:
    
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL> create tablespace LDJC_DATA   datafile '/home/oracle_space/ldjc_data01.dbf' size 50m   autoextend on maxsize unlimited  extent management local;
    
    Tablespace created.
    
    SQL> create user TEST identified by 123456 default tablespace LDJC_DATA;
    grant connect,resource to JCCB;
    grant dba to TEST;
    
    User created.
    
    SQL>
    Grant succeeded.
    
    SQL>
    Grant succeeded.
    
    SQL> 
    alter tablespace LDJC_DATA add datafile '/home/oracle_space/ldjc_data02.dbf' size 50m autoextend on next 50m maxsize unlimited;
    alter tablespace LDJC_DATA add datafile '/home/oracle_space/ldjc_data03.dbf' size 50m autoextend on next 50m maxsize unlimited;
    alter tablespace LDJC_DATA add datafile '/home/oracle_space/ldjc_data04.dbf' size 50m autoextend on next 50m maxsize unlimited;
    alter tablespace LDJC_DATA add datafile '/home/oracle_space/ldjc_data05.dbf' size 50m autoextend on next 50m maxsize unlimited;
    alter tablespace LDJC_DATA add datafile '/home/oracle_space/ldjc_data06.dbf' size 50m autoextend on next 50m maxsize unlimited;
    alter tablespace LDJC_DATA add datafile '/home/oracle_space/ldjc_data07.dbf' size 50m autoextend on next 50m maxsize unlimited;
    alter tablespace LDJC_DATA add datafile '/home/oracle_space/ldjc_data08.dbf' size 50m autoextend on next 50m maxsize unlimited;
    alter tablespace LDJC_DATA add datafile '/home/oracle_space/ldjc_data09.dbf' size 50m autoextend on next 50m maxsize unlimited;
    alter tablespace LDJC_DATA add datafile '/home/oracle_space/ldjc_data10.dbf' size 50m autoextend on next 50m maxsize unlimited;
    alter tablespace LDJC_DATA add datafile '/home/oracle_space/ldjc_data11.dbf' size 50m autoextend on next 50m maxsize unlimited;
    alter tablespace LDJC_DATA add datafile '/home/oracle_space/ldjc_data12.dbf' size 50m autoextend on next 50m maxsize unlimited;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46

    4.18 验证新用户

    [root@localhost ~]# sqlplus / as sysdba
    
    SQL*Plus: Release 11.2.0.4.0 Production on Fri Sep 16 10:41:15 2022
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    ERROR:
    ORA-01017: invalid username/password; logon denied
    
    
    Enter user-name: TEST
    Enter password:
    
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL>  select* from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    PL/SQL Release 11.2.0.4.0 - Production
    CORE    11.2.0.4.0      Production
    TNS for Linux: Version 11.2.0.4.0 - Production
    NLSRTL Version 11.2.0.4.0 - Production
    
    SQL>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29

    4.19 其他问题

    • 问题一:oracle dbca命令找不到,检测环境变量是否设置成功
    
    [root@localhost ~]#  su -l oracle
    最后一次失败的登录:五 916 09:16:28 CST 2022120.48.37.84ssh:notty 上
    最有一次成功登录后有 63 次失败的登录尝试。
    [oracle@localhost ~]$ vim .bash_profile
    # 注意 第一次配置完记得source一下
    [oracle@localhost ~]$ source .bash_profile
    [oracle@localhost ~]$
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    ORACLE_BASE=/data/oracle
    ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4
    ORACLE_SID=orcl
    PATH=$PATH:$ORACLE_HOME/bin
    export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
    
    • 1
    • 2
    • 3
    • 4
    • 5

    image.png

    • 问题二:模板 General_Purpose.dbc 不存在。请为数据库创建操作指定现有模板。

    注意解压文件夹应该一起解压,可能是解压时丢失了某些东西

    五 JDK在Linux上的安装

    5.1 下载上传服务器

    链接:https://pan.baidu.com/s/19OmcZruVkVKFICU7mHNPXQ?pwd=04yd
    提取码:04yd
    image.png

    [root@shu /]# cd usr
    [root@shu usr]# ls
    bin  etc  games  include  lib  lib64  libexec  local  sbin  share  src  tmp
    [root@shu usr]# cd local/
    [root@shu local]# ls
    bin  btjdk  bttomcat  curl  etc  games  include  lib  lib64  libexec  libiconv  man  nginx  openssl  redis  sbin  share  src  uniagent
    [root@shu local]# mkdir java
    [root@shu local]# chmod 777 java
    [root@shu local]#
    # 复制到该目录
    [root@shu java]# cp /environment/jdk/jdk-8u161-linux-x64.tar.gz .
    # 解压
    [root@shu java]# tar -zxvf jdk-8u161-linux-x64.tar.gz
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    5.2 配置环境变量

    [root@shu jdk1.8.0_161]# vim /etc/profile
    [root@shu jdk1.8.0_161]# cat /etc/profile
    # 添加环境变量语句
    export JAVA_HOME=/usr/local/java/jdk1.8.0_161
    export JRE_HOME=${JAVA_HOME}/jre
    export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
    export  PATH=${JAVA_HOME}/bin:$PATH
    # 注意需要执行这句代码才能生效
    [root@shu jdk1.8.0_161]# source /etc/profile
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    5.3 验证

    [root@shu jdk1.8.0_161]# java -version
    java version "1.8.0_161"
    Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
    [root@shu jdk1.8.0_161]#
    
    • 1
    • 2
    • 3
    • 4
    • 5

    六 Zookeeper在Linux上的安装

    6.1 安装配置

    下载地址:https://archive.apache.org/dist/zookeeper

    # 解压
    [root@shu zookeeper]# tar -zxvf apache-zookeeper-3.6.3-bin.tar.gz
    # 修改配置文件
    cd conf
    cp zoo_sample.cfg zoo.cfg
    vim zoo.cfg
    #启动
    bin/zkServer.sh start
    #查看
    jps
    #状态查看
    bin/zkServer.sh status
    #停止
    bin/zkServer.sh stop
    #启动客户端
    bin/zkCli.sh
    #退出
    quit
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    6.2 配置解释

    • tickTime = 2000:通信心跳时间,Zookeeper服务器与客户端心跳时间,单位毫秒
    • initLimit = 10:LF初始通信时限,Leader和Follower初始连接时能容忍的最多心跳数(tickTime的数量)
    • syncLimit = 5:LF同步通信时限,Leader和Follower之间通信时间如果超过syncLimit * tickTime,Leader认为Follwer死 掉,从服务器列表中删除Follwer
    • dataDir:保存Zookeeper中的数据,注意:默认的tmp目录,容易被Linux系统定期删除,所以一般不用默认的tmp目录。
    • clientPort = 2181:客户端连接端口,通常不做修改。

    七 Kafka在Linux上的安装

    #解压
    tar -zxvf kafka_2.11-2.4.0.tgz
    #修改配置文件
    cd config
    vim server.properties
    # 修改以下配置
    #broker.id属性在kafka集群中必须要是唯⼀
    broker.id=0
    #kafka部署的机器ip和提供服务的端⼝号(内网)
    #listeners=PLAINTEXT://服务器地址:9092 
    #阿里云外网
    advertised.listeners=PLAINTEXT://阿里云地址:9092
    #kafka的消息存储⽂件
    log.dir=/usr/local/data/kafka-logs
    #kafka连接zookeeper的地址
    zookeeper.connect=192.168.65.60:2181
    #是否可以删除
    delete.topic.enable=true
    # 启动
    cd bin
    ./kafka-server-start.sh -daemon ../config/server.properties
    # 检查是否启动
    jps
    #查看端口问题
    netstat -an | grep 9092
    #或者
    lsof -i:9092
    # 防火墙开发端口
    firewall-cmd --zone=public --add-port=9092/tcp --permanent
    firewall-cmd --reload
    #停止kafka
    ./kafka-server-stop.sh ../config/server.properties
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
  • 相关阅读:
    js Fetch返回数据res.json()报错问题
    GORM CRUD 5 分钟快速上手
    11、将数组中的 0 移动到末尾
    UG画弹簧模型教程
    6.2二叉树的迭代遍历(LC144,LC145,LC94-E)
    python-docx办公自动化批量生成离职证明
    牛客 NC25020 [USACO 2007 Nov S]Cow Hurdles
    告别BeanUtils,Mapstruct从入门到精通
    【算法 】两组随机变量协方差矩阵 矩阵的特征值与特征向量
    Explainability: What, Why, What For and How?可解释性:是什么、为什么、为什么以及如何做?‌
  • 原文地址:https://blog.csdn.net/weixin_44451022/article/details/126888464