神州通用数据库安装(单机-静默安装)

环境:
OS:Centos 7
DB:V7

 

1.介质下载地址
http://www.shentongdata.com/old_bak/iso/wzsyx/ShenTong7.0_linux64.rar

 

2.安装rar
[root@localhost soft]# tar -xvf rarlinux-x64-5.3.0.tar.gz
[root@localhost soft]# cd rar
[root@localhost rar]# make install

 

3.解压数据库安装包
[root@localhost soft]#rar x ShenTong7.0_linux64.rar
[root@localhost soft]#cd ShenTong7.0_linux64/
[root@localhost ShenTong7.0_linux64]#chmod u+x setup
[root@localhost ShenTong7.0_linux64]#./setup -f auto-install.xml

 

软件安装在如下目录:
[root@localhost ShenTong]# pwd
/opt/ShenTong

 

4.启动

 

启动数据库与agent代理服务
/etc/init.d/oscardb_OSRDBd start
/etc/init.d/oscaragentd start

 

 

[root@localhost db]# cd /etc/init.d
[root@localhost init.d]# ./oscardb_OSRDBd start 
Starting oscar -o normal -d OSRDB:
/opt/ShenTong/bin/oscar -o normal -d OSRDB running at 8194:SYSMULTIUSER:170
Database OSRDB startup failed

查看端口:
[root@localhost ShenTong]# ss -nlp|grep 2003
u_str  LISTEN     0      4096   /tmp/.s.oscar.2003 504208                * 0                   users:(("oscar",pid=8194,fd=14))
tcp    LISTEN     0      4096      *:2003                  *:*                   users:(("oscar",pid=8194,fd=13))
 

 

查看相关进程

 

[root@localhost ShenTong7.0_linux64]# ps -ef|grep oscar
root       688     1  0 08:46 ?        00:00:06 /opt/ShenTong/bin/oscar -o normal -d OSRDB
root       694     1  0 08:46 ?        00:00:00 /opt/ShenTong/bin/oscaragent -e /opt/ShenTong
root      2326  2123  0 09:02 pts/1    00:00:00 grep --color=auto oscar

 

 

 

 

默认端口 2003
初始用户名 SYSDBA
默认数据库实例名 OSRDB
对应密码 szoscar55 ##谐音"神州奥斯卡55"
默认部署路径 /opt/ShenTong

 

5.登录

[root@localhost bin]#cd /opt/ShenTong/bin
[root@localhost bin]# ./isql -h localhost -p 2003 -d osrdb sysdba
Password for user sysdba: 
Welcome to isql 7.1.20200811 the ShenTongDB interactive terminal.
Type:  COPYRIGHT for distribution terms
       HELP for help with SQL commands
       ? for help on internal commands
       ! to run system commands
       EXIT to quit
SQL> 

[root@localhost bin]# ./isql -l
Password for default user: 
     List of databases
 Name  | Owner  | Encoding 
-------+--------+----------
 OSRDB | SYSDBA | UTF8
(1 row)

 

查看数据库
SQL> SELECT DATNAME FROM sys_database;
 DATNAME 
---------
 OSRDB
(1 row)

查询所有模式
SQL> SELECT NSPNAME FROM sys_namespace;
     NSPNAME     
-----------------
 DIRECTORIES
 INFO_SCHEM
 PUBLIC
 REPLICATION
 STAGENT
 SYSAUDIT
 SYSDBA
 SYSFTSDBA
 SYSSECURE
 SYS_GLOBAL_TEMP
 WMSYS
(11 rows)

 

6.查看表空间对应的数据文件

SQL> select file_name,tablespace_name,autoextensible from dba_data_files;
                FILE_NAME                | TABLESPACE_NAME | AUTOEXTENSIBLE 
-----------------------------------------+-----------------+----------------
 /opt/ShenTong/odbs/OSRDB/OSRDB01.dbf    | SYSTEM          | YES
 /opt/ShenTong/odbs/OSRDB/undots01.dbf   | UNDOTS01        | YES
 /opt/ShenTong/odbs/OSRDB/OSRDBtmp01.dbf | TEMP            | YES
 /opt/ShenTong/odbs/OSRDB/OSRDBaux01.dbf | AUDIT           | YES
(4 rows)

 

7.创建表空间

SQL>create tablespace tps_hxl datafile '/opt/ShenTong/odbs/OSRDB/hxl01.dbf' size 100m autoextend on next 10m;
SQL>alter tablespace tps_hxl add datafile '/opt/ShenTong/odbs/OSRDB/hxl02.dbf' size 50m autoextend on next 10m;

 

8.创建用户

SQL>create user hxl with password 'oracle' default tablespace tps_hxl;
SQL>grant role resource to user hxl;

SQL> select username,default_tablespace,temporary_tablespace from dba_users;
 USERNAME  | DEFAULT_TABLESPACE | TEMPORARY_TABLESPACE 
-----------+--------------------+----------------------
 SYSDBA    | SYSTEM             | TEMP
 SYSFTSDBA | SYSTEM             | TEMP
 SYSAUDIT  | AUDIT              | TEMP
 SYSSECURE | SYSTEM             | TEMP
 HXL       | SYSTEM             | TEMP
(5 rows)
SQL> 

 

9.使用刚创建的用户登录
[root@localhost bin]# ./isql -h localhost -p 2003 -d osrdb hxl
SQL>

 

10.停掉数据库

 

systemctl status oscardb_OSRDBd.service

 

 11.删除服务

[root@localhost ShenTong]# systemctl disable oscardb_OSRDBd.service
Removed symlink /etc/systemd/system/graphical.target.wants/oscardb_OSRDBd.service.

 

 

 

#######################################创建非osrdb数据库#################################

1.进入backend模式创建数据库

 

[root@localhost bin]#mkdir -p /dbdata/ShenTong/arch/
[root@localhost bin]#mkdir -p /dbdata/ShenTong/odbs/OSRDB
[root@localhost bin]# ./oscar
backend>CREATE DATABASE hxl ENCODING 'UTF-8' PAGESIZE 8K ARCHIVELOG '/dbdata/ShenTong/arch/'  CONTROLFILE '/dbdata/ShenTong/odbs/OSRDB/OSRDB.ctrl' LOGFILE  '/dbdata/ShenTong/odbs/OSRDB/OSRDB01.log' SIZE 100M TEMPFILE  '/dbdata/ShenTong/odbs/OSRDB/OSRDB01temp.dbf' SIZE 100M AUDITFILE  '/dbdata/ShenTong/odbs/OSRDB/OSRDBaux01.dbf' SIZE 100M AUTOEXTEND ON NEXT 20M DATAFILE '/dbdata/ShenTong/odbs/OSRDB/OSRDB01.dbf' SIZE 100M AUTOEXTEND ON NEXT 100M DATEFORMAT 'ORACLE';

 

注意:若创建了名称非OSRDB的新数据库,
还需要在$SZ_OSCAR_HOME/admin目录下新建一个文件:db_name.conf(注意db_name需大写),
可以通过copy默认的 oscar.conf 文件,再修改其中的 PORT 端口号创建.

echo>/opt/ShenTong/admin/HXL.conf
cd /opt/ShenTong/admin/
vim HXL.conf
#使用的端口号
PORT=2004

说明:
这里除了具体指定的文件,其他创建的文件存放在 /opt/ShenTong/odbs/HXL/ 下面

 

2.初始化数据库
/opt/ShenTong/bin/oscar -o restrict -d HXL

 

3.启动数据库
/opt/ShenTong/bin/oscar -o normal -d HXL
这种方式的话屏幕关闭的话,进程就好自动关闭了的,需要做成服务的方式启动

 

[root@localhost bin]#cd /opt/ShenTong/bin
[root@localhost bin]# ./oscar -o install -d HXL
Created symlink from /etc/systemd/system/graphical.target.wants/oscardb_HXLd.service to /usr/lib/systemd/system/oscardb_HXLd.service.
service type : systemctl
Database service was successfully installed!

 

使环境变量生效
[root@localhost bin]# source /etc/profile

数据库创建成功后,数据文件存放路径默认为 $SZ_OSCAR_HOME/odbs,配置文件存放路径默认为$SZ_OSCAR_HOME/admin

启动数据库
[root@localhost admin]# /etc/init.d/oscardb_HXLd start
Starting oscar -o normal -d HXL:
Database HXL startup success

 

4.登录数据库
./isql -h localhost -p 2004 -d hxl sysdba

 

###############################################删除数据库###########################################

1.停掉服务
/etc/init.d/oscardb_HXLd stop

 

2.登录backend进行删除
[root@localhost bin]#cd /opt/ShenTong/bin
[root@localhost bin]# ./oscar
backend> drop database hxl;
/*Session 0*/ NOTICE, DROP PHYSICAL DATABASE: OK

执行删除语句的话,该数据库相应的数据文件和配置文件也会自动删除掉

 

[root@localhost bin]#cd /opt/ShenTong/bin

[root@localhost bin]# ./oscar -o remove -d HXL


3.删除系统服务
systemctl disable oscardb_HXLd.service

 

 

#############################################开启归档模式##############################################

1.查看数据库是否在归档模式

 

[root@localhost bin]# ./isql -h localhost -p 2003 -d osrdb sysdba
SQL> select log_mode from v$database;
   LOG_MODE   
--------------
 NOARCHIVELOG
(1 row)

 

 

2.开启归档并设置归档目录
alter database archivelog '/opt/ShenTong/arch';

 

3.查看归档情况
select archivemode, archivepath from v_sys_archivelog_info;
select path, create_time, start_lsn, end_lsn from v$archived_log;

 

 

###################################创建表#######################################

 

[root@localhost bin]# ./isql -h localhost -p 2003 -d HXL utest
Password for user utest: 

create table tb_test
(
id number not null,
name1 varchar2(32),
name2 varchar2(32),
name3 varchar2(32),
name4 varchar2(32),
name5 varchar2(32),
name6 varchar2(32),
createtime timestamp default sysdate,
updatetime timestamp default sysdate
);

SQL> \d tb_test;
                          Table UTEST.TB_TEST
   Column   |         Type          |     Modifiers     | AutoIncrement 
------------+-----------------------+-------------------+---------------
 ID         | numeric(1000,38)      | not null          | f
 NAME1      | character varying(32) |                   | f
 NAME2      | character varying(32) |                   | f
 NAME3      | character varying(32) |                   | f
 NAME4      | character varying(32) |                   | f
 NAME5      | character varying(32) |                   | f
 NAME6      | character varying(32) |                   | f
 CREATETIME | date                  | default SYSDATE() | f
 UPDATETIME | date                  | default SYSDATE() | f
OID IS 34051 

insert into tb_test (id,name1,name2,name3,name4,name5,name6) values (1,'name1','name2','name3','name4','name5','name6');
insert into tb_test (id,name1,name2,name3,name4,name5,name6) values (2,'name1','name2','name3','name4','name5','name6');
insert into tb_test (id,name1,name2,name3,name4,name5,name6) values (3,'name1','name2','name3','name4','name5','name6');
insert into tb_test (id,name1,name2,name3,name4,name5,name6) values (4,'name1','name2','name3','name4','name5','name6');
insert into tb_test (id,name1,name2,name3,name4,name5,name6) values (5,'name1','name2','name3','name4','name5','name6');

 

posted @ 2024-02-29 17:27  slnngk  阅读(360)  评论(0编辑  收藏  举报