暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

M AC环境

amazingweiwei 2021-07-12
934

一、MAC应用安装

1、常用软件地址

https://www.macwk.com

2、常见问题

https://stackoverflow.com

3、HomeBrew

     mac安装brew方式
     /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
    、、、
    电脑系统版本:11.3
    All user-space services OK, nothing cleaned...


    ==> brew update-reset

    ==> Fetching usr/local/Homebrew...


    ==> Resetting usr/local/Homebrew...
    Branch 'master' set up to track remote branch 'master' from 'origin'.
    Reset branch 'master'
    Your branch is up to date with 'origin/master'.


    ==> Fetching usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...


    ==> Resetting usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...
    Branch 'master' set up to track remote branch 'master' from 'origin'.
    Reset branch 'master'
    Your branch is up to date with 'origin/master'.


    ==> Fetching usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...


    ==> Resetting usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
    Updating files: 100% (5721/5721), done.
    Branch 'master' set up to track remote branch 'master' from 'origin'.
    Reset branch 'master'
    Your branch is up to date with 'origin/master'.


    ==> Fetching usr/local/Homebrew/Library/Taps/homebrew/homebrew-services...


    ==> Resetting usr/local/Homebrew/Library/Taps/homebrew/homebrew-services...
    Branch 'master' set up to track remote branch 'master' from 'origin'.
    Reset branch 'master'
    Your branch is up to date with 'origin/master'.




    Brew自动安装程序运行完成
    国内地址已经配置完成


    桌面的Old_Homebrew文件夹,大致看看没有你需要的可以删除。


    初步介绍几个brew命令
    本地软件库列表:brew ls
    查找软件:brew search google(其中google替换为要查找的关键字)
    查看brew版本:brew -v 更新brew版本:brew update
    安装cask软件:brew install --cask firefox 把firefox换成你要安装的

    欢迎右键点击下方地址-打开URL 来给点个赞
    https://zhuanlan.zhihu.com/p/111014448


    重启终端 或者 运行 source Users/erwei.zheng/.zprofile 否则可能无法使用


    、、、


    4、docker

    • 官方下载地址:https://docs.docker.com/get-docker/

    • Mac OS系统如何通过Docker安装Oracle11g

        

      Mac OS 系统如何通过docker安装Oracle11g


      一、下载并安装docker
      https://docs.docker.com/get-docker/


      二、通过Docker来安装Oracle11g
      1、Docker是一个容器,在容器内部存在很多的镜像文件,通过具体的镜像文件可以运行具体的容器。要想在Docker中安装Oracle镜像,我们首先应该在Docker的远程仓库中进行搜索,因为Docker没有自带Oracle相关镜像,命令如下:
      sudo docker search docker-oracle-xe-11g


      、、、
      localhost:~ erwei.zheng$ sudo docker search docker-oracle-xe-11g
      NAME DESCRIPTION STARS OFFICIAL AUTOMATED
      deepdiver/docker-oracle-xe-11g 40 [OK]
      epiclabs/docker-oracle-xe-11g Customized Oracle XE 11g build for CI and de… 20 [OK]
      pengbai/docker-oracle-xe-11g-r2 oracle xe 11g r2 with sql initdb and web con… 10 [OK]
      arahman/docker-oracle-xe-11g phusion/baseimage based spin off of alexei-l… 9 [OK]
      konnecteam/docker-oracle-xe-11g Fork of https://github.com/wnameless/docker-… 3 [OK]
      rafaelri/docker-oracle-xe-11g Fork from wnameless/docker-oracle-xe-11g 3 [OK]
      ignatov/docker-oracle-xe-11g Dockerfile of Oracle Database Express Editio… 3 [OK]
      gswteam/docker-oracle-xe-11g Oracle XE 11g 0 [OK]
      jeromefromcn/docker-oracle-xe-11g docker-oracle-xe-11g 0 [OK]
      nguoianphu/docker-oracle-xe-11g Oracle Express Edition 11g Release 2 on Ubun… 0 [OK]
      lynxsolutions/docker-oracle-xe-11g docker-oracle-xe-11g 0 [OK]
      zzzfree/docker-oracle-xe-11g docker-oracle-xe-11g 0 [OK]
      deadok22/docker-oracle-xe-11g docker-oracle-xe-11g 0
      rdehuyss/docker-oracle-xe-11g Oracle Express 11g R2 on Ubuntu 14.04.2 LTS 0 [OK]
      dbanttari/docker-oracle-xe-11g Branch of wnameless/docker-oracle-xe-11g tha… 0 [OK]
      xtechnologies/docker-oracle-xe-11g docker-oracle-xe-11g 0 [OK]
      bizybot/docker-oracle-xe-11g wnameless/docker-oracle-xe-11g 0 [OK]
      cheyu0325/docker-oracle-xe-11g docker-oracle-xe-11g 0
      kikicarbonell/docker-oracle-xe-11g Docker image of Oracle Database Express Edit… 0 [OK]
      ceagan/docker-oracle-xe-11g Modified version of wnameless/docker-oracle-… 0 [OK]
      zigac/docker-oracle-xe-11g Oracle xe 11g 0 [OK]
      dockerbolcom/docker-oracle-xe-11g Fork of https://github.com/wnameless/docker-… 0 [OK]
      demers/docker-oracle-xe-11g-spark Oracle XE 11g with Spark 0
      gmartsenkov/docker-oracle-xe-11g oracle 0 [OK]
      demers/docker-oracle-xe-11g Docker Oracle 11g XE with Java 13 and Python… 0
      localhost:~ erwei.zheng$ sudo docker search docker-oracle-19c


      、、、


      2、选择第一个STAR最多的镜像进行安装,拉取镜像命令如下:
      localhost:~ erwei.zheng$ sudo docker pull deepdiver/docker-oracle-xe-11g


      、、、
      localhost:~ erwei.zheng$ sudo docker pull deepdiver/docker-oracle-xe-11g
      Using default tag: latest
      latest: Pulling from deepdiver/docker-oracle-xe-11g
      Image docker.io/deepdiver/docker-oracle-xe-11g:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/
      a3ed95caeb02: Pulling fs layer
      9cf7e98c567b: Pulling fs layer
      d2ff49536f4d: Pulling fs layer
      f94adccdbb9c: Waiting
      ee950bf8af06: Waiting
      eec0023b823a: Waiting
      2bbcf2933a57: Pull complete
      1d639c2160a1: Pull complete
      2631aa3055c3: Pull complete
      d859f4b0261f: Pull complete
      344fe8edcc0a: Pull complete
      48fec8d59976: Pull complete
      c9c81ef7960f: Pull complete
      7e928eb7228a: Pull complete
      56e977b47ad6: Pull complete
      5c896b34601c: Pull complete
      bcab6dcbd345: Pull complete
      42e031cc37c0: Pull complete
      fd6c6b47d0ba: Pull complete
      546a383ffbe3: Pull complete
      5acead7005d0: Pull complete
      206b7448a401: Pull complete
      bdf584565438: Pull complete
      4ce7a34d8c4b: Pull complete
      8702b3ee1143: Pull complete
      777d696e58cd: Pull complete
      8271d90e318b: Pull complete
      c0e2d1590154: Pull complete
      aeb67e38d18e: Pull complete
      Digest: sha256:30c9b1f61397bbca016c25b21c4c2e5399af225306e41272874411ae2bd741d3
      Status: Downloaded newer image for deepdiver/docker-oracle-xe-11g:latest
      docker.io/deepdiver/docker-oracle-xe-11g:latest
      、、、


      3、待镜像下载完毕之后,我们需要将该镜像转成容器并使用该容器,命令如下:
      sudo docker run -d -p 1521:1521 --name oracle11g deepdiver/docker-oracle-xe-11g


      、、、
      localhost:~ erwei.zheng$ sudo docker run -d -p 1521:1521 --name oracle11g deepdiver/docker-oracle-xe-11g
      Password:
      2b6e39d1b126ddbf42f9ddd14c6510ad2dfcb50082fe0fb7954e566a32a3443c
      、、、


      值得注意的就是将容器内部的1521端口映射到宿主机中的1521端口,这样一来就能在宿主机中通过Navicat等数据库可视化管理工具进行连接了。在这步完成之后,我们需要进到荣日内部对已经安装的Oracle进行简单配置


      4、在Oracle容器中简单配置你的Oracle数据库并通过Navicat进行连接
      进入容器内部的命令如下:
      1>查询容器ID --2b6e39d1b126
      docker ps
      、、、
      bogon:~ erwei.zheng$ docker ps
      CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
      2b6e39d1b126 deepdiver/docker-oracle-xe-11g "/bin/sh -c 'sed -i …" 4 hours ago Up 4 hours 22/tcp, 8080/tcp, 0.0.0.0:1521->1521/tcp, :::1521->1521/tcp oracle11g
      、、、
      2>进入容器
      sudo docker exec -it 你的容器ID(可通过docker ps 命令获得) bin/bash


      、、、
      bogon:~ erwei.zheng$ sudo docker exec -it 2b6e39d1b126 bin/bash
      Password:
      root@2b6e39d1b126:/#


      、、、
      3>通过sqlplus进入Oracle
      sqlplus system/oracle


      、、、
      root@2b6e39d1b126:/# sqlplus system/oracle


      SQL*Plus: Release 11.2.0.2.0 Production on Sun Jul 4 09:39:02 2021


      Copyright (c) 1982, 2011, Oracle. All rights reserved.


      ERROR:
      ORA-28002: the password will expire within 7 days






      Connected to:
      Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production


      SQL>
      、、、
      依次进行如下操作:
      查看数据库用户名和密码:


      select username, password from dba_users;


      、、、
      Connected to:
      Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production


      SQL> select username, password from dba_users;


      USERNAME PASSWORD
      ------------------------------ ------------------------------
      SYS
      GCS
      ANONYMOUS
      AUTOTEST
      SYSTEM
      APEX_PUBLIC_USER
      APEX_040000
      XS$NULL
      OUTLN
      XDB
      CTXSYS


      USERNAME PASSWORD
      ------------------------------ ------------------------------
      MDSYS
      FLOWS_FILES
      HR


      14 rows selected.


      可以使用已经存在的用户名和密码来登陆数据库,推荐使用新创建的用户来进行数据库的登陆,sql如下:
      create user 用户名 identified by 密码;


      、、、
      SQL> create user gcs identified by gcs;


      User created.
      、、、


      创建完后,可以通过如下sql进行验证:
      select * form all_users;


      对新创建的用户进行授权,sql如下:
      grant connect, resource to GCSHS; -- 这里需要将用户名大写,否则授权不成功
      -- connect表示具有连接数据库的权限;resource表示具有操作数据库的权限;


      、、、
      SQL> grant connect, resource to GCSHS;


      Grant succeeded.
      、、、


      至此,所有需要配置的数据库配置都已经配置完毕,可以通过Navicat进行连接了,


      navicat创建连接注意事项:


      connection name: 随便
      connection type: basic
      host:localhost 或 127.0.0.1
      port:1521 -- 端口为docker内部Oracle容器映射到宿主机的端口,上述命令有将1521端口映射到宿主机的1521端口
      service name:XE
      role:default
      username:gcs
      password:gcs


      配置完后,可进行连接测试;


      参考连接:
      https://blog.csdn.net/qq_36314960/article/details/100111935?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522162532422716780366582422%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=162532422716780366582422&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-1-100111935.first_rank_v2_pc_rank_v29&utm_term=mac%E5%AE%89%E8%A3%85oracle%E6%95%B0%E6%8D%AE%E5%BA%93&spm=1018.2226.3001.4187


      问题:
      重启docker或者重启电脑后,使用docker ps命令看重启前的oracle容器ID:
      使用命令查看被stop的容器id:
      docker ps -a


      、、、
      localhost:~ erwei.zheng$ docker ps -a
      CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
      2b6e39d1b126 deepdiver/docker-oracle-xe-11g "/bin/sh -c 'sed -i …" 5 hours ago Exited (255) 12 minutes ago 22/tcp, 8080/tcp, 0.0.0.0:1521->1521/tcp, :::1521->1521/tcp oracle11g
      、、、


      重启被stop的容器id:
      Docker start id(通过docker ps -a 查看停止运行的容器id)
      或者
      docker restart id


      、、、
      localhost:~ erwei.zheng$ docker ps -a
      CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
      2b6e39d1b126 deepdiver/docker-oracle-xe-11g "/bin/sh -c 'sed -i …" 5 hours ago Exited (137) About a minute ago oracle11g
      localhost:~ erwei.zheng$ docker restart 2b6e39d1b126
      2b6e39d1b126
      localhost:~ erwei.zheng$ docker ps
      CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
      2b6e39d1b126 deepdiver/docker-oracle-xe-11g "/bin/sh -c 'sed -i …" 5 hours ago Up 6 seconds 22/tcp, 8080/tcp, 0.0.0.0:1521->1521/tcp, :::1521->1521/tcp oracle11g
      localhost:~ erwei.zheng$
      、、、




      4、.bash_profile 环境变量

      • Mac使用HomeBrew安装python3.*并设置为默认版本


        • Mac使用HomeBrew安装python3.*并设置为默认版本
          一、安装
          1、查看Mac自带的python版本
          python
          2、查看python3的安装包
          brew search python3
          3、安装python3
          brew install python3


          ==> Caveats
          Python has been installed as
          usr/local/bin/python3


          Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
          `python3`, `python3-config`, `pip3` etc., respectively, have been installed into
          usr/local/opt/python@3.9/libexec/bin


          You can install Python packages with
          pip3 install <package>
          They will install into the site-package directory
          usr/local/lib/python3.9/site-packages


          tkinter is no longer included with this formula, but it is available separately:
          brew install python-tk@3.9


          See: https://docs.brew.sh/Homebrew-and-Python
          ==> Summary
          🍺 usr/local/Cellar/python@3.9/3.9.6: 3,078 files, 54.6MB
          ==> Caveats
          ==> python@3.9
          Python has been installed as
          usr/local/bin/python3


          Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
          `python3`, `python3-config`, `pip3` etc., respectively, have been installed into
          usr/local/opt/python@3.9/libexec/bin


          # 可以看到python3的世界安装目录是/usr/local/Cellar/python@3.9/3.9.6


          # 配置python的外部环境变量
          1、打开配置文件并写入python外部环境变量
          open ~/.bash_profile
          export PATH=${PATH}:/usr/local/Cellar/python@3.9/3.9.6/bin
          2、重命名python
          alias python="/usr/local/Cellar/python@3.9/3.9.6/bin/python3.9"
          3、让配置文件生效
          source ~/.bash_profile
          4、使用python命令查看
          python
        • mac pro 环境变量的配置 (当不存在 .bash_profile 文件的时候)

          mac pro 环境变量的配置 (当不存在 .bash_profile 文件的时候)


          1、启动终端terminal
          2、进入当前用户的home目录(/user/erwei.zheng)
          输入 cd ~


          、、、
          # 查看home目录下的所有文件和文件夹
          localhost:~ erwei.zheng$ ls -a
          、、、
          3、创建.bash_profile文件
          输入 touch .bash_profile
          4、编辑 .bash_profile文件,打开后编辑文件,配置环境变量
          输入 open -e .bash_profile


          5、保存文件,关闭 .bash_profile
          Command + s 保存
          6、更新刚配置的环境变量
          输入 source .bash_profile
          7、验证配置是否成功
          输入python


          、、、


          # 以python3为例,配置环境变量
          # python3的安装目录是/usr/local/Cellar/python@3.9/3.9.6


          # 配置python的外部环境变量
          1、打开配置文件并写入python外部环境变量
          open ~/.bash_profile
          export PATH=${PATH}:/usr/local/Cellar/python@3.9/3.9.6/bin
          2、重命名python
          alias python="/usr/local/Cellar/python@3.9/3.9.6/bin/python3.9"
          3、让配置文件生效
          source ~/.bash_profile
          4、使用python命令查看
          python
          、、、

          5、cx_Oracle

          • pip安装:sudo pip3 install cx_Oracle

            localhost:~ erwei.zheng$ sudo pip3 install cx_Oracle


            Password:


            WARNING: The directory '/Users/erwei.zheng/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.


            Collecting cx_Oracle


            Downloading cx_Oracle-8.2.1.tar.gz (359 kB)


            |████████████████████████████████| 359 kB 29 kB/s


            Installing build dependencies ... done


            Getting requirements to build wheel ... done


            Preparing wheel metadata ... done


            Building wheels for collected packages: cx-Oracle


            Building wheel for cx-Oracle (PEP 517) ... done


            Created wheel for cx-Oracle: filename=cx_Oracle-8.2.1-cp39-cp39-macosx_11_0_x86_64.whl size=185941 sha256=000cf3f949a48c1680ab91ea7af700e8422275d80fc3c86caa60de0d8bc7013d


            Stored in directory: /private/tmp/pip-ephem-wheel-cache-rkoifbul/wheels/0c/ad/1b/d206b2ada8e1381a02024ef67608cf919b5cd025cc24f38faa


            Successfully built cx-Oracle


            Installing collected packages: cx-Oracle


            Successfully installed cx-Oracle-8.2.1


            WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv


            localhost:~ erwei.zheng$
            • 问题:cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit OracleClientlibrary: "dlopen(/opt/oracle/instantclient_11_2/lib/libclntsh.dylib, 1): image not found".

              MacOS cx_Oracle.DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: 解决方案


              问题:
              cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(/opt/oracle/instantclient_11_2/lib/libclntsh.dylib, 1): image not found".


              https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html
              、、、
              instantclient-basic-macos.x64-19.8.0.0.0dbru.zip 客户端软件对应的Oracle数据库版本:
              参考官网:https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html


              Version 21 client libraries can connect to Oracle Database 12.1 or greater. Version 19, 18 and 12.2 client libraries can connect to Oracle Database 11.2 or greater. Version 12.1 client libraries can connect to Oracle Database 10.2 or greater. Version 11.2 client libraries can connect to Oracle Database 9.2 or greater.
              、、、


              、、、
              客户端软件下载地址:
              https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html
              、、、


              准备工作:
              下载 instant client 客户端,客户端与oracle数据库版本对照关系见上面网站


              开始设置:
              1、创建文件夹,并将压缩包解压到这个文件夹下
              mkdir -p /opt/oracle
              — 将客户端文件拷贝到 /opt/oracle目录下
              cp instantclient-basic-macos.x64-19.8.0.0.0dbru.zip /opt/oracle


              —- cd当前路径到 /opt/oracle/下
              — 解压客户端压缩包到当前目录
              Unzip instantclient-basic-macos.x64-19.8.0.0.0dbru.zip


              2、创建超链接,以使应用程序能够找到该库
              mkdir ~/lib
              sudo unzip instantclient-basic-macos.x64-19.8.0.0.0dbru.zip




              3、将instan client 路径添加到环境变量中
              open -e .bash_profile


              4、保存文件后,更新刚配置的环境变量
              source .bash_profile


              • pycharm2019.3 python报错:ModuleNotFoundError- No module named 'cx_Oracle'.rtf

                • pycharm2019.3 python报错:ModuleNotFoundError: No module named 'cx_Oracle'
                  Pycharm 设置问题,更新配置即可
                  步骤:file-setting-project:xxx,如下:选择add
                  选择system interpreter ,后目录会自动更新到你python安装目录下的解释器python.exe。点击确定即可。
                文章转载自amazingweiwei,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

                评论